Ask Your Question

How to generate .sdf file from quadrotor.gazebo.xacro

asked 2017-07-11 22:08:22 -0500 gravatar image

Hi everyone

I meet with a issue for converting a .xacro file to a .sdf file for calling the service: spawn_sdf_model. I use Jade ros with gazebo 5. The robot model is hector_quadrotor. The package can be downloaded from the website: . I try to generate a hector_quadrotor.sdf file from the file quadrotor.gazebo.xacro by using the following command:

rosrun xacro xacro --check-order quadrotor.gazebo.xacro > hector_quadrotor.sdf.

However, when I call the service spawn_sdf_model, the gazebo crashes for every trial. I try the same code with another .sdf (for spawning a box in the space). It works without any problem. I attached the code of sdf file as below. Hope anyone can give me some suggestions for correcting this conversion.

<robot name="quadrotor" xmlns:xacro=""> <link name="base_link"> <inertial> <mass value="1.477"/> <origin xyz="0 0 0"/> <inertia ixx="0.01152" ixy="0.0" ixz="0.0" iyy="0.01152" iyz="0.0" izz="0.0218"/> </inertial> <visual> <origin rpy="0 0 0" xyz="0 0 0"/> <geometry> <mesh filename="package://hector_quadrotor_description/meshes/quadrotor/quadrotor_base.dae"/> </geometry> </visual> <collision> <origin rpy="0 0 0" xyz="0 0 0"/> <geometry> <mesh filename="package://hector_quadrotor_description/meshes/quadrotor/quadrotor_base.stl"/> </geometry> </collision> </link> <joint name="sonar_joint" type="fixed"> <origin rpy="0 1.57079632679 0" xyz="-0.16 0.0 -0.012"/> <parent link="base_link"/> <child link="sonar_link"/> </joint> <link name="sonar_link"> <inertial> <mass value="0.001"/> <origin rpy="0 0 0" xyz="0 0 0"/> <inertia ixx="0.000000017" ixy="0" ixz="0" iyy="0.000000017" iyz="0" izz="0.000000017"/> </inertial> <visual> <origin rpy="0 0 0" xyz="0 0 0"/> <geometry> <mesh filename="package://hector_sensors_description/meshes/sonar_sensor/max_sonar_ez4.dae"/> </geometry> </visual> <collision> <origin rpy="0 0 0" xyz="0 0 0"/> <geometry> <box size="0.01 0.01 0.01"/> </geometry> </collision> </link> <gazebo reference="sonar_link"> <sensor name="sonar" type="ray"> <always_on>true</always_on> <update_rate>10</update_rate> <pose>0 0 0 0 0 0</pose> <visualize>false</visualize> <ray> <scan> <horizontal> <samples>3</samples> <resolution>1</resolution> <min_angle>-0.349065850399</min_angle> <max_angle> 0.349065850399</max_angle> </horizontal> <vertical> <samples>3</samples> <resolution>1</resolution> <min_angle>-0.349065850399</min_angle> <max_angle> 0.349065850399</max_angle> </vertical> </scan> <range> <min>0.03</min> <max>3.0</max> <resolution>0.01</resolution> </range> </ray> <plugin filename="" name="gazebo_ros_sonar_controller"> <gaussiannoise>0.005</gaussiannoise> <topicname>sonar_height</topicname> <frameid>sonar_link</frameid> </plugin> </sensor> </gazebo> <gazebo> <plugin filename="" name="quadrotor_imu_sim"> <updaterate>100.0</updaterate> <bodyname>base_link</bodyname> <frameid>base_link</frameid> <topicname>raw_imu</topicname> <rpyoffset>0 0 0</rpyoffset> <gaussiannoise>0</gaussiannoise> <acceldrift>0.5 0.5 0.5</acceldrift> <accelgaussiannoise>0.35 0.35 0.3</accelgaussiannoise> <ratedrift>0.1 0.1 0.1</ratedrift> <rategaussiannoise>0.05 0.05 0.015</rategaussiannoise> </plugin> <plugin filename="" name="quadrotor_baro_sim"> <updaterate>10.0</updaterate> <bodyname>base_link</bodyname> <frameid>base_link</frameid> <topicname>pressure_height</topicname> <altimetertopicname>altimeter</altimetertopicname> <offset>0</offset> <drift>10.0</drift> <gaussiannoise ... (more)

edit retag flag offensive close merge delete


rosrun xacro xacro --check-order quadrotor.gazebo.xacro > hector_quadrotor.sdf

xacro converts files using xacro into plain urdfs, not sdf. a subset of urdf is sdf compliant, so it could be that your simple cube works, but the quadrotor xacro doesn't. You'd need to convert urdf to sdf.

gvdhoorn gravatar image gvdhoorn  ( 2017-07-12 05:06:23 -0500 )edit

Hi. Does that mean I needto use the same xacro commmand to convert the file twice(xacro->urdf->sdf)? gravatar image  ( 2017-07-12 05:28:47 -0500 )edit


The xacro utility cannot be used to generate or convert SDF. It doesn't do anything with SDF.

You'd have to look at other tools for that.

gvdhoorn gravatar image gvdhoorn  ( 2017-07-12 05:34:42 -0500 )edit

Thank gvdhoorn. I will have a look gravatar image  ( 2017-07-12 07:11:41 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2018-09-16 06:24:40 -0500

At August 2018 the xacro tool cannot generate sdf models. It can only generate urdf models.

You will get an error from the xacro tool complaining about the lack of the "<robot>" tag.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2017-07-11 22:08:22 -0500

Seen: 600 times

Last updated: Sep 16 '18