Home | Tutorials | Wiki | Issues
Ask Your Question
1

How does one use /gazebo/spawn_sdf_model ?

asked 2014-02-24 19:45:20 -0500

Ben B gravatar image

updated 2014-02-25 16:39:27 -0500

I'm trying to delete and respawn an SDF model as a (hopeful) work around to my problem here.

I'd like to use a rosservice so I can call it using a rospy.ServiceProxy.

For now, I'm just trying to get it to run from the command line:

$ rosservice call /gazebo/spawn_sdf_model "model_name: 'joe'
model_xml: '/home/benb/Dropbox/RoboticsResearch/WAMInProgress/tp/AllInOne/Trajectory_Phonebook/ros_stuff/src/iiim_wam_description/wam.sdf'
robot_namespace: ''
initial_pose:
  position: {x: 0.0, y: 0.0, z: 0.0}
  orientation: {x: 0.0, y: 0.0, z: 0.0, w: 0.0}
reference_frame: ''"

I've tried using a few things for the model_xml argument:

  • The above is the absolute path to the sdf.
  • I've tried launching it from /home/benb/Dropbox/RoboticsResearch/WAMInProgress/tp/AllInOne/Trajectory_Phonebook/ros_stuff/src/iiim_wam_description/ with the argument model_xml: 'wam.sdf'
  • I've tried using the directory name iiim_wam_description
  • I've tried using the name specified in the model.config, iiim_ros_wam

In all cases, I get the message:

success: False
status_message: GazeboRosApiPlugin SpawnModel Failure: input model_xml not SDF or URDF, or cannot be converted to Gazebo compatible format.

It would be especially helpful if someone could give me pointers on doing this using the rospy ServiceProxy.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-02-25 17:13:34 -0500

Ben B gravatar image

Got it. The answer is that the SDF argument is not a location to an SDF file -- it's the whole content of the SDF file.

To access this in rospy, you can do this:

import rospy
from gazebo_msgs.srv import SpawnModel
from geometry_msgs.msg import Pose


rospy.init_node('insert_object',log_level=rospy.INFO)

initial_pose = Pose()
initial_pose.position.x = 1
initial_pose.position.y = 1
initial_pose.position.z = 1

f = open('/home/benb/Dropbox/RoboticsResearch/WAMInProgress/tp/AllInOne/Trajectory_Phonebook/ros_stuff/src/iiim_wam_description/wam.sdf','r')
sdff = f.read()

rospy.wait_for_service('gazebo/spawn_sdf_model')
spawn_model_prox = rospy.ServiceProxy('gazebo/spawn_sdf_model', SpawnModel)
spawn_model_prox("some_robo_name", sdff, "robotos_name_space", initial_pose, "world")
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2014-02-24 19:45:20 -0500

Seen: 3,262 times

Last updated: Feb 25 '14