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

lookupTransform and tf2_echo shows different results

asked 2022-11-10 22:53:07 -0600

MrOCW gravatar image

updated 2022-11-11 01:11:23 -0600

Hi, I am writing code for transformations using apriltag.

tf_buffer_->lookupTransform(tag_frame_, camera_frame_, tf2::TimePointZero);

gives different transformation matrix values compared to

ros2 run tf2_ros tf2_echo camera_frame_ tag_frame_

tf2_echo:

- Matrix:
  0.984  0.162 -0.068 -0.405
  0.123 -0.912 -0.391 -0.223
 -0.125  0.376 -0.918  0.937
  0.000  0.000  0.000  1.000
- Matrix:
  0.962  0.256 -0.097 -0.311
  0.199 -0.896 -0.396 -0.186
 -0.189  0.362 -0.913  0.929
  0.000  0.000  0.000  1.000
- Matrix:
  0.972  0.234 -0.024 -0.437
  0.215 -0.924 -0.316 -0.181
 -0.097  0.302 -0.948  0.988
  0.000  0.000  0.000  1.000
- Matrix:
  0.957  0.289  0.033 -0.388
  0.278 -0.876 -0.393 -0.157
 -0.085  0.385 -0.919  0.986
  0.000  0.000  0.000  1.000
- Matrix:
  0.943  0.325  0.074 -0.327
  0.332 -0.893 -0.305 -0.168
 -0.033  0.313 -0.949  1.008
  0.000  0.000  0.000  1.000
- Matrix:
  0.952  0.299 -0.071 -0.174
  0.266 -0.918 -0.295 -0.229
 -0.153  0.262 -0.953  0.934
  0.000  0.000  0.000  1.000
- Matrix:
  0.934  0.323 -0.149 -0.099
  0.264 -0.910 -0.320 -0.241
 -0.239  0.260 -0.935  0.931
  0.000  0.000  0.000  1.000
- Matrix:
  0.911  0.301 -0.282  0.075
  0.234 -0.941 -0.246 -0.252
 -0.339  0.158 -0.928  0.982
  0.000  0.000  0.000  1.000
- Matrix:
  0.904  0.310 -0.295  0.175
  0.253 -0.943 -0.215 -0.213
 -0.345  0.120 -0.931  0.991
  0.000  0.000  0.000  1.000
- Matrix:
  0.853  0.311 -0.419  0.175
  0.240 -0.947 -0.213 -0.211
 -0.463  0.081 -0.883  0.865
  0.000  0.000  0.000  1.000

lookupTransform:

cam -> tag:
  0.993005   0.115175 -0.0259908   0.480949
  0.115586  -0.903337   0.413064  -0.542837
 0.0240963  -0.413179  -0.910331   0.743633
         0          0          0          1
cam -> tag:
    0.961699     0.198847    -0.188665     0.511308
    0.256293    -0.896393     0.361654    -0.422628
   -0.097204    -0.396155    -0.913024     0.743996
6.91763e-310 7.29112e-304            0            1
cam -> tag:
    0.961699     0.198847    -0.188665     0.511308
    0.256293    -0.896393     0.361654    -0.422628
   -0.097204    -0.396155    -0.913024     0.743996
6.91763e-310 7.29112e-304            0            1
cam -> tag:
    0.956792      0.27811   -0.0848747     0.498498
     0.28892    -0.876387      0.38532    -0.405495
   0.0327782    -0.393193    -0.918872     0.856553
6.91763e-310 7.29112e-304            0            1
cam -> tag:
    0.939404     0.342707  -0.00846977     0.407591 ...
(more)
edit retag flag offensive close merge delete

Comments

Shouldn't the last row be [0, 0, 0, 1] in the output of lookupTransform of the right side?

ravijoshi gravatar image ravijoshi  ( 2022-11-11 00:56:35 -0600 )edit

Please copy and paste the console info into questions instead of screenshotting. It's not easily debugged without being able to copy and paste.

tfoote gravatar image tfoote  ( 2022-11-11 01:01:55 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-11-11 00:52:18 -0600

tfoote gravatar image

The echo command outputs the transform from the source frame to the target frame.

The lookupTransform API provides the transform to take data from the source_frame to the target_frame

There's been a lot of threads about it one of the original is here: https://github.com/ros/geometry/issue...

edit flag offensive delete link more

Comments

OK got it so to get coordinate of B with reference to coordinate of A, i have to use: tf_buffer_->lookupTransform(A Frame, B Frame_, tf2::TimePointZero);

MrOCW gravatar image MrOCW  ( 2022-11-11 01:04:32 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2022-11-10 22:53:07 -0600

Seen: 266 times

Last updated: Nov 11 '22