文章目录

① 背景
② 前提
③ 任务
Ⅰ 检查设置
Ⅱ 检查系统
Ⅲ 生成全面的报告
④ 总结

① 背景

ros2doctor可以用来ros2的一些问题
ros2doctor 检查ROS 2的所有方面,包括平台,版本,网络,环境,运行的系统等,并警告您可能的错误和问题原因。

还在开发中,谨慎使用,估计会有点问题

② 前提

确保安装了ros2doctor,ros2cli的组成部分
使用小乌龟包来测试

③ 任务

Ⅰ 检查设置
这个是ros2doctor的帮助文档

utry@utry:~/dev_ws$ ros2 doctor -h
usage: ros2 doctor [-h] [--report | --report-failed] [--include-warnings]

Check ROS setup and other potential issues

optional arguments:
  -h, --help            show this help message and exit
  --report, -r          Print all reports.
  --report-failed, -rf  Print reports of failed checks only.
  --include-warnings, -iw
                        Include warnings as failed checks. Warnings are
                        ignored by default.

执行ros2 doctor会检查所有的设置模块

utry@utry:~$ ros2 doctor 

All 3 checks passed

utry@utry:~$ 

我的是没啥错警告的格式是这个样子的:

<path>: <line>: UserWarning: <message>

比如使用不稳定版本

UserWarning: Distribution <distro> is not fully supported or tested. To get more consistent features, download a stable version at https://index.ros.org/doc/ros2/Installation/

把网络关了就这个提示

utry@utry:~/dev_ws$ ros2 doctor 
/opt/ros/eloquent/lib/python3.6/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

All 2 checks passed

也可能出现error

1/3 checks failed

Failed modules:  network

出现问题解决问题

Ⅱ 检查系统

可以检测正在运行的系统,这里运行小乌龟

ros2 run turtlesim turtlesim_node
ros2 run turtlesim turtle_teleop_key

在这里插入图片描述

Ⅲ 生成全面的报告

使用这个命令就行

ros2 doctor --report

生成的结果可以复制出来一个一个处理这个是我生成结果

utry@utry:~$ ros2 doctor --report

  NETWORK CONFIGURATION
inet         : 192.168.241.131
inet4        : ['192.168.241.131']
ether        : 00:0c:29:67:0e:2f
inet6        : ['fe80::89a1:b2ed:4240:258f']
netmask      : 255.255.255.0
device       : ens33
flags        : 4163<UP,BROADCAST,RUNNING,MULTICAST> 
mtu          : 1500
broadcast    : 192.168.241.255
inet         : 127.0.0.1
inet4        : ['127.0.0.1']
inet6        : ['::1']
netmask      : 255.0.0.0
device       : lo
flags        : 73<UP,LOOPBACK,RUNNING> 
mtu          : 65536

  PLATFORM INFORMATION
system           : Linux
platform info    : Linux-5.3.0-45-generic-x86_64-with-Ubuntu-18.04-bionic
release          : 5.3.0-45-generic
processor        : x86_64

  RMW MIDDLEWARE
middleware name    : rmw_fastrtps_cpp

  ROS 2 INFORMATION
distribution name      : eloquent
distribution type      : ros2
distribution status    : active
release platforms      : {'ubuntu': ['bionic']}

  TOPIC LIST
topic               : /turtle1/cmd_vel
publisher count     : 1
subscriber count    : 1
topic               : /turtle1/color_sensor
publisher count     : 1
subscriber count    : 1
topic               : /turtle1/pose
publisher count     : 1
subscriber count    : 1
topic               : /turtle1/rotate_absolute/_action/feedback
publisher count     : 1
subscriber count    : 1
topic               : /turtle1/rotate_absolute/_action/status
publisher count     : 1
subscriber count    : 1
utry@utry:~$

在这里插入图片描述

④ 总结

ros2doctor会告诉您ROS 2安装和运行系统中的问题。您可以使用–report参数更深入地了解这些警告背后的信息。

请记住,ros2doctor它不是调试工具;它不会帮助解决代码或系统实现方面的错误。