Final Model

Create a Mobile Robot Model with ROS + URDF

Pasindu_Sandima
Arimac

--

Mobile robots are used in most of the ROS applications. These mobile robots can be categorized in to different types by its steering mechanism such as differential drive, ackerman steering, skid steering etc. To simulate these robots in Gazebo as well as to visualize in Rviz, a robot description is needed. In ROS, URDF (Universal Robot Description Format) is used for this task. This article is a step-by-step guide on creating a differential drive mobile robot using ROS and URDF.

Step 1 — Creating the 3D files

First, a CAD model of the robot should be designed. This can be done using any CAD design software such as Solidworks and AutoCAD. The Solidworks files for this tutorial can be found here.

The Solidworks parts such as the base, wheel and the caster should be exported to Collada(.dae) format to be able to include in the robot description. This can be done using Blender. The process of exporting from Solidworks to blender can be found here. The Collada files generated from Blender can be found here.

Solidworks and Blender View

Step 2 — Creating the Workspace

Create a workspace for the robot model and create a package named onebot_description and build the workspace.

mkdir onebot_ws
cd onebot_ws/
mkdir src
catkin init
cd src/
catkin_create_pkg onebot_description
catkin build

Step 3 — Creating the URDF files

Inside the onebot_description package create a folder named URDF and create new files named onebot.urdf.xacro, caster.urdf.xacro and wheel.urdf.xacro.

Create folder named meshes and place the Collada (.dae) files inside that folder. After this step the folder structure should be as follows.

└── src
└── onebot_description
├── CMakeLists.txt
├── package.xml
├── meshes
│ ├── base_link.dae
│ ├── caster_base2.dae
│ ├── caswheel.dae
│ └── wheel.dae
└── urdf
├── caster.urdf.xacro
├── onebot.urdf.xacro
└── wheel.urdf.xacro

Step 4 — Creating the Launch File

Now that the URDF is ready, a launch file is needed to upload the robot description to the parameter server and run the necessary nodes needed for the simulation and visualization.

Create a new package named onebot_bringup using the following command.

cd onebot_ws/src
catkin_create_pkg onebot_bringup

Inside the package create a folder named launch and create a launch file named onebot_bringup.launch inside it.

In the launch file, first the gazebo simulator is launched with an empty world. Next, robot description is uploaded to the parameter server using xacro. The node onebot_spawn is launched to spawn the robot in the gazebo simulator.

Then the joint state publisher and the robot state publisher nodes are launched. Joint state publisher node helps to visualize the robot in Rviz by publishing fake joint state values and the robot state publisher publishes the TFs by listening the joint states published by the joint state publisher.

To launch the robot, first use the catkin build command to build the workspace as a new package was created. Then source the setup files of the workspace. Finally, launch the above launch files. The set of commands are listed below.

catkin build
source devel/setup.bash
roslaunch onebot_bringup onebot_bringup.launch mesh_enabled:=true

To visualize the the robot in Rviz run the following command in a new terminal after sourcing the setup file.

rosrun rviz rviz

rviz can be directly launched by adding the following code snippet to the launch file.

<node name="rviz" pkg="rviz" type="rviz" output="screen"/>

Onebot visualization and simulation in Rviz and Gazebo respectively.

Step 5 — Integrating the Diff Drive Controller

First create a package to include the controller configurations.

catkin_create_pkg onebot_control

Create a new folder named config and create a file named control.yaml inside it.

The joint state controller is used to publish the joint states from the hardware interfaces defined in the URDF and the Diff Drive Controller is used to control the robot navigation.

Next, change the onebot_bringup.launch file to load the parameters and fire up the controllers by adding the following code snippet.

<rosparam command="load" file="$(find onebot_control)/config /control.yaml " />
<node name="base_controller_spawner" pkg="controller_manager" type="spawner" args="joint_state_controller velocity_controller"/>

Then remove the joint state publisher node from the launch file. The final launch file can be found here.

Now the folder structure should be as follows.

.
└── src
├── onebot_bringup
│ ├── launch
│ │ └── onebot_bringup.launch
│ ├── CMakeLists.txt
│ └── package.xml
├── onebot_control
│ ├── config
│ │ └── control.yaml
│ ├── CMakeLists.txt
│ └── package.xml
└── onebot_description
├── meshes
│ ├── base_link.dae
│ ├── caster_base2.dae
│ ├── caswheel.dae
│ └── wheel.dae
├── CMakeLists.txt
├── package.xml
└── urdf
├── caster.urdf.xacro
├── materials.urdf.xacro
├── onebot.urdf.xacro
└── wheel.urdf.xacro

Step 6 — Navigate the robot

Now the robot can be navigated in the world by publishing into the velocity_controller/cmd_vel topic.

$ rostopic pub -r 50 /velocity_controller/cmd_vel geometry_msgs/Twist "linear:
x: 0.20
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0"

It is difficult to navigate with this method. Therefore rqt_plugins have provided a robot steering plugin to make this task less difficult. This plugin can be loaded by running the following command.

$ rosrun rqt_robot_steering rqt_robot_steering

Make sure to change the topic to velocity_controller/cmd_vel of the rqt_robot_steering plugin.

Conclusion

After following all the steps above, launch the onebot_bringup.launch file and the rqt_robot_steering plugin. Then the robot can be navigated in the world as follows.

Navigating the Robot

The complete workspace can be cloned from here.

--

--

Pasindu_Sandima
Arimac

Graduate | Electronics and Telecommunication Engineering | University of Moratuwa