I want to fix a z position using SetModelState
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():
rospy.init_node('pos_fix_test')
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
rospy.wait_for_service('/gazebo/set_model_state')
while not rospy.is_shutdown():
set_state = rospy.ServiceProxy('/gazebo/set_model_state', SetModelState)
resp = set_state(state_msg)
if __name__ == '__main__':
main()