Home | Tutorials | Wiki | Issues
Ask Your Question
0

URDF to Gazebo differs from URDF to SDF to Gazebo

asked 2016-02-16 09:15:35 -0500

alextoind gravatar image

I found out a strange behaviour when spawning model in Gazebo.

I have an URDF model of a humanoid robot and a launch file where it is sapwned to Gazebo through model_spawn of the gazebo_ros package using -urdf flag:

<param name="robot_description" 
       command="$(find xacro)/xacro.py '$(find my_robot_description)/urdf/my_robot.xacro'"/>
<node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
      args="-urdf -model my_robot -param robot_description"/>

In such a case, if I endow the URDF with a simple <gazebo> property as follows:

<gazebo>
  <!-- robot model offset -->
  <pose>0 0 0.5 0 0 0</pose>
</gazebo>

It doesn't affect my model in Gazebo, which generate a warning like this:

Warning [parser_urdf.cc:1232] multiple inconsistent <pose> exists due to fixed joint reduction overwriting previous value [0 0 0.5 0 0 0] with [0 0 0 0 -0 0].

However, if I convert the URDF first to SDF (using gz sdf -p my_robot.urdf) and spawn the SDF directly with the -sdf flag, this does not happen and everything works as expected.

Why does this happen? Is a problem of the URDF parser of Gazebo or I'm doing something wrong?

edit retag flag offensive close merge delete

Comments

1

And if you try to do : <gazebo reference="robot_base_link"> <pose>0 0 0.5 0 0 0</pose> </gazebo>

Brosseau.F gravatar imageBrosseau.F ( 2016-02-17 01:42:29 -0500 )edit

Nothing happens, but no warning is displayed this time... At a closer look it seems that no properties in the `<gazebo>` tags pass from the URDF to Gazebo (I've specified frictional parameters but they are filled with default values), even if the `gazebo_ros_control` plugin is properly loaded... I'm using Gazebo7 with ROS Jade; could this be a problem?

alextoind gravatar imagealextoind ( 2016-02-17 03:25:03 -0500 )edit

Thanks @hsu, I probably got the problem: as I said in http://answers.ros.org/question/226659/ros-jade-gazebo7-and-gazebo_ros_control-compatibility/ I compiled directly the `jade-devel` branch of `gazebo_ros_pkgs` because there is no `gazebo_ros_pkgs` for ROS Jade and Gazebo7 yet. I thought that it was quite fine because I could control my robot from ROS as explained in the tutorials, but now I believe that the `spawn_model` could be a bit dated. Why `gz sdf` and `spawn_model` use distinct code?

alextoind gravatar imagealextoind ( 2016-02-17 15:51:47 -0500 )edit

What would you suggest now? Switch to Gazebo 6? Create two distinct models (SDF only for Gazebo simulation and URDF for control purposes) even if this would mean update twice when modifying something in the model? Or even other advices?

alextoind gravatar imagealextoind ( 2016-02-17 15:52:07 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2016-02-18 02:21:10 -0500

hsu gravatar image

updated 2016-02-18 02:23:09 -0500

You could use additional options from spawn_model (-z 0.5):

$ rosrun gazebo_ros spawn_model 
Commands:
    -[urdf|sdf|trimesh|gazebo] - specify incoming xml is urdf, sdf or trimesh format. gazebo arg is deprecated in ROS Hydro
    -[file|param|database] [<file_name>|<param_name>|<model_name>] - source of the model xml or the trimesh file
    -model <model_name> - name of the model to be spawned.
    -reference_frame <entity_name> - optinal: name of the model/body where initial pose is defined.
                                     If left empty or specified as "world", gazebo world frame is used.
    -gazebo_namespace <gazebo ros_namespace> - optional: ROS namespace of gazebo offered ROS interfaces.  Defaults to /gazebo/ (e.g. /gazebo/spawn_model).
    -robot_namespace <robot ros_namespace> - optional: change ROS namespace of gazebo-plugins.
    -unpause - optional: !!!Experimental!!! unpause physics after spawning model
    -wait - optional: !!!Experimental!!! wait for model to exist
    -trimesh_mass <mass in kg> - required if -trimesh is used: linear mass
    -trimesh_ixx <moment of inertia in kg*m^2> - required if -trimesh is used: moment of inertia about x-axis
    -trimesh_iyy <moment of inertia in kg*m^2> - required if -trimesh is used: moment of inertia about y-axis
    -trimesh_izz <moment of inertia in kg*m^2> - required if -trimesh is used: moment of inertia about z-axis
    -trimesh_gravity <bool> - required if -trimesh is used: gravity turned on for this trimesh model
    -trimesh_material <material name as a string> - required if -trimesh is used: E.g. Gazebo/Blue
    -trimesh_name <link name as a string> - required if -trimesh is used: name of the link containing the trimesh
    -x <x in meters> - optional: initial pose, use 0 if left out
    -y <y in meters> - optional: initial pose, use 0 if left out
    -z <z in meters> - optional: initial pose, use 0 if left out
    -R <roll in radians> - optional: initial pose, use 0 if left out
    -P <pitch in radians> - optional: initial pose, use 0 if left out
    -Y <yaw in radians> - optional: initial pose, use 0 if left out
    -J <joint_name joint_position> - optional: initialize the specified joint at the specified value

So something like this could work:

 <param name="robot_description" 
   command="$(find xacro)/xacro.py '$(find my_robot_description)/urdf/my_robot.xacro'"/>
<node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
  args="-z 0.5 -urdf -model my_robot -param robot_description"/>

On the other hand, I like the suggestion of supporting robot extensions that goes directly under the model tag, issued

https://bitbucket.org/osrf/sdformat/i...

edit flag offensive delete link more

Comments

Thank you very much, I didn't see those options! At least the model pose is fine now, even if I still don't get why some parameters in the <gazebo> tags are not passed to the SDF model... I'll open another question in the next few days with a code example.

alextoind gravatar imagealextoind ( 2016-02-18 03:11:28 -0500 )edit

the <gazebo> extension tags are not passed to sdf, issue has been created to track this missing feature: https://bitbucket.org/osrf/sdformat/issues/edit/112

hsu gravatar imagehsu ( 2016-02-18 12:22:56 -0500 )edit

Yes sorry, I've already seen it. I was talking about something like the ones in Brosseau answer; they should appear in the SDF as told in the tutorial, aren't they?

alextoind gravatar imagealextoind ( 2016-02-18 13:26:17 -0500 )edit
0

answered 2016-02-17 08:35:05 -0500

Brosseau.F gravatar image

For the friction params, do you have something like that (${prefix}_caster_wheel is a link of one of my model):

<gazebo reference="${prefix}_caster_wheel">
        <collision>
            <surface>
                <friction>
                    <ode>
                        <mu>0.0</mu>
                        <mu2>0.0</mu2>
                        <slip1>1.0</slip1>
                        <slip2>1.0</slip2>
                    </ode>
                </friction>
            </surface>
        </collision>
    </gazebo>
edit flag offensive delete link more

Comments

I had tried with those specified in the tutorial: http://gazebosim.org/tutorials?tut=ros_urdf&cat=connect_ros#<gazebo>ElementsForLinks and http://gazebosim.org/tutorials?tut=ros_urdf&cat=connect_ros#<gazebo>ElementsForJoints. I'll try this evening with your proposal. Thanks for now.

alextoind gravatar imagealextoind ( 2016-02-17 08:56:04 -0500 )edit

I've tried your proposal, but nothing appears in the SDF even if it is said in the tutorial above that "[...] any arbitrary blobs that are not parsed according to the table above are inserted into the the corresponding <link> element in the SDF.".

alextoind gravatar imagealextoind ( 2016-02-18 03:15:21 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-02-16 09:15:35 -0500

Seen: 481 times

Last updated: Feb 18 '16