Skip to content

This is a tool that converts the directory generated by sw2urdf into a format usable by ROS2, allowing the model to be easily displayed in RViz2 and Gazebo.

License

Notifications You must be signed in to change notification settings

fish1sheep/sw2urdf_ROS2

Repository files navigation

SW2URDF ROS2

Environment Setup

  1. Ubuntu
  2. ROS2
  3. Gazebo11
  4. gazebo_ros
  5. robot_state_publisher
  6. joint_state_publisher

Install Dependencies

# Install Gazebo and gazebo_ros
sudo apt install gazebo && sudo apt install ros-$ROS_DISTRO-gazebo-ros-pkgs
# Install robot_state_publisher and joint_state_publisher
sudo apt install ros-$ROS_DISTRO-robot-state-publisher && sudo apt install ros-$ROS_DISTRO-joint-state-publisher

Tool Description

Run dir_ros2.py to select the directory generated by sw2urdf. This will automatically convert the sw2urdf output directory into a ROS2-compatible package.

The package can be visualized in rviz2 and gazebo.

Necessary Configuration

Set the geometric relationship between base_footprint and base_link in the insert_urdf.txt file:

  <link name="base_footprint"/>

  <joint name="base_footprint_joint" type="fixed">
      <origin xyz="0 0 0.001" rpy="0 0 0" />
      <parent link="base_footprint"/>
      <child link="base_link" />
  </joint>

Running Test

Convert Directory

  1. Run dir_ros2.py.

image-20241221170805196

  1. Select the directory where sw2urdf was generated. Remember to back up the original directory before proceeding, in case of any issues.

image-20241221170940960

  1. Go into the directory, then click OK and wait for the conversion to complete.

image-20241221171227422

  1. Move the converted directory to the src folder of your ROS2 workspace. Run colcon build and source the workspace.

rviz2

Run the display.launch.py launch file

Note: The arm_description directory is used as an example.

ros2 launch arm_description display.launch.py

Make sure to set the following:

  • Fixed Frame: Choose base_footprint.
  • Description Topic: Choose /robot_description.

image-20241221171539556

Gazebo

Run the gazebo.launch.py launch file

Note: The arm_description directory is used as an example.

ros2 launch arm_description gazebo.launch.py

image-20241221172237859

In this case, the model is loaded correctly, but no controllers were added, so the behavior shown is due to the absence of control mechanisms.

About

This is a tool that converts the directory generated by sw2urdf into a format usable by ROS2, allowing the model to be easily displayed in RViz2 and Gazebo.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published