11、初步使用roswtf

Posted by pzque on 2016-04-19     

在实践本篇文章前,请确保你的机器上没有roscore在运行。

一、检查安装状态

roswtf检查你的系统并且报告存在的问题,让我们尝试一下:

1
2
roscd
roswtf

我的机器里得到:

1
2
3
4
5
6
7
8
9
No package or stack in context
================================================================================
Static checks summary:

No errors or warnings
================================================================================

ROS Master does not appear to be running.
Online graph checks will not be run.

很好,ROS系统目前没有问题。

上面的输出包含三部分:

  1. "Stack: ros"roswtf 命令根据当前所处的目录来决定要检查的内容。在这里我们用roswtf是检查了ros stack.。
  2. "Static checks summary":这是对整个文件系统的静态检查,这次检查没有发现任何问题。
  3. "ROS Master does not appear to be running. Online graph checks will not be run."roscore没有在运行,所以不能检查在线信息。

二、在线检查

首先启动ROS:roscore

然后进行检查:

1
2
roscd
roswtf

这次的输出类似于:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Loaded plugin tf.tfwtf
No package or stack in context
================================================================================
Static checks summary:

No errors or warnings
================================================================================
Beginning tests of your ROS graph. These may take awhile...
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将会检查ROS系统内的节点联系图,检查所花费的时间取决于正在运行的节点数量以及节点间联系的复杂程度。上面的检查里给出一条警告信息:

1
2
3
WARNING The following node subscriptions are unconnected:
* /rosout:
* /rosout

/rosout订阅了一个没有发布者的话题。这是正常的,因为我们还没有运行任何节点。

三、Errors

roswtf不仅能报告看似正常实则可疑的警告,还可以检查出确定的错误。

这里我们把ROS_PACKAGE_PATH设定为一个错误的值,然后观察roswtf能不能检查出这个错误。

首先修改ROS_PACKAGE_PATH,不用担心,在下一次重启终端时它会恢复为正常的值:

1
ROS_PACKAGE_PATH=bad:$ROS_PACKAGE_PATH

然后:

1
2
roscd
roswtf

这次的输出为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
No package or stack in context
================================================================================
Static checks summary:

Found 1 error(s).

ERROR Not all paths in ROS_PACKAGE_PATH [bad:/opt/ros/indigo/share:/opt/ros/indigo/stacks] point to an existing directory:
* bad

================================================================================
Beginning tests of your ROS graph. These may take awhile...
analyzing graph...
... done analyzing graph
running graph rules...
... done running graph rules

Online checks summary:

Found 2 warning(s).
Warnings are things that may be just fine, but are sometimes at fault

WARNING The following node subscriptions are unconnected:
* /rosout:
* /rosout

WARNING The following nodes are unexpectedly connected:
* unknown (http://192.168.1.4:48024/)->/rosout (/rosout)

可以发现成功地报告了错误。

roswtf可以检查包括系统设置以及节点间沟通的各种错误,在我们遇到问题时,不妨使用此命令来定位、排除错误。

最后说一句,wtf这个名字起得真是俏皮。