rosrust, and actionlib
Overview
Introduction
My name is Salvatore and I am a Development Engineer at 株式会社Rist.
About this article
This article is meant to be a quick and direct introduction to the actionlib support in rosrust, based on the examples of the rosrust repository.
rosrust
What is rosrust
rosrust is a Rust implementation of a ROS client library.
Being rosrust a Rust crate, it assumes an existing underlying Rust environment in order to be used.
Why it is needed
rosrust allows to interface code written in Rust to the standard ROS environment.
Installation
Environment
Software | Version |
---|---|
OS | Ubuntu 18.04.4 LTS (Bionic Beaver) |
Python | Python 2.7.17 |
Python 3.6.9 (Default) | |
ROS | ROS 1 (Melodic) |
Rust | Rust 1.45.2 (d3fb005a3 2020-07-31) |
rosrust | rosrust v0.9.3 |
For information on setting up a ROS 1 Melodic
environment on a machine running Ubuntu, refer to the official documentation.
Rust
The installation of Rust is straight forward and all the needed packages will be located into the user home directory.
- Proceed with the installation:
$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
- Verify the installation:
$ rustc --version
For more details on the installation, or alternative platforms, refer to The Rust Programming Language book, or the official documentation.
rosrust
The rosrust crate is available at the official github repository.
- To proceed with the installation, clone the official repository:
$ git clone https://github.com/adnanademovic/rosrust.git
- Build the crate:
Note: in order to successfully build the rosrust crate, due to message dependencies, it is necessary to source the ROS installation path.
$ . /opt/ros/melodic/setup.bash
$ cargo build
At this point, the rosrust crate is available for use.
Verify the installation
To verify the correct installation of the rosrust crate, it is possible to run the examples provided by the crate itself.
- To show a list of all available examples, run the following command from the root of the rosrust crate folder structure:
$ cargo run --example
- Comprehensive list of available examples in the rosrust crate:
slb@salvatorepc: rosrust (master=) $ cargo run --example
error: "--example" takes one argument.
Available examples:
access_image_message
camera_subscriber
client
client_node
example
fibonacci_cancelling_client
fibonacci_client
fibonacci_multi_call_client
fibonacci_server
frequency_status
function_task
function_task_extra
old_client
old_service
parameters
publisher
publisher_latch_demo
publisher_node
pubsub_loopback
service
service_node
subscriber
subscriber_node
subscriber_with_ids
Next, it will be shown the simplest publisher/subscriber example in order to determine the correct behaviour of the ROS/rosrust environment.
Running the publisher/subscriber example
Considering the simplest example of the communication between a publisher and a subscriber on a common topic.
Shell 1: roscore
- Launch roscore:
$ . /opt/ros/melodic/setup.bash
$ roscore
Shell 2: publisher
- Launch the publisher:
$ . /opt/ros/melodic/setup.bash
$ cargo run --example publisher
Shell 3: subscriber
- Launch the subscriber:
$ . /opt/ros/melodic/setup.bash
$ cargo run --example subscriber
Shell 4: topics
- Show the nodes and the exchange of the messages on the specified topic:
$ . /opt/ros/melodic/setup.bash
$ rosnode list
$ rostopic list
$ rostopic info /chatter
$ rostopic echo /chatter
Terminals
Running the actionlib example
The actionlib example shows a fully functional integration with the ROS actionlib.
Shell 1: roscore
- Launch roscore:
$ . /opt/ros/melodic/setup.bash
$ roscore
Shell 2: fibonacci_server
- Launch the publisher:
$ . /opt/ros/melodic/setup.bash
$ cargo run --example fibonacci_server
Shell 3: fibonacci_client
- Launch the subscriber:
$ . /opt/ros/melodic/setup.bash
$ cargo run --example fibonacci_client
Terminals
As shown earlier, there are a lot more examples available in the rosrust crate. Feel free to try them all!