GAZEBO usage of set_model_state (to set obejct positions)
Dear community,
COARSE PROBLEM DEFINITION: I want to use the system as simulation environment for image based machine learning. Therefore I tried both having a camera on a robot and having a robot independent camera that I want to manipulate in the scene in order to create relevant images from which I want to learn. My problem is that the camera in Gazebo doesn't move (or at least doesn't appear to move) if I use the set_model_state command. Apparently the original camera position is restored right after unpausing physics. How can I avoid that ? Can you help me with an explanation on how the set_model_state() command is used correctly ? Does it have something todo with Gazebo running simulations in the background?
I try do the following :
self.model_coordinates = rospy.ServiceProxy( '/gazebo/get_model_state', GetModelState)
self.object_coordinates = self.model_coordinates("camera", "world")
# example movement -> move camera up 0.1m
self.object_coordinates.pose.position.z = self.object_coordinates.pose.position.z + 0.1
self.pause_physics()
state = ModelState()
state.pose = self.object_coordinates.pose
state.model_name = "camera"
try:
ret = self.set_mstate(state)
print ret
except Exception, e:
rospy.logerr('Error on calling service set_mstate: %s',str(e))
# the camera position is successfully changed -> I see that from the movement of a attached geometry in GAZEBO
self.unpause_physics()
# right after unpausing physics -> which is required to update the rendered camera image the camera (or the attached geometry) is moved to its original position -> if not commented out or triggered seperately it's so fast that it doesn't even appear to move.
SETUP_DESCRIPTION: I'm running ROS Kinetic on Xenial ("Ubuntu 16.04.5 LTS") with Gazebo 7.0.0.
OTHER TRIALS:
- I also tried it with Kinetic on Xenial running Gazebo 9.
- I tried it from the console with according rosservice calls
- I tried with a camera on a robot which joint configuration -> same effect after unpausing physics set by the same command
set_model_state is a publisher, did you try publishing ?
Maybe an example https://github.com/neobotix/neo_simul...
Also, I guess it does not have anything to do with the Gazebo running simulations in the background.