roswtf工具将检查您的ROS设置,例如您的环境变量,并查找配置问题。如果你有一个在线的ROS系统,它会查看并检查任何潜在的问题。
首先,关闭上一博客中所启动的roscore。
检查是否安装了roswtf
首先检查是否安装了roswf,执行下述两条命令:
$ roscd rosmaster
$ roswtf
如果我们安装的tf能够正常运行,那么应该返回类似于下述值:
Loaded plugin tf.tfwtf
Package: rosmaster
================================================================================
Static checks summary:
No errors or warnings
================================================================================
ROS Master does not appear to be running.
Online graph checks will not be run.
ROS_MASTER_URI is [http://localhost:11311]
这些输出内容告诉我们:
- Package: rosmaster:这个输出告诉我们是在rosmaster包目录中启动了roswtf。
- Static checks summary:这里是任何文件系统或任何非运行时(即不需要运行roscore)问题的报告。这里是告诉我们没有错误。
上述过程中ROS Master没有运行,所以没有进行在线检查。
在线尝试
下一步,我们想要ROS Master正在运行,所以在另外一个terminal窗口上启动roscore。
$ roscore
然后再次尝试下述命令:
# 回到默认工作空间的devel文件夹
$ roscd
$ roswtf
得到下述内容:
Loaded plugin tf.tfwtf
No package or stack in the current directory
================================================================================
Static checks summary:
No errors or warnings
================================================================================
Beginning tests of your ROS graph. These may take a while...
analyzing graph...
... done analyzing graph
running graph rules...
... done running graph rules
Online checks summary:
Found 1 warning(s).
Warnings are things that may be just fine, but are sometimes at fault
WARNING The following node subscriptions are unconnected:
* /rosout:
* /rosout
在roscore正在运行的状态下,roswtf对你的graph做了一些测试。其完成的时间取决于多少个ROS节点正在运行。
如下所示,此次产生了下述warning
WARNING The following node subscriptions are unconnected:
* /rosout:
* /rosout
此次,roscd在切换的时候没有加入参数,这会带我们进入一个没有ROS包的文件,所以我们在输出的内容中看到:“No package or stack in context”。
下面的warning提示是说rosout节点正在订阅一个topic,但是没有节点发布它。这是因为没有其他节点在运行,所以这也是可以预料的。
错误
roswtf将会警告您系统中看起来可疑但可能正常的事情。它还可以报告已知错误的问题。
对于此部分,我们将设置我们的ROS_PACKAGE_PATH为一个错误值。同时,我们也会停止 roscore,以简化输出便于查看。
$ roscd
$ ROS_PACKAGE_PATH=bad:$ROS_PACKAGE_PATH roswtf
返回结果为:
Loaded plugin tf.tfwtf
No package or stack in the current directory
================================================================================
Static checks summary:
Found 1 error(s).
ERROR Not all paths in ROS_PACKAGE_PATH [bad:/home/xiaochen/workspace/catkin_ws/src:/opt/ros/melodic/share] point to an existing directory:
* bad
================================================================================
ROS Master does not appear to be running.
Online graph checks will not be run.
ROS_MASTER_URI is [http://localhost:11311]
我们可以看到,roswtf给我们提示出一个关于ROS_PACKAGE_PATH的错误。
除此之外,roswtf还能找到很多其他的问题。如果发现自己编译或者communication过程中出现了错误,可以尝试通过运行roswtf工具来查看错误原因。