Ask Your Question

Using SDF instead of URDF with Robot State Publisher

asked 2020-07-13 07:18:55 -0600

teshansj gravatar image

updated 2020-07-13 07:21:33 -0600

With URDF models, you can use robot_state_publisher to have the joints published in tf. Since this needs the <robot> tag, it does not work with SDF models. If you try to roslaunch for a SDF it would say

Could not find the 'robot' element in the xml file

Everything else works fine in gazebo but the state publisher dies

Is there any way I can use robot state publisher with SDF? Maybe include URDF into the SDF? Or specify the <robot> tag in it somehow?


I have found many other questions related to this question but none had a positive answer and most of them are more than 5 years old. However,

  • This answer suggests that you can do anything with SDF that is possible in URDF.
  • This question has an answer suggesting an alternative by having both URDF and SDF but it's an ugly solution
  • There's this old unanswered question as well

I want to created a 6 wheeled robot model with two wheels having shock absorbers (prismatic joints with damping and spring actions). To my understanding, this cannot be done using URDF

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-07-14 07:30:03 -0600

Weasfas gravatar image

Hi @teshansj,

The main question here is why you want to use the native Gazebo description format with ROS utilities. Looking at the robot_state_publisher implementation you can see that it uses a KDL tree to parse only URDFs, that are the standard robot description format used in ROS, since RST is a ROS application you cannot expect it can parse other than the standard formats.

The second question is if there is a real need for using a SDF since ROS already support a direct translation between: Xacro -> URDF -> SDF to be able to spawn models on Gazebo worlds. So from here we reach this point in your question:

_I want to created a 6 wheeled robot model with two wheels having shock absorbers (prismatic joints with damping and spring actions). To my understanding, this cannot be done using URDF_

An that is actually not true, since you can create 4 normal wheels and another 2 with a shock absorber joint, I know this because I was able to implement that in a Gazebo Car model. The most important thing here is that while you cannot use URDF things in SDF files, you can use SDF tags in URDF files. And that is done with the <gazebo> tag.

So if you really want to generate a shock absrober joint you can use in a URDF the <gazebo> tag with the reference name as your joint name and provide the proper dynamic parameters.

This will look like:

For the joint

<joint name="shock" type="prismatic">
  <parent link=parent"/>
  <child link="child"/>
  <origin xyz="x y z" rpy="r p y" />
  <axis xyz="x y z"/>
  <limit lower="low" upper="upp" effort="eff" velocity="vel"/>
  <dynamics damping="damp" friction="fric"/>

and for the SDF

<gazebo reference="shock">

That should fill the SDF <dynamic> tag to generate a good shock absorber joint.

With that you willl have your URDF and no problems when using RSP. Apart from that I recommend you Xacro instead of URDF.

Hope it helps.


edit flag offensive delete link more


After posting this question I actually got it to work using gazebo tags. I wasn't aware of the <gazebo> tag at the time of posting the question. Anyway I'm going to let the question be as it is since your answer might help others as well.

teshansj gravatar image teshansj  ( 2020-07-14 13:55:17 -0600 )edit

if I want to use the gearbox joint of sdf file,but there is not the gearbox joint in urdf file,and what I should do by using <gazebo> tag?

LR gravatar image LR  ( 2020-10-10 23:26:52 -0600 )edit

@LR, This a different question from the original post, hence, following community rules you may want to write your question in a different post. However, since this I think has a fast solution you can try with the <gazebo> tag like:

  <joint name="joint_gearbox" type="gearbox">
      <xyz>0 1 0</xyz>

      <xyz>0 1 0</xyz>
Weasfas gravatar image Weasfas  ( 2020-10-12 04:29:10 -0600 )edit

what is the reference frame of the <xyz> in <axis> and <axis2>?I have set the revolute joint between parent_link/child_link and ${name}_base_link,so the reference frame of <xyz> is parent_link/child_link frame?and thanks for you advices.

LR gravatar image LR  ( 2020-10-12 09:04:05 -0600 )edit

@LR You can check everything about this is the SDF format specification here. But to answer your question, extracted from the manual:

  1. axis: Parameters related to the axis of rotation for revolute joints, the axis of translation for prismatic joints.
  2. axis2: Parameters related to the second axis of rotation for revolute2 joints and universal joints.

Basically axis is the input axis (relative to child) and axis2 is output axis (relative to child). You can also check the joint_demo from gazebo here to know more about this.

Weasfas gravatar image Weasfas  ( 2020-10-12 11:56:18 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-07-13 07:18:55 -0600

Seen: 900 times

Last updated: Jul 14 '20