Gazebo | Ignition | Community
Ask Your Question

URDF (.xacro) vs model file (.sdf) with ROS

asked 2017-05-10 11:58:44 -0600

tsbertalan gravatar image

updated 2017-05-10 17:31:59 -0600

I'm trying to develop a simulation in Gazebo of my existing ROS-controlled bot. It occurs to me that it would be nice to be able to use the same control/mapping/planning software on the real machine or Gazebo, with only a difference in launch files.

I've written an SDF file by hand that roughly models my bot, and a launch file that (apparently) allows me to keyboard-teleop (though it's not clear that there's any actual feedback control happening).

However, to write this, I had to selectively ignore parts of many tutorials I found that referred to <gazebo> tags and URDF/.xacro files. Am I doing this wrong? Should I not have a models/gunnarsubdirectory (symlinked into ~/.gazebo/models)? Should I have some set of .xacro, .xml, and .gazebo files, derived from my current .sdf and .config files? How should my launch file change? And my environment variables?

Various pieces of information available in many incomplete or outdated tutorials disagree on these points, and the Gazebo documentation seems to be much more complete for the C++ interface.

For that matter, do I have to use ros_control? How much of my current move_base stack will I need to rewrite to so that the simulation and the real bot are drop-in replacements for each other, API-wise? My guess is that ros_control simulates my existing embedded (Arduino) PID controllers from the physical robot, but doesn't supplant move_base.

The robotican repo, which seems to be under active development and so presumably uses modern techniques, uses sdf files only for props, and a hierarchy of xacro files for each robot. When launching, it seems like they're using <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" ... for getting this into Gazebo, and to load part of this hierachy into a ROS parameter called robot_description otherwise, though I'm not sure why.

So, I suppose I'll try to copy the methods of the robotican repo, but it's frustrating that there isn't a complete MWE for each of the Gazebo tutorials.

After trawling around a bit, I'm now finding that the contents of the various ros-kinetic-turtlebot-* packages might have the examples I need, in particular turtlebot_gazebo and all of its dependencies. I'm at work now adapting its .launch, .urdf.xacro, etc. files to my robot now.

If no one has any comments on what I might be doing wrong by this (outdated methods, etc.) I'll summarize what I end up doing in my own answer later in the week.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-05-24 17:13:50 -0600

tsbertalan gravatar image

updated 2017-05-24 17:29:17 -0600

The turtlebot_gazebo turned out to be the best reference. In particular, I looked at the turtlebot_description and kobuki_description files. The primary difference between .urdf.xacro files and plain .sdf seems to be the ability to write macros in files which are eventually passed to xacro for compilation into sdf files.

However, it's still less clear to me when I should be writing xdf xml and when I should be writing urdf. The Gazebo ROS documentation claims that I should be using <gazebo> tags for my links, joints, and the main robot tag. However, I seem to be getting similar functionality simply by putting the relevant tags in directly (<surface>, <dynamic>, <static>, etc). However, I haven't done an exhaustive test to see whether e.g. my friction settings are actually taking effect, and Gazebo isn't just using default values.

As is, my .urdf.xacro file is a bit of a mix, using a <gazebo> environment to contain <plugin> tags, but regular <surface> etc tags for other things. I'll let the file itself stand as an answer to this question, but would still appreciate some review on it.

Subsequently, I tried to use <gazebo> tags as described in the Gazebo ROS documentation, and as is used in kobuki_gazebo.urdf.xacro.

edit flag offensive delete link more


thanks for the answer and references!

naveedhd gravatar imagenaveedhd ( 2017-06-07 04:10:52 -0600 )edit

Question Tools

1 follower


Asked: 2017-05-10 11:58:44 -0600

Seen: 9,919 times

Last updated: May 24 '17