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

Revision history [back]

hello there,

About the node, There is a gazebo service that allow to modify the position of an object.

Here is an example:

from gazebo_msgs.msg import ModelState 
from gazebo_msgs.srv import SetModelState

#GAZEBO SERVICE
        rospy.wait_for_service('/gazebo/set_model_state')
        try:
           self.set_state = rospy.ServiceProxy('/gazebo/set_model_state', SetModelState)
        except rospy.ServiceException :
            print("Service call failed")

        state_msg = ModelState()
        state_msg.model_name = 'the name of the model you want to move as presented by gazebo"'


            state_msg.pose.position.x =  25
            state_msg.pose.position.y = 25
            state_msg.pose.position.z =  -18.48
            state_msg.pose.orientation.w = 1
            state_msg.pose.orientation.x = 0
            state_msg.pose.orientation.y = 0
            state_msg.pose.orientation.z = 0

enter code here

Would this be useful?

hello there,

About the node, There is a gazebo service that allow to modify the position of an object.

Here is an example:

from gazebo_msgs.msg import ModelState 
from gazebo_msgs.srv import SetModelState

#GAZEBO SERVICE
        rospy.wait_for_service('/gazebo/set_model_state')
        try:
           self.set_state = rospy.ServiceProxy('/gazebo/set_model_state', SetModelState)
        except rospy.ServiceException :
            print("Service call failed")

        state_msg = ModelState()
        state_msg.model_name = 'the name of the model you want to move as presented by gazebo"'


            state_msg.pose.position.x =  25
            state_msg.pose.position.y = 25
            state_msg.pose.position.z =  -18.48
            state_msg.pose.orientation.w = 1
            state_msg.pose.orientation.x = 0
            state_msg.pose.orientation.y = 0
            state_msg.pose.orientation.z = 0

enter code here
resp = self.set_state(state_msg)

Would this be useful?