ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
1

invert an coordinate axis with tf

asked 2016-06-22 21:45:06 -0600

uwleahcim gravatar image

updated 2016-06-22 23:12:48 -0600

The coordinate of my robot and the bundled API is

x -> forward
y -> right
z -> down

I want to map such that my base_link is the following

x -> forward
y -> right
z -> up

(I think this is the most common base_link setup)

tf::Transform transform;
//setup transform

tf_broadcaster.sendTransform(tf::StampedTransform(transform, time, "base_link", "my_robot"));

How do I setup tf::Transform to invert the z axis? Do I use a 3x3 matrix to setup my transform to invert the axis? Possible to use the following 3x3 Matrix for the transformation? (tried using .setBasis but I got a bunch of tf warnings).

[[1,0,0],
 [0,1,0],
 [0,0,-1]]
edit retag flag offensive close merge delete

Comments

My UAV uses an internal Left Handed frame (because they thought positive values for z for altitude was more intuitive). I want to switch it to Right Handed frame so that it works with ROS tf.

uwleahcim gravatar image uwleahcim  ( 2016-06-23 11:44:59 -0600 )edit

The UAV is left handed axis is the following.

x -> North y -> East z -> Up

A right handed setup would have z-> Down

uwleahcim gravatar image uwleahcim  ( 2016-06-23 12:59:15 -0600 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2016-06-23 10:36:32 -0600

According to REP 103, all coordinate frames are right-handed. The "standard" base_link setup actually has x forward, y left, and z up. That's what I would suggest transforming your frames to.

AFAIK, tf has no support for left-handed frames. Some of the libraries with geometry support that are common in ROS (bullet, Eigen, transformations.py, KDL, etc.) may have some support for transformations with rotations not strictly in SO(3) (such as mirroring transformations), but unless you really have some good reason for getting into this, I think it's best to avoid.

edit flag offensive delete link more

Comments

Since tf has no support for left-handed frames, how will I go about transforming my Robot's internal left-handed frame setup?

Btw, my robot is drone. Typically z-axis should be pointing down, but the SDK has the z-axis pointing up (since they though negative values for height feels odd).

uwleahcim gravatar image uwleahcim  ( 2016-06-23 11:39:15 -0600 )edit

Are you sure that the coordinate system for your UAV is left-handed? The description in the question makes it sound like the native system is right-handed, and the system you want to transform it to is left-handed.

jarvisschultz gravatar image jarvisschultz  ( 2016-06-23 12:02:42 -0600 )edit

The UAV is from DJI and here is the frame setup https://developer.dji.com/onboard-sdk...

Notice the "*", they switch the frame to left handed by inverting the height/z-axis.

I need transformation so I can switch the internal left handed frame to work with ros tf.

uwleahcim gravatar image uwleahcim  ( 2016-06-23 12:46:56 -0600 )edit

Convention would say the green axis is the "y axis" not the "z axis". It looks to me like tf will not be able to natively handle any data coming from the API. I'd recommend manually converting any information into a right-handed coordinate system before broadcasting transforms.

jarvisschultz gravatar image jarvisschultz  ( 2016-06-23 14:56:29 -0600 )edit

As explained in the document you can just reverse their change which is to make the Z direction positive downward by multiplying by -1 in Z only to make it right handed again.

The diagram does use odd colors standard is X red, Y green, Z blue.

tfoote gravatar image tfoote  ( 2016-06-23 15:20:54 -0600 )edit

Currently I'm just inverting the z-axis data from the API before they get publish. So at least all the topics being published into ROS are right handed. However, I have to manually keep track of making API since the API are still left handed.

uwleahcim gravatar image uwleahcim  ( 2016-06-23 15:30:57 -0600 )edit
0

answered 2016-06-23 09:24:35 -0600

Nexus8 gravatar image

You can build a rotation matrix or a quaternion that represents the change in orientation from one reference frame to the other reference frame. Then all you do is rotate your vector [x,y,z] with the quaternion or matrix.

Cheers

edit flag offensive delete link more

Comments

Problem is you can't invert an axis with rotations. My robot internally is internally mapped on left handed axis and I need to remap it to a traditional right handed axis. Go from [x y z] to [x y -z]. Only method I can think right now is manually add a "-" to whatever z data the robot spits out.

uwleahcim gravatar image uwleahcim  ( 2016-06-23 10:02:41 -0600 )edit

Oh! Good! I was about to point out that your are asking for a left to right handed axis transformation. Ok, be careful with your reference frames. I would suggest to change your perspective to:

x: North y: East z: Down

Georeferenced systems used that reference frame (drones, rovers, planes).

Nexus8 gravatar image Nexus8  ( 2016-06-23 10:37:25 -0600 )edit

Can I use tf to convert a left handed frame to a right handed frame? I tried using tf with "-" for the z axis transformation between frames, but it only corrects my base_link. My odometery z-axis is still flipped. I'm thinking of editing the SDK to switch z to point down if possible.

uwleahcim gravatar image uwleahcim  ( 2016-06-23 11:43:11 -0600 )edit

North-East-Down is a right handed frame! No doubt about it. The image you shared from DJI displays the drone from its back x axis pointing towards the front. X CROSS Y = Z, so it is a right handed frame. Use a rotation to convert between frames.

Nexus8 gravatar image Nexus8  ( 2016-06-23 14:49:39 -0600 )edit

Here is the documentation of the frame setup for the drone: https://developer.dji.com/onboard-sdk...

Unfortunately the ground frame is left handed and tf doesn't seem to have a way to handle left handed frames. I'm leaning towards modifying the SDK to be right handed.

uwleahcim gravatar image uwleahcim  ( 2016-06-23 15:33:24 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2016-06-22 21:45:06 -0600

Seen: 3,087 times

Last updated: Jun 23 '16