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
Copy file name to clipboardExpand all lines: src/pycyphal2/__init__.py
+121-1Lines changed: 121 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,127 @@ async def main():
42
42
43
43
### Name resolution
44
44
45
-
The topic naming system shares many similarities with ROS.
45
+
The topic naming system shares many similarities with [ROS Names](https://wiki.ros.org/Names).
46
+
47
+
Name resolution is the process by which a topic name passed to `node.advertise()` or `node.subscribe()` is resolved to a topic name as used on the Cyphal network.
48
+
49
+
There exist 4 kinds of topic names in Cyphal, used effectively they allow the developer to split up complex systems into smaller sub-systems, simplifying development and debugging.
50
+
51
+
#### 1. Relative Name
52
+
53
+
A relative name is a name that does not start with '/' or `~/`.
54
+
55
+
```
56
+
sensor/temperature
57
+
cmd_vel
58
+
camera/image_raw
59
+
```
60
+
61
+
It's resolved name is prefixed with the node namespace.
Use case: Use relative names for topics that are specific to a node, but might be reused across multiple nodes.
69
+
70
+
Example: A robot contains 4 motor controllers of the same type, each has its own namespace (`motor_1`, `motor_2`, `motor_3`, `motor_4`).
71
+
Using relative names, the application code is the same for all 4 motor controllers, however the topics are resolved differently based on the node namespace.
Use case: Use absolute names for topics that are shared across multiple nodes.
97
+
98
+
Example: Shared system topics like `/log`, since multiple nodes may publish to the same topic.
99
+
Conversely, topics like `/battery_voltage` that might be sourced from multiple nodes but need one single source of truth for other nodes like the motor controllers to subscribe to.
Note that the node namespace is ignored. Also note that `~foo` is not homeful and resolves as relative name to `ns/~foo` (this is confusing so don't use this).
Use case: For topics tied to specific nodes. The most common use case is configuring a node's parameters or settings.
123
+
124
+
Example: We want to configure an antenna to transmit at a specific frequency. The antenna node has a `~/config/frequency` topic that we can publish to.
125
+
126
+
#### 4. Pattern Name
127
+
128
+
A pattern name contains wildcard `*` (matches any _single_ name segment)
129
+
130
+
```
131
+
*/speed # matches any topic under `speed` (e.g. `motor_1/speed`, `motor_2/speed/`, `motor_3/value`, ...)
132
+
```
133
+
134
+
or `>` (matches _zero or more_ trailing segments)
135
+
136
+
```
137
+
sensor/> # matches any topic under `sensor` (e.g. `sensor/`, `sensor/temperature`, `sensor/pressure/`, ...)
138
+
```
139
+
140
+
Use case: Use `*` to subscribe to a _specific_ topic coming from a undetermined number of nodes.
141
+
Use `>` to subscribe to _multiple_ topics under a given namespace.
142
+
143
+
Example: `*/battery_pct` to subscribe to all nodes publishing battery data, of which there may be multiple per vehicle.
144
+
'logs/>' to subscribe to all topics publishing under '/logs' which may contain 'log_info', 'log_warning', 'log_error' topics.
145
+
146
+
#### Extra functions
147
+
148
+
*Topping* is the process by which a unique subject ID is assigned upon initialization.
149
+
For some applications that require a high level of reliability, determinism is required and can be achieved by using `#` to pin a topic to a specific subject ID.
150
+
151
+
```
152
+
motor/speed#1234
153
+
```
154
+
155
+
The resolved topic name is 'motor/speed' and the subject ID is fixed to 1234.
156
+
157
+
*Remapping* lets a node replace one name with another before final resolution.
158
+
This can be useful when trying to match the expected topic name from one node to another (when integrating multiple subsystems).
159
+
160
+
```
161
+
node.remap({"sensor/temperature": "temp"})
162
+
```
163
+
164
+
Now any topic name matching `sensor/temperature` will be remapped to `temp` before final resolution.
165
+
46
166
A valid name contains printable ASCII characters except space (ASCII codes [33, 126]).
47
167
Normalized names do not have leading or trailing segment separators `/` and do not have consecutive separators.
48
168
Every node should have a unique name, which is called its *home*; home substitution is done via `~/`.
0 commit comments