Generates packages with launch files automatically from URDF for ROS2 with your required simulator with a simple GUI. Built to view URDF quickly on RViz and Gazebo. Currently supports Ignition Gazebo Fortress and Gazebo Classic .
Also adds both Robot_state_publisher, Joint_state_publisher and joint_state_publisher_gui if required to test your robot.
This project has been tested with Ubuntu 22.04. To install the necessary components, follow these steps:
-
ROS2 Humble Hawksbill:
Follow the installation instructions for ROS2 Humble Hawksbill from here. -
Ignition Gazebo Fortress:
Install Ignition Gazebo Fortress by following the steps outlined here.
An easier way to install both ROS2 and Ignition Gazebo Fortress is to use apt
:
sudo apt-get install ros-humble-desktop-full
Also if you would like to test the joint-states of your robot, don't forget to install joint-state-publisher-gui with
sudo apt-get install ros-humble-joint-state-publisher-gui
Also do install the send2trash python library as it'll allow you to quickly send your older, redundant package to trash if you are creating a new one with the same name.
pip install send2trash
I'll be demonstrating the use of these repo with two examples:
-
A Standalone URDF file without any meshes. I've taken the example from gz_ros2_control
-
An URDF with meshes. I've used the MiR 100 Robot developed as a community project. You can check it out here
Each step will be tried with these two examples. You can choose the suitable method based on your requirement.
The same approach will work with Docker as well.
To utilize this project, follow these steps:
-
Clone this repository and copy your URDF file or folder into the cloned repository inside the urdf folder. If you have meshes required with your URDF, copy them too inside the meshes folder.
-
Execute the following command in your terminal from within our repo:
python main.py
-
Just enter your package name, path of the file relative to the urdf folder, simulators you want to work with and if you would like the joint state publisher GUI to test your joints
- Standalone URDF:
- URDF with Meshes: Since the urdf file links to other files in the include folder with a specific pkg name (in this case, mir_description), you MUST use the same name for the pkg name. Else you can change the pkg name in URDF file manually. Let's keep the same default name given in the URDF.
-
Once the package is generated, copy it into your ROS2 workspace, then build and launch it.
To run the demo with GUI we are going to use Rocker which is a tool to run docker images with customized local support injected for things like nvidia support. Rocker also supports user id specific files for cleaner mounting file permissions. You can install this tool with the following instructions. Make sure you meet all of the prerequisites.
-
Clone the repository:
Copy your URDF file or folder into the cloned repository inside the urdf folder. If you have meshes required with your URDF, copy them too inside the meshes folder -
Build the Dockerfile: Navigate into the repo and run
docker build . -t image_name
-
Run the docker: The following commands will open the main program which generates the pkg. Replace path_of_ros_autogen_on_your_host with the actual path.
rocker --x11 --nvidia --name ros_autogen image_name --volume /path_of_ros_autogen_on_your_host:/ros_autogen_runner
-
Run the Script and provide package name and URDF path:
python3 main.py
When prompted, enter your package name and copy the RELATIVE path of the URDF present inside the repository (usually urdf/your_urdf.urdf). This will generate your ROS2 package inside the repository.
-
Launch your Package: In another terminal, run the following commands. Replace package_name with your ros2_pkg generated by the autogen.
cp -r package_name /ros2_ws/src cd /ros2_ws colcon build source install/setup.bash ros2 launch package_name package_name.launch.py
Note: If you have any other dependencies for your launch, use Rosdep or APT installs to install them.
- Support for additional scripts and nodes to be added in launch file (Will be part of another project)
-
If you are spawning the robot with Gazebo Classic, make sure that the main urdf is of format .urdf and NOT .urdf.xacro as it'll cause some troubles while trying to parse it on Gazebo Classic. Just run the command after sourcing the description pkg of the robot to convert the .urdf. xacro to just .urdf
ros2 run xacro xacro your_file.urdf.xacro > your_file.urdf
Then copy THIS .urdf file into the ROS Autogen's urdf folder along with all the other files from the description pkg's urdf folder.
When running the main.py, make sure to point to this .urdf when asked about the path to the URDF.
There's no need to change anything with Ignition Gazebo as it can work with both .urdf and .urdf.xacro.