Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rviz2 showing gray image only #1333

Open
tajish opened this issue Jan 31, 2025 · 0 comments
Open

Rviz2 showing gray image only #1333

tajish opened this issue Jan 31, 2025 · 0 comments

Comments

@tajish
Copy link

tajish commented Jan 31, 2025

Hello guys,

As discussed from my last post, I am unable to see any image in rviz2. It just showing a gray image when I try to visualize it rviz2 even I place any object infront of the camera. Can somebody help me in that. I am posting my urdf file and the launch file here for information. It would very kind of you if someone can help.

URDF:

<xacro:macro name="robotiq_85_gripper" params="prefix parent *origin">
<xacro:property name="d455_zero_depth_to_glass" value="4.55e-3"/>
<xacro:property name="d455_cam_depth" value="0.026"/>
<xacro:property name="d455_cam_depth_py" value="0.0475"/>
<xacro:property name="d455_cam_width" value="0.124"/>
<xacro:property name="d455_cam_height" value="0.029"/>

    <joint name="${prefix}robotiq_85_base_joint" type="fixed">
        <parent link="${parent}"/>
        <child link="${prefix}robotiq_85_base_link"/>
        <xacro:insert_block name="origin"/>
    </joint>

    <link name="${prefix}robotiq_85_base_link">
        <visual>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/visual/robotiq_85_base_link.dae"/>
            </geometry>
        </visual>
        <collision>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/collision/robotiq_85_base_link.stl"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="0.636951" />
            <origin xyz="0.0 0.0 0.0" />
            <inertia ixx = "0.000380" ixy = "0.000000" ixz = "0.000000"
                     iyx = "0.000000" iyy = "0.001110" iyz = "0.000000"
                     izx = "0.000000" izy = "0.000000" izz = "0.001171" />
        </inertial>
    </link>

    <link name="camera_link">
        <visual name="camera">
           <origin xyz="0 0 0" rpy="0 0 0"/>
           <geometry>
             <mesh filename="package://robotiq_description/meshes/visual/d455.stl" scale="0.0005 0.0005 0.0005"/>
            </geometry>
        </visual>
        <collision name="camera">
          <origin xyz="${d455_zero_depth_to_glass-d455_cam_depth/2} ${-d455_cam_depth_py} 0" rpy="0 0 0"/>
          <geometry>
            <box size="${d455_cam_depth} ${d455_cam_width} ${d455_cam_height}"/>
          </geometry>
        </collision>
        <inertial>
           <mass value="0.072" />
           <origin xyz="0 0 0" />
           <inertia ixx="0.003881243" ixy="0.0" ixz="0.0" iyy="0.000498940" iyz="0.0" izz="0.003879257" />
        </inertial>
    </link>

    <link name="camera_frame_link"></link>

    <joint name='robotiq_85_base_link_to_camera_link' type="fixed">
      <parent link="robotiq_85_base_link"/>
      <child  link="camera_link"/>
      <origin xyz="0.052 -0.0001 -0.020" rpy="${pi/2} ${pi} ${pi/2}"/>
    </joint>

    <joint name="camera_link_to_camera_frame_link" type="fixed">
      <parent link ="camera_link"/>
      <child link="camera_frame_link"/>
      <origin xyz="0 0 0" rpy="${-pi/2} 0 ${-pi/2}"/>
    </joint>

    <joint name="${prefix}robotiq_85_left_knuckle_joint" type="revolute">
        <parent link="${prefix}robotiq_85_base_link"/>
        <child link="${prefix}robotiq_85_left_knuckle_link"/>
        <axis xyz="0 0 1"/>
        <origin rpy="${pi} 0.0 0.0" xyz="0.05490451627 0.03060114443 0.0"/>
        <limit lower="0.0" upper="0.804" velocity="2.0" effort="1000"/>
    </joint>

    <joint name="${prefix}robotiq_85_right_knuckle_joint" type="continuous">
        <parent link="${prefix}robotiq_85_base_link"/>
        <child link="${prefix}robotiq_85_right_knuckle_link"/>
        <axis xyz="0 0 1"/>
        <origin rpy="0.0 0.0 0.0" xyz="0.05490451627 -0.03060114443 0.0"/>
        <limit lower="-3.14" upper="3.14" velocity="100.0" effort="1000"/>
        <mimic joint="${prefix}robotiq_85_left_knuckle_joint"/>
    </joint>

    <link name="${prefix}robotiq_85_left_knuckle_link">
        <visual>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/visual/robotiq_85_knuckle_link.dae"/>
            </geometry>
        </visual>
        <collision>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/collision/robotiq_85_knuckle_link.stl"/>
            </geometry>
        </collision>
        <inertial>
            <origin
                    xyz="0.0178331863169983 3.68915177224286E-11 0.0021442477325704"
                    rpy="0 0 0" />
            <mass
                    value="0.00684838849434396" />
            <inertia
                    ixx="2.66832029033166E-07"
                    ixy="1.66142314639824E-15"
                    ixz="1.45945633322873E-07"
                    iyy="1.3889233257419E-06"
                    iyz="2.82951161241588E-15"
                    izz="1.26603336914415E-06" />
        </inertial>
    </link> 

    <link name="${prefix}robotiq_85_right_knuckle_link">
        <visual>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/visual/robotiq_85_knuckle_link.dae"/>
            </geometry>
        </visual>
        <collision>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/collision/robotiq_85_knuckle_link.stl"/>
            </geometry>
        </collision>
        <inertial>
            <origin
                xyz="0.0168606186773776 3.93808471820465E-10 0.0226699950793434"
                rpy="0 0 0" />
            <mass
                value="0.0110930853895903" />
            <inertia
                ixx="4.27134775939882E-06"
                ixy="-8.53568456728898E-15"
                ixz="1.77774229944246E-06"
                iyy="3.96548790524392E-06"
                iyz="-8.45108024914164E-15"
                izz="3.20325997634666E-06" />
        </inertial>
    </link>

    <joint name="${prefix}robotiq_85_left_finger_joint" type="continuous">
        <parent link="${prefix}robotiq_85_left_knuckle_link"/>
        <child link="${prefix}robotiq_85_left_finger_link"/>
        <origin xyz="-0.00408552455 -0.03148604435 0.0" rpy="0 0 0" />
    </joint>

    <joint name="${prefix}robotiq_85_right_finger_joint" type="continuous">
        <parent link="${prefix}robotiq_85_right_knuckle_link"/>
        <child link="${prefix}robotiq_85_right_finger_link"/>
        <origin xyz="-0.00408552455 -0.03148604435 0.0" rpy="0 0 0" />
    </joint>

    <link name="${prefix}robotiq_85_left_finger_link">
        <visual>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/visual/robotiq_85_finger_link.dae"/>
            </geometry>
        </visual>
        <collision>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/collision/robotiq_85_finger_link.stl"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="0.027309" />
            <origin xyz="0.0 0.0 0.0" />
            <inertia ixx = "0.000003" ixy = "-0.000002" ixz = "0.000000"
                     iyx = "-0.000002" iyy = "0.000021" iyz = "0.000000"
                     izx = "0.000000" izy = "0.000000" izz = "0.000020" />
        </inertial>
    </link> 

    <link name="${prefix}robotiq_85_right_finger_link">
        <visual>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/visual/robotiq_85_finger_link.dae"/>
            </geometry>
        </visual>
        <collision>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/collision/robotiq_85_finger_link.stl"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="0.027309" />
            <origin xyz="0.0 0.0 0.0" />
            <inertia ixx = "0.000003" ixy = "-0.000002" ixz = "0.000000"
                     iyx = "-0.000002" iyy = "0.000021" iyz = "0.000000"
                     izx = "0.000000" izy = "0.000000" izz = "0.000020" />
        </inertial>
    </link> 

    <joint name="${prefix}robotiq_85_left_inner_knuckle_joint" type="continuous">
        <parent link="${prefix}robotiq_85_base_link"/>
        <child link="${prefix}robotiq_85_left_inner_knuckle_link"/>
        <axis xyz="0 0 1"/>
        <origin xyz="0.06142 0.0127 0" rpy="${pi} 0.0 0.0" />
        <limit lower="-3.14" upper="3.14" velocity="100.0" effort="0.1"/>
        <mimic joint="${prefix}robotiq_85_left_knuckle_joint" offset="0"/>
    </joint>

    <joint name="${prefix}robotiq_85_right_inner_knuckle_joint" type="continuous">
        <parent link="${prefix}robotiq_85_base_link"/>
        <child link="${prefix}robotiq_85_right_inner_knuckle_link"/>
        <axis xyz="0 0 1"/>
        <origin xyz="0.06142 -0.0127 0" rpy="0 0 0"/>
        <limit lower="-3.14" upper="3.14" velocity="100.0" effort="0.1"/>
        <mimic joint="${prefix}robotiq_85_left_knuckle_joint" offset="0"/>
    </joint>

    <link name="${prefix}robotiq_85_left_inner_knuckle_link">
        <visual>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/visual/robotiq_85_inner_knuckle_link.dae"/>
            </geometry>
        </visual>
        <collision>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/collision/robotiq_85_inner_knuckle_link.stl"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="0.029951" />
            <origin xyz="0.0 0.0 0.0" />
            <inertia ixx = "0.000039" ixy = "0.000000" ixz = "0.000000"
                     iyx = "0.000000" iyy = "0.000005" iyz = "0.000000"
                     izx = "0.000000" izy = "0.000000" izz = "0.000035" />
        </inertial>
    </link>
    <link name="${prefix}robotiq_85_right_inner_knuckle_link">
        <visual>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/visual/robotiq_85_inner_knuckle_link.dae"/>
            </geometry>
        </visual>
        <collision>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/collision/robotiq_85_inner_knuckle_link.stl"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="0.029951" />
            <origin xyz="0.0 0.0 0.0" />
            <inertia ixx = "0.000039" ixy = "0.000000" ixz = "0.000000"
                     iyx = "0.000000" iyy = "0.000005" iyz = "0.000000"
                     izx = "0.000000" izy = "0.000000" izz = "0.000035" />
        </inertial>
    </link>

    <joint name="${prefix}robotiq_85_left_finger_tip_joint" type="continuous">
        <parent link="${prefix}robotiq_85_left_inner_knuckle_link"/>
        <child link="${prefix}robotiq_85_left_finger_tip_link"/>
        <axis xyz="0 0 1"/>
        <origin xyz="0.04303959807 -0.03759940821 0.0" rpy="0.0 0.0 0.0"/>
        <limit lower="-3.14" upper="3.14" velocity="100.0" effort="0.1"/>
        <mimic joint="${prefix}robotiq_85_left_knuckle_joint" multiplier="-1"/>
    </joint>

    <joint name="${prefix}robotiq_85_right_finger_tip_joint" type="continuous">
        <parent link="${prefix}robotiq_85_right_inner_knuckle_link"/>
        <child link="${prefix}robotiq_85_right_finger_tip_link"/>
        <axis xyz="0 0 1"/>
        <origin rpy="0.0 0.0 0.0" xyz="0.04303959807 -0.03759940821  0.0"/>
        <limit lower="-3.14" upper="3.14" velocity="100.0" effort="0.1"/>
        <mimic joint="${prefix}robotiq_85_left_knuckle_joint" multiplier="-1"/>
    </joint>


    <link name="${prefix}robotiq_85_left_finger_tip_link">
        <visual>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/visual/robotiq_85_finger_tip_link.dae"/>
            </geometry>
        </visual>
        <collision>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/collision/robotiq_85_finger_tip_link.stl"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="0.019555" />
            <origin xyz="0.0 0.0 0.0" />
            <inertia ixx = "0.000002" ixy = "0.000000" ixz = "0.000000"
                     iyx = "0.000000" iyy = "0.000005" iyz = "0.000000"
                     izx = "0.000000" izy = "0.000000" izz = "0.000006" />
        </inertial>
    </link> 

    <link name="${prefix}robotiq_85_right_finger_tip_link">
        <visual>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/visual/robotiq_85_finger_tip_link.dae"/>
            </geometry>
        </visual>
        <collision>
            <geometry>
                <mesh filename="package://robotiq_description/meshes/collision/robotiq_85_finger_tip_link.stl"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="0.019555" />
            <origin xyz="0.0 0.0 0.0" />
            <inertia ixx = "0.000002" ixy = "0.000000" ixz = "0.000000"
                     iyx = "0.000000" iyy = "0.000005" iyz = "0.000000"
                     izx = "0.000000" izy = "0.000000" izz = "0.000006" />
        </inertial>
    </link>

    <!-- For better grasping-->

    <gazebo reference="${prefix}robotiq_85_left_finger_tip_link">
                <kp>1000000.0</kp>
                <kd>1.0</kd>
                <mu1>1.0</mu1>
                <mu2>1.0</mu2>
                <minDepth>0.001</minDepth>
    </gazebo>

    <gazebo reference="${prefix}robotiq_85_right_finger_tip_link">
                <kp>1000000.0</kp>
                <kd>1.0</kd>
                <mu1>1.0</mu1>
                <mu2>1.0</mu2>
                <minDepth>0.001</minDepth>
    </gazebo>

    <gazebo reference="camera_link">
            <sensor name="camera" type="camera">
                <always_on>true</always_on>
                <update_rate>30.0</update_rate>
                <visualize>true</visualize>
                <topic>/image_raw</topic>
                <gz_frame_id>/rgb_camera</gz_frame_id>
                <camera name="camera">
                    <horizontal_fov>1.21126</horizontal_fov>  <!-- Field of View -->
                    <image>
                        <width>1920</width>
                        <height>1080</height>
                        <format>R8G8B8</format>
                    </image>
                    <clip>
                       <near>0.1</near>
                       <far>10.0</far>
                    </clip>
                    <distortion>
                        <k1>0.0</k1>
                        <k2>0.0</k2>
                        <k3>0.0</k3>
                        <p1>0.0</p1>
                        <p2>0.0</p2>
                        <center>0.5 0.5</center>
                    </distortion>
                </camera>
                <plugin filename="gz-sim-sensors-system" name="gz::sim::systems::Sensors">
                    <render_engine>ogre2</render_engine>
                    <frame_name>camera_frame_link</frame_name>
                </plugin>
            </sensor>
    </gazebo>

    
    <xacro:robotiq_85_gripper_transmission prefix="${prefix}" />

</xacro:macro>

Launch file:

Image

import os
from pathlib import Path
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, SetEnvironmentVariable, IncludeLaunchDescription
from launch.substitutions import Command, LaunchConfiguration
from launch.launch_description_sources import PythonLaunchDescriptionSource

from launch_ros.actions import Node
from launch_ros.parameter_descriptions import ParameterValue

def generate_launch_description():
ur5_robot_description = get_package_share_directory("ur5_robot_description")

# Declare argument for robot model file
model_arg = DeclareLaunchArgument(
    name="model",
    default_value=os.path.join(
        ur5_robot_description, "urdf", "ur5_gripper_main.xacro"
    ),
    description="Absolute path to robot URDF file"
)

 

# Set Gazebo environment variables
gazebo_resource_path = SetEnvironmentVariable(
    name="GZ_SIM_RESOURCE_PATH",
    value=[
        str(Path(ur5_robot_description).parent.resolve())
    ]
)

ros_distro = os.environ["ROS_DISTRO"] 
is_classic = "True" if ros_distro == "humble" else "False" 

# Process robot description using xacro
robot_description = ParameterValue(
    Command([
        "xacro ", LaunchConfiguration("model"),
        " is_classic:=", is_classic
    ]),
    value_type=str
)

# Robot State Publisher node
robot_state_publisher_node = Node(
    package="robot_state_publisher",
    executable="robot_state_publisher",
    parameters=[{
        "robot_description": robot_description,
        "use_sim_time": True
    }]
)


gazebo_classic = IncludeLaunchDescription(
    PythonLaunchDescriptionSource([os.path.join(
                get_package_share_directory("ros_gz_sim"), "launch"), "/gz_sim.launch.py"]),
            launch_arguments=[
                ("gz_args", [" -v 4 -r empty.sdf"]
                )
            ]
         )


gz_spawn_entity = Node(
    package="ros_gz_sim",
    executable="create",
    output="screen",
    arguments=["-topic", "robot_description",
               "-name", "ur5_robot"],
)

gz_ros2_bridge = Node(
    package="ros_gz_bridge",
    executable="parameter_bridge",
    arguments=[
        '/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock',
        "/image_raw@sensor_msgs/msg/Image[gz.msgs.Image",
        "/camera_info@sensor_msgs/msg/CameraInfo[gz.msgs.CameraInfo",
    ],
    output='screen',
)


tf2_ros_bridge = Node(
        package='tf2_ros',
        namespace = 'base_to_wrist_3',
        executable='static_transform_publisher',
        arguments= ["0", "0", "0", "0", "0", "0", "base_link", "ur5_robot/wrist_3_link/camera"]
    )

"""
tf2_ros2_bridge = Node(
        package='tf2_ros',
        namespace = 'wrist3_to_camera',
        executable='static_transform_publisher',
        arguments= ["0", "0", "0", "0", "0", "0", "ur5_robot/wrist_3_link/camera", "camera_frame_link"]
    )"""



# Return launch description
return LaunchDescription([
    model_arg,
    gazebo_resource_path,
    robot_state_publisher_node,
    gazebo_classic,
    gz_spawn_entity,
    gz_ros2_bridge,
    tf2_ros_bridge,
    #tf2_ros2_bridge,
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant