ros2与windows入门教程-监听和发布话题
说明:
- 介绍如何在windows ROS2上监听和发布话题
步骤:
- 新打开一个cmd命令提示符窗口,使用call命令设置环境
call C:\opt\ros\foxy\x64\local_setup.bat
- python监听话题
ros2 run demo_nodes_py listener
- 再打开一个cmd命令提示符窗口,使用call命令设置环境
call C:\opt\ros\foxy\x64\local_setup.bat
- C++ 发布话题
ros2 run demo_nodes_cpp talker
- 如果文件成功启动,发布终端将显示以下内容
[INFO] [1653898262.009778100] [talker]: Publishing: 'Hello World: 1'
[INFO] [1653898263.009887600] [talker]: Publishing: 'Hello World: 2'
[INFO] [1653898264.009452100] [talker]: Publishing: 'Hello World: 3'
[INFO] [1653898265.009794500] [talker]: Publishing: 'Hello World: 4'
[INFO] [1653898266.009774400] [talker]: Publishing: 'Hello World: 5'
[INFO] [1653898267.010018100] [talker]: Publishing: 'Hello World: 6'
- 如果文件成功启动,监听终端将显示以下内容
[INFO] [1653898262.068988700] [listener]: I heard: [Hello World: 1]
[INFO] [1653898263.030273700] [listener]: I heard: [Hello World: 2]
[INFO] [1653898264.026498000] [listener]: I heard: [Hello World: 3]
[INFO] [1653898265.030515200] [listener]: I heard: [Hello World: 4]
[INFO] [1653898266.030402000] [listener]: I heard: [Hello World: 5]
[INFO] [1653898267.030818200] [listener]: I heard: [Hello World: 6]
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号