capnp struct definitions and messaging used in comma ecosystem
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Go to file
Kurt Nistelberger fa3e77b7c8
GPS: add tow count (#411)
16 hours ago
.github/workflows CI: update docker login 6 months ago
include remove java.capnp 1 year ago
logger fix suppression for older cppcheck 11 months ago
messaging add cpplint (#401) 1 month ago
site_scons/site_tools cython dependency scanner 2 years ago
visionipc add cpplint (#401) 1 month ago
.dockerignore Run scons in CI (#14) 3 years ago
.gitignore include from project root (#402) 1 month ago
.pre-commit-config.yaml add cpplint (#401) 1 month ago
Dockerfile include from project root (#402) 1 month ago
LICENSE Add the same license on this repo as openpilot (#78) 2 years ago
README.md fix CI badge 2 months ago
SConscript cleanup comma two stuff 10 months ago
SConstruct include from project root (#402) 1 month ago
__init__.py add pre-commit static analysis (#48) 3 years ago
car.capnp carState.radarOffCan -> radarUnavailable (#409) 6 days ago
codecov.yml Coverage analysis in CI (#75) 3 years ago
generate_javascript.sh initial commit, internal from 6/13/19 4 years ago
legacy.capnp bring qcomgnss back from deprecation 11 months ago
log.capnp GPS: add tow count (#411) 16 hours ago
maptile.capnp get rid of the java (#199) 1 year ago
services.py add a few can msgs in qlog (#403) 4 weeks ago

README.md

What is cereal? cereal tests codecov

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.

Message definition Best Practices

  • All fields must describe quantities in SI units, unless otherwise specified in the field name.

  • In the context of the message they are in, field names should be completely unambiguous.

  • All values should be easy to plot and be human-readable with minimal parsing.

Pub Sub Backends

cereal supports two backends, one based on zmq and another 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)