mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-24 01:33:46 +08:00
29f108de10
651199064 log focus state 8efe413a4 qlog radarState eeb3d5697 Add liveLocationKalman to qlogs 128b3f9a3 add networkStrength to thermal (#36) 2e5cbfc83 Create and init message in one line with `new_message` in messaging (#35) 458910759 not everyone likes gpstime 17363e988 support for end of log sentinel (#34) f6e9345cb val valid is confusing bb2cc7572 fix duplicate ordinals 0c38fc9e1 Add blindspot cereal values (#26) bd9a877d8 pulse desire and e2e 20c7fd608 Add subaru pre-Global safety mode 522ff85d9 Merge pull request #31 from commaai/good_location_packet ab07f229d deprecate b03c2c52a already exists 166418c00 improvements 97373f9d2 or rigor in american 365abba2e rigour 25eaf9df5 add espDisabled to carState (#30) bb1312128 add honda ecus (#29) git-subtree-dir: cereal git-subtree-split: 6511990644c5a133518b88d0cdaec089d216f607
42 lines
1.3 KiB
Markdown
42 lines
1.3 KiB
Markdown
What is cereal?
|
|
----
|
|
|
|
cereal is both a messaging spec for robotics systems as well as generic high performance IPC pub sub messaging with a single publisher and multiple subscribers.
|
|
|
|
Imagine this use case:
|
|
* A sensor process reads gyro measurements directly from an IMU and publishes a sensorEvents packet
|
|
* A calibration process subscribes to the sensorEvents packet to use the IMU
|
|
* A localization process subscribes to the sensorEvents packet to use the IMU also
|
|
|
|
|
|
Messaging Spec
|
|
----
|
|
|
|
You'll find the message types in [log.capnp](log.capnp). It uses [Cap'n proto](https://capnproto.org/capnp-tool.html) and defines one struct called Event.
|
|
|
|
All Events have a logMonoTime and a valid. Then a big union defines the packet type.
|
|
|
|
|
|
Pub Sub Backends
|
|
----
|
|
|
|
cereal supports two backends, one based on [zmq](https://zeromq.org/), the other called msgq, a custom pub sub based on shared memory that doesn't require the bytes to pass through the kernel.
|
|
|
|
Example
|
|
---
|
|
```python
|
|
import cereal.messaging as messaging
|
|
|
|
# in subscriber
|
|
sm = messaging.SubMaster(['sensorEvents'])
|
|
while 1:
|
|
sm.update()
|
|
print(sm['sensorEvents'])
|
|
|
|
# in publisher
|
|
pm = messaging.PubMaster(['sensorEvents'])
|
|
dat = messaging.new_message('sensorEvents', size=1)
|
|
dat.sensorEvents[0] = {"gyro": {"v": [0.1, -0.1, 0.1]}}
|
|
pm.send('sensorEvents', dat)
|
|
```
|