$\color{white}\colorbox{FE9227}{Gaining momentum and expanding knowledge with each milestone!}$
$$▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░ 28.6%
As described in the TF2 section, a robot is described using tf2
transforms. But how do you actually write tf2
transforms? That's where URDF
comes in. A URDF
(Unified Robotics Description Format) is used to define all attributes of a robot in XML format. A URDF
is written such that a simulated environment can interpret all the tf2
transforms for dimensions, sensors, joints, attributes, and visuals of a robot.
Before writing your robot URDF
, it's good practice to create a folder to contain all robot description files. Depending on the complexity of your robot, it's recommended to do this in one of two ways.
For simple robots that use general shape-defined geometry (circles, squares, and cylinders) and do not require any custom mesh
or config
files, all URDFs can be contained within a urdf
folder.
Create a urdf
folder in the root of your package, and make sure that you add this data_files
to your setup.py
.
cd ~/humble_ws/src/ros_robot/
mkdir urdf
For more complex robots, for example, ones that have meshes
to describe joint
geometry and config
files for joint
controllers, creating a models
subfolder will be useful in order to organize and include all necessary files.
In the root of your package, create a models
folder, and then create a subfolder with the name of your robot.
cd ~/humble_ws/src/ros_robot/
mkdir models/my_robot/
Within your named robot subfolder, create three new directories: config
, meshes
, and urdf
(urdf
can be replaced by xacro
ADD LINK TO XACRO TUTORIAL if you are using that format).
Make sure you add this models
folder to data_files
in setup.py
.
To begin a URDF
file, you must declare the robot
tag and give your robot a unique name. These tags will both begin and end your robot description, so all relevant robot descriptions should be included within these tags.
<robot name="robot">
<!-- ALL ROBOT DESCRIPTIONS -->
</robot>
Having a clear and organized URDF
file is very helpful when creating your robot. It allows for much easier debugging and tweaks to joint
positions and parameters. The common practice when writing a URDF
is to first define all your links
, then to define all your joints
. This ensures that no joints
are called before their contained links
are defined.
<robot name="robot">
<!-- ALL LINK DEFINITIONS -->
<!-- ALL JOINT DEFINITIONS -->
</robot>