ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to use .xacro file for spawning model by using spawn_model service in c++

asked 2017-04-21 12:13:05 -0500

jasonwang538@gmail.com gravatar image

Hi everyone

I have a question about spawning model by using spawn_model service. I use .xacro file for descripting the hector_quadrotor model. And I need to dynamically spawning new model by calling spawn_model service. But I feel confused about how to use .xacro file as parameter for the model_xml fild of gazebo_msgs/SpawnModel message type.If conversion is necessary, does anyone know how to conver .xacro to .urdf or .xml in c++ code.

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-04-23 21:59:12 -0500

Geoff gravatar image

Xacro files need to be parsed by the xacro parser before you can load them into Gazebo, rViz, etc.

When you are running things through a launch file, you can do this easily at launch time, like the example below. But if you are using the file from a node, it's easier to run xacro first to produce an output that you save to a file and work with that processed file.

<param name="robot_description" command="$(find xacro)/xacro.py '$(find my_robot_description)/urdf/my_robot.urdf.xacro' "/>
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-04-21 12:13:05 -0500

Seen: 929 times

Last updated: Apr 23 '17