当前位置:   article > 正文

ROS2极简总结-坐标变换-TF_ros2 tf 坐标变换

ros2 tf 坐标变换

参考:


TF2 - 概述

  • TF2 是 TF (TransForm) 库的第二代。 事实上,ROS1 中的 TF 目前在后台调用 TF2。 ROS2 仅使用 TF2。
  • TF2 跟踪树结构中的所有坐标系。
  • 与 ROS2 中的大多数功能一样,TF2 API 仍在开发中,但基本功能已经可用。
  • TF2 vs TF - 更快、更高效、新功能和更容易扩展。

*此处重点,ROS1成熟,而ROS2还是深度开发中的实验版,LTS长期支持版目前也没有5年,而是3年,此版本不适合初学者学习!

rviz2中可视化

rqt_tf_tree

设计

TF2 核心独立于 ROS & BufferCore 类提供 API


时间同步

  • 用户可以查询任意给定时间点树中任意 2 帧之间的转换 - 即使在过去!
    • 对于异步/分布式系统必不可少


广播

提供坐标之间的转换(动态/静态)。

  • 例如:robot_state_publisher 提供基于 URDF 的 TF 数据
  • 例如:用户编写的具有专用广播器的节点


监听

可以访问变换树并查找 2 帧之间的特定变换(阻塞/非阻塞)。

  1. buffer = tf2_ros.Buffer()
  2. transform = buffer.lookup_transform("base_link","camera_link", rclpy.time.Time()) # Blocking
  3. transform = await buffer.lookup_transform_async("base_link","camera_link",rclpy.time.Time()) #Non-Blocking

函数原型:lookup_transform(target_frame,source_frame,time)

使用 rclpy.time.Time() 提供最新的可用转换。


工具:

tf2_ros buffer_server.exe
tf2_ros static_transform_publisher.exe
tf2_ros tf2_echo.exe
tf2_ros tf2_monitor.exe
tf2_tools view_frames.py

ros2 launch dummy_robot_bringup dummy_robot_bringup.launch.py 

rviz2

发布坐标变换数据

ros2 run tf2_ros static_transform_publisher 1 2 3 0.5 0.1 -1.0 foo bar

接受坐标变换数据

ros2 run tf2_ros tf2_echo foo bar

数据:

  1. [INFO] [1628841444.349748000] [tf2_echo]: Waiting for transform foo -> bar: Invalid frame ID "foo" passed to canTransform argument target_frame - frame does not exist
  2. At time 0.0
  3. - Translation: [1.000, 2.000, 3.000]
  4. - Rotation: in Quaternion [-0.475, -0.076, 0.240, 0.843]
  5. At time 0.0
  6. - Translation: [1.000, 2.000, 3.000]
  7. - Rotation: in Quaternion [-0.475, -0.076, 0.240, 0.843]
  8. At time 0.0
  9. - Translation: [1.000, 2.000, 3.000]
  10. - Rotation: in Quaternion [-0.475, -0.076, 0.240, 0.843]
  11. At time 0.0
  12. - Translation: [1.000, 2.000, 3.000]
  13. - Rotation: in Quaternion [-0.475, -0.076, 0.240, 0.843]
  14. At time 0.0
  15. - Translation: [1.000, 2.000, 3.000]
  16. - Rotation: in Quaternion [-0.475, -0.076, 0.240, 0.843]
  17. At time 0.0
  18. - Translation: [1.000, 2.000, 3.000]
  19. - Rotation: in Quaternion [-0.475, -0.076, 0.240, 0.843]
  20. At time 0.0
  21. - Translation: [1.000, 2.000, 3.000]
  22. - Rotation: in Quaternion [-0.475, -0.076, 0.240, 0.843]
  23. At time 0.0
  24. - Translation: [1.000, 2.000, 3.000]
  25. - Rotation: in Quaternion [-0.475, -0.076, 0.240, 0.843]
  26. At time 0.0
  27. - Translation: [1.000, 2.000, 3.000]
  28. - Rotation: in Quaternion [-0.475, -0.076, 0.240, 0.843]
  29. At time 0.0
  30. - Translation: [1.000, 2.000, 3.000]
  31. - Rotation: in Quaternion [-0.475, -0.076, 0.240, 0.843]
  32. At time 0.0
  33. - Translation: [1.000, 2.000, 3.000]
  34. - Rotation: in Quaternion [-0.475, -0.076, 0.240, 0.843]
  1. ros2 run tf2_ros tf2_monitor
  2. Gathering data on all frames for 10 seconds...
  3. RESULTS: for all Frames
  4. Frames:
  5. Frame: bar, published by <no authority available>, Average Delay: 336.186, Max Delay: 336.186
  6. Frame: single_rrbot_camera_link, published by <no authority available>, Average Delay: 0.0112712, Max Delay: 0.0168042
  7. Frame: single_rrbot_hokuyo_link, published by <no authority available>, Average Delay: 0.011265, Max Delay: 0.016798
  8. Frame: single_rrbot_link1, published by <no authority available>, Average Delay: 0.0112664, Max Delay: 0.0167992
  9. Frame: single_rrbot_link2, published by <no authority available>, Average Delay: 0.0197751, Max Delay: 0.0335286
  10. Frame: single_rrbot_link3, published by <no authority available>, Average Delay: 0.0197761, Max Delay: 0.033529
  11. All Broadcasters:
  12. Node: <no authority available> 34.0131 Hz, Average Delay: 0.940838 Max Delay: 336.186
  13. RESULTS: for all Frames
  14. Frames:
  15. Frame: bar, published by <no authority available>, Average Delay: 336.186, Max Delay: 336.186
  16. Frame: single_rrbot_camera_link, published by <no authority available>, Average Delay: 0.0111137, Max Delay: 0.0169733
  17. Frame: single_rrbot_hokuyo_link, published by <no authority available>, Average Delay: 0.0111072, Max Delay: 0.0169675
  18. Frame: single_rrbot_link1, published by <no authority available>, Average Delay: 0.0111086, Max Delay: 0.0169683
  19. Frame: single_rrbot_link2, published by <no authority available>, Average Delay: 0.0197954, Max Delay: 0.0335286
  20. Frame: single_rrbot_link3, published by <no authority available>, Average Delay: 0.0197964, Max Delay: 0.033529

ros2 run tf2_tools view_frames.py


 

 

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/555338
推荐阅读
相关标签
  

闽ICP备14008679号