ROS2 and Gazebo: multiple robots

URDF files


Two XACRO variables are added, "robot_name" and "namespace". That meand we can pass these variables to our "main" XACRO file (this one) and variables will be available in all included XACROs:


Earlier, I have passed these variables like this:


You saw this approach in a previous tutorial, where I have passed colors for two different robots. Here I also pass variables to replace placeholders (below).


In this (and all other) XACRO file, we need to take care of the topic names and frame names. As I already mentioned, topic names should be prefixed (namespaced) like this:
topic -> /robot1/topic
while frame names should have no leading slash:
frame -> robot1/frame

We can access variables passed to URDF as $(arg robot_name) (here "robot_name" is the name of a variable).



Same idea as above, we need to add a namespace prefix to topics and frames. Note the difference between $(arg robot_name) (robot1/) and $(arg namespace) (/robot1). I am almost sure there is an easier way, but this one works.


imu_sensor and rest of xacro files

Again, same idea as above, nothing new.

(C), all rights reserved

Please read the disclaimer