Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Building a Robotic Arm Model from Scratch Using ROS

Tech 2

URDF Modeling

URDF Overview

The Unified Robot Description Format (URDF) is a standard XML-based format used to describe the geometry and kinematic properties of robotic systems. It plays a key role in simulation, motion planning, control development, and visualization with in the Robot Operating System (ROS).

URDF modeling focuses on defining several core components:

  • Links: Represent rigid parts of a robot such as arms or legs. Each link includes physical properties like mass and inertia, along with geometric representations for collision detection and visualization.
  • Joints: Define how links connect, specifying joint types (e.g., revolute, prismatic), axes, limits, and dynamic characteristics.
  • Inertial Properties: Include mass distribution and moment of inertia for accurate dynamics simulation.
  • Collision Geometry: Simplified shapes used for physics simulation and detecting collisions.
  • Visual Geometry: Detailed mesh representations for rendering and visual feedback.
  • Materials: Color and texture definitions for visual appearance.
  • Actuators: Information about motors or hydraulic systems driving joints.
  • Transmissions: Describe the relationship between actuators and joints.
  • Gazebo Plugins: Extend robot behavior in simulation environments.

URDF models can be manually authored or generated using tools, often based on Denavit-Hartenberg parameters that define relative positions and orientations of joints.

Robot Structure

Links and Joints

Each robot component is defined as either a link or a joint. Links represent static or moving parts, while joints specify their connection and movement constraints.

URDF Limitations

While powerful, URDF has limitations when dealing with complex assemblies or repetitive structures. To address these, Xacro (XML Macros) is commonly used to simplify model creation through reusable macros and parameterization.

Xacro Models

Xacro files allow modular and parametric URDF generation. They support:

  • Constants and variables
  • Mathematical expressions
  • Macro definitions for repeated elements
  • File inclusion for organizing large models

Directory Layout

A typical robot package structure includes:

  • urdf/: Contains URDF and Xacro files
  • meshes/: STL or other 3D model files
  • launch/: Launch files for simulation and visualization
  • config/: Configuration files

Example Package Files

CMakeLists.txt

 cmake_minimum_required(VERSION 2.8.3)
 project(UR3)
 find_package(catkin REQUIRED)
 catkin_package()
 find_package(roslaunch)
 foreach(dir config launch meshes urdf)
   install(DIRECTORY ${dir}/
     DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/${dir})
 endforeach(dir)

package.xml

<package format="2">
  <name>UR3</name>
  <version>1.0.0</version>
  <description>
    <p>URDF Description package for UR3</p>
    <p>This package contains configuration data, 3D models and launch files
for UR3 robot</p>
  </description>
  <author>TODO</author>
  <maintainer email="TODO@email.com" />
  <license>BSD</license>
  <buildtool_depend>catkin</buildtool_depend>
  <depend>roslaunch</depend>
  <depend>robot_state_publisher</depend>
  <depend>rviz</depend>
  <depend>joint_state_publisher_gui</depend>
  <depend>gazebo</depend>
  <export>
    <architecture_independent />
  </export>
</package>

Display Launch File

<launch>
  <arg name="model" />
  <param name="robot_description" textfile="$(find UR3)/urdf/UR3.urdf" />
  
  <node name="joint_state_publisher_gui" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" />
  
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
  
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(find UR3)/urdf.rviz" />
</launch>

Gazebo Launch File

<launch>
  <include file="$(find gazebo_ros)/launch/empty_world.launch" />
  <node name="tf_footprint_base" pkg="tf" type="static_transform_publisher"
    args="0 0 0 0 0 0 base_link base_footprint 40" />
  <node name="spawn_model" pkg="gazebo_ros" type="spawn_model"
    args="-file $(find UR3)/urdf/UR3.urdf -urdf -model UR3"
    output="screen" />
  <node name="fake_joint_calibration" pkg="rostopic" type="rostopic"
    args="pub /calibrated std_msgs/Bool true" />
</launch>

UR3 URDF Model

<?xml version="1.0" encoding="utf-8"?>
<robot name="UR3">
  <link name="base_link">
    <inertial>
      <origin xyz="2.105E-05 0.098059 -0.0036545" rpy="0 0 0" />
      <mass value="1.371" />
      <inertia ixx="0.0018288" ixy="4.4582E-07" ixz="-2.0556E-07"
        iyy="0.0019082" iyz="0.00013405" izz="0.0017646" />
    </inertial>
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://UR3/meshes/base_link.STL" />
      </geometry>
      <material name="">
        <color rgba="0.89804 0.91765 0.92941 1" />
      </material>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://UR3/meshes/base_link.STL" />
      </geometry>
    </collision>
  </link>
  <!-- Additional links and joints follow similarly -->
</robot>

SolidWorks Integration

To convert a SolidWorks model into URDF, utilize plugins like sw2urdf. This process requires selecting a compatible SolidWorks version based on plugin support, complexity of the model, hardware capabilities, licensing costs, and user familiarity.

Model Testing

Once generated, test the model using RViz and Gazebo to verify correct visualization and simulation behavior.

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.