# URDF
## What is a URDF
A **URDF (Unified Robot Description Format)** in ROS 2 is an XML file format used to describe a robot's structure. It defines the robot's physical properties, such as its links (rigid parts), joints (connections), dimensions, and more. URDFs are crucial for simulation, visualization, and robot control as they provide the framework for tools like RViz and Gazebo to understand the robot's design.
here is a sample:
```xml title="my_robot.udrf" linenums="1"
```
### Materials
Materials allow color and other information to be added to a ``
```xml linenums="1"
```
### Links
**Links** are fundamental building blocks in a URDF file that represent the robot's physical parts. They allow you to create the individual parts of the robot and they are made up of multiple parts.
#### Visual
1. **`origin`**:
- Specifies the position and orientation of the visual geometry relative to the link's frame.
- Example: ``.
2. **`geometry`**:
- Describes the shape of the link. Shapes can be:
- **Box**: `` specifies dimensions.
- **Cylinder**: ``.
- **Sphere**: ``.
- **Mesh**: `` for complex shapes.
3. **`material`**:
- Specifies the color or texture of the link.
- **Color**: `` uses RGBA values (alpha for transparency).
- **Texture**: `` for applying an image.
```xml linenums="1"
```
#### Inertial
The inertia element is used to calculate the movement of the robot in gazebo. The inertia element is a requirement for the gazebo simulation. To get the 3D tensor for the inertia values use this [Wikipedia link](https://en.wikipedia.org/wiki/List_of_moments_of_inertia#List_of_3D_inertia_tensors). I is usually best to put these inertia calculations in xacro function to allow them to be use all over the robot like shown.
```xml linenums="1"
```
##### Bug
Sometimes the inertial values have to be increased to fix drifting in gazebo. To do this usual you just multiply all the inertial input by `2` or `3`.
```xml linenums="1"
```
#### Collisions
The collision element is added inside the link element to give gazebo the information on the collision shape of the robot. This is usually a simplify shape to make the simulation easy on the computer.
```xml linenums="1"
```
### Gazebo
The gazebo element allows you to specifies information for gazebo.
#### Plugin
The plugin feature of URDF for gazebo lets you add ROS topics to URDF files so that you can simulate different inputs and outputs of values.
```xml
50base_left_wheel_jointbase_right_wheel_joint${wheel_length + base_width}${wheel_radius}cmd_veltruetruetrueodomodombase_footprint
```
#### Material
Adding material to gazebo you have to add a custom gazebo material.
```xml
Gazebo/Gray
```
### Joints
Joints are what old different objects together. There are many different types of joints as shown below. There are also different parts to a joint. The `` link tells the join what it is attached to while the `` link tells it what its child is. The `` section tells the joint where it is located with the `xyz`being the coordinates and the `rpy` being role, pitch, and yaw. The `` section indicates a 1 for allowed moment and a 0 for no movement. Finally the `` section gives a lower and upper bound.
#### revolute
A hinge joint that rotates along the axis and has a limited range specified by the upper and lower limits that are in radians.
```xml
```
#### continuous
A continuous hinge joint that rotates around the axis and has no upper and lower limits.
```xml
```
#### prismatic
A sliding joint that slides along the axis, and has a limited range specified by the upper and lower limits in meters.
```xml
```
#### fixed
This is not really a joint because it cannot move. All degrees of freedom are locked. This type of joint does not require the ``, ``, ``, `` or ``.
```xml
```
#### floating
This joint allows motion for all 6 degrees of freedom.
```xml
```
#### planar
This joint allows motion in a plane perpendicular to the axis.
```xml
```
### Meshes
This allows you to import meshes into your URDF from CAD programs. This allows you to add complex parts to your robot.
```xml
```
## Links For Help
Here are some links for help.
- [ROS.org](https://wiki.ros.org/urdf/XML)