Improving the URDF with Xacro
The more complex your robot, the bigger the URDF. As you add more links and joints, you will end up having problems scaling your robot model. Also, what we have written so far is not so dynamic: all the values are hardcoded.
Xacro is an additional ROS feature you can use to solve all those issues. We will now see how to make a URDF file compatible with Xacro, how to create variables and functions, and how to split your URDF into several files.
With Xacro, your URDF files will become more dynamic and scalable. All serious ROS 2 projects use Xacro, so it’s important to learn how to work with it.
Let’s get started with the setup.
Making a URDF file compatible with Xacro
We will start by making sure our URDF file can use Xacro features. Before doing anything, let’s make sure that Xacro is installed (it should already be there with all the previous packages we installed):
$ sudo apt install ros-<distro>-xacro
Now...