GithubHelp home page GithubHelp logo

isabella232 / cereal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from commaai/cereal

0.0 0.0 0.0 846 KB

capnp struct definitions and messaging used in comma ecosystem

License: MIT License

Shell 0.34% C++ 38.11% Python 16.64% C 0.41% Cap'n Proto 39.67% Cython 4.16% Dockerfile 0.68%

cereal's Introduction

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)

cereal's People

Contributors

adeebshihadeh avatar pd0wm avatar rbiasini avatar haraschax avatar zwx1616 avatar geohot avatar sshane avatar robbederks avatar deanlee avatar gijskoning avatar briskspirit avatar jyoung8607 avatar nuwandavek avatar gregjhogan avatar mitchellgoffpc avatar valish avatar grekiki2 avatar qiubit avatar mayfieldiv avatar lukaspetersson avatar jwooning avatar vladdoster avatar vanillagorillaa avatar sjdavalle avatar hewers avatar ntegan1 avatar jpancotti avatar iejmac avatar dimar01123 avatar wmoralesap avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.