22个版本
0.9.0 | 2024年5月17日 |
---|---|
0.8.4 | 2024年3月19日 |
0.8.3 | 2024年1月14日 |
0.8.2 | 2023年12月11日 |
0.5.3 | 2021年9月20日 |
#18 in 过程宏
9,585 每月下载次数
在 3 crates 中使用
4MB
69K SLoC
R2R - 简单易用,运行时无关,异步Rust绑定用于ROS2。
适用于ROS2的简单易用绑定,无需挂钩到ROS2构建基础设施 - cargo build
就足够了。通过调用c插口库创建方便的Rust类型。这通过依赖已生成的C代码来绕过ROS2 .msg/.idl管道。默认情况下,行为是构建绑定到RCL和当前源ros环境中可找到的所有消息类型,但可以更具体地构建以节省构建时间(见下文说明)。
当希望与colcon构建系统集成时,可以使用CMakeLists.txt文件来限制绑定生成的范围,仅包括特定的(idl)依赖项。这是通过额外的环境变量来完成的。这里提供了一个colcon集成的最小示例:https://github.com/m-dahl/r2r_minimal_node。
此库在风格上与rclpy和rclcpp略有不同,因为它消除了所有同步回调,转而使用rust futures和streams。结合rust的await语法,这使得在单线程设置中(例如service.rs示例)使用ROS服务和动作变得非常愉快。该库故意不选择异步运行时 - 这意味着用户需要负责任何任务创建。这也限制了API到futures-rs提供的。
文档可在docs.rs上找到: https://docs.rs/r2r/latest/r2r。
这些绑定是根据我的和其他人的需求自然编写的,因此请注意,API将会更改。到目前为止,我没有任何意图仅为了完整性而封装所有的RCL。然而,如果您需要一些特定的功能,请随时打开一个问题或PR!
如何使用
- 请确保您已安装libclang。(例如,在ubuntu上安装libclang-dev)
- 在Cargo.toml中依赖此包:
r2r = "0.9.0"
- 在构建/运行之前,您需要设置ROS2安装。
- 如果您设置了工作区,绑定将自动重新构建。
- 如果您修改了现有的消息类型,请在下一次构建时强制重新编译Rust消息类型,请运行
cargo clean -p r2r_msg_gen
如何使用此包的示例包含在examples/中
. /opt/ros/humble/setup.sh
cargo build
cargo run --example subscriber
# In other shell
ros2 topic pub /topic std_msgs/msg/String "data: 'Hello, world'"
关于构建时间的说明
由于默认行为是构建所有源消息类型,对于较大的工作区,构建时间可能会迅速成为问题。为了避免构建所有内容,可以使用环境变量IDL_PACKAGE_FILTER
仅声明所需的消息包。为了方便起见,可以在.cargo/config.toml
中设置此变量,例如https://github.com/m-dahl/r2r_minimal_node/blob/master/r2r_minimal_node/.cargo/config.toml。注意,嵌套消息类型没有自动依赖关系解析,因此需要显式包含所有使用的消息包。
什么工作?
- 与ROS2
DashingEloquentFoxy Galactic Humble Iron - 构建Rust类型
- 发布/订阅
- 服务
- 动作
- 参数处理
- 模拟时间(确保在构建时设置
rosgraph_msgs
以启用) - 在Linux、OSX和Windows上运行。
变更日志
[未发布]
[0.9.0] - 2024-05-17
- 修复与rust 1.78冲突的不安全先决条件(s) https://github.com/sequenceplanner/r2r/issues/96。可能会有更多此类问题需要修复,如果在遇到此类问题时请报告。
- 公开服务客户端和服务器QoS设置 https://github.com/sequenceplanner/r2r/pull/95。注意,API有轻微变化!
- 使参数的顺序确定 https://github.com/sequenceplanner/r2r/pull/94
- 添加r2r_info示例以打印环境信息 https://github.com/sequenceplanner/r2r/pull/92
- 代码清理 https://github.com/sequenceplanner/r2r/pull/90, https://github.com/sequenceplanner/r2r/pull/91
- 移除is_available的节点mut-ref依赖 https://github.com/sequenceplanner/r2r/pull/89。注意,API有轻微变化!
- 支持模拟时间 https://github.com/sequenceplanner/r2r/pull/88
[0.8.4] - 2024-03-19
- 修复rolling QoS https://github.com/sequenceplanner/r2r/pull/87
- 为ros2 iron更新 https://github.com/sequenceplanner/r2r/pull/84
[0.8.3] - 2024-01-14
- 添加
get_publishers_info_by_topic
https://github.com/sequenceplanner/r2r/pull/80 - 原始发布者 https://github.com/sequenceplanner/r2r/pull/76
- 添加与
rcl_publisher_get_subscription_count
相关的方法 https://github.com/sequenceplanner/r2r/pull/75 - 从
WrappedNativeMsgUntyped
的序列化字节开始 https://github.com/sequenceplanner/r2r/commit/d5f2ef0eac7072c66fe8866a3dbbfc2326b13804 - 消息(反)序列化助手 https://github.com/sequenceplanner/r2r/pull/74。
- 原始消息订阅者。 https://github.com/sequenceplanner/r2r/pull/73
[0.8.2] - 2023-12-11
- 修复Linux上的包含路径回退。 https://github.com/sequenceplanner/r2r/pull/71
[0.8.1] - 2023-11-30
- 修复使用 colcon/cmake 构建时的回归问题。 https://github.com/sequenceplanner/r2r/commit/7fc96e3eb2fd9f7f272258e07204041aeecfba76
[0.8.0] - 2023-10-05
- 支持 Windows! https://github.com/sequenceplanner/r2r/pull/66
- 推导用于 ros 参数的宏。 https://github.com/sequenceplanner/r2r/pull/65 和 https://github.com/sequenceplanner/r2r/pull/68。 注意:破坏了旧的参数 API,请参阅提交信息以获取详细信息 https://github.com/sequenceplanner/r2r/commit/00d7a3db0b48c27a61ce153b084eadeef799765a。
- 实现 rcl_interfaces::srv::ListParameters 服务。 https://github.com/sequenceplanner/r2r/pull/64
- 消除关于虚拟工作区解析器的编译警告。 https://github.com/sequenceplanner/r2r/pull/63
[0.7.5] - 2023-06-27
- 修复 idl 头文件蛇形命名转换的问题。 https://github.com/sequenceplanner/r2r/pull/61
- 修复在生成头文件和调用 bindgen 之间发生竞争条件时的构建问题。 https://github.com/sequenceplanner/r2r/commit/f5f41baa2554b24813cc2f212ecf2e45476063e1
[0.7.4] - 2023-06-26
- 使用 syn 和 quote 重新整理代码生成,并提高构建时间 https://github.com/sequenceplanner/r2r/pull/58
- 将 (e)println 替换为 log https://github.com/sequenceplanner/r2r/pull/51
[0.7.3] - 2023-06-20
- 修复文档生成中的错误。
[0.7.2] - 2023-06-20
- 各种 CI 改进: https://github.com/sequenceplanner/r2r/pull/54, https://github.com/sequenceplanner/r2r/pull/56
- 修复 docs.rs 上的构建问题 https://github.com/sequenceplanner/r2r/pull/56
- 根据 https://github.com/sequenceplanner/r2r/issues/53 的建议,在 README.md 中澄清有关构建时间的编译标志。
[0.7.1] - 2023-05-21
- 将关联常量添加到生成的消息类型中。 https://github.com/sequenceplanner/r2r/pull/46
- 仅记录一次借用的消息错误。 https://github.com/sequenceplanner/r2r/pull/44
- 更新 r2r_cargo.cmake 到最新版本(见 此处)
[0.7.0] - 2023-03-21
- 使用非混淆名称进行 serde 序列化。 https://github.com/sequenceplanner/r2r/pull/40
- 当 rcl_init 失败时避免段错误。 https://github.com/sequenceplanner/r2r/pull/41
- 支持借用的消息。 (更改了
publish_native
api)。 https://github.com/sequenceplanner/r2r/pull/42
[0.6.7] - 2023-02-20
- 修复 Foxy 上的未声明类型。 https://github.com/sequenceplanner/r2r/pull/39
TODO
- 文档不足。 (目前,请参阅示例。)
授权
除非源文件中指定了其他许可证,否则所有代码均受 MIT 许可证的约束。此存储库中包含 rclrust (https://github.com/rclrust/rclrust) 软件包的一些部分,并受 Apache 2.0 许可证的约束。

由 ROSIN 支持的 - ROS-Industrial 质量保证机器人软件组件。更多信息: rosin-project.eu
该项目已从欧盟的 Horizon 2020 研究和创新计划获得资金,资助协议号 732287。
依赖项
~13MB
~232K SLoC