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

How do I get the displacement vector from one object to another?

asked 2017-08-01 12:23:40 -0500

ysl208 gravatar image

I have two objects A and B, each in the form of geometry_msgs/PoseStamped. I would like to calculate the displacement (translation & rotation) vector that I can apply to any (similar) object A' and arrive to a (similar) object B' (respectively).

  1. I guess the vector should also be of the form PoseStamped.

  2. For translation, can I simply take B.PoseStamped.position.x - A.PoseStamped.position.x (similar for y,z)?

  3. For the quaternion, I am not sure if I can simply do division (since adding angles in quaternions is done by multiplication?) i.e. B.PoseStamped.quaternion.x/A.PoseStamped.quaternion.x ?

I would like to avoid having to transform the quaternion to euler and back.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-08-09 22:53:33 -0500

Ed Venator gravatar image

Unfortunately, you cannot do mathematical operations on the geometry_msgs message types. They are plain old ROS messages with no overloaded operators. For what you want to do, you'll need to convert the messages to tf::Pose types. Once you do that, follow the instructions in this answer to calculate displacement.

edit flag offensive delete link more

Comments

They are plain old ROS messages [..]

+1 for this :)

That would be a PORM.

gvdhoorn gravatar image gvdhoorn  ( 2017-08-10 03:24:18 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-08-01 12:23:40 -0500

Seen: 413 times

Last updated: Aug 09 '17