0
$\begingroup$

I'm currently learning how to simulate a simple robotic arm with Gazebo-11 and ROS Noetic in Ubuntu 20.04. I'm following this tutorial, which is made to work with ROS2 foxy, but the URDF can still be used in ROS Noetic (or so I'm assuming). I've configured the necessary .xacro files in a package, and created a launch file to run the Gazebo simulation of the robot.

Here's the repository for the package: learn-urdf.

Here's the launch file (launch_gazebo.launch):

<launch>
    <!-- Start Gazebo and load the empty world -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="paused" value="false"/>
        <arg name="use_sim_time" value="true"/>
        <arg name="gui" value="true"/>
    </include>

    <!-- Load the robot description (URDF or Xacro) -->
    <param name="robot_description" command="$(find xacro)/xacro '$(find learn-urdf)/urdf/example_robot.urdf.xacro'" />

    <!-- Start the robot_state_publisher -->
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" output="screen"/>


    <!-- Start the Gazebo spawn_model node -->
    <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" output="screen" args="-urdf -model robot -param robot_description"/>
</launch>

The xacro file for Gazebo configuration (example_gazebo.launch) contains the following plugins:

    <gazebo>
        <plugin name="gazebo_ros_joint_state_publisher"
            filename="libgazebo_ros_joint_state_publisher.so">
            <update_rate>20</update_rate>
            <joint_name>slider_joint</joint_name>
            <joint_name>arm_joint</joint_name>
        </plugin>
    </gazebo>

    <gazebo>
        <plugin name="gazebo_ros_joint_pose_trajectory"
            filename="libgazebo_ros_joint_pose_trajectory.so">
            <update_rate>2</update_rate>
        </plugin>
    </gazebo>

And the joints in the URDF file (example_robot.urdf.xacro) are described as follows:

    <joint name="slider_joint" type="prismatic">
        <origin xyz="-1.25 0 0.1" rpy="0 0 0"/>
        <parent link="base_link"/>
        <child link="slider_link"/>
        <axis xyz="1 0 0"/>
        <limit lower="0" upper="2" velocity="100" effort="100"/> 
    </joint>

    <joint name="arm_joint" type="revolute">
        <origin xyz="0.25 0 0.15" rpy="0 0 0"/>
        <parent link="slider_link"/>
        <child link="arm_link"/>
        <axis xyz="0 -1 0"/>
        <limit lower="0" upper="${pi/2}" velocity="100" effort="100"/> 
    </joint>

When I run the launch_gazebo.launch file, the gazebo simulation begins, and everything in Gazebo simulation works fine (the joints are working, as well as physics). But when I try to run the RViz simulation, it gives an error. Apparently, it cannot find the transforms for the joints, which means Gazebo is not publishing into the TF tree properly. I ran rostopic echo /joint_states and got this output:

header: 
  seq: 22060
  stamp: 
    secs: 220
    nsecs: 780000000
  frame_id: ''
name: []
position: []
velocity: []
effort: []

The position data is always [], which shouldn't be the case. My understanding says that the gazebo_ros_joint_state_publisher isn't publishing the joint angles, hence the RViz simulation is failing.

I'm fairly new into the simulations. Could anyone help me fix this issue, or let me know where I can learn more about what I should do here? TIA.

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.