How to change the orientation of a robot
Hello guys, i have a problem with my simulation. I wanna learn a robot to navigate via reinforcement learning and that the robot generalizes better i wanted the robot to have multiple start locations which get picked randomly
But i got the issue that even though my code sets the orientation yaw angle the robot always faces the same direction at each point
Here is the function i wrote to set the pose of the robot:
def reset_pose():
state_msg = ModelState()
state_msg.model_name = 'pepper_MP'
n_pose=range(4)
choice= random.choice(n_pose)
if choice == 0:
x=0
y=0
z=3.14
if choice == 1:
x=-7
y=4
z=-1
if choice == 2:
x=1
y=4
z=3.7
if choice == 3:
x=-7
y=-4
z=0.7
state_msg.pose.position.x = x
state_msg.pose.position.y = y
state_msg.pose.position.z = 0
state_msg.pose.orientation.x = 0
state_msg.pose.orientation.y = 0
state_msg.pose.orientation.z = z
state_msg.pose.orientation.w = 0
rospy.wait_for_service('/gazebo/set_model_state')
try:
set_state = rospy.ServiceProxy('/gazebo/set_model_state', SetModelState)
resp = set_state( state_msg )
return x,y
except rospy.ServiceException:
print ("Service call failed: %s")
The x and y coordinate get set correct but the state_msg.pose.orientation doesnt get set correctly
Doesn't state_msg.pose.orientation.w also need to be changed?