ROS 2边学边练(19)-- ROS 2的体检医生ros2doctor

前言

        当你的ROS在启动的时候出现了问题,当你在运行一些节点的时候发生了未期待的情况,诸如此类,我们需要去找到原因,并尝试解决掉,那么今天说的这个ros2doctor工具可以助我们一臂之力(找原因,但不能帮助我们进行调试用啊)。

        ros2doctor可以检查ROS 2的所有方面,包括但不限于平台、版本、网络、环境、运行时系统等,它充当了ROS 2体检医生的角色。

动动手

        ros2doctor的用途可归类为静态检测和动态检测,我们分别说说。

静态检测

        静态检测指的是当不运行任何ROS节点时,检测ROS的各个部分(包括但不限于平台、版本、环境等),举个例子,我们打开一个终端,source一下环境变量,然后运行下述命令看看:

$ros2 doctor

(5个部分)全部通过,但是有几个UserWarning,都是关于某些模块的版本不是最新版本的警告,一般UserWarning不怎么影响,但是如果有UserWarning: ERROR:的内容,那就要好好看看了:

1/3 checks failed

Failed modules:  network

 比如上面,体检不达标,心肝脾肺肾,问题出在哪呢,喏,network这个部分。

动态检测

        动态检测指的是,ROS 2节点在运行过程中的检测(依然包含静态检测的内容,很尽责的),可以尽量帮助我们找到问题可能的起因,为了更直观的感受到此服务,我们隆重请出久违的小海龟。

        打开两个终端(记得source哦),一个终端启动小海龟仿真节点,另外一个启动控制节点,命令分别如下:

$ros2 run turtlesim turtlesim_node
$ros2 run turtlesim turtle_teleop_key

我们再打开另外一个终端,让rosdoctor出场:

$ros2 doctor

大家将眼睛放到最下面的两个UserWarning上(其上面的内容其实就是静态检测时的那些东西),话说这位医生给出的结论是,有俩主题只有发布者没有订阅者 ,我们可以自己拿命令检查确认一下,首先通过ros2 topic list罗列出当前活着的主题,然后通过ros2 topic info <topic_name>看看更详细的:

确实如此哇。但是这种警告无关紧要的,只是拿来演示一下,假如实际过程中就是由于类似这样的警告而导致一些问题出现,那我们就要重视了。 

        我们再打开一个终端,echo其中一个没有订阅者的主题(turtlesim/msg/Pose)后再看看ros2doctor怎么说。

$ros2 topic echo /turtle1/pose

ros2doctor

 果真,/turtle1/pose这个主题没有订阅者的警告没啦。

获取完整体检报告

        如同现实中的体检,检查完了之后我们还可以主动要求生成一份报告,方便让别人帮助我们分析下具体的问题并提供有价值的建议。

        

$ros2 doctor --report
mike@mike-virtual-machine:~/Desktop/ros2_ws$ ros2 doctor --report

   NETWORK CONFIGURATION
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
inet         : 192.168.0.150
inet4        : ['192.168.0.150']
ether        : 00:0c:29:74:f4:0c
inet6        : ['fe80::ee27:8ddf:efbf:82dd%ens33']
netmask      : 255.255.255.0
device       : ens33
flags        : 4163<UP,MULTICAST,BROADCAST,RUNNING>
mtu          : 1500
broadcast    : 192.168.0.255

   PACKAGE VERSIONS
qt_gui_py_common                          : latest=2.4.3, local=2.4.3
rosidl_runtime_c                          : latest=4.0.1, local=4.0.1
std_msgs                                  : latest=5.0.0, local=5.0.0
composition_interfaces                    : latest=1.6.0, local=1.6.0
osrf_pycommon                             : latest=2.1.2, local=2.1.2
pcl_msgs                                  : latest=1.0.0, local=1.0.0
rosidl_typesupport_c                      : latest=3.0.1, local=3.0.1
rosbag2_cpp                               : latest=0.22.6, local=0.22.6
rviz_assimp_vendor                        : latest=12.4.7, local=12.4.6
shared_queues_vendor                      : latest=0.22.6, local=0.22.6
ament_lint                                : latest=0.14.3, local=0.14.3
rqt_service_caller                        : latest=1.1.1, local=1.1.1
trajectory_msgs                           : latest=5.0.0, local=5.0.0
ament_cmake_gmock                         : latest=2.0.4, local=2.0.4
rqt_reconfigure                           : latest=1.3.4, local=1.3.4
rosbag2_transport                         : latest=0.22.6, local=0.22.6
qt_dotgraph                               : latest=2.4.3, local=2.4.3
ros_core                                  : latest=0.10.0, local=0.10.0
stereo_msgs                               : latest=5.0.0, local=5.0.0
ament_cmake_xmllint                       : latest=0.14.3, local=0.14.3
tf2_msgs                                  : latest=0.31.5, local=0.31.5
rcl                                       : latest=6.0.5, local=6.0.5
ros2run                                   : latest=0.25.5, local=0.25.5
tf2_py                                    : latest=0.31.5, local=0.31.5
rqt_py_common                             : latest=1.3.4, local=1.3.4
examples_rclcpp_minimal_action_server     : latest=0.18.0, local=0.18.0
ament_cmake_python                        : latest=2.0.4, local=2.0.4
eigen3_cmake_module                       : latest=0.2.2, local=0.2.2
ros2cli_common_extensions                 : latest=0.2.2, local=0.2.2
rcl_yaml_param_parser                     : latest=6.0.5, local=6.0.5
ros_workspace                             : latest=1.0.3, local=1.0.3
tango_icons_vendor                        : latest=0.2.2, local=0.2.2
tf2_ros_py                                : latest=0.31.5, local=0.31.5
ros2bag                                   : latest=0.22.6, local=0.22.6
pluginlib                                 : latest=5.2.2, local=5.2.2
rosidl_typesupport_fastrtps_c             : latest=3.0.2, local=3.0.2
ament_cmake_export_libraries              : latest=2.0.4, local=2.0.4
rosidl_generator_type_description         : latest=4.0.1, local=4.0.1
teleop_twist_keyboard                     : latest=2.4.0, local=2.4.0
demo_nodes_py                             : latest=0.27.1, local=0.27.1
ament_cmake_pytest                        : latest=2.0.4, local=2.0.4
sdl2_vendor                               : latest=3.3.0, local=3.3.0
examples_rclcpp_minimal_timer             : latest=0.18.0, local=0.18.0
rosbag2_interfaces                        : latest=0.22.6, local=0.22.6
ament_index_python                        : latest=1.5.2, local=1.5.2
ament_cmake_uncrustify                    : latest=0.14.3, local=0.14.3
launch_testing                            : latest=2.0.2, local=2.0.2
image_transport                           : latest=4.2.4, local=4.2.3
common_interfaces                         : latest=5.0.0, local=5.0.0
rosidl_dynamic_typesupport                : latest=0.0.5, local=0.0.5
rosidl_pycommon                           : latest=4.0.1, local=4.0.1
ament_cmake_auto                          : latest=2.0.4, local=2.0.4
ament_cmake_lint_cmake                    : latest=0.14.3, local=0.14.3
type_description_interfaces               : latest=1.6.0, local=1.6.0
ament_cpplint                             : latest=0.14.3, local=0.14.3
rosidl_typesupport_fastrtps_cpp           : latest=3.0.2, local=3.0.2
launch_yaml                               : latest=2.0.2, local=2.0.2
tlsf_cpp                                  : latest=0.15.0, local=0.15.0
ament_cmake_cpplint                       : latest=0.14.3, local=0.14.3
examples_rclcpp_minimal_composition       : latest=0.18.0, local=0.18.0
rosidl_generator_cpp                      : latest=4.0.1, local=4.0.1
dummy_sensors                             : latest=0.27.1, local=0.27.1
zstd_vendor                               : latest=0.22.6, local=0.22.6
ament_cmake_export_dependencies           : latest=2.0.4, local=2.0.4
ros2node                                  : latest=0.25.5, local=0.25.5
ament_cmake_export_targets                : latest=2.0.4, local=2.0.4
rqt_gui                                   : latest=1.3.4, local=1.3.4
libstatistics_collector                   : latest=1.5.2, local=1.5.2
console_bridge_vendor                     : latest=1.6.0, local=1.6.0
tinyxml_vendor                            : latest=0.9.2, local=0.9.2
ament_cppcheck                            : latest=0.14.3, local=0.14.3
ros_environment                           : latest=4.1.1, local=4.1.1
action_tutorials_interfaces               : latest=0.27.1, local=0.27.1
examples_rclpy_minimal_subscriber         : latest=0.18.0, local=0.18.0
sros2_cmake                               : latest=0.11.3, local=0.11.3
examples_rclpy_minimal_action_client      : latest=0.18.0, local=0.18.0
logging_demo                              : latest=0.27.1, local=0.27.1
composition                               : latest=0.27.1, local=0.27.1
ament_cmake_pep257                        : latest=0.14.3, local=0.14.3
launch_xml                                : latest=2.0.2, local=2.0.2
rosbag2_storage_mcap                      : latest=0.22.6, local=0.22.6
geometry2                                 : latest=0.31.5, local=0.31.5
orocos_kdl_vendor                         : latest=0.3.4, local=0.3.4
ament_lint_common                         : latest=0.14.3, local=0.14.3
std_srvs                                  : latest=5.0.0, local=5.0.0
ros2topic                                 : latest=0.25.5, local=0.25.5
rqt_bag                                   : latest=1.3.4, local=1.3.4
urdf_parser_plugin                        : latest=2.8.2, local=2.8.2
examples_rclpy_executors                  : latest=0.18.0, local=0.18.0
message_filters                           : latest=4.7.0, local=4.7.0
geometry_msgs                             : latest=5.0.0, local=5.0.0
demo_nodes_cpp_native                     : latest=0.27.1, local=0.27.1
examples_rclpy_minimal_action_server      : latest=0.18.0, local=0.18.0
rosidl_runtime_cpp                        : latest=4.0.1, local=4.0.1
visualization_msgs                        : latest=5.0.0, local=5.0.0
rosbag2                                   : latest=0.22.6, local=0.22.6
ros2service                               : latest=0.25.5, local=0.25.5
fastrtps_cmake_module                     : latest=3.0.2, local=3.0.2
turtlesim                                 : latest=1.6.1, local=1.6.1
rosidl_default_generators                 : latest=1.5.0, local=1.5.0
rmw_implementation                        : latest=2.12.0, local=2.12.0
rqt_image_view                            : latest=1.2.0, local=1.2.0
ament_copyright                           : latest=0.14.3, local=0.14.3
rqt_shell                                 : latest=1.1.1, local=1.1.1
ament_cmake_flake8                        : latest=0.14.3, local=0.14.3
topic_monitor                             : latest=0.27.1, local=0.27.1
statistics_msgs                           : latest=1.6.0, local=1.6.0
tinyxml2_vendor                           : latest=0.8.3, local=0.8.3
rosgraph_msgs                             : latest=1.6.0, local=1.6.0
rqt_gui_cpp                               : latest=1.3.4, local=1.3.4
image_geometry                            : latest=3.4.0, local=3.4.0
rosidl_typesupport_interface              : latest=4.0.1, local=4.0.1
examples_rclpy_minimal_publisher          : latest=0.18.0, local=0.18.0
domain_coordinator                        : latest=0.11.2, local=0.11.2
qt_gui                                    : latest=2.4.3, local=2.4.3
rosidl_typesupport_introspection_cpp      : latest=4.0.1, local=4.0.1
launch_testing_ros                        : latest=0.24.1, local=0.24.1
rosidl_adapter                            : latest=4.0.1, local=4.0.1
ros2param                                 : latest=0.25.5, local=0.25.5
ament_cmake_ros                           : latest=0.11.2, local=0.11.2
rviz2                                     : latest=12.4.7, local=12.4.6
sensor_msgs                               : latest=5.0.0, local=5.0.0
rcpputils                                 : latest=2.6.3, local=2.6.3
rqt_topic                                 : latest=1.6.1, local=1.6.1
ament_lint_auto                           : latest=0.14.3, local=0.14.3
ament_cmake_export_interfaces             : latest=2.0.4, local=2.0.4
rmw_dds_common                            : latest=2.0.1, local=2.0.1
rcutils                                   : latest=6.2.2, local=6.2.2
lifecycle_msgs                            : latest=1.6.0, local=1.6.0
ament_lint_cmake                          : latest=0.14.3, local=0.14.3
robot_state_publisher                     : latest=3.2.1, local=3.2.1
actionlib_msgs                            : latest=5.0.0, local=5.0.0
unique_identifier_msgs                    : latest=2.3.2, local=2.3.2
examples_rclcpp_minimal_publisher         : latest=0.18.0, local=0.18.0
dummy_map_server                          : latest=0.27.1, local=0.27.1
desktop                                   : latest=0.10.0, local=0.10.0
ament_cmake_export_definitions            : latest=2.0.4, local=2.0.4
examples_rclcpp_minimal_subscriber        : latest=0.18.0, local=0.18.0
ament_cmake                               : latest=2.0.4, local=2.0.4
ament_cmake_gtest                         : latest=2.0.4, local=2.0.4
launch                                    : latest=2.0.2, local=2.0.2
class_loader                              : latest=2.5.0, local=2.5.0
tf2_sensor_msgs                           : latest=0.31.5, local=0.31.5
quality_of_service_demo_cpp               : latest=0.27.1, local=0.27.1
uncrustify_vendor                         : latest=2.1.2, local=2.1.2
rosbag2_compression                       : latest=0.22.6, local=0.22.6
action_msgs                               : latest=1.6.0, local=1.6.0
rclcpp                                    : latest=21.0.5, local=21.0.5
map_msgs                                  : latest=2.2.0, local=2.2.0
rviz_ogre_vendor                          : latest=12.4.7, local=12.4.6
libcurl_vendor                            : latest=3.2.2, local=3.2.2
ament_cmake_cppcheck                      : latest=0.14.3, local=0.14.3
diagnostic_msgs                           : latest=5.0.0, local=5.0.0
ros_base                                  : latest=0.10.0, local=0.10.0
pendulum_msgs                             : latest=0.27.1, local=0.27.1
tf2_eigen_kdl                             : latest=0.31.5, local=0.31.5
rviz_common                               : latest=12.4.7, local=12.4.6
keyboard_handler                          : latest=0.1.0, local=0.1.0
lifecycle                                 : latest=0.27.1, local=0.27.1
teleop_twist_joy                          : latest=2.5.0, local=2.5.0
examples_rclcpp_minimal_client            : latest=0.18.0, local=0.18.0
rosidl_parser                             : latest=4.0.1, local=4.0.1
pendulum_control                          : latest=0.27.1, local=0.27.1
python_qt_binding                         : latest=1.2.4, local=1.2.4
rosidl_generator_py                       : latest=0.18.0, local=0.18.0
examples_rclpy_minimal_client             : latest=0.18.0, local=0.18.0
intra_process_demo                        : latest=0.27.1, local=0.27.1
rosbag2_compression_zstd                  : latest=0.22.6, local=0.22.6
rqt_bag_plugins                           : latest=1.3.4, local=1.3.4
examples_rclcpp_multithreaded_executor    : latest=0.18.0, local=0.18.0
mcap_vendor                               : latest=0.22.6, local=0.22.6
launch_ros                                : latest=0.24.1, local=0.24.1
rqt_plot                                  : latest=1.2.3, local=1.2.3
rosidl_core_generators                    : latest=0.1.1, local=0.1.1
rviz_rendering                            : latest=12.4.7, local=12.4.6
shape_msgs                                : latest=5.0.0, local=5.0.0
rosbag2_storage_default_plugins           : latest=0.22.6, local=0.22.6
examples_rclpy_minimal_service            : latest=0.18.0, local=0.18.0
tracetools                                : latest=6.3.1, local=6.3.1
ros2lifecycle                             : latest=0.25.5, local=0.25.5
rcl_interfaces                            : latest=1.6.0, local=1.6.0
urdf                                      : latest=2.8.2, local=2.8.2
tf2_tools                                 : latest=0.31.5, local=0.31.5
demo_nodes_cpp                            : latest=0.27.1, local=0.27.1
rcl_logging_spdlog                        : latest=2.5.1, local=2.5.1
tlsf                                      : latest=0.8.2, local=0.8.2
rosidl_core_runtime                       : latest=0.1.1, local=0.1.1
ros2doctor                                : latest=0.25.5, local=0.25.5
quality_of_service_demo_py                : latest=0.27.1, local=0.27.1
tf2_geometry_msgs                         : latest=0.31.5, local=0.31.5
ros2component                             : latest=0.25.5, local=0.25.5
ament_flake8                              : latest=0.14.3, local=0.14.3
ament_cmake_export_link_flags             : latest=2.0.4, local=2.0.4
ament_cmake_test                          : latest=2.0.4, local=2.0.4
rosidl_default_runtime                    : latest=1.5.0, local=1.5.0
ament_package                             : latest=0.15.3, local=0.15.3
builtin_interfaces                        : latest=1.6.0, local=1.6.0
rmw                                       : latest=7.1.0, local=7.1.0
ament_cmake_export_include_directories    : latest=2.0.4, local=2.0.4
tf2_ros                                   : latest=0.31.5, local=0.31.5
rqt_common_plugins                        : latest=1.2.0, local=1.2.0
rttest                                    : latest=0.15.0, local=0.15.0
ament_cmake_include_directories           : latest=2.0.4, local=2.0.4
resource_retriever                        : latest=3.2.2, local=3.2.2
rclcpp_components                         : latest=21.0.5, local=21.0.5
ros2launch                                : latest=0.24.1, local=0.24.1
ament_cmake_libraries                     : latest=2.0.4, local=2.0.4
rosidl_runtime_py                         : latest=0.12.0, local=0.12.0
interactive_markers                       : latest=2.4.0, local=2.4.0
ament_pep257                              : latest=0.14.3, local=0.14.3
rqt_graph                                 : latest=1.4.2, local=1.4.2
action_tutorials_cpp                      : latest=0.27.1, local=0.27.1
launch_testing_ament_cmake                : latest=2.0.2, local=2.0.2
rcl_action                                : latest=6.0.5, local=6.0.5
rmw_fastrtps_shared_cpp                   : latest=7.1.3, local=7.1.3
ros2pkg                                   : latest=0.25.5, local=0.25.5
libyaml_vendor                            : latest=1.5.0, local=1.5.0
rclpy                                     : latest=4.1.4, local=4.1.4
rqt_action                                : latest=2.1.2, local=2.1.2
ament_cmake_copyright                     : latest=0.14.3, local=0.14.3
ament_index_cpp                           : latest=1.5.2, local=1.5.2
rviz_default_plugins                      : latest=12.4.7, local=12.4.6
rosidl_typesupport_introspection_c        : latest=4.0.1, local=4.0.1
rclcpp_action                             : latest=21.0.5, local=21.0.5
tf2                                       : latest=0.31.5, local=0.31.5
dummy_robot_bringup                       : latest=0.27.1, local=0.27.1
rqt_msg                                   : latest=1.3.1, local=1.3.1
ros2multicast                             : latest=0.25.5, local=0.25.5
rosidl_typesupport_cpp                    : latest=3.0.1, local=3.0.1
rqt_py_console                            : latest=1.1.1, local=1.1.1
rqt_gui_py                                : latest=1.3.4, local=1.3.4
pcl_conversions                           : latest=2.4.0, local=2.4.0
action_tutorials_py                       : latest=0.27.1, local=0.27.1
rosidl_cli                                : latest=4.0.1, local=4.0.1
rosbag2_storage                           : latest=0.22.6, local=0.22.6
service_msgs                              : latest=1.6.0, local=1.6.0
rpyutils                                  : latest=0.3.2, local=0.3.2
yaml_cpp_vendor                           : latest=8.1.2, local=8.1.2
sensor_msgs_py                            : latest=5.0.0, local=5.0.0
laser_geometry                            : latest=2.5.0, local=2.5.0
rcl_lifecycle                             : latest=6.0.5, local=6.0.5
examples_rclcpp_minimal_service           : latest=0.18.0, local=0.18.0
ament_xmllint                             : latest=0.14.3, local=0.14.3
sqlite3_vendor                            : latest=0.22.6, local=0.22.6
tf2_kdl                                   : latest=0.31.5, local=0.31.5
angles                                    : latest=1.16.0, local=1.16.0
rmw_fastrtps_cpp                          : latest=7.1.3, local=7.1.3
rclcpp_lifecycle                          : latest=21.0.5, local=21.0.5
examples_rclcpp_minimal_action_client     : latest=0.18.0, local=0.18.0
ament_cmake_core                          : latest=2.0.4, local=2.0.4
nav_msgs                                  : latest=5.0.0, local=5.0.0
image_tools                               : latest=0.27.1, local=0.27.1
joy                                       : latest=3.3.0, local=3.3.0
rqt_srv                                   : latest=1.1.1, local=1.1.1
ament_cmake_gen_version_h                 : latest=2.0.4, local=2.0.4
ament_cmake_version                       : latest=2.0.4, local=2.0.4
ros2cli                                   : latest=0.25.5, local=0.25.5
rcl_logging_interface                     : latest=2.5.1, local=2.5.1
pybind11_vendor                           : latest=3.0.3, local=3.0.3
ros2action                                : latest=0.25.5, local=0.25.5
spdlog_vendor                             : latest=1.4.4, local=1.4.4
rmw_implementation_cmake                  : latest=7.1.0, local=7.1.0
ament_cmake_target_dependencies           : latest=2.0.4, local=2.0.4
python_cmake_module                       : latest=0.10.2, local=0.10.2
tf2_eigen                                 : latest=0.31.5, local=0.31.5
cv_bridge                                 : latest=3.4.0, local=3.4.0
rqt_console                               : latest=2.1.1, local=2.1.1
tf2_bullet                                : latest=0.31.5, local=0.31.5
qt_gui_cpp                                : latest=2.4.3, local=2.4.3
rosidl_cmake                              : latest=4.0.1, local=4.0.1
rosidl_generator_c                        : latest=4.0.1, local=4.0.1
rqt_publisher                             : latest=1.6.3, local=1.6.3
ament_uncrustify                          : latest=0.14.3, local=0.14.3
ros2interface                             : latest=0.25.5, local=0.25.5
depthimage_to_laserscan                   : latest=2.5.1, local=2.5.1
kdl_parser                                : latest=2.9.0, local=2.9.0
example_interfaces                        : latest=0.10.2, local=0.10.2
rosidl_dynamic_typesupport_fastrtps       : latest=0.0.2, local=0.0.2
rosbag2_py                                : latest=0.22.6, local=0.22.6
rosbag2_storage_sqlite3                   : latest=0.22.6, local=0.22.6
sros2                                     : latest=0.11.3, local=0.11.3

   PLATFORM INFORMATION
system           : Linux
platform info    : Linux-6.5.0-26-generic-x86_64-with-glibc2.35
release          : 6.5.0-26-generic
processor        : x86_64

   QOS COMPATIBILITY LIST
compatibility status    : No publisher/subscriber pairs found

   RMW MIDDLEWARE
middleware name    : rmw_fastrtps_cpp

   ROS 2 INFORMATION
distribution name      : iron
distribution type      : ros2
distribution status    : active
release platforms      : {'rhel': ['9'], 'ubuntu': ['jammy']}

   TOPIC LIST
topic               : none
publisher count     : 0
subscriber count    : 0

这份报告有点小长,但内容主要包括5大块,分别如下:

NETWORK CONFIGURATION
...

PLATFORM INFORMATION
...

RMW MIDDLEWARE
...

ROS 2 INFORMATION
...

TOPIC LIST
...

我们把检查到failed那块内容拷贝出来贴到相关ROS论坛或邮件里面,这对于别人帮助我们分析解决问题来说,是非常有用的。

本篇完。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值