commaai / openpilot

openpilot is an operating system for robotics. Currently, it upgrades the driver assistance system on 275+ supported cars.
https://comma.ai/openpilot
MIT License
49.94k stars 9.11k forks source link

Move car.capnp to opendbc #33646

Closed sshane closed 1 month ago

sshane commented 1 month ago

@deanlee interested in this? We want to replace the dataclasses with car.capnp again, but it can live in opendbc. The duplication of the structs is starting to get annoying and is error-prone if one place is forgotten to be updated.

There are some issues we need to resolve:

deanlee commented 1 month ago

https://github.com/commaai/opendbc/pull/1288

The approach of this PR is to move car.capnp to opendbc/car while keeping all other capnp files unchanged. In opendbc, the following code is used to avoid the duplicate ID error:

try:
  from cereal import car
except ImportError:
  capnp.remove_import_hook()
  car = capnp.load(os.path.join(OPENDBC_CAR_PATH, "car.capnp"))

This ensures that car.capnp can be imported properly without conflicts