ROS 2 over email. rmw_email contains a middleware that sends & receives strings over email and an RMW implementation that allows ROS 2 to use this middleware to exchange messages.
For an overview of the motivation and process behind this project, see this blog post: christophebedard.com/ros-2-over-email.
- Overview
- Packages
- Supported features
- Performance
- How to use
- Configuration
- Tracing
- Logging
email
examples
rmw_email_cpp
uses type support introspection to convert messages to YAML objects.
This is done for both C and C++ type supports using the dynmsg
package.
The YAML objects are then converted to strings.
Those strings are sent via email using the email
package.
The topic name is used as the email subject; the email body contains the YAML string representing the message.
Messages can therefore easily be read.
To receive messages, this process is repeated in the opposite direction.
Successive messages on the same topic generally end up in the same email thread (depending on the client).
Service responses are email replies to the corresponding email request (this is handled by email
).
email
also has an intraprocess communication mode to bypass actually sending and receiving emails.
This repository contains a few packages:
email
: simple publish/subscribe & service middleware using emails to exchange strings- See the API documentation.
- See the design document (rendered version).
- This package claims to be in the Quality Level 4 category, see the Quality Declaration for more details.
email_examples
: various examples usingemail
- See
email
examples. - This package claims to be in the Quality Level 4 category, see the Quality Declaration for more details.
- See
rmw_email_cpp
: ROS 2rmw
implementation usingemail
as the middleware- See supported features.
- This package claims to be in the Quality Level 4 category, see the Quality Declaration for more details.
The following table shows the features currently supported/unsupported by rmw_email_cpp
.
ROS 2 feature | Status |
---|---|
publishers/subscriptions | ✔️ |
services, actions | ✔️ |
introspection using ros2 * commands |
❌ |
QoS, rmw events | ❌ |
rmw_email was primarily developed on Ubuntu. However, it should work on macOS and Windows without too much effort. See REP 2000.
We can use performance_test to compare the performance of rmw_email_cpp
to another RMW implementation.
See the perf_test.sh
and perf_plot.sh
scripts to run performance_test and generate a plot like the one above.
- Clone this repo into your ROS 2 workspace
$ cd ~/ws/src/ $ git clone https://github.com/christophebedard/rmw_email.git
- Clone dependencies
$ cd ~/ws/ $ vcs import src --input https://raw.githubusercontent.com/christophebedard/rmw_email/rolling/dependencies.repos
- Build
$ cd ~/ws/ $ colcon build # ...
- Create
email
configuration file(s) for your executable(s)
See configuration. - Use by setting the
RMW_IMPLEMENTATION
environment variable tormw_email_cpp
and theEMAIL_CONFIG_FILE
environment variable to your configuration file, e.g.$ cd ~/ws/ $ source install/setup.bash $ export RMW_IMPLEMENTATION=rmw_email_cpp $ export EMAIL_CONFIG_FILE=path/to/email.yml $ ros2 run demo_nodes_cpp talker $ # ...
In order to send & receive emails, a YAML configuration file must be provided.
By default, the path to the config file is email.yml
, relative to the current working directory.
However, the path can be changed using the EMAIL_CONFIG_FILE
environment variable, e.g., EMAIL_CONFIG_FILE=other/dir/myemail.yml
.
If that file does not exist, ~/email.yml
will be used as a backup if it exists.
A sample configuration file is provided: email.yml
.
As for the values:
url-smtp
: SMTP server URL- for Gmail:
smtp.gmail.com
- for Gmail:
url-imap
: IMAP server URL- for Gmail:
imap.gmail.com
- for Gmail:
username
: your email addresspassword
: your password- it is recommended to generate a "unique" password. For Gmail, that is an app password. Under Select app, click Other (Custom name) and simply enter something like rmw_email. Copy the generated password and paste it in the config file.
to
/cc
/bcc
: recipients- either as simple string values or as an array of string values, e.g.:
to: my@email.com cc: - some@email.com - another@email.com
to
must be defined and must contain at least one email address, butcc
andbcc
are optional
- either as simple string values or as an array of string values, e.g.:
polling-period
: email polling period in nanoseconds- optional; by default, polling will be done as fast as possible
intraprocess
: enable intraprocess mode by setting totrue
- optional; by default, intraprocess is disabled
- this makes
email
act as if it was sending emails to itself and entirely bypasses actually sending and receiving emails - all other options are optional and have no effect in practice if intraprocess is enabled
Using the same configuration file with the same email for the username
and to
fields (i.e., same email address for sending & receiving) for multiple executables should work.
Alternatively, you can use two different configuration files for two different executables, e.g., if they're sending emails to each other.
email
has LTTng tracepoints for publishers and subscriptions.
See email/include/email/lttng.hpp
.
Tracepoints are automatically included if LTTng is installed and detected.
To completely remove them, build with --cmake-args -DEMAIL_ENABLE_TRACING=OFF
.
rmw_email_cpp
supports the ros2_tracing
tracepoints for the rmw
layer.
It also has another LTTng tracepoint in order to link ROS 2 messages to email
messages.
See rmw_email_cpp/include/rmw_email_cpp/lttng.hpp
.
See ros2_tracing
's README for information on how to enable or disable tracepoints.
There are a few logging options for email
itself:
- Set the console logging level through the
EMAIL_LOG_LEVEL
environment variable, e.g.,EMAIL_LOG_LEVEL=debug
.- The logging levels are:
off
,debug
,info
,warn
,error
, andfatal
. - The default level is
info
.
- The logging levels are:
- Write all logs to a file by setting the
EMAIL_LOG_FILE
environment variable to a file path.- This writes all logs to the file, independently of the logging level set through
EMAIL_LOG_LEVEL
. - A leading
~
is expanded to the user's home directory.
- This writes all logs to the file, independently of the logging level set through
- Set the
EMAIL_CURL_VERBOSE
environment variable to be non-empty, e.g.,EMAIL_CURL_VERBOSE=y
. This will enable libcurl's verbose option.- Generally produces too much output to be useful.
As for rmw_email_cpp
, simply use the existing logging configuration options, including:
- CLI option
$ ros2 run $pkg $exec --ros-args --log-level debug $ ros2 run $pkg $exec --ros-args --log-level rmw_email_cpp:=debug
The email_examples
package contains simple examples using email
:
- email sender
- email receiver
- publisher
- subscription
- service client
- service server
- intraprocess (meant to be used with the intraprocess option enabled)
- publisher & subscription
- service client & service server