You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This article specifies the ROS 2 Interface Definition Language, a simple and standardized manner to export the complete interface (action/message/parameter/service) of node(s) in a package.
6
+
This article specifies the ROS 2 Node Definition Language, a simple and standardized manner to export the complete interface (action/message/parameter/service) of node(s) in a package.
7
7
author: >
8
8
[Jérémie Deray](https://github.com/artivis),
9
9
[Kyle Fazzari](https://github.com/kyrofa)
10
+
[Ted Kern](https://github.com/arnatious)
10
11
published: true
11
12
categories: Interfaces
12
13
---
@@ -38,13 +39,13 @@ While it is usually readily available to a developer looking at the code, it can
38
39
It therefore calls for the creation of a standardized way to explicitly define and export this information.
39
40
40
41
This article defines a high-level abstraction allowing upstream packages to specify the communication requirements of the nodes in the package, such that the final user, be it a developer or a static analysis tool, can benefit from it.
41
-
The Interface Definition Language (IDL) specified in the next section is meant to be distributed alongside its associated package, be it in the source code or a generated release packaging format (e.g. debian).
42
-
Whether the interface is declared or not is up to the package author and should not prevent the correct execution of any system pre-existing the IDL.
42
+
The Node Definition Language (NoDL) specified in the next section is meant to be distributed alongside its associated package, be it in the source code or a generated release packaging format (e.g. debian).
43
+
Whether the interface is declared or not is up to the package author and should not prevent the correct execution of any system pre-existing the NoDL.
43
44
Similarly, the declared interface may be only partial and allow for the full use of pre-existing systems and the use of dependent systems on the parts covered by the partial interface.
44
45
45
46
## Motivation
46
47
47
-
While initially being approached from a ROS 2 Security perspective, the abstraction level of the IDL allows for the developments of other functionalities and tools.
48
+
While initially being approached from a ROS 2 Security perspective, the abstraction level of the NoDL allows for the developments of other functionalities and tools.
48
49
49
50
### Security motivation
50
51
@@ -85,7 +86,7 @@ Such assertions could include:
85
86
These assertions results would then be summarized in a logging file for later debugging.
86
87
87
88
Another example of the usefulness of having a static interface is the ability to create graphical tools for putting a ROS system together.
88
-
Yet another example would be an additional feature in `ros2 pkg create` that would allow a developer to hand it an IDL and have it generate scaffolding for a node with that interface.
89
+
Yet another example would be an additional feature in `ros2 pkg create` that would allow a developer to hand it a NoDL and have it generate scaffolding for a node with that interface.
89
90
90
91
These examples are only a subset of use-cases made possible by such an interface.
91
92
It's clear that this is useful well beyond security.
@@ -113,43 +114,63 @@ Another is the fact that, as soon as the node is running, RCL itself (or another
113
114
How do upstream packages specify their interface requirements?
114
115
Through a high-level description of all the actions, parameters, services and topics, provided or required, by each node within the package.
115
116
116
-
The package interface is defined in a separate [XML][xml_wiki] file and exported from the `package.xml` using [REP 149's export mechanism][rep149_export], thereby avoiding pollution of the package manifest.
117
+
The package interface is defined in a separate [XML][xml_wiki] file with suffix `.nodl.xml`.
118
+
This XML file is exported to the [ament index][ament_index], either manually in the case of python projects or with a helper CMake macro.
117
119
The interface may cover only a subset of nodes in a package, as long as the nodes that _are_ covered are done so completely.
118
120
119
-
Here is an example IDL for a package containing two nodes:
121
+
Here is an example NoDL for a package containing two nodes:
Once an IDL file is written, it is exported from the package manifest:
125
+
Once an NoDL file is written, it is exported from either `CMakeLists.txt` or `setup.py` (more details below).
126
+
Note that several NoDL files can be exported, allowing for writing one NoDL file per node if desired.
124
127
125
-
{% include_relative ros2_node_idl/package.xml %}
128
+
### Exporting a NoDL to the Ament Index
126
129
127
-
Note that several IDL files can be exported, allowing for writing an IDL file per node.
130
+
Per the design philosophy of the [ament index][ament_index], files will be installed in two locations.
131
+
In the case of a package named `Foo`, the NoDL file `foo.nodl.xml` should be placed in the package share directory, `share/foo/foo.nodl.xml`.
132
+
A corresponding marker file, `share/ament_index/nodl_desc/foo`, should be created.
133
+
It is either empty or contains the relative path to the `foo.nodl.xml` file.
128
134
129
-
###Schema for `package.xml`'s export tag
135
+
#### CMake Macro
130
136
131
-
#### `interface`
137
+
For packages using ament_cmake, the package `ament_nodl` provides the macro `nodl_export_node_description_file` which performs the export described in [Exporting a NoDL to the Ament Index](#exporting-a-nodl-to-the-ament-index).
132
138
133
-
This is how the package exports its defined IDL for other tools to consume.
139
+
For a package `Foo`, containing `foo.nodl.xml`, the following lines are added to `CMakeLists.txt`:
134
140
135
-
Attributes:
141
+
```cmake
142
+
find_package(ament_nodl REQUIRED)
143
+
nodl_export_node_description_file(foo.nodl.xml)
144
+
```
136
145
137
-
**path**: Path to XML file containing IDL
146
+
#### setup.py
138
147
139
-
Note that the introduction of the `interface` tag within the `export` tag of the package manifest raises a small difficulty with regards to the [REP 149][rep149_export].
140
-
The REP specifies:
148
+
In the case of setup.py, placement of the NoDL file and marker in the index must be done manually alongside the placement of the package's marker in the ament index.
149
+
One can re-use the same empty marker file placed in the package index.
150
+
An example `data_files` argument to `setuptools.setup()` in `setup.py` follows:
141
151
142
-
> To avoid potential collisions, an export tag should have the same name as the package which is meant to process it. The content of that tag is up to the package to define and use.
152
+
```python
153
+
data_files=[
154
+
('share/ament_index/resource_index/packages',
155
+
['resource/'+ package_name]),
156
+
('share/ament_index/resource_index/nodl_desc',
157
+
['resource/'+ package_name]),
158
+
('share/'+ package_name,
159
+
['package.xml', package_name +'.nodl.xml']),
160
+
],
161
+
```
143
162
144
-
Considering the high level abstraction of the IDL, the `interface` tag is not meant for a specific package but rather declares intrinsic properties for anyone to process it.
145
-
However, the keyword is likely solidly descriptive enough to either be accepted as falling under [REP 149][rep149_export] or else to motivate an amendment of the REP.
163
+
### NoDL Schema
146
164
147
-
### IDL Schema
165
+
An `.xsd` xml schema is provided alongside the NoDL implementation.
166
+
This can be used to programmatically validate the NoDL's `.xml` document.
167
+
There are some semantics that cannot be expressed in this schema, so the the `.xsd` is not authoritative.
168
+
Rather, it is a heuristic, and the [NoDL reference implementation][nodl-reference] can reject a document that does not conform to other requirements.
148
169
149
170
#### `interface`
150
171
151
-
Root tag of the IDL file, it is made up of a collection of node interfaces.
152
-
There must be only one tag per IDL file.
172
+
Root tag of the NoDL file, it is made up of a collection of node interfaces.
173
+
There must be only one tag per NoDL file.
153
174
154
175
Attributes:
155
176
-**version**: version of schema in use, allowing for future revisions.
@@ -161,6 +182,7 @@ It is specific to a node as determined by its associated attributes.
161
182
162
183
Attributes:
163
184
-**name**: The base name of the node.
185
+
-**executable**: The name of the generated executable that contains the node.
164
186
165
187
#### `action`
166
188
@@ -175,10 +197,6 @@ Valid values are "true" or "false". Defaults to "false".
175
197
-**client**: Whether or not the node provides a client for the action.
176
198
Valid values are "true" or "false". Defaults to "false".
177
199
178
-
Sub-tag:
179
-
-**qos**: The Quality of Service setting for the action - see the [qos tag](####qos).
180
-
Defaults to [rcl_action_qos_profile_status_default][rcl_action_qos_profile_status_default_link]
181
-
182
200
#### `parameter`
183
201
184
202
Define the interface for a given parameter.
@@ -201,10 +219,6 @@ Valid values are "true" or "false". Defaults to "false".
201
219
-**client**: Whether or not the node provides a client for the service.
202
220
Valid values are "true" or "false". Defaults to "false".
203
221
204
-
Sub-tag:
205
-
-**qos**: The Quality of Service setting for the service - see the [qos tag](####qos).
206
-
Defaults to [rmw_qos_profile_services_default][rmw_qos_profile_services_default_link]
207
-
208
222
#### `topic`
209
223
210
224
Define the interface for a given topic.
@@ -218,32 +232,10 @@ Valid values are "true" or "false". Defaults to "false".
218
232
-**subscription**: Whether or not the node subscribes to the topic.
219
233
Valid values are "true" or "false". Defaults to "false".
220
234
221
-
Sub-tag:
222
-
-**qos**: The Quality of Service setting for the topic - see the [qos tag](####qos).
223
-
Defaults to [rmw_qos_profile_default][rmw_qos_profile_default_link]
224
-
225
-
#### `qos`
226
-
227
-
Define the quality of service. It reflects the qos parameters of the [rmw_qos_profile_t][rmw_qos_profile_t] structure.
228
-
This tag is a sub-element of either an action, a service or a topic.
229
-
230
-
Attributes:
231
-
-**history**: The size of the message queue.
232
-
-**reliability**: The reliability QoS policy setting.
233
-
-**durability**: The durability QoS policy setting.
234
-
-**deadline**: The period at which messages are expected to be sent/received.
235
-
-**lifespan**: The age at which messages are considered expired and no longer valid.
236
-
-**liveliness**: Liveliness QoS policy setting.
237
-
-**liveliness_lease_duration**: The time within which the RMW node or publisher must show that it is alive.
238
-
-**avoid_ros_namespace_conventions**: If true, any ROS specific namespacing conventions will be circumvented.
0 commit comments