Skip to content
Pedro Alcantara edited this page Oct 21, 2020 · 2 revisions

Welcome to the mobile_robot_description wiki!

This wiki shows with more details the usage of the modules of this package. This is an example of how to use the modules of this package to create the generic mobile robot shown in the image.

mobile_robot

<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="mobile_robot">

  <xacro:property name="package_name" value="mobile_robot_description"/>
  <xacro:property name="robot_name" value="mobile_robot"/>

  <xacro:include filename="$(find ${package_name})/urdf/include/common_macros.urdf.xacro" /> 

  <xacro:property name="back_wheel_yaml" value="$(find ${package_name})/config/${robot_name}/back_wheel.yaml" />
  <xacro:property name="back_wheel_props" value="${load_yaml(back_wheel_yaml)}"/>

  <xacro:property name="front_wheel_yaml" value="$(find ${package_name})/config/${robot_name}/front_wheel.yaml" />
  <xacro:property name="front_wheel_props" value="${load_yaml(front_wheel_yaml)}"/>

  <xacro:property name="base_yaml" value="$(find ${package_name})/config/${robot_name}/base.yaml" />
  <xacro:property name="base_props" value="${load_yaml(base_yaml)}"/>

  <!-- Base link -->
  <xacro:base base_prop="${base_props}" >
    <origin xyz="0 0 0" rpy="0 0 0" />
  </xacro:base> 
  <!-- Back Wheels -->
  <xacro:wheel prefix="back_right" reflect="-1"
                      wheel_props="${back_wheel_props}"
                      base_props="${base_props}">                    
  </xacro:wheel>

  <xacro:wheel prefix="back_left" reflect="1"
                      wheel_props="${back_wheel_props}"
                      base_props="${base_props}">
  </xacro:wheel>

  <!-- Front Wheels -->
  <xacro:wheel prefix="front_right" reflect="-1" 
                      wheel_props="${front_wheel_props}"
                      base_props="${base_props}"> 
  </xacro:wheel>

  <xacro:wheel prefix="front_left" reflect="1" 
                      wheel_props="${front_wheel_props}"
                      base_props="${base_props}"> 
  </xacro:wheel>       

</robot>

Let's break this code into pieces to explain it.

  <xacro:property name="package_name" value="mobile_robot_description"/>
  <xacro:property name="robot_name" value="mobile_robot"/>

These two lines are very important. In order to use the modules correctly, you should set the global xacro:property package_name and robot_name with the name of your project and the name of the robot that should be the same name as the folder used to organize the config files. These xacro:properties are used for the modules as path files reference. After that, the file includes the common_macro.urdf.xacro file that works as a "module library".

   <xacro:include filename="$(find ${package_name})/urdf/include/common_macros.urdf.xacro" /> 

The wheel and base link properties are set using YAML files. This approach makes more flexible the configuration of the model.

  <xacro:property name="back_wheel_yaml" value="$(find ${package_name})/config/${robot_name}/back_wheel.yaml" />
  <xacro:property name="back_wheel_props" value="${load_yaml(back_wheel_yaml)}"/>

  <xacro:property name="front_wheel_yaml" value="$(find ${package_name})/config/${robot_name}/front_wheel.yaml" />
  <xacro:property name="front_wheel_props" value="${load_yaml(front_wheel_yaml)}"/>

  <xacro:property name="base_yaml" value="$(find ${package_name})/config/${robot_name}/base.yaml" />
  <xacro:property name="base_props" value="${load_yaml(base_yaml)}"/>

Here the content of the config files is loaded and attributed to the variables that are dictionaries. With all the information, to build the robot you just need to add the modules to compose your module.

  <!-- Base link -->
  <xacro:base base_prop="${base_props}" >
    <origin xyz="0 0 0" rpy="0 0 0" />
  </xacro:base> 
  <!-- Back Wheels -->
  <xacro:wheel prefix="back_right" reflect="-1"
                      wheel_props="${back_wheel_props}"
                      base_props="${base_props}">                    
  </xacro:wheel>

  <xacro:wheel prefix="back_left" reflect="1"
                      wheel_props="${back_wheel_props}"
                      base_props="${base_props}">
  </xacro:wheel>

  <!-- Front Wheels -->
  <xacro:wheel prefix="front_right" reflect="-1" 
                      wheel_props="${front_wheel_props}"
                      base_props="${base_props}"> 
  </xacro:wheel>

  <xacro:wheel prefix="front_left" reflect="1" 
                      wheel_props="${front_wheel_props}"
                      base_props="${base_props}"> 
  </xacro:wheel>       

The specific information of each module is on the respective page. For more information about the xacro you can check the Xacro ROS Wiki

Clone this wiki locally