Skip to content

Commit 4d50aeb

Browse files
committed
Add section on interface identification to IDL design doc
Signed-off-by: Jacob Perron <[email protected]>
1 parent e686281 commit 4d50aeb

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

articles/142_idl.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Both line comments (`//`) as well as block comments (`/* ... */`) are being supp
4040

4141
#### 7.2.3 Identifiers
4242

43-
An identifier must start with an is an ASCII alphabetic characteran followed by any number of ASCII alphabetic, digit and underscore (`_`) characters.
43+
An identifier must start with an ASCII alphabetic character followed by any number of ASCII alphabetic, digit and underscore (`_`) characters.
4444

4545
#### 7.2.6 Literals
4646

@@ -129,7 +129,7 @@ the DDS-XTypes specification 1.2 defines it with 16-bit.
129129
| ---------------------- | ---------------------------------------------------------- |
130130
| sequence\<type\_spec> | sequence of items of the specific type\_spec |
131131
| | the sequence is unbounded and no maximum size is specified |
132-
| sequence<type_spec, N> | sequence of of up to N items of the specified type\_spec |
132+
| sequence<type_spec, N> | sequence of up to N items of the specified type\_spec |
133133
| | the sequence is bounded and contain between 0 and N items |
134134

135135
#### 7.4.1.4.4.3.2 Strings
@@ -159,6 +159,60 @@ An enumerated type consist of an ordered list of enumerators.
159159
A multidimensional, fixed-size array is defined by the type of each item and the explicit sizes for each dimension.
160160
For now only a one-dimensional, fixed-size array is supported though.
161161

162+
### Interface Identification
163+
164+
#### Uniform Resource Name (URN)
165+
166+
Following 7.5.1 from the IDL 4.2 specification, every IDL definition can be uniquely identified with a qualified name of the form
167+
**<scoped\_name>::<identifier>**.
168+
In addition to the specification, the scope of an IDL definition is prefixed with the package name from which the defintions is derived.
169+
This is to guarantee uniqueness of definitions across packages (under the assumption that package names are unique).
170+
Therefore, each interface defintion can be resolved with a URN of the form: **<package\_name>/<scoped\_name>/<identifier>**.
171+
172+
#### Uniform Resource Locator (URL)
173+
174+
For source code to use an interface (e.g. include or import) there needs to be a way to reference the file containing the defintion.
175+
To reference the location of an IDL defintion we use a URL of the form: **rosidl:<package\_name>/<subfolder>/<file>**.
176+
Where *<subfolder>* is the relative path from the root of the package where generated defintions can be found.
177+
178+
#### Example
179+
180+
Imagine we have a package `foo_pkg` containing an IDL file `Bar.idl` with the following contents:
181+
182+
```idl
183+
struct MsgA {
184+
boolean bool_member;
185+
};
186+
187+
module bar {
188+
const int8 MY_CONSTANT = 42;
189+
190+
struct MsgB {
191+
int8 int_member;
192+
};
193+
194+
module baz {
195+
struct MsgC {
196+
string string_member;
197+
};
198+
};
199+
};
200+
```
201+
202+
Also imagine the message generation pipeline places the generated implementation to a subfolder `interface`.
203+
204+
Then, we can reference the interfaces with the following URNs:
205+
206+
- `foo_pkg/MsgA`
207+
- `foo_pkg/bar/MY_CONSTANT`
208+
- `foo_pkg/bar/MsgB`
209+
- `foo_pkg/bar/baz/MsgC`
210+
211+
And all can be located with the URL: `rosidl:foo_pkg/interface/Bar`.
212+
213+
For example, the definitions could be included in C++ with `#include <foo_pkg/interface/Bar.hpp>`
214+
or imported in Python with `import foo_pkg.interface.Bar`.
215+
162216
### Annotations
163217

164218
The syntax for arbitrary annotations is supported.

0 commit comments

Comments
 (0)