ros tf

欢迎访问我的博客首页。


tf

  • 1. tf 命令行工具
    • 1.1 发布 tf
    • 1.2 查看 tf
  • 2.参考

1. tf 命令行工具


1.1 发布 tf


  我们根据 cartographer_ros 的 launch 文件 backpack_2d.launch 写一个 tf.launch,并使用命令 roslaunch cartographer_ros tf.launch 启动。该 launch 文件运行 ros 系统包 robot_state_publisher 中的同名节点 robot_state_publisher,根据 backpack_2d.urdf 文件发布机器人各坐标系到 base_link 的变换。

<launch>
  <param name="robot_description" textfile="$(find cartographer_ros)/urdf/backpack_2d.urdf" />
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
launch>

1.2 查看 tf


  使用 rosrun tf view_frames 查看广播的坐标系关系。该命令会在命令行目录生成两个文件 frames.pdf 和 frames.gv。

ros tf_第1张图片

图 1.1 广播中的坐标变换关系

上面的命令可能会报错。需要把 /opt/ros/noetic/lib/tf/view_frames 中的 m = r.search(vstr) 修改为 m = r.search(str(vstr))。

Listening to /tf for 5.0 seconds
Done Listening
b'dot - graphviz version 2.43.0 (0)\n'
Traceback (most recent call last):
  File "/opt/ros/noetic/lib/tf/view_frames", line 119, in 
    generate(dot_graph)
  File "/opt/ros/noetic/lib/tf/view_frames", line 89, in generate
    m = r.search(vstr)
TypeError: cannot use a string pattern on a bytes-like object

  使用命令 rosrun tf tf_monitor 查看广播的坐标关系。

RESULTS: for all Frames

Frames:
Frame: horizontal_laser_link published by unknown_publisher(static) Average Delay: 0 Max Delay: 0
Frame: imu_link published by unknown_publisher(static) Average Delay: 0 Max Delay: 0
Frame: vertical_laser_link published by unknown_publisher(static) Average Delay: 0 Max Delay: 0

All Broadcasters:
Node: unknown_publisher(static) 1e+08 Hz, Average Delay: 0 Max Delay: 0

  使用 rosrun tf tf_monitor /imu_link /base_link 查看两个坐标系的关系。

Waiting for transform chain to become available between imu_link and base_link 

RESULTS: for imu_link to base_link
Chain is: imu_link -> base_link
Net delay     avg = 3.2183e+08: max = 1.69142e+09

Frames:
Frame: imu_link published by unknown_publisher(static) Average Delay: 0 Max Delay: 0

All Broadcasters:
Node: unknown_publisher(static) 1e+08 Hz, Average Delay: 0 Max Delay: 0

  使用 rosrun tf tf_echo /imu_link /base_link 查看两个坐标系的变换。

At time 0.000
- Translation: [0.000, 0.000, 0.000]
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]
            in RPY (radian) [0.000, -0.000, 0.000]
            in RPY (degree) [0.000, -0.000, 0.000]

2.参考


1.ROS tf,CSDN,2022。

你可能感兴趣的:(ROS)