-
Notifications
You must be signed in to change notification settings - Fork 1
Gazebo Onboarding
This part corresponds to the Official Gazebo Tutorials: Build a Robot. Read through this tutorial. After this tutorial, you should be able to spawn an SDF-defined robot in Gazebo. The following are some notes I found useful.
-
To make your SDF model visible to Gazebo you must 1)have your model follow the formatting rules for the Gazebo Model Database directory structure. 2)put your model inside the Gazebo model search path. Here is an example to create a
My Robot
model defined bymodel.sdf
file inside the default search path (~/.gazebo/models
) -
It is possible to put your SDF model in other directories. Let's say you put it inside your ROS workspace
~/ros_ws/src/my_package/models
, then you have to run$ export GAZEBO_MODEL_PATH=~/ros_ws/src/my_package/models
to add your path to the gazebo search path. -
Gazebo requires that mesh files be formatted as STL, Collada or OBJ, with Collada and OBJ being the preferred formats. If you use STL file, all texture information (e.g., colors) is lost.
build a simple model and spawn inside the Gazebo using the SDF model. For example, a table with five links (i.e., tabletop + four legs).
This part corresponding to the section Using roslaunch to Open World Models.
- The world file in the tutorial is within the /worlds directory of the Gazebo resource path. Alternatively, you can put your world file inside your ROS package src path then use
$(find pkg)
command to locate it.
Create a ROS package. Create a world file that loads your created SDF-based model above, put it inside the /world subfolder of your ROS package root (e.g., ~/ros_ws/src/ros_pkg/world/my_world.world). Create a launch file for your ROS package that launches Gazebo and spawn your SDF-based model.
According to the statement, SDF is superior to URDF in many ways. However, we use URDF instead of SDF to describe a Robot in ROS. For example, Rviz visualizes the robot with the help of URDF (not SDF).
Take a look at this tutorial about building a robot model with URDF. You will find that the syntax is quite similar.
The Xacro is commonly used to crate URDF in a more systematic way. Take a look at this tutorial.
Take a look at this tutorial.
- An
<inertia>
element within each<link>
element must be properly specified and configured.
Take a look at this tutorial. There are two methods documented, but you will find most packages online used the "ROS Service Call Spawn Method".
In the same ROS package that you created in 2. Launch Gazebo using roslaunch command
, create another folder /urdf
. Use XACRO format to model your robot then put it into the /urdf
folder. Create a launch file and use the "ROS Service Call Spawn Method" to launch your model in Gazebo.
This will guide you to add actuators for your robot and setting up the controllers.
Many ROS drivers of a real robot (e.g., Universal_Robots_ROS_Driver) use ros_control to structure the controllers. In Gazebo, we also use ros_control to structure the controller. This makes it much easier to transient from simulation to reality.
- Add transmission elements to link actuators to joints
- Add the gazebo_ros_control plugin into your URDF/XACRO
- Create a .yaml config file to define your controller (see [here] for some commonly used controllers)
- In the launch file, use controller_manager package to spawn or load the controllers.
After this tutorial, you should be able to control the motion of the simulated robot using ROS messages or action services.
Here I listed some problems that I have encountered and finally figured out the cause. Please feel free to contribute to the list.
-
When using roslaunch, Gazebo sometimes can't boot properly.
- This may be caused by your last Gazebo server wasn't being exited properly. Go to the Ubuntu service monitor, see if the process named "gzservice" is running. If so, manually kill this process before roslaunch.
-
Controller manager can’t load controllers properly.
- Some controllers will load only after the simulation start. When started gazebo in paused mode, some controllers will not load until you started the simulation.
-
Newly created simple Xacro-based robot didn’t show up in Gazebo.
- The
<initial>
tag of my link is not specified, which is however required in Gazebo.
- The
Hui showed a step-by-step demo on building a simple robot in Gazebo using URDF and connected with ros_control. The recorded video is uploaded to our google drive (ask permissions if you don't have access)
Quick Links
- Home
- Table of Content
- How to contribute
- Lab Onboarding
- Tutorials