Skip to content

Generates packages with launch files automatically from URDF for ROS2 with Gazebo !

Notifications You must be signed in to change notification settings

Spartan-Velanjeri/ROS2_Autogen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROS_Autogen

License

Description

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.

Table of Contents

Installation

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

Usage

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 diff_drive

  • An URDF with meshes. I've used the MiR 100 Robot developed as a community project. You can check it out here mir100

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.

Linux

To utilize this project, follow these steps:

  1. Clone the repository:

    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.

    • Standalone URDF: Just copy the test_diff_drive.xacro.urdf into the URDF folder of our repo

      standalone_copy

    • URDF with Meshes: Copy the urdf and the include folder into the URDF folder and the mesh files in the mesh folder of the repo respectively.

      mesh_copy

  2. Run the main.py file:

    Execute the following command in your terminal from within our repo:

    python main.py 
    
    
  3. Provide package name and URDF path:

    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:

    standalone_pkg


    • 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.

    create_mesh_pkg


  4. Copy the package into your workspace:

    Once the package is generated, copy it into your ROS2 workspace, then build and launch it.

    • Standalone URDF:

      standalone_demo

    • URDF with Meshes:

      mesh_demo The reason for the lack of rear wheels is that we haven't initialised any controllers here. Once we do that, we can see the wheels as well (not included here)

Docker

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.

  1. 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

  2. Build the Dockerfile: Navigate into the repo and run

    docker build . -t image_name
  3. 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
  4. 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.

  5. 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.

Upcoming_Features

  1. Support for additional scripts and nodes to be added in launch file (Will be part of another project)

Troubleshooting

  1. 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.

About

Generates packages with launch files automatically from URDF for ROS2 with Gazebo !

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published