Tf frame question

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 close merge delete

1

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

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

Sort by » oldest newest most voted

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!

more