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

Tf frame question

asked 2015-11-28 04:58:02 -0500

dmngu9 gravatar image

i have a '/world' frame and '/sensor' frame. '/sensor' frame is a child frame of the '/world' frame.

Now i want to make a reference vector in the '/sensor' frame ,lets say (1,0,0) which is unit vector x axis (x axis of the sensor coordinate). I define the vector as tf::Quaternion (1,0,0,0) (ignore the rotation atm) in the code.

The question is how can i make sure the vector is inside the /sensor frame? and when i define a vector with x,y,z coordinates, do they follow the rviz axis convention?

edit retag flag offensive close merge delete

Comments

1

Just a quick comment: tf::Quaternion is used for orientation only, not position.

gvdhoorn gravatar image gvdhoorn  ( 2015-11-28 05:30:33 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-11-29 15:38:29 -0500

mrslvgg gravatar image

The relationship between two frames is represented by a 6 DOF relative pose, a translation followed by a rotation. If /world and /sensor are two frames, the pose of /sensor in /frame is given by the translation from /world's origin to /sensor's origin, and the rotation of /sensor's coordinate axes in /world.

The translation is a vector in /world's coordinates, lets say v_s_w. It is represented by tf::Vector3.

The rotation of /sensor is given by a rotation matrix, represented as R_s_w, using same convention. The way to read this is: "the rotation of the frame /sensor in /world's coordinate system." The columns of R_s_w are formed from the three unit vectors of /sensor's axes in /world: r_x_s, r_y_s, and r_z_s.

There is no tf type for a rotation matrix; instead, tf represents rotations via tf::Quaternion (you could use an external library, such as KDL or Bullet, for transforming rotation matrix in quaternions and viceversa).

It's convenient to describe the translation + rotation in Homogeneous coordinates, as a single 4x4 matrix W_s_w. This can be read as: "the pose of frame /sensor relative to frame /world." The relative pose is constructed as follows:

                               W_s_w =  | R_s_w  v_s_w  |
                                        | 0 0 0    1    |

In tf, relative poses are represented as tf::Pose, which is equivalent to the bullet type btTransform or KDL::Frame. The member functions allow you to get the rotation (also the quaternion), and the translation of the pose. See respective class reference.

When you create a vector b_s in the /sensor frame you can obtain its components in the /world frame b_w by multiplying (in Homogeneous coordinates):

b_w = W_s_w * b_s

Obviously, you can apply the inverse transform in the opposite case (indicating with W_w_s = W_s_w^(-1)):

b_s = W_w_s * b_w

Hope this helps.

Good Luck!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-11-28 04:58:02 -0500

Seen: 601 times

Last updated: Nov 29 '15