[Documentation] [TitleIndex] [WordIndex

Tf/教程/ tf 介绍 Note: This tutorial assumes you have a working knowledge of compiling programs in ROS. Check out the ROS tutorials to learn how to do this. It is appreciated that problems/questions regarding this tutorial are asked on answers.ros.org. Don't forget to include in your question the link to this page, versions of your OS & ROS, and also add appropriate tags. 1. tf 介绍 描述:本教程将主要描述 tf 的功能。它显示了使用 tf 驱动 turtlesim 多机器人的例子。还介绍 了使用 tf_echo,view_frames,和 rviz。 关键词:变换,坐标系 等级:新手教程 下个教程:写一个 tf 广播 (Python) (C++) 目录: 1. tf 介绍 2. 编译演示 3. 运行演示 4. 发生了什么事 5. tf 工具 使用 view_frames 使用 tf_echo 6. rviz 和 tf 选择你想要的教程版本:indigo 选择你的使用的编译系统:catkin 2. 编译演示 我们以获得依赖和编译演示包开始: $ rosdep install turtle_tf rviz 3. 运行 Demo 现在,我们编译 the turtle_tf tutorial 包,运行 demo. $ roslaunch turtle_tf turtle_tf_demo.launch 你能看见 turtlesim 以两个小乌龟开始: 为了防止程序卡死, a workaround is available.) turtlesim 开始后,你可以使用键盘箭头控制小乌龟在 turtlesim 周围移动,选择 roslaunch 终端窗口以便捕 捉您的键盘信息去驱动乌龟。 正如你看到的,一个乌龟会不断跟随你驱动的小乌龟移动。 4. 发生了什么 本演示使用 TF 库创建了三个坐标系:世界坐标系, turtle1 坐标系和 turtle2 坐标系。本教程采用一个 tf 广 播去公布的小乌龟的坐标系和一个 tf 监听器来计算小乌龟坐标系之间的差距,并且驱动一个小乌龟跟上另 外一个。 5. tf 工具 现在我们看看 tf 如何创建这个演示 demo。同时,我们使用 tf 工具去观察屏幕下 tf 是怎样工作的。 5.1 使用可视化框架(view_frames) view_frames 创建一个 ROS 中发布 tf 的框图。 可以看到: Transform Listener initing Listening to /tf for 5.000000 seconds Done Listening dot - Graphviz version 2.16 (Fri Feb 8 12:52:03 UTC 2008) Detected dot version 2.16 frames.pdf generated 这是一个 tf 监听者去接收 ROS 中发布放坐标系,把坐标系之间的联系画成树状,想看树时: $ evince frames.pdf 从这里,我们可以看出 tf 发布的坐标系有三个: the world, turtle1, and turtle2. 同样,我们看到 world 是 turtle1 和 turtle2 是 frames. 为了调试方便, view_frames 报告了一些关于接收到的旧坐标与最新坐标的转 换以及发布 tf 坐标系的快慢的诊断信息。 5.2 使用 tf_echo tf_echo 打印显示了 ROS 中两个坐标系发布的 transform 信息。 使用方法: $ rosrun tf tf_echo [reference_frame] [target_frame] 让我们看看 turtle2 关于 turtle1 坐标系的 transform frame,等价于 : $ rosrun tf tf_echo turtle1 turtle2 你能看到 ROS 中 tf_echo 监听器接收到的坐标系,显示如下: [ INFO] 1253585683.529245000: Started node [/tf_echo_1253585683508144000], pid [24418], bound on [aqy], xmlrpc port [41125], tcpros port [57369], logging to [~/ros/ros/log/tf_echo_1253585683508144000_24418.log], using [real] time Exception thrown:Frame id /turtle1 does not exist! When trying to transform between /turtle2 and /turtle1. The current list of frames is: Success at 1253585684.557003974 [0.000000 0.000000 0.140754 0.990045] Euler(0.282446 -0.000000 0.000000) Translation: [-0.000036 -0.000010 0.000000] Success at 1253585685.544698953 [0.000000 0.000000 0.140754 0.990045] Euler(0.282446 -0.000000 0.000000) Translation: [-0.000036 -0.000010 0.000000] Success at 1253585686.557049989 [0.000000 0.000000 0.140754 0.990045] Euler(0.282446 -0.000000 0.000000) Translation: [-0.000036 -0.000010 0.000000] Success at 1253585687.552628993 [0.000000 0.000000 0.140754 0.990045] Euler(0.282446 -0.000000 0.000000) Translation: [-0.000036 -0.000010 0.000000] Success at 1253585688.553683042 [0.000000 0.000000 0.140754 0.990045] Euler(0.282446 -0.000000 0.000000) Translation: [-0.000036 -0.000010 0.000000] Success at 1253585688.910640001 [0.000000 0.000000 0.140754 0.990045] Euler(0.282446 -0.000000 0.000000) Translation: [-0.000036 -0.000010 0.000000] 当你驱动小乌龟在附近运动时,你能看见两小乌龟位置相对变化时的坐标变化信息。 6. rviz 和 tf 检查 tf 变换时,rviz 是一个实用的可视化工具。下面,我们使用 turtle_tf 配置文件(rviz 的-d 选项)启动 rviz,来看我们的小乌龟坐标系: 在一边的信息栏里,能看见通过 tf 发布的坐标系。当你驱动小乌龟运动时,你能从 rviz 中看到坐标系的移 动。 现在我们已经验证了 turtle_tf_demo,下面我们来看看怎么编写这个演示的发布程序(Python) (C++) 。


2024-02-24 12:29