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

Invert a TF frame axis

asked 2022-08-16 16:55:32 -0600

zrahman gravatar image

updated 2022-08-16 16:56:05 -0600

I want to add a camera frame with x on the right, y up, and z forward. I am using the following command:

rosrun tf2_ros static_transform_publisher x y z yaw pitch roll map camera

First I tried to set up yaw, pitch, and roll manually by changing those three values. But there was always one axis that needed to be inverted which I could not do since if I change one of the three values, two axes change, not one. So, I ended up having a frame with x on the right, y up and z backward. Then I calculated a rotation matrix between those two coordinate frames. I found

     0 0 1
R = -1 0 0
     0 1 0

Then from the rotation matrix to yaw, pitch, and roll (-1.57, -0, 1.57). But the result is the same. How can I flip only one axis keeping the other two unchanged?

edit retag flag offensive close merge delete

Comments

What do you mean by "x on the right"? After rotation you want the positive x-axis pointing to the left?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-08-17 06:34:10 -0600 )edit

@Mike Scheutzow The coordinate system I want should have x pointing to the right, y upward, and z forward.

zrahman gravatar image zrahman  ( 2022-08-17 10:16:18 -0600 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2022-08-17 02:57:55 -0600

ljaniec gravatar image

Did you check this StackOverflow post?

  • Check that the frame you get from your API is right-handed. You do so by computing the determinant of the 3x3 rotation part of your 4x4 transform matrix: it must be +1 or very close to it.

  • If it is -1, then flip one if its axis, i.e. change the sign of one of the columns of the 3x3 rotation.

  • Note carefully: I said "columns" because I assume that you apply a transform Q to a point x by multiplying as Q * x, x being a 4x1 column vector with the last component equal to one. If you use row vectors left-multiplied by Q you need flip a row.

  • If that determinant is +1, you have a bug someplace else.

You can try to use quaternions too, here are some great sources:

P.S. This part from the second link seems to be related to your case

Conventions

From REP 105 Coordinate Frames for Mobile Platforms

On a mobile robot, x is forward, y is left, and z is up 

For cameras z is forward, x is right, y is down, and frame_id ends with _optical
edit flag offensive delete link more

Comments

1

@Ijaniec I checked those answers. It seems, ROS tf uses right-handed rules and there is no way I can get the frame I want. So, I will just multiply one axis by -1.

zrahman gravatar image zrahman  ( 2022-08-17 11:31:41 -0600 )edit

OK, please report with the effects later! If this answer helped you, you can accept it as a correct one (right under the note, "✓") so it will be marked as solved in the queue

ljaniec gravatar image ljaniec  ( 2022-08-18 07:09:46 -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

1 follower

Stats

Asked: 2022-08-16 16:55:32 -0600

Seen: 297 times

Last updated: Aug 17