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

Revision history [back]

click to hide/show revision 1
initial version

It sounds like you're using C++ and looking for a vector in the parent frame with the same direction as the x axis of the child frame, or vector D in this picture.

image description

You've got the geometry_msgs/Pose expressed as a tf::Transform, that's great! The basis of the transform is the rotation matrix to go from the child frame to the parent frame. An x axis vector is (1,0,0). To transform an x axis vector from the child frame to the parent frame you can use operator*(Matrix3x3, Vector3) from the following link

http://docs.ros.org/jade/api/tf2/html/namespacetf2.html#aa066c1c13ee857e7c53e747698297d03

tf::Transform my_pose = ... //You already have this
tf::Vector3 x_axis(1,0,0);
tf::Vector3 D = myPose.getBasis() * x_axis;

Make sure to do matrix * vector and not vector * matrix. The latter will return the parent x axis expressed in the child frame.