Minimal ROS 2 Rust bindings
Go to file
Kristofer Bengtsson fae64ec6ce Merge remote-tracking branch 'origin/master' into futures
# Conflicts:
#	.github/workflows/rust_and_ros2.yml
2021-07-06 16:06:31 +02:00
.github/workflows fixed the actions to test on all branches 2021-07-06 16:05:34 +02:00
actions bump version numbers to 0.1.0 2021-06-18 14:20:30 +02:00
common bump version numbers to 0.1.0 2021-06-18 14:20:30 +02:00
examples cancel actions 2021-06-18 13:47:21 +02:00
msg_gen bump version numbers to 0.1.0 2021-06-18 14:20:30 +02:00
rcl bump version numbers to 0.1.0 2021-06-18 14:20:30 +02:00
src cancel actions 2021-06-18 13:47:21 +02:00
tests Added testing of tokio when running cargo test 2021-07-06 15:33:35 +02:00
.gitignore Switch from failure to thiserror. Closes #2 2021-05-11 16:30:38 +02:00
Cargo.toml bump version numbers to 0.1.0 2021-06-18 14:20:30 +02:00
LICENSE add ROSIN acknowledgement and LICENSE file 2020-10-14 19:14:43 +02:00
README.md Fix panic in subscriber_with_thread example and improve readme. 2021-05-11 11:50:51 +02:00
build.rs minimal action clients. no handling or failed goals or canceling. 2021-06-12 08:09:39 +02:00
rustfmt.toml apply rustfmt 2021-05-15 11:04:32 +02:00

README.md

R2R - Minimal ROS2 Rust bindings

Minimal bindings for ROS2 that do not require hooking in to the ROS2 build infrastructure -- cargo build is all you need. Convenience Rust types are created by calling into the c introspection libraries. This circumvents the ROS2 .msg/.idl pipeline by relying on already generated C code. The convenience types can be ignored when you need to trade convenience for performance, e.g. treating large chunks of data manually. By default, the behavior is to build bindings to the RCL and all message types that can be found in the currently sourced ros environment.

When integration with the colcon build system is desired, a CMakeLists.txt file can be used to limit the generation of bindings to only include specific (idl) dependencies. This is done through additional environment variables. A minimal example is available here: https://github.com/m-dahl/r2r_minimal_node/.

Manual is available on github pages https://sequenceplanner.github.io/r2r/

How to use

  1. Make sure you have libclang installed. (e.g. libclang-dev on ubuntu)
  2. Depend on this package: r2r = { git = "https://github.com/sequenceplanner/r2r" }.
  3. You need to source your ROS2 installation before building/running.
  4. The bindings will rebuild automatically if/when you source your workspace(s).
  5. If you make changes to existing message types, run cargo clean -p msg_gen to force recompilation of the rust message types on the next build.

A couple of examples are included in examples/

. /opt/ros/foxy/setup.sh
cargo build
cargo run --example subscriber_with_thread
# In other shell
ros2 topic pub /hi std_msgs/msg/String "data: 'Hello, world!'"

An example application can be found here https://github.com/sequenceplanner/r2r-echo, which can be installed by running cargo install --git https://github.com/sequenceplanner/r2r-echo.

What works?

  • Up to date with ROS2 ~Dashing~ ~Eloquent~ Foxy
  • Building Rust types
  • Publish/subscribe
  • Services
  • Parameters

TODO

  • The code generation is currently just a big hack. Needs cleanup and refactoring.
  • Expose more of the RCL like QoS settings.
  • Action types?
  • Async API!

rosin_logo

Supported by ROSIN - ROS-Industrial Quality-Assured Robot Software Components. More information: rosin-project.eu

eu_flag

This project has received funding from the European Unions Horizon 2020 research and innovation programme under grant agreement no. 732287.