This is a Work in Progress document.
So in that case, the specific model and variation of the robot depends only in the robot.urdf.xacro that can be found in robots folder
To create a new robot that it's not defined in robotnik_description we will use the mobile base macro files. This macro files includes the body and wheels, all the basics of the robots, all the modifications are over this macro.
You can base in the robot_template.urdf.xacro file.
- Start by including the macro files needed (robot base macro, sensors and all the needed structures).
<!-- Import all posible elements defined in the urdf.xacro files. All these elements are defined as macro:xacros -->
<xacro:include filename="$(find robotnik_description)/urdf/bases/rbvogui/rbvogui_base.urdf.xacro" />
<xacro:include filename="$(find robotnik_sensors)/urdf/all_sensors.urdf.xacro" />
- Define arguments of the urdf.
<!-- Args -->
<xacro:arg name="robot" default="rbvogui"/>
<xacro:arg name="namespace" default="robot"/>
<xacro:arg name="prefix" default="robot_"/>
<xacro:arg name="has_arm" default="false"/>
<xacro:arg name="gazebo_classic" default="false"/>
- Define parameters of the urdf.
<!-- Properties -->
<xacro:property name="hq" value="true"/>
<xacro:property name="front_laser_offset_x" value="0.2865"/>
<xacro:property name="front_laser_offset_y" value="-0.20894"/>
<xacro:property name="front_laser_offset_z" value="0.2973"/>
- Call the macro of the robot base.
<!-- Robot -->
<xacro:rbvogui prefix="$(arg prefix)" hq="${hq}"/>
- Call the macros of the sensors.
<!-- Sensors -->
<xacro:sensor_sick_s300 prefix="rbkairos_front_laser" parent="rbkairos_base_link" prefix_topic="front_laser" gpu="true">
<origin xyz="${front_laser_offset_x} ${front_laser_offset_y} ${front_laser_offset_z}" rpy="0 ${-PI} ${3/4*PI}" />
</xacro:sensor_sick_s300>
- Add arm if the robot has it.
<!-- Arm -->
<xacro:if value="$(arg has_arm)">
<xacro:arg name="ur_type" default="ur5e"/>
<xacro:arg name="ur_name" default="$(arg ur_type)"/>
<xacro:arg name="joint_limit_params" default="$(find ur_description)/config/$(arg ur_type)/joint_limits.yaml"/>
<xacro:arg name="kinematics_params" default="$(find ur_description)/config/$(arg ur_type)/default_kinematics.yaml"/>
<xacro:arg name="physical_params" default="$(find ur_description)/config/$(arg ur_type)/physical_parameters.yaml"/>
<xacro:arg name="visual_params" default="$(find ur_description)/config/$(arg ur_type)/visual_parameters.yaml"/>
<xacro:arg name="use_fake_hardware" default="false" />
<xacro:arg name="fake_sensor_commands" default="false" />
<xacro:arg name="sim_gazebo" default="true" />
<xacro:arg name="sim_ignition" default="false" />
<xacro:include filename="$(find robotnik_description)/urdf/arms/ur/ur.urdf.xacro"/>
</xacro:if>
- Add the control plugin for Gazebo, if it is going to be used in simulation
<!-- Control -->
<xacro:include filename="$(find robotnik_description)/simulators/gazebo_classic/rbvogui/rbvogui_control.urdf.xacro" />
<xacro:if value="$(arg gazebo_classic)">
<xacro:rbvogui_gz_classic_control namespace="$(arg namespace)" prefix="$(arg prefix)"/>
<xacro:ros_planar_move_gazebo_classic/>
</xacro:if>
To understand the structure of the robots definition let's see an example, in this case the rbkairos.urdf.xacro.
First, it is included the macro file of the base robot (body + wheels) and the sensors macro that are in the package robotnik_sensors.
<xacro:include filename="$(find robotnik_description)/urdf/bases/rbkairos/rbkairos_base.urdf.xacro" />
<!-- Import all available sensors -->
<xacro:include filename="$(find robotnik_sensors)/urdf/all_sensors.urdf.xacro" />
Then, there are some properties declared to define the position of the sensors.
<xacro:property name="front_laser_offset_x" value="0.2865"/>
<xacro:property name="front_laser_offset_y" value="-0.20894"/>
<xacro:property name="front_laser_offset_z" value="0.2973"/>
<xacro:property name="rear_laser_offset_x" value="-0.2865"/>
<xacro:property name="rear_laser_offset_y" value="0.20894"/>
<xacro:property name="rear_laser_offset_z" value="0.2973"/>
<xacro:property name="imu_offset_x" value="0.127"/>
<xacro:property name="imu_offset_y" value="-0.129"/>
<xacro:property name="imu_offset_z" value="0.212"/>
Next, the macro of the robot is called.
<xacro:rbkairos/>
And finally the sensors are called, including the position declared in the properties.
<!-- IMU -->
<xacro:sensor_vectornav prefix="rbkairos_" parent="rbkairos_base_link" topic="imu/data">
<origin xyz="${imu_offset_x} ${imu_offset_y} ${imu_offset_z}" rpy="0 0 0"/>
</xacro:sensor_vectornav>
<!-- SENSORS -->
<xacro:sensor_sick_s300 prefix="rbkairos_front_laser" parent="rbkairos_base_link" prefix_topic="front_laser" gpu="true">
<origin xyz="${front_laser_offset_x} ${front_laser_offset_y} ${front_laser_offset_z}" rpy="0 ${-PI} ${3/4*PI}" />
</xacro:sensor_sick_s300>
<xacro:sensor_sick_s300 prefix="rbkairos_rear_laser" parent="rbkairos_base_link" prefix_topic="rear_laser" gpu="true">
<origin xyz="${rear_laser_offset_x} ${rear_laser_offset_y} ${rear_laser_offset_z}" rpy="0 ${-PI} ${-1/4*PI}" />
</xacro:sensor_sick_s300>
Let's see now the macro file definition.
Moving to the macro file included in the previous robot file rbkairos_base.urdf.xacro.
As in the previous robot file, first it is included the robot body macro file and the wheels macro file.
<xacro:include filename="$(find robotnik_description)/urdf/bodies/rbkairos/rbkairos_plus_body.urdf.xacro" />
<xacro:include filename="$(find robotnik_description)/urdf/wheels/omni_wheel/omni_wheel.urdf.xacro" />
Then, it is defined the properties of the position of the wheels.
<xacro:property name="PI" value="3.1415926535897931"/>
<!-- Wheel parameters -->
<xacro:property name="wheel_offset_x" value="0.21528" /> <!-- x,y,z in translation from base_link to the center of the wheel -->
<xacro:property name="wheel_offset_y" value="0.2590" />
<xacro:property name="wheel_offset_z" value="0.0" />
And finally, the robot macro definition which includes calling the macro body (chassis + logos) and the wheels macros.
<xacro:macro name="rbkairos">
<!-- *************** -->
<!-- Robots Elements -->
<!-- *************** -->
<!-- Here we create the robot elements using the xacro:macros imported at the beggining of this file -->
<xacro:rbkairos_plus_body />
<xacro:omni_wheel prefix="rbkairos_front_right" parent="rbkairos_base_link" reflect="false" hq="true">
<origin xyz="${wheel_offset_x} -${wheel_offset_y} ${wheel_offset_z}" rpy="0 0 0"/>
</xacro:omni_wheel>
<xacro:omni_wheel prefix="rbkairos_front_left" parent="rbkairos_base_link" reflect="true" hq="true">
<origin xyz="${wheel_offset_x} ${wheel_offset_y} ${wheel_offset_z}" rpy="0 0 0"/>
</xacro:omni_wheel>
<xacro:omni_wheel prefix="rbkairos_back_left" parent="rbkairos_base_link" reflect="true" hq="true">
<origin xyz="-${wheel_offset_x} ${wheel_offset_y} ${wheel_offset_z}" rpy="0 0 0"/>
</xacro:omni_wheel>
<xacro:omni_wheel prefix="rbkairos_back_right" parent="rbkairos_base_link" reflect="false" hq="true">
<origin xyz="-${wheel_offset_x} -${wheel_offset_y} ${wheel_offset_z}" rpy="0 0 0"/>
</xacro:omni_wheel>
</xacro:macro>
The macro body file includes the links and joints definition of the base_link, base_footprint, etc.
The wheels macro file includes the links and joints of the mecanum wheel.