Home » ROS2与arduino指南 » ROS2与arduino入门教程-安装micro_ros_arduino

ROS2与arduino入门教程-安装micro_ros_arduino

ROS2与arduino入门教程-安装micro_ros_arduino

说明:

  • 介绍如何使用micro_ros_arduino包
  • micro_ros_arduino包和ros2arduino类似,不过micro_ros_arduino支持会更新
  • 本教程使用opencr作为演示

步骤:

  • 安装arduino,参考ROS2与arduino入门教程-安装ros2arduino
  • 下载micro_ros_arduino,进入下载页面,选择最新版本的zip下载包
  • 打开arduino,选择Sketch -> Include library -> Add .ZIP Library...
  • 再点击下载包的zip压缩包,完成导入
  • 导入后,在examples下就会出现micro_ros_arduino

测试:

  • 在arduino界面上,选择File -> Examples -> micro_ros_arduino -> micro-ros_publisher
  • 效果如图:

请输入图片描述

  • pc端终端,启动MicroXRCEAgent
MicroXRCEAgent serial --dev /dev/ttyACM0 -b 115200 -v6 
  • 效果如下:
$ MicroXRCEAgent serial --dev /dev/ttyACM0 -b 115200 -v6  
[1608288074.472661] info     | TermiosAgentLinux.cpp | init                     | running...             | fd: 3
[1608288074.473002] info     | Root.cpp           | set_verbose_level        | logger setup           | verbose_level: 6
[1608288074.473145] info     | Root.cpp           | create_client            | create                 | client_key: 0x5CE949F7, session_id: 0x81
[1608288074.473180] info     | SessionManager.hpp | establish_session        | session established    | client_key: 0x1558792695, address: 1
[1608288074.473253] debug    | SerialAgentLinux.cpp | send_message             | [** <<SER>> **]        | client_key: 0x5CE949F7, len: 19, data:
0000: 81 00 00 00 04 01 0B 00 00 00 58 52 43 45 01 00 01 0F 00
[1608288074.474010] debug    | SerialAgentLinux.cpp | recv_message             | [==>> SER <<==]        | client_key: 0x5CE949F7, len: 112, data:
0000: 81 80 00 00 01 05 66 00 00 0A 00 01 01 02 00 00 57 00 00 00 3C 64 64 73 3E 3C 70 61 72 74 69 63
0020: 69 70 61 6E 74 3E 3C 72 74 70 73 3E 3C 6E 61 6D 65 3E 6D 69 63 72 6F 5F 72 6F 73 5F 61 72 64 75
0040: 69 6E 6F 5F 6E 6F 64 65 3C 2F 6E 61 6D 65 3E 3C 2F 72 74 70 73 3E 3C 2F 70 61 72 74 69 63 69 70
0060: 61 6E 74 3E 3C 2F 64 64 73 3E 00 00 00 00 00 00
[1608288074.477283] debug    | ProxyClient.cpp    | create_participant       | participant created    | client_key: 0x5CE949F7, participant_id: 0x000(1)
[1608288074.477414] debug    | SerialAgentLinux.cpp | send_message             | [** <<SER>> **]        | client_key: 0x5CE949F7, len: 14, data:
0000: 81 80 00 00 05 01 06 00 00 0A 00 01 00 00
[1608288074.477426] debug    | SerialAgentLinux.cpp | send_message             | [** <<SER>> **]        | client_key: 0x5CE949F7, len: 13, data:
0000: 81 00 00 00 0A 01 05 00 01 00 00 00 80
[1608288074.477944] debug    | SerialAgentLinux.cpp | recv_message             | [==>> SER <<==]        | client_key: 0x5CE949F7, len: 13, data:
0000: 81 00 00 00 0A 01 05 00 01 00 00 00 80
[1608288074.478019] debug    | SerialAgentLinux.cpp | recv_message             | [==>> SER <<==]        | client_key: 0x5CE949F7, len: 148, data:
  • pc端终端,查看话题列表
ros2 topic list 
  • 效果如下:
~$ ros2 topic list
/micro_ros_arduino_node_publisher
/parameter_events
/rosout
  • pc端终端,查看话题
ros2 topic echo /micro_ros_arduino_node_publisher
  • 效果如下:
~$ ros2 topic echo /micro_ros_arduino_node_publisher
data: 23
---
data: 24
---
data: 25
---
data: 26
---
data: 27
---
data: 28
---
data: 29
---
data: 30

参考:

  • https://github.com/micro-ROS/micro_ros_arduino

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: ros2与arduino入门教程