![]() |
rosrust repositoryrust ros client-library actionlib_msgs common_msgs diagnostic_msgs geometry_msgs nav_msgs sensor_msgs shape_msgs stereo_msgs trajectory_msgs visualization_msgs |
Repository Summary
Description | Pure Rust implementation of a ROS client library |
Checkout URI | https://github.com/adnanademovic/rosrust.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2025-02-03 |
Dev Status | UNKNOWN |
Released | UNRELEASED |
Tags | rust ros client-library |
Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Packages
Name | Version |
---|---|
actionlib_msgs | 1.13.1 |
common_msgs | 1.13.1 |
diagnostic_msgs | 1.13.1 |
geometry_msgs | 1.13.1 |
nav_msgs | 1.13.1 |
sensor_msgs | 1.13.1 |
shape_msgs | 1.13.1 |
stereo_msgs | 1.13.1 |
trajectory_msgs | 1.13.1 |
visualization_msgs | 1.13.1 |
README
rosrust
rosrust is a pure Rust implementation of a ROS client library.
Usage
For all the key features, it is enough to depend on the crate itself. It’s highly recommended to depend on rosrust_msg
as well, as it provides bindings for message generation.
The following dependencies are recommended to use the crate:
[dependencies]
rosrust = "0.9"
rosrust_msg = "0.1"
If using Rust 2015 edition, just depend on the library with macro usage, using:
#[macro_use]
extern crate rosrust;
Examples are written using Rust 2018, as it’s the expected edition to use now.
Implementation
rosrust is almost there with implementing all features of a ROS Client Library by fulfilling ROS requirements for implementing client libraries which are given in a more detailed form in the technical overview.
Mostly the missing features are related to extra tooling, like sensor_msgs/PointCloud2
and sensor_msgs/Image
encoding/decoding, TF tree handling, and other things that are external libraries in roscpp
and rospy
as well.
The API is very close to the desired final look.
Integration with catkin will be handled once a satisfying set of features has been implemented.
Examples
The API is close to reaching its final form.
There are multiple examples in the examples folder. The publisher/subscriber and service/client examples are designed to closely imitate the roscpp
tutorial.
Features
Message Generation
Message generation can be done automatically by depending on rosrust_msg
, or manually using rosrust::rosmsg_include
.
The preferred way is automatic, as it allows interop between dependencies that use messages and your crate.
If you do not have ROS installed, then the message generation utilizes the ROSRUST_MSG_PATH
environment variable, which is a colon separated list of directories to search.
These directories should have the structure <ROSRUST_MSG_PATH>/<anything>/<package>/msg/<message>
or <ROSRUST_MSG_PATH>/<anything>/<package>/srv/<service>
.
Automatic
For automatic message generation just depend on rosrust_msg
, with the version specified at the top of this document.
After that you’ll be able to generate a sensor_msgs/Imu
message object by using rosrust_msg::sensor_msgs::Imu::default()
. All fields are always public, so you can initialize structures as literals.
Manual
Message generation is done at build time. If you have ROS installed and sourced in your shell session, you will not need to do any extra setup for this to work.
To generate messages, create a module for messages. Using something like a msg.rs
file in your project root results in importing similar to roscpp
and rospy
. The file only needs one line:
// If you wanted
// * messages: std_msgs/String, sensor_msgs/Imu
// * services: roscpp_tutorials/TwoInts
// * and all the message types used by them, like geometry_msgs/Vector3
rosrust::rosmsg_include!(std_msgs/String,sensor_msgs/Imu,roscpp_tutorials/TwoInts);
Just add this file to your project and you’re done.
If you have put this in a src/msg.rs
file, this will include all the generated structures, and add them to the msg
namespace. Thus, to create a new sensor_msgs/Imu
, you call msg::sensor_msgs::Imu::default()
. All fields are always public, so you can initialize structures as literals.
Publishing to Topic
If we wanted to publish a defined message (let’s use std_msgs/String
) to topic chatter
ten times a second, we can do it in the following way.
```rust fn main() { // Initialize node rosrust::init(“talker”);
// Create publisher
let chatter_pub = rosrust::publish("chatter", 100).unwrap();
let mut count = 0;
// Create object that maintains 10Hz between sleep requests
let rate = rosrust::rate(10.0);
// Breaks when a shutdown signal is sent
while rosrust::is_ok() {
// Create string message
File truncated at 100 lines see the full file