9 unstable releases (4 breaking)
|new 0.6.0||Nov 28, 2023|
|0.5.5||Oct 31, 2023|
|0.5.3||Jul 24, 2023|
|0.5.2||Jun 13, 2023|
|0.2.0||Mar 17, 2022|
#1270 in Network programming
177 downloads per month
The API is not identical to
rclpy, because some parts would be very awkward in Rust. For example, there are no callbacks. Rust
async mechanism is used instead. Alternatively, some of the functionality can be polled using the Metal I/O library.
There is a
.spin() call, but it is required only to have
ros2-client execute some background tasks. You can spawn an async task to run it, and retain the flow of control in your code.
Please see the included examples on how to use the various features.
- Topics, Publish and Subscribe ✅
- QoS ✅
- Serialization ✅ - via Serde
- Services: Clients and Servers ✅ (async recommended)
- Actions ✅ (async)
- Discovery / ROS Graph update events ✅ (async)
- Parameters - not yet
- Message generation: from
- ROS 2 Security - experimental
New in Version 0.6:
- Reworked ROS 2 Discovery implementation. Now
.spin()call to run the Discovery mechanism.
- New API for naming Nodes, Topics, Services, Actions, and data types for Topics, Actions, and Services. The new API is more structured to avoid possible confusion and errors from parsing strings.
New in version 0.5:
- Actions are supported
- async programming interface. This should make a built-in event loop unnecessary, as Rust async executors sort of do that already. This means that
ros2-clientis not going to implement a call similar to
Example: minimal_action_server and minimal_action_client
These are re-implementations of similarly named ROS examples. They should be interoperable with ROS 2 example programs in C++ or Python.
To test this, start a server and then, in a separate terminal, a client, e.g.
ros2 run examples_rclcpp_minimal_action_server action_server_member_functions
cargo run --example=minimal_action_client
cargo run --example=minimal_action_server
ros2 run examples_rclpy_minimal_action_client client
You should see the client requesting for a sequence of Fibonacci numbers, and the server providing them until the requested sequence length is reached.
The included example program should be able to communicate with out-of-the-box ROS2 turtlesim example.
Install ROS2 and start the simulator by
ros2 run turtlesim turtlesim_node. Then run the
turtle_teleop example to control the simulator.
Teleop example program currently has the following keyboard commands:
- Cursor keys: Move turtle
r: reset simulator
p: change pen color (for turtle1 only)
b: spawn turtle1 / turtle2
B: kill turtle1 / turtle2
2: switch control between turtle1 / turtle2
g: Trigger or cancel absolute rotation action.
Install ROS2. This has been tested to work against "Galactic" release, using either eProsima FastDDS or RTI Connext DDS (
cargo run --example=ros2_service_server
In another terminal or computer, run a client:
ros2 run examples_rclpy_minimal_client client
Similar to above.
ros2 run examples_rclpy_minimal_service service
cargo run --example=ros2_service_client
- ros2_rust is closest(?) to an official ROS2 client library. It links to ROS2
rcllibrary written in C.
- rclrust is another ROS2 client library for Rust. It supports also ROS2 Services in addition to Topics. It links to ROS2 libraries, e.g.
- rus2 exists, but appears to be inactive since September 2020.
Copyright 2022 Atostek Oy
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
This crate is developed and open-source licensed by Atostek Oy.