Skip to content

Commit be18cb1

Browse files
BorjaOutereloJulián Bermúdez Ortega
andauthored
Feature/middlewaredocs (#86)
* Add rosserial & micro-ROS comparisson. * Add IoT, MQTT and DDS-XRCE concept. * Set mqtt image size. * Apply suggestions from code review Co-Authored-By: Julián Bermúdez Ortega <julianbermudez@eprosima.com> * Add QoS behaviour table. * htmlproofer ignore only added files. Include button ref to ignore list. Co-authored-by: Julián Bermúdez Ortega <julianbermudez@eprosima.com>
1 parent b7d498b commit be18cb1

5 files changed

Lines changed: 251 additions & 6 deletions

File tree

‎_data/docs.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
docs:
2020
- concepts/middleware/Micro_XRCE-DDS
2121
- concepts/middleware/FIROS2
22+
- concepts/middleware/rosserial
23+
- concepts/middleware/IoT
2224

2325
- title: RTOS
2426
docs:
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
title: DDS-XRCE, MQTT & IoT
3+
permalink: /docs/concepts/middleware/IoT/
4+
---
5+
6+
Nowadays almost everybody knows what it is or has heard something about IoT.
7+
An informal definition could be "everything connected with everything".
8+
However, to be a bit more precise, IoT or Internet of Things is extending regular connectivity, traditionally reserved for specific devices, to almost any kind of equipment we can imagine, from small sensors in our fields and farms to life monitors in hospitals.
9+
It is estimated that in 2020, 50 billion of such as devices will be connected to each other ([@evans2011cisco](https://www.cisco.com/c/dam/en_us/about/ac79/docs/innov/IoT_IBSG_0411FINAL.pdf)).
10+
One thing that these 50 billion devices will share is the need to communicate, that is the field where the middleware plays an important role inside this vast technological challenge.
11+
The middleware is in charge of facilitating the network deployment allowing developers to focus on the application implementation.
12+
13+
This article will introduce two standards though and developed with IoT in mind, MQTT and DDS-XRCE.
14+
15+
## MQTT
16+
17+
Message Queuing Telemetry Transport (MQTT) is one of the most used protocols in IoT solutions.
18+
It has been designed as a lightweight message protocol to be used over TCP transports providing a standard and simple publish/subscribe interface for exchanging data.
19+
20+
The communication mechanism of MQTT is based on a client-server architecture.
21+
This means that clients (MQTT Clients) are connected to a server (MQTT Broker) which is in charge of orchestrating the exchange of data using a publish-subscribe messaging pattern.
22+
In other words, clients publish messages associated with a particular Topic in the Broker, and this last redirects these messages to the clients subscribed to the Topic.
23+
24+
So in MQTT, we can speak of some key concepts: Broker, Client, Topic, Message, Publish and Subscribe.
25+
Each of these concepts has its role and meaning:
26+
27+
* The Broker acts as the backbone of the system.
28+
Dealing with the messages of topics.
29+
* The Clients are the parts in charge of publishing and receiving subscription data from the Broker.
30+
* The Topic is a channel of information.
31+
* Message a piece of information on a defined Topic.
32+
* Publish is the action of sending a Message for a defined Topic to the Broker.
33+
* Subscribe is the action of reflecting an interest in receiving all the Messages of a defined Topic.
34+
It is handled in by the Broker.
35+
36+
![](./mqtt.png){:.img-responsive and style="max-width: 50%; margin-left: auto; margin-right: auto;"}
37+
38+
All this is done over a TCP protocol allowing the connection between Clients and Brokers over WANs and the Internet.
39+
Such a connection is made statically, i.e., the client must know the Broker address before a first connection is made.
40+
These communications could obey three different QoS specifying the delivery behaviour:
41+
42+
| QoS | Guaranteed delivery | Duplicity protection |
43+
|:-:|:-:|:-:|
44+
| QoS0 | No | No |
45+
| QoS1 | Yes | No |
46+
| QoS2 | Yes | Yes |
47+
48+
As mentioned before, there is the concept of Topic in this kind of middleware.
49+
The Topic's type is set by the application as well as its name.
50+
Publications are done using the Topic name and a set of data with a user-defined format.
51+
Analogously, subscriptions are done to Topic names, while the data interpretation is the responsibility of the Clients.
52+
MQTT standard does not mark how this topic-type tuple is related, so the responsibility of topic understanding resides on the user side.
53+
54+
This architecture and communication pattern natively allows the interchange of data between devices (M2M protocol), composing this way a good IoT middleware.
55+
56+
## DDS-XRCE
57+
58+
The DDS for eXtremely Resource-Constrained Environments (DDS-XRCE) is a wire protocol, adopted by the Object Management Group (OMG),
59+
whose aim is to provide access to the DDS (Data Distribution Service) data-space from low resource devices.
60+
As in the MQTT case, the DDS-XRCE follows a client-server architecture where clients (XRCE Clients) are connected to a server (XRCE Agent).
61+
In contrast to MQTT, the XRCE Agent is not in charge of managing the publication/subscription of Topics, but it acts on behalf of the XRCE Clients in the DDS global data-space.
62+
That is, the DDS-XRCE protocol allows the XRCE Clients to act as first-class citizens in a traditional DDS network.
63+
64+
![](../Micro_XRCE-DDS/uxrce_scope.png)
65+
66+
This protocol specified how the XRCE Clients interact with the XRCE Agent.
67+
Basically, there are two ways of interactions between them:
68+
69+
* XRCE Clients can handle proxy entities on the Agent.
70+
Such proxy entities are the ones acting on the DDS network.
71+
This allows the Clients to operate as a stateless system, as the state resides in the Agent.
72+
This, among other things, will enable sleep cycles, and resource-constrained devices to communicate with DDS.
73+
* XRCE Clients can publish/subscribe to/from any DDS Topic as if they were regular DDS participants.
74+
This makes the separation between resource-constrained devices and DDS networks diffuse, so they can participate as real entities in DDS world.
75+
76+
In a nutshell, DDS-XRCE provides the XRCE Client with a simple publish/subscribe messaging pattern with which to communicate with existing DDS networks.
77+
78+
In the same way as traditional DDS networks, there are some inherited concepts:
79+
80+
* Topic.
81+
Channels of information
82+
* Message.
83+
Information pieces.
84+
* Publish.
85+
The operation which exposes Messages.
86+
* Subscribe.
87+
The procedure which allows receiving chosen Messages.
88+
89+
Also, added ones:
90+
91+
* XRCE Client.
92+
These are lightweight actors on resource-constrained devices with a simple publish/subscribe interface.
93+
* XRCE Agent.
94+
Central part of the protocol providing the required DDS access to the XRCE Clients mentioned above.
95+
96+
The DDS-XRCE wire protocol is specified to be in at least TCP and UDP transport protocol, but there is room to expand to other protocols.
97+
Currently, implementations are supporting Serial links and possible to be extended to any other such Zigbee, 6LoWPAN, and more.
98+
DDS-XRCE allows setting two different delivery QoS:
99+
100+
* Reliable.
101+
* Best-effort.
102+
103+
As part of the DDS family standard, the use of OMG's IDL standard has also been included.
104+
This provides the user with a way to define the types of topics used as well as setting a standard serialisation format.
105+
Doing that ensures interoperability and leverage the application layer of the matter of defining custom serialisation formats and type matching mechanisms.
106+
107+
This protocol brings a new spectrum of possibilities to IoT devices as it brings all the benefits of DDS (Distributed system, configurable QoS, interoperability).
108+
109+
## MQTT vs DDS-XRCE
110+
111+
At this point, you probably are wondering which are the differences between MQTT and DDS-XRCE.
112+
At first glance, they seem to share a lot of the foundations such as similar architecture and communication patterns but differ on some crucial matters, exposed in the following table.
113+
114+
| | DDS-XRCE | MQTT |
115+
|:--------------------------|:------------------------:|:----------------------:|
116+
| **architecture pattern** | client-server | client-server |
117+
| **messaging pattern** | publish-subscribe | publish-subscribe |
118+
| **transport protocol** | UDP/TCP/Serial/Custom | TCP |
119+
| **security** | DTLS/TLS (non normative) | TLS (non normative) |
120+
| **types** | Standard IDL | Opaque, user choice |
121+
| **QoS** | Reliable & best-effort | 3 Message delivery |
122+
| **session oriented** | yes | yes |
123+
| **minimum overhead** | 12 B\*\*\* | 5 B\* \*\* |
124+
| **maximum overhead** | 16 B\*\*\* | 2^16 B\* |
125+
| **max payload size** | 64 KB | 256 MB |
126+
| **topologies** | 1 to 0, 1 to 1, 1 to n | 1 to 0, 1 to 1, 1 to n |
127+
| **discovery support** | yes | no |
128+
129+
_ \* Scales with the topic name._
130+
131+
_ \*\* For a topic name composed by 8 ASCII characters (8 Bytes) the MQTT overhead will equate to DDS-XRCE overhead.
132+
From that point, the MQTT overhead will scale with the name size.
133+
However, DDS-XRCE will be static_
134+
135+
_ \*\*\* Maximum and minimum DDS-XRCE overhead depends on whether the message using client ID._
136+
137+
The previous tables compare both protocols.
138+
Aside from this protocol differences, we may point out one of the critical concepts of DDS-XRCE, bringing small devices to distributed networks.
139+
This provides this protocol with a great range of use cases as well as prepared to be scaled in a significant amount being far more dynamic in this sense to MQTT alternative.
22.9 KB
Loading
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
title: micro-ROS compared to rosserial
3+
permalink: /docs/concepts/middleware/rosserial/
4+
---
5+
6+
In ROS, there is a package that stands out when we want to send ROS messages through serial communications.
7+
This package is rosserial.
8+
9+
rosserial allows platforms based on microcontrollers to communicate with a regular computer communicating with ROS network on its behalf.
10+
rosserial provides the protocol to set such communication, using a client-server architecture approach.
11+
rosserial-clients serialise data into the serial link, then, the serialised data is received by the rosserial-server and forwarded to the conventional ROS network.
12+
An analogous process is done to forward data from the ROS network towards the microcontroller.
13+
This rosserial-server can be used either in C++ or Python; meanwhile, the rosserial-client has a set of available supported microprocessors.
14+
15+
This solution is commonly used to integrate hardware pieces within Robots using ROS.
16+
Rosserial, in those cases, acts as a bridge between hardware communication protocols and a ROS network.
17+
18+
## micro-ROS
19+
20+
In the case of the new version of ROS, ROS 2, there was not a solution for such microcontroller-robot integrations.
21+
But there is a project called micro-ROS bringing ROS2 to microcontrollers.
22+
One of the capabilities of micro-ROS is the use of serial connexion between a microcontroller and a ROS2 capable computer.
23+
Such a connection is possible thanks to the use of OMG's DDS-XRCE standard and a serial transport layer.
24+
Micro-ROS solution follows the same client-server architecture as rosserial, as it is one of the most suitable architectural approaches when we speak of microcontroller communications.
25+
26+
This approach uses the concept of client-agent communication.
27+
In this specific case, clients generate entities within the agent which will act on behalf of the clients on a DDS network (as ROS 2 has drifted into using DDS networks instead of the original ROS network).
28+
29+
This usage, as you can see, resembles the one used by rosserial, but they have subtle differences in their implementations which we will expose in this article.
30+
31+
## micro-ROS vs rosserial
32+
33+
Now that we have a quick view of rosserial and micro-ROS we will go on a comparison between them.
34+
35+
### micro-ROS (over Serial Transport)
36+
37+
micro-ROS, when communicating over serial transports (it allows communications over other transports such as UDP, TCP ...), uses a serial protocol with a predefined format.
38+
This format is explained in the following frame dissection:
39+
40+
```
41+
0 8 16 24 40 X X+16
42+
+--------+--------+--------+--------+--------+--------//--------+--------+--------+
43+
| FLAG | SADD | RADD | LEN | PAYLOAD | CRC |
44+
+--------+--------+--------+--------+--------+--------//--------|--------+--------+
45+
```
46+
47+
* `FLAG`: synchronization flag (0xFF).
48+
* `SADD`: source address.
49+
* `RADD`: remote address.
50+
* `LEN`: payload length without framing (2 bytes in little-endian).
51+
* `PAYLOAD`: serialised message with XRCE headers.
52+
* `CRC`: message CRC after stuffing.
53+
54+
This is the message that is serialised on the link layer.
55+
This is the message going from an towards the microcontroller thanks to two different operations: publish and subscribe.
56+
57+
## rosserial
58+
59+
In contrast, this is the rosserial frame:
60+
61+
```
62+
0 8 16 32 40 56 X X+16
63+
+-------+-------+-------+-------+-------+-------+-------+-------//-------+------+------+
64+
| FLAG | PROT | LEN | LCRC | TOPID | PAYLOAD | MCRC |
65+
+-------+-------+-------+-------+-------+-------+-------+-------//-------|------+------+
66+
```
67+
68+
* `FLAG`: synchronization flag (0xFF).
69+
* `PROT`: protocol version.
70+
* `LEN`: payload length (2 bytes in little-endian).
71+
* `LCRC`: length CRC.
72+
* `TOPID`: topic ID.
73+
* `PAYLOAD`: serialised message.
74+
* `MCRC`: message CRC.
75+
76+
As you can see comparing with the micro-ROS serial frame, it uses a completely different frame.
77+
78+
## Comparison
79+
80+
The following table, summarises the key aspects of both implmentations:
81+
82+
| | micro-ROS-serial | rosserial |
83+
|:-|:-:|:-:|
84+
| **ROS** | ROS 2 | ROS |
85+
| **API** | C/C++ | C++ |
86+
| **integrity** | [HDLC](https://en.wikipedia.org/wiki/High-Level_Data_Link_Control) framing | none |
87+
| **security** | [CRC-16-CCITT](https://en.wikipedia.org/wiki/Cyclic_redundancy_check) | vague CRC (% 256) |
88+
| **memcopy** | uxr_stream ---> serial_buffer ---> hardware_buffer | serialization_buffer ---> hardware_buffer |
89+
| **memory usage** | uxr_stream + (2 * aux-buffer[42 B]) | 2 * serialization_buffer |
90+
| **message size limit** | uxr_stream size | hardware_buffer size |
91+
| **reliability** | yes | no |
92+
| **routing** | yes | no |
93+
| **overhead** | 7 B + 12 B* | 9 B |
94+
| **architecture** | client-server | client-server |
95+
96+
_* Overhead is divided between framing, 7 B and that added by DDS-XRCE protocol 12 B._
97+
98+
As exposed in this table, micro-ROS serial increases the number of memory operations but reduces in a great way the memory required for serial communications as it does not require a that the hardware buffer has the same size as the serialisation buffer.
99+
This use of buffers reduces memory usage.
100+
Also, the micro-ROS provide routing and reliability capabilities in contrast with rosserial.
101+
micro-ROS protocol embraces standards for some of its parts, like the usage of standard CRC or a standard framing.

‎scripts/cibuild‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
#!/usr/bin/env bash
22
set -e # halt script on error
33

4-
CHANGED_FILES=$(git diff --name-only origin/master)
5-
if grep -q "_docs" <<< $CHANGED_FILES; then
6-
TOUCHED=${TOUCHED:+$TOUCHED }micro-ros.github.io//docs
7-
else if grep -q "_posts" <<< $CHANGED_FILES; then
8-
TOUCHED=${TOUCHED:+$TOUCHED,}micro-ros.github.io//blog
4+
# Get the list of added files compared to the origin/master (origin/master is the deployed branch)
5+
# New files will not be deployed at the moment of this check so htmlproofer should ignore those links refering them.
6+
ADDED_FILES=$(git diff --name-only --diff-filter=A origin/master)
7+
if grep -q "_docs" <<< $ADDED_FILES; then
8+
ADDITIONS=${ADDITIONS:+$ADDITIONS }micro-ros.github.io//docs
9+
ADDITIONS=${ADDITIONS:+$ADDITIONS }micro-ros.github.io/blob/master/_docs
10+
else if grep -q "_posts" <<< $ADDED_FILES; then
11+
ADDITIONS=${ADDITIONS:+$ADDITIONS,}micro-ros.github.io//blog
912
fi
1013
fi
1114

1215
IGNORE_HREFS=${IGNORE_HREFS:+$IGNORE_HREFS,}$(ruby -e "puts %w{
1316
vimeo.com
14-
${TOUCHED}
17+
${ADDITIONS}
1518
}.map{|h| \"/#{h}/\"}.join(\",\")"
1619
)
1720

0 commit comments

Comments
 (0)