TF 的简单介绍
TF(transform) 是一个允许用户时刻跟踪多个坐标架构的包,能及时地维持树结构中坐标帧之间的关系,并允许用户在任何时间点变化任何两个坐标帧之间的点和变量等。
目前 TF 已经被“弃用”了,转而支持 TF2 。
TF2 有 TF 特征的超集 及其依赖关系的子集,因此,TF所实现的功能在底层上已经由调用 TF2 中的函数所代替,这意味着所有用户都能够与TF2 兼容。
TF的包的简单使用
使用两个乌龟,
涉及到的包:
ros-melodic-ros-tutorials
ros-melodic-geometry-tutorials
ros-melodic-rviz
ros-melodic-rosbash
ros-melodic-rqt-tf-tree
使用 sudo apt-get install…
一般都有,没再按提示下也行。
(1)运行 turtle 功能包
roslaunch turtle_tf turtle_tf_demo.launch
然后在开启的那个终端框内使用方向键,即可以之间控制一个乌龟移动了,另外一个乌龟会跟着你控制移动的乌龟运动。
(2)使用 ros 的 tf tools 来监视 tf 信息。利用 view_frames
derek@derek-virtual-machine:~$ rosrun tf view_frames
Listening to /tf for 5.0 seconds
Done Listening
dot - graphviz version 2.40.1 (20161225.0304)
Detected dot version 2.40
frames.pdf generated
坐标系已经保存在 frames.pdf 中了,使用指令查看
evince frames.pdf
或者 使用 rqt_tf_tree 来查看 TF 树:
rosrun rqt_tf_tree rqt_tf_tree
比较这两张坐标关系树,两个框架(turtle frame )的之间都存在 一个 Broadcaster , 这个是连接两个frame 必须的,中间一个节点会发布消息给 Broadcaster 。
如果缺少节点来发布消息维护这个联通,那这两者的连接必然断开。
同时,Broadcaster 也是一个发布者,如果连个frame 之间发生了相对运动,Broadcaster 就会发布相关的消息。
(3)使用 tf_echo 来监视两个坐标系之间的坐标变换关系,
derek@derek-virtual-machine:~$ rosrun tf tf_echo turtle2 turtle1
At time 1632462575.663
- Translation: [0.000, 0.000, 0.000]
- Rotation: in Quaternion [0.000, 0.000, 0.463, 0.886]
in RPY (radian) [0.000, -0.000, 0.963]
in RPY (degree) [0.000, -0.000, 55.162]
At time 1632462576.382
- Translation: [0.000, 0.000, 0.000]
- Rotation: in Quaternion [0.000, 0.000, 0.463, 0.886]
in RPY (radian) [0.000, -0.000, 0.963]
in RPY (degree) [0.000, -0.000, 55.162]
。。。。
如上,会打印两者的相对位置
(4)为了更直观的看到tf 的位置关系,此时还可以使用rivz
rosrun rviz rviz
在Add 中添加 TF 即可以看到如此画面。