Exploring ROS using a 2 Wheeled Robot #1: Basics of Robot Modeling using URDF
Explore the basics of robot modeling using the URDF
In this tutorial, we’re going to explore the basics of robot modeling using the Unified Robot Description Format (URDF). At the end of this tutorial, we will have a model ready and running in Gazebo simulator. Let’s start!
First of all, this project was created to help ROS beginners to understand the main tools ROS provides using a quite simple kind of robot. In order to do that, we are going to use ROSDS (ROS Development Studio). In this first part, we are going to create a robot model, visualize it in RViz and spawn it into a gazebo world.
Go to this page to start using it! Create a new ROSject and open it. That’s our development environment or ROSDS desktop:
Let’s start creating our package, inside of simulation_ws/src:
user:~$ cd ~/simulation_ws/src
user:~$ catkin_create_pkg m2wr_description urdf
The first we are gonna do it to create the robot description file. We are using a XACRO file. It’s a big file in this first moment, we will explain how to break it into different ones in the next posts, but for now let’s keep it like that. It’s shown only the beginning of the file. See the full content here.
Create a new folder urdf inside of ~/simulation_ws/src/m2wr_description and paste the robot description to a new file: ~/simulation_ws/src/m2wr_description/urdf/m2wr.xacro
<?xml version="1.0" ?>
<robot name="m2wr" xmlns:xacro="http://www.ros.org/wiki/xacro">
<color rgba="0.0 0.0 0.0 1.0"/>
<color rgba="0.203125 0.23828125 0.28515625 1.0"/>
<color rgba="0.0 0.8 0.0 1.0"/>
What do we have there?
Basically, it’s a robot composed by 3 links and 2 joints. Every robot needs a base link, in this case, the chassis is in charge of connecting all the parts of the robot. See below an image that represents the relation between the links and joints. (Links in green, joints in blue).
We have our robot model defined. Let’s check it in RViz. In order to do that, let’s create a launch file and that opens RViz and fill its robot visualization with our fresh new model.
Create a new folder: ~/simulation_ws/src/m2wr_description/launch/rviz.launch
You can copy & paste the content below to the launch file we have just created:
<param name="robot_description" command="cat '$(find m2wr_description)/urdf/m2wr.xacro'"/>
<!-- send fake joint values -->
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
<param name="use_gui" value="False"/>
<!-- Combine joint values -->
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"/>
<!-- Show in Rviz -->
<node name="rviz" pkg="rviz" type="rviz" />
Now, open a terminal or get back to the one you had opened before and compile the simulation_ws. (we actually don’t have anything to be compiled, but we need catkin to generate ROS header files, in order to have it into our $ROS_PACKAGE_PATH). After compiling it, launch the RViz visualization of the robot. You’ll execute something like:
user:~$ cd ~/simulation_ws
user:~/simulation_ws/$ roslaunch m2wr_description rviz.launch
Now, let’s open the Graphical Tools application:
Great! We have a consistent robot model!
Now.. Let’s spawn it into a gazebo simulation. First, create a new launch file: ~/simulation_ws/src/m2wr_description/launch/spawn.launch
Stop the last launch file we started (for RViz), we are going to use the same terminal once again.
Start an empty simulation, from the simulations menu:
You should have the empty simulation ready:
Finally, spawn the robot to the Gazebo simulation. In your terminal, execute the following:
user:~/simulation_ws$ roslaunch m2wr_description spawn.launch
Check gazebo simulation again, the robot is there!
In case you have missed some part of the tutorial, you can have a copy of the ROSject we generated by writing this post: http://www.rosject.io/l/8e6c887/
In this next tutorial, we will explore the macros for URDF files using XACRO files.
Don’t forget to leave a comment! Let us know what you think about this kind of post! We will be glad to have your opinion!
- Click to share on Twitter (Opens in new window)
- Click to share on Facebook (Opens in new window)
- Click to share on Reddit (Opens in new window)
- Click to email this to a friend (Opens in new window)
- Click to print (Opens in new window)
- Click to share on Google+ (Opens in new window)
- Click to share on Tumblr (Opens in new window)
- Share on Skype (Opens in new window)
- Click to share on Pinterest (Opens in new window)
- Click to share on WhatsApp (Opens in new window)
- Click to share on Telegram (Opens in new window)