ROS2 and Gazebo: multiple robots

URDF files

robot.urdf.xacro

This file includes other files, allowing us to use modular approach.

                        
                    

If you compare this file to what you saw in the previous sections, you will see the following changes:

                        
                    

We use xacro:arg to get the parameter that was passed to the xacro from the outside; in our case, we passed it from the launch file by adding the following to robot_description_config:

                        
                    

Now we can use same xacro with different namespace and colors.

robot_core.xacro

This file describes the robot (as opposed to camera, lidar, controllers...) It is very similar to what you saw in previous sections, except now we use parameters we passed from launch file. You can see the complete code in an archive, here I am going to focus on important details:

                        
                    

gazebo_control.xacro

I use diff. drive in our robot and to control it, diff. drive controller is required. Of course to send distinctive commands to wheels of different robots it has to know their (wheels') full (prefixed by namespace) names:

                        
                    

imu_sensor and rest of xacro files

The idea is the same as with dif. drive controller: we need to make this sensor distinct, so that robots each use its own sensor.

                        
                    

The approach used in other xacro files is the same: we prefix all we need, and that's all.

(C) snowcron.com, all rights reserved

Please read the disclaimer