rosrust
rosrust is a pure Rust implementation of a ROS client library.
Implementation
rosrust is under development to implement 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.
Currently implemented features:
- ROS Master API, Parameter Server API and most of ROS Slave API (excluding 2 ambiguous methods)
- Interface for handling parameters
- Publisher, Subscriber, Client, Service fully working (until packet snooping for another undocumented feature is needed)
- Simple bindings for messages, but ROS integration for generating them has yet to be done, and will be part of the catkin integration
- Manual remapping is provided, and CLI parameter remapping is coming!
There are still quite some features to be implemented for this to become a stable API (for the library user's interface to stop changing). The most important ones are listed as Issues by the repository owner.
Integration with catkin will be handled once a satisfying set of features has been implemented.
Examples
The API is far from being stable, but this is the current desired functionality.
Most of the examples are followed by an infinite loop. ROS shutdown signal checking is coming!
Messages
Currently we don't have any support for message generation by ROS itself, because a 100% decision of how we'll integrate generated files hasn't been made. There is a prototype in the works, but in the meantime messages have to be manually generated. Looking from the bright side - at least you'll know what constitutes a ROS message.
Let's demonstrate the std_msgs/UInt64.msg
message.
Services are not too different, so let's show the rospy_tutorials/AddTwoInts.srv
service, from the rospy
Service/Client tutorial.
This will all be unimportant information once message generation is done, but it's useful to know that ROS Messages and Services will just be normal structures. It's important to note that all of this depends on rustc-serialize
.
Publishing to topic
If we wanted to publish a defined message (let's use the previously described UInt64
) to topic some_topic
approximately every second, we can do it in the following way.
extern crate rosrust;
use Ros;
use ;
Subscribing to topic
If we wanted to subscribe to an std_msgs/UInt64
topic some_topic
, we just declare a callback. An alternative extra interface with iterators is being considered, but for now this is the only option.
extern crate rosrust;
use Ros;
use ;
Creating a service
Creating a service is the easiest out of all the options. Just define a callback for each request. Let's make our own AddTwoInts
service on the topic /add_two_ints
.
extern crate rosrust;
use Ros;
use ;
Creating a client
Clients can handle requests synchronously and asynchronously. The sync method behaves like a function, while the async approach is via a callback. The async consumes the passed parameter, since we're passing the parameter between threads, and it's more common for users to pass and drop a parameter, so this being the default prevents needless cloning. Let's call requests from the AddTwoInts
service on the topic /add_two_ints
.
extern crate rosrust;
use Ros;
use ;
Parameters
extern crate rosrust;
use Ros;
License
rosrust is distributed under the MIT license.