Fc0001
Fc0001

Reputation: 118

Robot not loading on Gazebo

My Robot is not loading on Gazebo although loading fine on rviz2. Below is my code. On gazebo, only leg_link is loading not any other links. Although on the side panel under models all the links and the joints are showing fine. This is my first time modelling a robot. Any solution will be appreciated. Thank you.

URDF FILE:

<?xml version="1.0"?>
<robot name="giraff_robot">
    <material name="red">
        <color rgba="1 0 0 1"/>
    </material>
    <material name="blue">
        <color rgba="0 0 1 1"/>
    </material>


    <link name="world">
        <origin rpy="0 0 0" xyz="0 0 0"/>
    </link>
    <link name="base_link">
        <visual> 
            <geometry>
                <box size="0.1 0.1 0.1"/>
            </geometry>
            <material name="red"/>
        </visual>
        <collision>
            <geometry>
                <box size="0.1 0.1 0.1"/>
            </geometry>
            <origin xyz="0 0 0"/>
        </collision>
        <inertial>
            <mass value="1.0"/>
            <origin xyz="0 0 0"/>
            <inertia ixx="0.1" ixy="0" ixz="0" iyy="0.1" iyz="0" izz="0.1"/>
        </inertial>
    </link>
    <link name="leg_link">
        <visual>
            <geometry>
                <cylinder length="0.6" radius="0.5"/>
            </geometry>
            <material name="red"/>
        </visual>
        <collision>
            <geometry>
                <cylinder length="0.6" radius="0.5"/>
            </geometry>
            <origin xyz="0 0 0"/>
        </collision>
        <inertial>
            <mass value="1.0"/>
            <origin xyz="0 0 0"/>
            <inertia ixx="0.1" ixy="0" ixz="0" iyy="0.1" iyz="0" izz="0.1"/>
        </inertial>
    </link> 
    <link name="arm_link">
        <visual>
            <geometry>
                <cylinder length="0.6" radius="0.5"/>
            </geometry>
            <material name="red"/>
        </visual> 
        <collision>
            <geometry>
                <cylinder length="0.6" radius="0.5"/>
            </geometry>
            <origin xyz="0 0 0"/>
        </collision>
        <inertial>
            <mass value="1.0"/>
            <origin xyz="0 0 0"/>
            <inertia ixx="0.1" ixy="0" ixz="0" iyy="0.1" iyz="0" izz="0.1"/>
        </inertial>
    </link>
    <link name="end_effector">
        <visual>
            <geometry>
                <cylinder length="0.6" radius="0.5"/>
            </geometry>
            <material name="red"/>
        </visual> 
        <collision>
            <geometry>
                <cylinder length="0.6" radius="0.5"/>
            </geometry>
            <origin xyz="0 0 0"/>
        </collision>
        <inertial>
            <mass value="1.0"/>
            <origin xyz="0 0 0"/>
            <inertia ixx="0.1" ixy="0" ixz="0" iyy="0.1" iyz="0" izz="0.1"/>
        </inertial>
    </link>
    <link name="tool_mic">
        <visual>
            <geometry>
                <cylinder length="0.6" radius="0.5"/>
            </geometry>
            <material name="red"/>
        </visual> 
        <collision>
            <geometry>
                <cylinder length="0.6" radius="0.5"/>
            </geometry>
            <origin xyz="0 0 0"/>
        </collision>
        <inertial>
            <mass value="1.0"/>
            <origin xyz="0 0 0"/>
            <inertia ixx="0.1" ixy="0" ixz="0" iyy="0.1" iyz="0" izz="0.1"/>
        </inertial>
    </link>


    <joint name="base_joint" type="revolute">
        <parent link="world"/>
        <child link="base_link"/>
        <origin rpy="0 0 0" xyz="0 0 0"/>
        <axis xyz="1 0 0" />
        <safety_controller k_position="3.1416" k_velocity="1000.0" k_effort="1000.0"/>
        <calibration rising="0.0" falling="0.0"/>
        <dynamics damping="0.0" friction="0.0"/>
        <limit lower="-3.1416" upper="3.1416" effort="1000.0" velocity="1000.0" />
        <visual>
            <geometry>
                <sphere radius="0.5"/>
            </geometry>
            <material name="blue"/>
        </visual> 
    </joint>
    <joint name="base_spherical_joint" type="revolute">
        <parent link="base_link"/>
        <child link="leg_link"/>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <axis xyz="1 0 0" />
        <safety_controller k_position="3.1416" k_velocity="1000.0" k_effort="1000.0"/>
        <calibration rising="0.0" falling="0.0"/>
        <dynamics damping="0.0" friction="0.0"/>
        <limit lower="-3.1416" upper="3.1416" effort="1000.0" velocity="1000.0" />
        <visual>
            <geometry>
                <sphere radius="0.5"/>
            </geometry>
            <material name="blue"/>
        </visual> 
    </joint>
    <joint name="leg_joint" type="prismatic">
        <parent link="leg_link"/>
        <child link="arm_link"/>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <limit lower="0.0" upper="100.0" effort="1000.0" velocity="1000.0" />
        <safety_controller k_position="100.0" k_velocity="1000.0" k_effort="1000.0"/>
        <calibration rising="0.0" falling="0.0"/>
        <dynamics damping="0.1" friction="0.0"/>
        <visual>
            <geometry>
                <box size="0.1 0.2 0.6"/>
            </geometry>
            <material name="blue"/>
        </visual> 
    </joint>
    <joint name="arm_joint" type="revolute">
        <parent link="arm_link"/>
        <child link="end_effector"/>
        <axis xyz="1 0 0" />
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <safety_controller k_position="3.1416" k_velocity="1000.0" k_effort="1000.0"/>
        <calibration rising="0.0" falling="0.0"/>
        <dynamics damping="0.0" friction="0.0"/>
        <limit lower="-3.1416" upper="3.1416" effort="1000.0" velocity="1000.0" />
        <visual>
            <geometry>
                <sphere radius="0.5"/>
            </geometry>
            <material name="blue"/>
        </visual> 
    </joint>
    <joint name="end_effector_joint" type="revolute">
        <parent link="end_effector"/>
        <child link="tool_mic"/>
        <axis xyz="0 1 0" />
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <safety_controller k_position="0.5236" k_velocity="1000.0" k_effort="1000.0"/>
        <calibration rising="0.0" falling="0.0"/>
        <dynamics damping="0.0" friction="0.0"/>
        <limit lower="0.0" upper="0.5236" effort="1000.0" velocity="1000.0" />
        <stiffness value="0.0"/>
        <visual>
            <geometry>
                <box size="0.6 0.1 0.2"/>
            </geometry>
            <material name="blue"/>
        </visual> 
    </joint>

    <gazebo reference="base_link">
       <material>Gazebo/Red</material>
   </gazebo>
   <gazebo reference="leg_link">
       <material>Gazebo/Red</material>
   </gazebo>
   <gazebo reference="arm_link">
       <material>Gazebo/Red</material>
   </gazebo>
   <gazebo reference="end_effector">
       <material>Gazebo/Red</material>
   </gazebo>
   <gazebo reference="tool_mic">
       <material>Gazebo/Red</material>
   </gazebo>
   <gazebo reference="base_joint">
       <material>Gazebo/Blue</material>
   </gazebo>
   <gazebo reference="base_spherical_joint">
       <material>Gazebo/Blue</material>
   </gazebo>
   <gazebo reference="leg_joint">
       <material>Gazebo/Blue</material>
   </gazebo>
   <gazebo reference="arm_joint">
       <material>Gazebo/Blue</material>
   </gazebo>
   <gazebo reference="end_effector_joint">
       <material>Gazebo/Blue</material>
   </gazebo>

    <gazebo>
        <plugin name="joint_state_publisher" filename="libgazebo_ros_joint_state_publisher.so">
            <robotNamespace>/giraff_robot</robotNamespace>
            <jointName>base_joint, base_spherical_joint, leg_joint, arm_joint, end_effector_joint</jointName>
            <updateRate>100.0</updateRate>
            <alwaysOn>true</alwaysOn>
        </plugin>
        <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
            <robotNamespace>/giraff_robot</robotNamespace>
        </plugin>
        <plugin name="joint_pose_trajectory_controller" filename="libgazebo_ros_joint_pose_trajectory.so">
        <!-- Parameters for the joint pose trajectory controller -->
            <robotNamespace>/giraff_robot</robotNamespace>
            <jointName>base_joint, base_spherical_joint, leg_joint, arm_joint, end_effector_joint</jointName>
            <updateRate>50.0</updateRate>
            <trajectoryTopic>/giraff_robot/joint_trajectory</trajectoryTopic>
            <robotBaseFrame>base_link</robotBaseFrame>
            <robotTipFrame>tool_mic</robotTipFrame>
            <maxJointDifference>0.1</maxJointDifference>
        </plugin>
    </gazebo>
</robot>

Upvotes: 1

Views: 85

Answers (2)

wissem chiha
wissem chiha

Reputation: 53

@Fc0001 , I've been working in robotics for three years now, and this particular issue is one of the most straightforward tasks I've encountered. Handling mesh parts and URDF files can be challenging, especially when exporting to ROS. Automatically generated URDF files from CAD software (like SolidWorks or others) often don't function correctly. I believe the issue lies in parameter values and coordinate references—CAD software references don't precisely align with the ROS ecosystem.

To address this, I've explored real-time debugging tools. While options like the VS Code URDF extension have had issues (they've raised this on their GitHub and seem to have fixed it in a pre-release version vscode-ros) I recommend using the Python URDF package for quick debugging and visualization of URDF files. Before starting, ensure your NumPy version is compatible, as URDFpy relies on the NetworkX Python library, which can encounter issues with certain versions of NumPy.

For more details, check out these resources:

urdfpy

urdf-visualizer

Upvotes: 1

wissem chiha
wissem chiha

Reputation: 53

I experienced a similar issue with ROS2 RViz and spent days trying to figure out what the problem was. It turned out to be a display scale issue. Your parts might be getting displayed, but their scale or position relative to the origin frame is larger than the screen's default extension.

Here are some steps to resolve it:

Try resizing your .STL mesh files and adjusting the positions in your URDF file. Before that, ensure your mesh files are valid and visualize their origin frame. I recommend using MeshLab software or FreeCAD for this. Another tip: Sometimes, a homogeneous transformation between mesh frames is necessary. Try writing a static_transform_publisher node that publishes a fixed XYZ_RPY transformation between each pair of robot frames. Also, try debugging each part individually in RViz first.

Upvotes: 1

Related Questions