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

Changing the orientation of a pose goal in rviz (python)

asked 2020-09-01 13:01:10 -0500

Matt Gibbon gravatar image

Coming off the back of the rviz tutorials, I've been trying to control the panda arm using only the pose goal but cannot change it's orientation. Changing the "pose_goal.orientation.w" value seems to do nothing and although I've read that rviz uses quaterion values to define orientation I can't understand how this translates to what I'd write in my code to achieve a specific orientation. My goal is to be able to set an orientation for the arm based on coordinates in Cartesian space and either values for pitch/roll/yaw or a direction vector

Here is the part of my code defining the pose goal

def go_to_pose_goal(self):

move_group = self.move_group

print("Starting planning to go to pose goal.\n")
pose_goal = geometry_msgs.msg.Pose()


pose_goal.orientation.w = 1
pose_goal.orientation.x = 1
pose_goal.orientation.y = 1
pose_goal.orientation.z = 1
pose_goal.position.x = 1
pose_goal.position.y = -0.518
pose_goal.position.z = 0.8

move_group.set_pose_target(pose_goal)

plan = move_group.go(wait=True)
move_group.stop()
move_group.clear_pose_targets()

current_pose = self.move_group.get_current_pose().pose
return all_close(pose_goal, current_pose, 0.01
edit retag flag offensive close merge delete

Comments

Coming off the back of the rviz tutorials

please always link to whatever you are referring to.

We can't know what you consider "the rviz tutorials".

gvdhoorn gravatar image gvdhoorn  ( 2020-09-02 03:16:27 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-09-02 02:14:42 -0500

gvdhoorn gravatar image

updated 2020-09-02 02:17:50 -0500

I would recommend to take a look at wiki/tf2/Tutorials/Quaternions in addition to a general introduction to what quaternions are (there are various textbooks (ie: math) and sites which discuss them, such as ), as I believe that's mostly where your confusion comes from.

Changing the "pose_goal.orientation.w" value seems to do nothing and although I've read that rviz uses quaterion values to define orientation I can't understand how this translates to what I'd write in my code to achieve a specific orientation

Changing the w element of a quaternion is not something you typically do manually: it's not the yaw component (there is no yaw component directly in a quaternion).

My goal is to be able to set an orientation for the arm based on coordinates in Cartesian space and either values for pitch/roll/yaw or a direction vector

As mentioned on wiki/tf2/Tutorials/Quaternions: Think in RPY then convert to quaternion, you can do this by using convenience/conversion functions from (for instance) the tf.transformations library:

from tf.transformations import quaternion_from_euler

if __name__ == '__main__':

  # RPY to convert: 90deg, 0, -90deg
  q = quaternion_from_euler(1.5707, 0, -1.5707)

  print "The quaternion representation is %s %s %s %s." % (q[0], q[1], q[2], q[3])

(this code is just a copy-paste from the linked wiki page)

edit flag offensive delete link more

Comments

See also #q9981 for a very old Q&A about this.

gvdhoorn gravatar image gvdhoorn  ( 2020-09-02 02:16:00 -0500 )edit

Note also btw: this has nothing to with RViz.

RViz only visualises external data. It's not a simulation or anything which maintains its own environment.

gvdhoorn gravatar image gvdhoorn  ( 2020-09-02 03:15:42 -0500 )edit

Thankyou, this has been very helpful

Matt Gibbon gravatar image Matt Gibbon  ( 2020-09-10 04:44:19 -0500 )edit

Question Tools

Stats

Asked: 2020-09-01 13:01:10 -0500

Seen: 1,185 times

Last updated: Sep 02 '20