pi-protocol 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,338 @@
1
+ # Copyright 2024 Till Blaha (Delft University of Technology)
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ """pi-protocol python client. Wire-compatible with pi-protocol.c.
22
+
23
+ Pairs with the generated ``pi_protocol.messages`` (``make`` writes it to
24
+ ``src/pi_protocol/messages.py``)::
25
+
26
+ from pi_protocol import PiSerial
27
+ from pi_protocol.messages import Imu, OffboardPose
28
+
29
+ with PiSerial("/dev/ttyUSB0", 921600) as pi:
30
+ pi.send(Imu(time_us=1, roll=0.1))
31
+ for msg in pi.recv(timeout=0.1): # blocks until >=1 msg or timeout
32
+ if type(msg) is OffboardPose:
33
+ print(msg.x, msg.y, msg.z)
34
+ last = pi.latest.get(OffboardPose) # like piMsgOffboardPoseRx in C
35
+
36
+ Without a serial port (sockets, pty, log files, ...)::
37
+
38
+ from pi_protocol import PiParser, encode
39
+ frame = encode(Imu(time_us=1)) # bytes, ready for the wire
40
+ msgs = PiParser().feed(frame) # list of decoded messages
41
+
42
+ Implementation notes (speed over elegance):
43
+ * Frames are found with ``bytes.split(STX)`` and unescaped with two
44
+ ``bytes.replace`` calls, so per-byte work runs in C. The only Python-level
45
+ per-byte loop is the CRC (table driven).
46
+ * A frame is decoded as soon as its last byte arrives (message lengths are
47
+ fixed per id), not when the next STX shows up. No added latency.
48
+ * Messages are NamedTuples, built straight from ``Struct.unpack_from``.
49
+ * ``PiSerial`` reads/writes the raw file descriptor on POSIX (``select`` +
50
+ ``os.read``/``os.write``), skipping pyserial's per-call overhead, and puts
51
+ the port into low-latency mode (FTDI: 16 ms -> 1 ms USB latency timer).
52
+ """
53
+
54
+ import os
55
+ from select import select
56
+ from time import monotonic
57
+
58
+ # --- Protocol definition (keep in sync with templates/pi-protocol.h.j2) ---
59
+ PI_STX = 0xFE
60
+ PI_ESC = 0x01
61
+ PI_STX_ESC = 0x02
62
+ PI_ESC_ESC = 0x03
63
+ PI_CRC8_POLYNOMIAL = 0xE7
64
+
65
+ _STX_B = b"\xfe"
66
+ _ESC_B = b"\x01"
67
+ _STX_SEQ = b"\x01\x02"
68
+ _ESC_SEQ = b"\x01\x03"
69
+
70
+
71
+ def _crc8_table(poly):
72
+ t = bytearray(256)
73
+ for i in range(256):
74
+ c = i
75
+ for _ in range(8):
76
+ c = ((c << 1) ^ poly) & 0xFF if c & 0x80 else (c << 1) & 0xFF
77
+ t[i] = c
78
+ return bytes(t)
79
+
80
+
81
+ CRC8_TABLE = _crc8_table(PI_CRC8_POLYNOMIAL)
82
+ _BYTE = [bytes((i,)) for i in range(256)]
83
+
84
+
85
+ def crc8(data, crc=0, _t=CRC8_TABLE):
86
+ """Same as crc8_calc_pi() applied to every byte of data."""
87
+ for b in data:
88
+ crc = _t[crc ^ b]
89
+ return crc
90
+
91
+
92
+ def encode(msg, _t=CRC8_TABLE, _B=_BYTE):
93
+ """Serialize one message into a complete, escaped frame (bytes)."""
94
+ body = msg._pack(msg.ID, *msg)
95
+ crc = 0
96
+ for b in body:
97
+ crc = _t[crc ^ b]
98
+ body += _B[crc]
99
+ # ESC first, otherwise the ESC of an escaped STX gets escaped again
100
+ return _STX_B + body.replace(_ESC_B, _ESC_SEQ).replace(_STX_B, _STX_SEQ)
101
+
102
+
103
+ def _unescape_prefix(seg):
104
+ """Unescape until the first invalid escape. Returns (bytes, bad) where bad
105
+ is False if the only problem is an ESC cut off at the very end."""
106
+ out = bytearray()
107
+ it = iter(seg)
108
+ for b in it:
109
+ if b == PI_ESC:
110
+ b = next(it, None)
111
+ if b == PI_STX_ESC:
112
+ b = PI_STX
113
+ elif b == PI_ESC_ESC:
114
+ b = PI_ESC
115
+ else:
116
+ return bytes(out), b is not None
117
+ out.append(b)
118
+ return bytes(out), False
119
+
120
+
121
+ def _default_messages():
122
+ from .messages import MESSAGES
123
+ return MESSAGES
124
+
125
+
126
+ class PiParser:
127
+ """Stream decoder. Feed it arbitrary chunks, get decoded messages back.
128
+
129
+ Counters (like piStats in C): n_success, n_invalid_checksum, n_esc_error,
130
+ n_no_such_msg, n_too_short.
131
+ """
132
+
133
+ def __init__(self, messages=None):
134
+ if messages is None:
135
+ messages = _default_messages()
136
+ # id -> (frame length incl. id and crc, unpack_from, class)
137
+ self._lut = lut = [None] * 256
138
+ for cls in messages:
139
+ if lut[cls.ID] is not None:
140
+ raise ValueError(f"duplicate message id {cls.ID}")
141
+ lut[cls.ID] = (cls.PAYLOAD_LEN + 2, cls._unpack, cls)
142
+ self._cb = [None] * 256
143
+ self._buf = b""
144
+ self.latest = {} # class -> most recently received message
145
+ self.n_success = 0
146
+ self.n_invalid_checksum = 0
147
+ self.n_esc_error = 0
148
+ self.n_no_such_msg = 0
149
+ self.n_too_short = 0
150
+
151
+ def on(self, cls, callback):
152
+ """Call callback(msg) from inside feed() whenever a cls arrives.
153
+ Pass None to unregister."""
154
+ self._cb[cls.ID] = callback
155
+
156
+ def reset(self):
157
+ self._buf = b""
158
+
159
+ def feed(self, data, _t=CRC8_TABLE, _tnew=tuple.__new__):
160
+ """Consume bytes, return a list of the messages completed by them."""
161
+ out = []
162
+ if self._buf:
163
+ data = self._buf + data
164
+ self._buf = b""
165
+ segs = data.split(_STX_B)
166
+ last = len(segs) - 1
167
+ if not last:
168
+ return out # no STX anywhere: nothing but noise
169
+ lut = self._lut
170
+ latest = self.latest
171
+ cbs = self._cb
172
+
173
+ # segs[0] precedes the first STX: noise (or b"" if data began with STX)
174
+ # segs[1:last] were terminated by an STX; segs[last] may be incomplete
175
+ i = 1
176
+ while i <= last:
177
+ seg = segs[i]
178
+ tail = i == last
179
+ i += 1
180
+
181
+ bad = False
182
+ if _ESC_B in seg:
183
+ raw = seg.replace(_STX_SEQ, _STX_B).replace(_ESC_SEQ, _ESC_B)
184
+ # every ESC must have been consumed by exactly one valid pair.
185
+ # If not (rare), unescape up to the problem the slow way: the
186
+ # frame may still be complete before it, as in the C parser.
187
+ if seg.count(_ESC_B) != len(seg) - len(raw):
188
+ raw, bad = _unescape_prefix(seg)
189
+ else:
190
+ raw = seg
191
+
192
+ if not raw:
193
+ if bad:
194
+ self.n_esc_error += 1
195
+ elif tail:
196
+ self._buf = _STX_B + seg
197
+ continue
198
+
199
+ entry = lut[raw[0]]
200
+ if entry is None:
201
+ self.n_no_such_msg += 1
202
+ continue
203
+ flen, unpack, cls = entry
204
+
205
+ if len(raw) < flen:
206
+ if bad:
207
+ self.n_esc_error += 1
208
+ elif tail:
209
+ self._buf = _STX_B + seg # wait for the rest
210
+ else:
211
+ self.n_too_short += 1
212
+ continue
213
+ # any bytes after the checksum are ignored, like the C parser
214
+
215
+ # crc over id + payload + crc is 0 iff the checksum matches
216
+ crc = 0
217
+ for b in raw[:flen]:
218
+ crc = _t[crc ^ b]
219
+ if crc:
220
+ self.n_invalid_checksum += 1
221
+ continue
222
+
223
+ msg = _tnew(cls, unpack(raw, 1))
224
+ latest[cls] = msg
225
+ out.append(msg)
226
+ self.n_success += 1
227
+ cb = cbs[raw[0]]
228
+ if cb is not None:
229
+ cb(msg)
230
+ return out
231
+
232
+ def stats(self):
233
+ return {
234
+ "success": self.n_success,
235
+ "invalid_checksum": self.n_invalid_checksum,
236
+ "esc_error": self.n_esc_error,
237
+ "no_such_msg": self.n_no_such_msg,
238
+ "too_short": self.n_too_short,
239
+ }
240
+
241
+
242
+ class PiSerial(PiParser):
243
+ """PiParser bound to a serial port. Extra kwargs go to serial.Serial."""
244
+
245
+ def __init__(self, port, baudrate=921600, messages=None, low_latency=True,
246
+ **serial_kwargs):
247
+ super().__init__(messages)
248
+ import serial # pyserial; only needed for this class
249
+
250
+ self.ser = ser = serial.Serial(port, baudrate, timeout=0, **serial_kwargs)
251
+ if low_latency and hasattr(ser, "set_low_latency_mode"):
252
+ try:
253
+ ser.set_low_latency_mode(True)
254
+ except (OSError, ValueError):
255
+ pass # driver does not support it; harmless
256
+ # fast path: raw non-blocking fd (pyserial opens it O_NONBLOCK)
257
+ self._fd = ser.fileno() if os.name == "posix" else None
258
+
259
+ # --- tx ---
260
+ def send(self, *msgs):
261
+ """Encode and write one or more messages with a single write()."""
262
+ frame = encode(msgs[0]) if len(msgs) == 1 else b"".join(map(encode, msgs))
263
+ self.write(frame)
264
+
265
+ def write(self, frame):
266
+ """Write pre-encoded bytes (e.g. from encode(), cached for reuse)."""
267
+ fd = self._fd
268
+ if fd is not None:
269
+ try:
270
+ n = os.write(fd, frame)
271
+ except BlockingIOError:
272
+ n = 0
273
+ if n == len(frame):
274
+ return
275
+ frame = frame[n:]
276
+ self.ser.write(frame) # handles kernel-buffer-full by blocking
277
+
278
+ # --- rx ---
279
+ def read_bytes(self, timeout=0):
280
+ """Return the bytes currently available, waiting up to timeout
281
+ seconds (None: forever) for the first one. b"" on timeout."""
282
+ fd = self._fd
283
+ if fd is None:
284
+ ser = self.ser
285
+ n = ser.in_waiting
286
+ if n or not timeout and timeout is not None:
287
+ return ser.read(n)
288
+ ser.timeout = timeout
289
+ data = ser.read(1)
290
+ ser.timeout = 0
291
+ return data + ser.read(ser.in_waiting) if data else data
292
+ if timeout != 0 and not select((fd,), (), (), timeout)[0]:
293
+ return b""
294
+ try:
295
+ data = os.read(fd, 65536)
296
+ except BlockingIOError:
297
+ return b""
298
+ if not data and timeout != 0:
299
+ # select said readable but nothing there: port is gone
300
+ import serial
301
+ raise serial.SerialException("device disconnected or multiple access on port?")
302
+ return data
303
+
304
+ def poll(self):
305
+ """Non-blocking: parse whatever has arrived, return the messages."""
306
+ return self.feed(self.read_bytes(0))
307
+
308
+ def recv(self, timeout=None):
309
+ """Block until at least one message arrived or timeout (seconds,
310
+ None: forever) passed. Returns a list (empty on timeout)."""
311
+ if timeout is None or timeout <= 0:
312
+ while True:
313
+ msgs = self.feed(self.read_bytes(timeout))
314
+ if msgs or timeout is not None:
315
+ return msgs
316
+ deadline = monotonic() + timeout
317
+ while True:
318
+ msgs = self.feed(self.read_bytes(timeout))
319
+ if msgs:
320
+ return msgs
321
+ timeout = deadline - monotonic()
322
+ if timeout <= 0:
323
+ return msgs
324
+
325
+ def __iter__(self):
326
+ """for msg in pi: ... -- yields messages forever."""
327
+ while True:
328
+ yield from self.recv()
329
+
330
+ # --- housekeeping ---
331
+ def close(self):
332
+ self.ser.close()
333
+
334
+ def __enter__(self):
335
+ return self
336
+
337
+ def __exit__(self, *exc):
338
+ self.close()
@@ -0,0 +1,284 @@
1
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
2
+ # this software and associated documentation files (the "Software"), to deal in
3
+ # the Software without restriction, including without limitation the rights to
4
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
5
+ # of the Software, and to permit persons to whom the Software is furnished to do
6
+ # so, subject to the following conditions:
7
+ #
8
+ # The above copyright notice and this permission notice (including the next
9
+ # paragraph) shall be included in all copies or substantial portions of the
10
+ # Software.
11
+ #
12
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
+ # SOFTWARE.
19
+
20
+ # THIS FILE HAS BEEN AUTOGENERATED BY generate.py, DO NOT MODIFY
21
+
22
+ """pi-protocol message definitions. Use together with the pi_protocol package.
23
+
24
+ Every message is a NamedTuple (immutable, fields default to 0). Byte order is
25
+ little-endian, matching the packed C structs on ARM/x86.
26
+ """
27
+
28
+ from struct import Struct
29
+ from typing import NamedTuple
30
+
31
+ PI_VERSION = (2, 0, 0)
32
+ PI_GLOBAL_MODE = "RXTX"
33
+
34
+
35
+ class Imu(NamedTuple):
36
+ """IMU: id 1, 28 payload bytes"""
37
+ time_us: int = 0 # uint32_t
38
+ roll: float = 0.0 # float
39
+ pitch: float = 0.0 # float
40
+ yaw: float = 0.0 # float
41
+ x: float = 0.0 # float
42
+ y: float = 0.0 # float
43
+ z: float = 0.0 # float
44
+
45
+ ID = 1
46
+ NAME = "IMU"
47
+ MODE = "RXTX"
48
+ PAYLOAD_LEN = 28
49
+ _pack = Struct("<BIffffff").pack
50
+ _unpack = Struct("<Iffffff").unpack_from
51
+
52
+
53
+ class FakeGps(NamedTuple):
54
+ """FAKE_GPS: id 2, 23 payload bytes"""
55
+ time_us: int = 0 # uint32_t
56
+ lat: int = 0 # int32_t
57
+ lon: int = 0 # int32_t
58
+ altCm: int = 0 # int32_t
59
+ hdop: int = 0 # uint16_t
60
+ groundSpeed: int = 0 # uint16_t
61
+ groundCourse: int = 0 # uint16_t
62
+ numSat: int = 0 # uint8_t
63
+
64
+ ID = 2
65
+ NAME = "FAKE_GPS"
66
+ MODE = "RXTX"
67
+ PAYLOAD_LEN = 23
68
+ _pack = Struct("<BIiiiHHHB").pack
69
+ _unpack = Struct("<IiiiHHHB").unpack_from
70
+
71
+
72
+ class ExternalPose(NamedTuple):
73
+ """EXTERNAL_POSE: id 3, 44 payload bytes"""
74
+ time_us: int = 0 # uint32_t
75
+ ned_x: float = 0.0 # float
76
+ ned_y: float = 0.0 # float
77
+ ned_z: float = 0.0 # float
78
+ ned_xd: float = 0.0 # float
79
+ ned_yd: float = 0.0 # float
80
+ ned_zd: float = 0.0 # float
81
+ body_qi: float = 0.0 # float
82
+ body_qx: float = 0.0 # float
83
+ body_qy: float = 0.0 # float
84
+ body_qz: float = 0.0 # float
85
+
86
+ ID = 3
87
+ NAME = "EXTERNAL_POSE"
88
+ MODE = "RXTX"
89
+ PAYLOAD_LEN = 44
90
+ _pack = Struct("<BIffffffffff").pack
91
+ _unpack = Struct("<Iffffffffff").unpack_from
92
+
93
+
94
+ class PosSetpoint(NamedTuple):
95
+ """POS_SETPOINT: id 4, 32 payload bytes"""
96
+ time_us: int = 0 # uint32_t
97
+ ned_x: float = 0.0 # float
98
+ ned_y: float = 0.0 # float
99
+ ned_z: float = 0.0 # float
100
+ ned_xd: float = 0.0 # float
101
+ ned_yd: float = 0.0 # float
102
+ ned_zd: float = 0.0 # float
103
+ yaw: float = 0.0 # float
104
+
105
+ ID = 4
106
+ NAME = "POS_SETPOINT"
107
+ MODE = "RXTX"
108
+ PAYLOAD_LEN = 32
109
+ _pack = Struct("<BIfffffff").pack
110
+ _unpack = Struct("<Ifffffff").unpack_from
111
+
112
+
113
+ class HilIn(NamedTuple):
114
+ """HIL_IN: id 5, 26 payload bytes"""
115
+ time_us: int = 0 # uint32_t
116
+ gyro_x: int = 0 # int16_t
117
+ gyro_y: int = 0 # int16_t
118
+ gyro_z: int = 0 # int16_t
119
+ acc_x: int = 0 # int16_t
120
+ acc_y: int = 0 # int16_t
121
+ acc_z: int = 0 # int16_t
122
+ baro: int = 0 # int16_t
123
+ rpm_1: int = 0 # int16_t
124
+ rpm_2: int = 0 # int16_t
125
+ rpm_3: int = 0 # int16_t
126
+ rpm_4: int = 0 # int16_t
127
+
128
+ ID = 5
129
+ NAME = "HIL_IN"
130
+ MODE = "RXTX"
131
+ PAYLOAD_LEN = 26
132
+ _pack = Struct("<BIhhhhhhhhhhh").pack
133
+ _unpack = Struct("<Ihhhhhhhhhhh").unpack_from
134
+
135
+
136
+ class HilOut(NamedTuple):
137
+ """HIL_OUT: id 6, 12 payload bytes"""
138
+ time_us: int = 0 # uint32_t
139
+ set_1: int = 0 # int16_t
140
+ set_2: int = 0 # int16_t
141
+ set_3: int = 0 # int16_t
142
+ set_4: int = 0 # int16_t
143
+
144
+ ID = 6
145
+ NAME = "HIL_OUT"
146
+ MODE = "RXTX"
147
+ PAYLOAD_LEN = 12
148
+ _pack = Struct("<BIhhhh").pack
149
+ _unpack = Struct("<Ihhhh").unpack_from
150
+
151
+
152
+ class VioPose(NamedTuple):
153
+ """VIO_POSE: id 7, 56 payload bytes"""
154
+ time_us: int = 0 # uint32_t
155
+ x: float = 0.0 # float
156
+ y: float = 0.0 # float
157
+ z: float = 0.0 # float
158
+ vx: float = 0.0 # float
159
+ vy: float = 0.0 # float
160
+ vz: float = 0.0 # float
161
+ p: float = 0.0 # float
162
+ q: float = 0.0 # float
163
+ r: float = 0.0 # float
164
+ qw: float = 0.0 # float
165
+ qx: float = 0.0 # float
166
+ qy: float = 0.0 # float
167
+ qz: float = 0.0 # float
168
+
169
+ ID = 7
170
+ NAME = "VIO_POSE"
171
+ MODE = "RXTX"
172
+ PAYLOAD_LEN = 56
173
+ _pack = Struct("<BIfffffffffffff").pack
174
+ _unpack = Struct("<Ifffffffffffff").unpack_from
175
+
176
+
177
+ class Keyboard(NamedTuple):
178
+ """KEYBOARD: id 8, 5 payload bytes"""
179
+ time_us: int = 0 # uint32_t
180
+ key: int = 0 # uint8_t
181
+
182
+ ID = 8
183
+ NAME = "KEYBOARD"
184
+ MODE = "RXTX"
185
+ PAYLOAD_LEN = 5
186
+ _pack = Struct("<BIB").pack
187
+ _unpack = Struct("<IB").unpack_from
188
+
189
+
190
+ class EkfInputs(NamedTuple):
191
+ """EKF_INPUTS: id 9, 24 payload bytes"""
192
+ time_us: int = 0 # uint32_t
193
+ x: int = 0 # int16_t
194
+ y: int = 0 # int16_t
195
+ z: int = 0 # int16_t
196
+ p: int = 0 # int16_t
197
+ q: int = 0 # int16_t
198
+ r: int = 0 # int16_t
199
+ omega1: int = 0 # uint16_t
200
+ omega2: int = 0 # uint16_t
201
+ omega3: int = 0 # uint16_t
202
+ omega4: int = 0 # uint16_t
203
+
204
+ ID = 9
205
+ NAME = "EKF_INPUTS"
206
+ MODE = "RXTX"
207
+ PAYLOAD_LEN = 24
208
+ _pack = Struct("<BIhhhhhhHHHH").pack
209
+ _unpack = Struct("<IhhhhhhHHHH").unpack_from
210
+
211
+
212
+ class OffboardPose(NamedTuple):
213
+ """OFFBOARD_POSE: id 10, 24 payload bytes"""
214
+ time_us: int = 0 # uint32_t
215
+ x: float = 0.0 # float
216
+ y: float = 0.0 # float
217
+ z: float = 0.0 # float
218
+ qw: int = 0 # int16_t
219
+ qx: int = 0 # int16_t
220
+ qy: int = 0 # int16_t
221
+ qz: int = 0 # int16_t
222
+
223
+ ID = 10
224
+ NAME = "OFFBOARD_POSE"
225
+ MODE = "RXTX"
226
+ PAYLOAD_LEN = 24
227
+ _pack = Struct("<BIfffhhhh").pack
228
+ _unpack = Struct("<Ifffhhhh").unpack_from
229
+
230
+
231
+ class OffboardPoseCov(NamedTuple):
232
+ """OFFBOARD_POSE_COV: id 11, 60 payload bytes"""
233
+ time_us: int = 0 # uint32_t
234
+ c00: int = 0 # int16_t
235
+ c01: int = 0 # int16_t
236
+ c11: int = 0 # int16_t
237
+ c02: int = 0 # int16_t
238
+ c12: int = 0 # int16_t
239
+ c22: int = 0 # int16_t
240
+ c03: int = 0 # int16_t
241
+ c13: int = 0 # int16_t
242
+ c23: int = 0 # int16_t
243
+ c33: int = 0 # int16_t
244
+ c04: int = 0 # int16_t
245
+ c14: int = 0 # int16_t
246
+ c24: int = 0 # int16_t
247
+ c34: int = 0 # int16_t
248
+ c44: int = 0 # int16_t
249
+ c05: int = 0 # int16_t
250
+ c15: int = 0 # int16_t
251
+ c25: int = 0 # int16_t
252
+ c35: int = 0 # int16_t
253
+ c45: int = 0 # int16_t
254
+ c55: int = 0 # int16_t
255
+ c06: int = 0 # int16_t
256
+ c16: int = 0 # int16_t
257
+ c26: int = 0 # int16_t
258
+ c36: int = 0 # int16_t
259
+ c46: int = 0 # int16_t
260
+ c56: int = 0 # int16_t
261
+ c66: int = 0 # int16_t
262
+
263
+ ID = 11
264
+ NAME = "OFFBOARD_POSE_COV"
265
+ MODE = "RXTX"
266
+ PAYLOAD_LEN = 60
267
+ _pack = Struct("<BIhhhhhhhhhhhhhhhhhhhhhhhhhhhh").pack
268
+ _unpack = Struct("<Ihhhhhhhhhhhhhhhhhhhhhhhhhhhh").unpack_from
269
+
270
+
271
+ MESSAGES = (
272
+ Imu,
273
+ FakeGps,
274
+ ExternalPose,
275
+ PosSetpoint,
276
+ HilIn,
277
+ HilOut,
278
+ VioPose,
279
+ Keyboard,
280
+ EkfInputs,
281
+ OffboardPose,
282
+ OffboardPoseCov,
283
+ )
284
+ MESSAGES_BY_ID = {m.ID: m for m in MESSAGES}