mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-27 00:42:05 +08:00
60baee4570b895cde84e185af800f1ce4da11f66
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
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. It uses Cap'n proto 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, the other called msgq, a custom pub sub based on shared memory that doesn't require the bytes to pass through the kernel.
Example
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)
Languages
Python
70%
C
16.2%
C++
5.7%
Cuda
4.2%
Metal
1.2%
Other
2.4%