AcmeIot-3-在嵌入式设备中运行ROS2

ROS2是作为第二代ROS,对ROS1进行了重大的优化,主要的特点有:

  • 实现跨平台运行,可以运行在Linux、windows、Mac、RTOS,甚至没有操作系统的裸机

  • 实现真正的分布式通信架构,去中心化,不再依赖于master节点

  • 使用更加成熟可靠的DDS/RTPS作为底层通信框架,在通信的可靠性、稳定性和实时性上都更加出色

ROS1与ROS2的架构对比如图所示:

既然ROS2可以运行在RTOS中,我们自然要动手玩一玩的。

micro-ROS是ROS2运行在嵌入式设备中的项目,而它官方支持FreeRTOS、Zephyr以及Nuttx三款RTOS。

在前面的AcmeIot的分享中,我们开发了一个在esp32上运行的ROS节点

AcmeIot-1-基于Nuttx和ESP32的ROS节点

这里我们再设计一个在esp32上运行的ROS2节点,通过esp32原生的wifi支持,可以与PC的ROS2节点直接互联

micro-ROS的架构如图所示:

图中涉及到一些通信框架上的专业名词,可能同学们看起来可能不是很理解,这里给大家列举一下:

名称说明
DDSDDS指数据分发服务(Data-Distribution Service),是由OMG组织定义的一种以数据为中心的通信模型
DDS-XRCE用于资源极度受限环境的DDS
RTPSRTPS表示实时发布-订阅传输协议(Real-Time Publish Subscribe),该协议已经成为了工业以太网的一个标准(IEC-PAS-62030)。RTPS十分符合DDS模型的要求,于是就被DDS作为它的传输协议
Fast-DDSeProsima开发的DDS实现,被用于ROS2作为主要的通信框架。它的曾用名为Fast-RTPS
Micro-XRCE-DDSeProsima开发的DDS-XRCE实现
Fast-CDReProsima开发的静态的低级序列化C++库,根据RTPS规范中定义的标准CDR串行化机制(参见数据封装章作为参考)进行串行化。Fast-DDS使用的底层序列化库
Micro-CDReProsima 开发的一个实现CDR标准序列化方法的C库。该库专注于嵌入式和资源有限的系统。 Micro-XRCE-DDS使用的底层序列化

在ROS2的软件包中可以经常看到关于这些相关的软件包名,都是ROS2使用的通信框架包,有一个基本的概念对于理解ROS2的软件框架会更清晰一些。

我们大致了解了micro-ROS的结构,我们移植 https://github.com/micro-ROS/micro_ros_nuttx_app 仓库的micro-ROS库与demo应用到Nuttx中。

从该软件包的micro_ros_lib/Makefile 中我们可以发现,micro-ROS实际上是大量的ros2、eprosima、micro-ROS的软件包集合

    git clone -b foxy https://github.com/eProsima/micro-CDR src/micro-CDR; \
    git clone -b foxy https://github.com/eProsima/Micro-XRCE-DDS-Client src/Micro-XRCE-DDS-Client; \
    git clone -b master https://github.com/micro-ROS/rcl src/rcl; \
    git clone -b master https://github.com/ros2/rclc src/rclc; \
    git clone -b master https://github.com/micro-ROS/rcutils src/rcutils; \
    git clone -b main https://github.com/micro-ROS/micro_ros_msgs src/micro_ros_msgs; \
    git clone -b main https://github.com/micro-ROS/rmw-microxrcedds src/rmw-microxrcedds; \
    git clone -b master https://github.com/micro-ROS/rosidl_typesupport src/rosidl_typesupport; \
    git clone -b main https://github.com/micro-ROS/rosidl_typesupport_microxrcedds src/rosidl_typesupport_microxrcedds; \
    git clone -b master https://github.com/ros2/rosidl src/rosidl; \
    git clone -b master https://github.com/ros2/rmw src/rmw; \
    git clone -b master https://github.com/ros2/rcl_interfaces src/rcl_interfaces; \
    git clone -b master https://github.com/ros2/rosidl_defaults src/rosidl_defaults; \
    git clone -b master https://github.com/ros2/unique_identifier_msgs src/unique_identifier_msgs; \
    git clone -b master https://github.com/ros2/common_interfaces src/common_interfaces; \
    git clone -b master https://github.com/ros2/test_interface_files src/test_interface_files; \
    git clone -b master https://github.com/ros2/rmw_implementation src/rmw_implementation; \
    git clone -b master https://github.com/ros2/rcl_logging src/rcl_logging; \
    git clone -b master https://gitlab.com/micro-ROS/ros_tracing/ros2_tracing src/ros2_tracing; \
    git clone -b main https://github.com/micro-ROS/micro_ros_utilities src/micro_ros_utilities; \

从仓库列表也可以发现,micro-ROS使用了micro-CDR与Micro-XRCE-DDS-Client替代First-CDR与First-DDS,作为底层通信框架。

在解决少量编译错误,并配置esp32支持后,我们的程序即可在esp32中正常运行了。

往期分享:

AcmeGCS-12-地图与任务规划优化

再见2021,你好2022

PX4-11-日志框架与常用日志消息

这里会不定期更新一些我整理的无人机相关知识,欢迎关注分享。

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值