Moving a static object with setmodelstate

asked 2019-10-01 10:24:22 -0600

Pablowally gravatar image

Hi! I have a little piece of code in Python that uses the SetModelState service to move objects in the simulation programmatically.

It works perfectly with not static objects, but static ones won't move. Is there any way to fix this?


I paste the code here:

   # coding=utf-8
   import rospy
   import rospkg
   from gazebo_msgs.srv import GetModelState
   from gazebo_msgs.msg import ModelState
   from gazebo_msgs.srv import SetModelState

   def set_item(goal_x, goal_y,goal_z,objeto):
         state_msg = ModelState()

         state_msg.model_name = objeto
         state_msg.pose.position.x = goal_x
         state_msg.pose.position.y = goal_y
         state_msg.pose.position.z = goal_z
         state_msg.pose.orientation.x = 1
         state_msg.pose.orientation.y = 0
         state_msg.pose.orientation.z = 0
         state_msg.pose.orientation.w = 0

               set_state = rospy.ServiceProxy(
                  '/gazebo/set_model_state', SetModelState)
               resp = set_state(state_msg)

         except rospy.ServiceException, e:
               print "Service call failed: %s" % e
edit retag flag offensive close merge delete