gazebo/spawn_sdf_model can't spawn object at correct coordinatesc

asked 2021-07-02 11:07:14 -0500

SpaceTime gravatar image

Hello everybody,

I found that there is a service call for spawning models in gazebo. I have tried it already and it works. The only problem I have is that my object doesn't get spawned at the coordinates I need it to have yet. Also I might be a bit confused about the parameters one can hand over with the request.

I am receiving the coordinates of an object in a certain frame, let's say /camera from a topic. Now I want to place the object correctly using these coordinates. I figured I should probably have them in /map coordinates, is that right?

So what I tried I currently do is:

pose = self.tf_listener.transformPose("map", oldPose) #old Pose is in the /camera frame
self.spawn_model_proxy=rospy.ServiceProxy('gazebo/spawn_sdf_model', SpawnModal)
self.sdf_file = open('path/to/file', 'r')
self.sdf = self.sdf_file.read()
self.spawn_model_proxy("new_object", "robot_name_space", self.sdf, pose, "world")

I don't exactly know what the "robot_name_space" parameter is, as I found it like this in the code snippet. If I leave a string (could be an empty one) away here, the call doesn't work.

When the pose object gets added to the scene, it however is at the wrong position. It should hover about 2 meter in front of the robot head. However the object is placed around 2m and the about the correct height in front of the origin of the world coordinate system. I tried changing the "world" above with the original frame name but this did not work either. Can anyone help me, what am I doing wrong?

edit retag flag offensive close merge delete