I want to fix a z position using SetModelState

asked 2022-11-29 10:33:50 -0500

asdasd1 gravatar image

I want to create a node that loads an object into the gazebo virtual environment and fixes only the z coordinate for it using SetModelState. However, when using SetModelState, not only the z coordinate but also the x, y coordinates are fixed together. I wonder if there is a way to fix only the z coordinate

#! /usr/bin/env python3

from gazebo_msgs.msg import ModelState 
from gazebo_msgs.srv import SetModelState
import rospy
import time
import tf

def main():
    state_msg = ModelState()
    state_msg.model_name = 'wamv'
    state_msg.pose.position.x = -532
    state_msg.pose.position.y = 162
    state_msg.pose.position.z = 0.1
    state_msg.pose.orientation.x = 0
    state_msg.pose.orientation.y = 0
    state_msg.pose.orientation.z = 0
    state_msg.pose.orientation.w = 0

    while not rospy.is_shutdown():
        set_state = rospy.ServiceProxy('/gazebo/set_model_state', SetModelState)
        resp = set_state(state_msg)

if __name__ == '__main__':
edit retag flag offensive close merge delete