Welcome to Jetson Orin NX Developer Kit repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
21.ROS2 URDF model
21. ROS2 URDF model
1. Introduction to URDF
The modeling method in ROS is called URDF, which stands for Unified Robot Description Format. It can not only clearly describe the robot model itself, but also describe the external environment of the robot. URDF model files use the XML format.
SolidWorks model to URDF plugin: sw_urdf_exporter - ROS Wiki
2. Composition of the robot
During the process of modeling and describing a robot, we first need to be familiar with the composition and parameters of the robot. For example, a robot is generally composed of four major parts: the hardware structure, the drive system, the sensor system and the control system. Some of the common robots on the market, whether mobile robots or robotic arms, can all be broken down according to these four major parts.

The hardware structure refers to the devices that you can really see, such as the chassis, the housing and the motors;
The drive system is the device that drives these devices to work properly, such as the motor driver, the power management system, etc.;
The sensor system includes the encoder on the motor, the onboard IMU, the installed camera, the radar, etc., which makes it convenient for the robot to sense its own state and the external environment;
The control system is the main carrier of our development process, generally a computing platform such as a Raspberry Pi or a computer, as well as the operating system and the application software inside it.
The process of robot modeling is actually a similar idea: describe every part of the robot clearly with a modeling language and then combine them together.
3. URDF syntax
3.1. Description of the link
The tag is used to describe the appearance and the physical properties of a rigid body of the robot. The appearance includes the size, the color and the shape, and the physical properties include the mass, the inertia matrix, the collision parameters, etc.

Taking this robotic arm link as an example, its link description is as follows:
The name in the link tag indicates the name of the link. We can customize it, and this name will be used when the joint connects the links in the future.
The
indicates the geometric shape. The inside it calls a blue appearance that was designed in advance in 3D software, that is, this stl file, which looks the same as the real robot. indicates the offset of the coordinate system relative to the initial position, which is the translation along the x, y and z directions, and the roll, pitch and raw rotations. If no offset is needed, all of them are 0.
The second part,
The
part focuses on describing what the robot looks like, that is, the visual effect; The
part describes the state of the robot during its motion, for example, how the robot is considered to be in collision with the outside world.
In this robot model, the blue part is described by

If it is a mobile robot, the link can also be used to describe the body of the car, the wheels and other parts.
3.2. Description of the joint
The rigid bodies in the robot model can finally produce a relative motion only after they are connected by the joints.
There are six motion types for the joints in URDF.

continuous, which describes rotational motion and can rotate infinitely around a certain axis. For example, the wheels of a car belong to this type.
revolute, which is also a revolute joint. The difference from the continuous type is that it cannot rotate infinitely but has an angle limit. For example, the two links of a robotic arm belong to this motion.
prismatic, which is a sliding joint. It can translate along a certain axis and also has a position limit. Generally, a linear motor uses this motion mode.
fixed, a fixed joint. It is the only joint that does not allow any motion, but it is still used quite frequently. For example, a camera link is installed on the robot and its relative position does not change. The connection type used in this case is Fixed.
Floating is the floating joint, and the sixth type, planar, is the planar joint. These two are used relatively less.

In a URDF model, every link is described with such a piece of xml content, for example what the name of the joint is and which motion type it is.
parent tag: describes the parent link;
child tag: describes the child link, and the child link moves relative to the parent link;
origin: indicates the relationship between the coordinate systems of the two links, which is the red vector in the figure. It can be understood as how the two links should be mounted together;
axis indicates the unit vector of the motion axis of the joint. For example, if z is equal to 1, it means that this rotational motion is carried out around the positive direction of the z axis;
limit indicates some restrictions on the motion, such as the minimum position, the maximum position and the maximum speed, etc.
4. Complete robot model

Finally, all the link and joint tags complete the description and the combination of every part of the robot. Putting them all into a single robot tag forms the complete robot model.
So when you are looking at a certain URDF model, do not rush to look at the details of each block of code. First, look for the link and the joint to see which parts this robot is composed of. After you understand the overall picture, then look at the details.
4.1. Creating the robot model
Taking the muto model as an example, copy the yahboomcar_description function package in the folder of this lesson into the src directory of the workspace:

urdf: stores the URDF or xacro file of the robot model
meshes: stores the model rendering files referenced in the URDF
launch: saves the relevant startup files
rviz: saves the rviz configuration file
Then compile the function package
colcon build --packages-select yahboomcar_description
4.2. Model visualization result
Refresh the environment variables and then run the startup command
xxxxxxxxxxros2 launch yahboomcar_description display.launch.py
Afterwards rviz is started automatically and displays the robot model: