Skip to content

openpilot logs open, with the schema bundled and the GPS as a reference - #33

Merged
Sherin-SEF-AI merged 1 commit into
mainfrom
feat/rlog
Sep 23, 2026
Merged

Sherin-SEF-AI merged 1 commit into
mainfrom
feat/rlog

Conversation

@Sherin-SEF-AI

Copy link
Copy Markdown
Owner

Why it never worked

openpilot rlog import was a listed limitation: it raised unless openpilot's cereal schema happened to be on the machine. It also could not have worked when the schema was present:

  1. Logs are distributed as rlog.bz2 or rlog.zst, and were read as raw capnp.
  2. The schema was loaded without an import path, which its absolute imports need.
  3. Only names ending .rlog/.qlog were routed to the reader. openpilot names its files rlog, rlog.bz2, qlog.zst.
  4. A panda echoes the frames it transmits (src 128 + bus). Those were mixed into the car's traffic.

The fix

  • canlab/core/openpilot_parser.py rewritten: bz2 and zstd, read_multiple_bytes, panda transmissions kept apart and counted in df.attrs["sent_frames"] (include_sent=True keeps them), gps_reference() returning the log's GPS as ReferenceSeries on the capture's clock.
  • Schema vendored under canlab/core/data/cereal/ (comma.ai, MIT; NOTICE.txt beside it), refreshed by tools/fetch_cereal.py. Shipped as package data and in the binary.
  • log_parser.is_openpilot_log() routes rlog, qlog, *.rlog, *.qlog, rlog.bz2, qlog.zst; the Open openpilot Log dialog accepts them.
  • pycapnp is the new openpilot extra. CI installs it; the binary build job now installs mdf and openpilot too, and canlab.spec collects pycapnp. Checked locally: the built binary contains capnp/ and the schema, and the bundled schema copy decodes the real log.

Checked on a real drive

A public 2021 Toyota RAV4 route from openpilot's CI:

  • 122,282 received frames from 158 IDs on buses 0, 1 and 2, parsed in 1.0 s; 78,896 panda transmissions kept apart; the two sum to pycapnp's own count.
  • Calibrated against the log's own GPS, 0x0B4 bytes 5-6 come back as 0.01 km/h per bit, the figure in openpilot's DBC, R² 0.993, and the signal decodes within 0.87% of openpilot's vEgo.

Both are phases of acceptance_new_sources.py (the log is fetched once, 8 MB). tests/test_openpilot_rlog.py pins the reader on logs built by hand with the vendored schema.

pytest -q: 748 passed. ruff clean.

…eference

openpilot rlog import was listed as a limitation because it raised
unless openpilot's cereal schema happened to be on the machine. It also
could not have worked when the schema was there:

- Logs are distributed as rlog.bz2 or rlog.zst and were read as raw
  capnp. They are now decompressed (zstd needs the zstandard module, and
  says so).
- The schema was loaded without an import path, which its absolute
  imports need. It is now vendored under core/data/cereal (comma.ai,
  MIT; NOTICE beside it), with tools/fetch_cereal.py to refresh it.
- Only files ending .rlog or .qlog were routed to the reader; openpilot
  names them rlog, rlog.bz2, qlog.zst. All of those route now, from the
  loader and the Open openpilot Log dialog.
- A panda echoes the frames it transmits with src 128 + bus. Those were
  mixed into the car's traffic; they are kept apart and counted.

gps_reference returns the log's GPS as reference series on the capture's
clock, ready for the calibrator.

On a public 2021 Toyota RAV4 drive from openpilot's CI routes: 122,282
received frames from 158 IDs on three buses, 78,896 panda transmissions
kept apart, the two summing to pycapnp's own count. Calibrated against
the log's own GPS, 0x0B4 bytes 5-6 come back as 0.01 km/h per bit, the
figure in openpilot's DBC, and decode within 0.87% of openpilot's vEgo.
Both are now phases of acceptance_new_sources.py.

pycapnp is the new openpilot extra; CI installs it, the binary build
installs it with mdf, and the spec collects it.
@Sherin-SEF-AI
Sherin-SEF-AI merged commit f300a60 into main Sep 23, 2026
2 checks passed
@Sherin-SEF-AI
Sherin-SEF-AI deleted the feat/rlog branch September 23, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant