Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Constructing URDF Models for ROS Simulation

Tech May 13 1

To begin modeling robots with in the ROS ecosystem, specific dependencies must be installed within your workspace. At a minimum, the urdf and xacro packages are required. If physical simulation is intended, additional packages such as gazebo_ros, gazebo_ros_control, and gazebo_plugins should be included in the environment setup.

Creating a Basic Model

The following example demonstrates how to define a simple rigid body using URDF. This model consists of a single link representing a chassis, which can be visualized directly in RViz.

Create a file named model.urdf with the following content:

<robot name="simple_bot">
    <link name="base_footprint">
        <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <box size="1.0 0.6 0.3" />
            </geometry>
            <material name="chassis_color">
                <color rgba="0.2 0.4 0.8 1.0" />
            </material>
        </visual>
    </link>
</robot>

To visualize this model, create a launch file named view_model.launch:

<launch>
    <param name="robot_description" textfile="$(find bot_description)/urdf/model.urdf" />
    <node pkg="rviz" type="rviz" name="visualizer" args="-d $(find bot_description)/rviz/config.rviz" />
</launch>

URDF Structure Breakdown

Understanding the hierarchy of tags is essential for building complex robots.

Robot Root

The <robot> tag serves as the root element for the entire description file. It must contain a name attribute.

<robot name="simple_bot">
    ...
</robot>

Link Definition

Links represent the rigid bodies of the robot. Each link requires a unique name.

<link name="base_footprint">
    ...
</link>

Visual Properties

Inside a link, the <visual> tag defines how the link appears in visualization tools.

<visual>
    ...
</visual>

Geometry

Supported shapes include boxes, spheres, and cylinders. Note the correct attribute names for dimensions.

<geometry>
    <box size="1.0 1.0 1.0" />
    <sphere radius="0.5" />
    <cylinder radius="0.2" length="0.5" />
</geometry>

Material

Colors are defined using RGBA values (Red, Green, Blue, Alpha).

<material name="chassis_color">
    <color rgba="0.2 0.4 0.8 1.0" />
</material>

Origin

This tag sets the position and orientation of the visual element relative to the link frame.

<origin xyz="0 0 0" rpy="0 0 0" />

Defining Joints

Joints connect two links together. A valid joint requires at least two links: a parent and a child.

<joint name="connector_joint" type="fixed">
    <parent link="base_footprint" />
    <child link="attachment_link" />
    <origin xyz="0 0 0.5" rpy="0 0 0" />
    <axis xyz="0 1 0" />
</joint>

Common joint types include:

  • fixed: No movement allowed between links.
  • revolute: Rotational movement with limits.
  • continuous: Unlimited rotational movement.
  • prismatic: Linear sliding movement with limits.
  • floating: Allows motion in all degrees of freedom.

Gazebo Simulation Integration

To enable physics simulation and control within Gazebo, specific plugins and properties must be added to the URDF. Below is an updated version of the model configured for simulation.

<robot name="simple_bot">
    <link name="base_footprint">
        <visual>
            <geometry>
                <box size="1.0 0.6 0.3" />
            </geometry>
            <material name="chassis_color">
                <color rgba="0.2 0.4 0.8 1.0" />
            </material>
        </visual>
        <collision>
            <geometry>
                <box size="1.0 0.6 0.3" />
            </geometry>
        </collision>
        <inertial>
            <mass value="10.0" />
            <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0" />
        </inertial>
    </link>

    <gazebo>
        <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
            <robotNamespace>/simple_bot</robotNamespace>
        </plugin>
    </gazebo>

    <gazebo reference="base_footprint">
        <material>Gazebo/Blue</material>
    </gazebo>
</robot>

Tags: ROS

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.