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
+37-22Lines changed: 37 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -5,15 +5,15 @@
5
5
6
6
Supports various transports such as Ethernet (UDP) and CAN FD with optional redundancy.
7
7
8
-
## Installation
8
+
# Installation
9
9
10
10
Optional features inside the brackets can be removed if not needed; see `pyproject.toml` for the full list:
11
11
12
12
```
13
13
pip install 'pycyphal2[udp,pythoncan]'
14
14
```
15
15
16
-
## Usage
16
+
# Usage
17
17
18
18
Set up a transport, make a node, publish and subscribe:
19
19
@@ -40,34 +40,34 @@ async def main():
40
40
Transport modules (`pycyphal2.udp`, `pycyphal2.can`) are imported separately
41
41
so that only the needed dependencies are pulled in.
42
42
43
-
### Name resolution
43
+
## Name resolution
44
44
45
45
The topic naming system shares many similarities with [ROS Names](https://wiki.ros.org/Names).
46
46
47
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
+
There exist 4 kinds of topic names in Cyphal:
48
49
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
+
<details markdown="1">
51
+
<summary>Relative Name</summary>
50
52
51
-
#### 1. Relative Name
52
-
53
-
A relative name is a name that does not start with '/' or `~/`.
53
+
A relative name is a name that does not start with `/` or `~/`.
54
54
55
55
```
56
56
sensor/temperature
57
57
cmd_vel
58
58
camera/image_raw
59
59
```
60
60
61
-
It's resolved name is prefixed with the node namespace.
61
+
Its 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.
68
+
*Use case:* Use relative names for topics that are specific to a node, but might be reused across multiple nodes.
69
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`).
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
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.
99
+
Use case: Use absolute names for topics that are *not* specific to a node and might be reused across multiple nodes.
97
100
98
101
Example: Shared system topics like `/log`, since multiple nodes may publish to the same topic.
99
102
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).
120
+
Its resolved name consists of the home and the input name, with the node namespace ignored. Note that `~foo` is not homeful and resolves as relative name to `ns/~foo` (this is confusing so don't use this).
121
+
122
+
Proposal: both `~` and `~foo` should not be allowed.
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
133
126
-
#### 4. Pattern Name
134
+
</details>
135
+
136
+
<details markdown="1">
137
+
<summary>Pattern Name (only for subscribing)</summary>
127
138
128
139
A pattern name contains wildcard `*` (matches any _single_ name segment)
129
140
@@ -143,7 +154,11 @@ async def main():
143
154
Example: `*/battery_pct` to subscribe to all nodes publishing battery data, of which there may be multiple per vehicle.
144
155
'logs/>' to subscribe to all topics publishing under '/logs' which may contain 'log_info', 'log_warning', 'log_error' topics.
145
156
146
-
#### Extra functions
157
+
</details>
158
+
159
+
Used effectively they allow to split up complex systems into smaller sub-systems simplifying development and debugging.
160
+
161
+
### Extra functions
147
162
148
163
*Topping* is the process by which a unique subject ID is assigned upon initialization.
149
164
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.
@@ -186,7 +201,7 @@ async def main():
186
201
187
202
See also :meth:`Node.remap`.
188
203
189
-
### Publish
204
+
## Publish
190
205
191
206
Publication is best-effort by default. Pass `reliable=True` when publishing to retry delivery until
192
207
acknowledged by every known subscriber or until the deadline; if the remote side does not acknowledge in time,
0 commit comments