Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selfdrive/car: ban cereal and capnp #33208

Merged
merged 142 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
1d3e059
ban cereal and msgq
sshane Aug 6, 2024
c17e80f
common too
sshane Aug 6, 2024
c2ec763
Merge remote-tracking branch 'upstream/master' into no-capnp-cars-simple
sshane Aug 8, 2024
db592ed
do toyota/values.py
sshane Aug 8, 2024
d2c5602
do all fingerprints
sshane Aug 8, 2024
1b7dca8
example without builder
sshane Aug 9, 2024
3597057
this still works, but no type checking anymore
sshane Aug 9, 2024
2e2f8f5
stash
sshane Aug 9, 2024
7795697
wtf, how does this work
sshane Aug 9, 2024
9ef0fab
okay actually not bad
sshane Aug 9, 2024
37d40a3
safe
sshane Aug 9, 2024
965f692
epic!
sshane Aug 9, 2024
bc24202
stash data_structures.py
sshane Aug 9, 2024
95351b1
some clean up
sshane Aug 9, 2024
a06264a
hell yeah
sshane Aug 9, 2024
e21593e
clean up old file
sshane Aug 9, 2024
90239b7
add to delete
sshane Aug 9, 2024
78139f7
delete
sshane Aug 9, 2024
e54ad02
switch more CarParams stuff over
sshane Aug 9, 2024
05d9366
fix car tests by removing cereal! mypy forgets about dataclass if we …
sshane Aug 9, 2024
94ef0f8
fix this too
sshane Aug 9, 2024
593b0a5
fix this too
sshane Aug 9, 2024
72895af
remove more cereal and add some good hyundai tests
sshane Aug 9, 2024
a55b8d2
bunch more typing
sshane Aug 9, 2024
b889d73
override default with 20hz radar
sshane Aug 9, 2024
419c143
temp capnp converter helper
sshane Aug 9, 2024
d40da13
more lateralTuning
sshane Aug 9, 2024
6e6ab9f
small union replicator is better than what i was trying, and fixes my…
sshane Aug 9, 2024
ce290a0
can keep all this the same now!
sshane Aug 9, 2024
e8afc6a
type ret: CarParams, add more missing structs, revert lateralTuning c…
sshane Aug 9, 2024
e52fae0
revert more
sshane Aug 9, 2024
bb28b22
get first enum automatically, but ofc mypy doesn't pick up the new me…
sshane Aug 9, 2024
672fc00
Revert "get first enum automatically, but ofc mypy doesn't pick up th…
sshane Aug 9, 2024
37304e1
remove cereal from car_helpers (TODO: caching)
sshane Aug 9, 2024
9b72521
remove a bunch of temp lines
sshane Aug 9, 2024
418d1ce
use dataclass_transform!
sshane Aug 9, 2024
b926893
remove some car.CarParams from the interfaces
sshane Aug 10, 2024
bddb9f3
remove rest of car.CarParams from the interfaces
sshane Aug 10, 2024
25fa73a
same which() API
sshane Aug 10, 2024
6f16c66
sort
sshane Aug 10, 2024
2b164dd
from cereal/cache from fingerprinting!
sshane Aug 10, 2024
20b34cb
more typing
sshane Aug 10, 2024
594d0b7
dataclass to capnp helper for CarParams, cached it since it's kinda slow
sshane Aug 10, 2024
abbb97a
(partial) fix process replay fingerprintig for new API
sshane Aug 10, 2024
0c89b2b
latcontrollers take capnp
sshane Aug 10, 2024
d17f3d2
forgot this
sshane Aug 10, 2024
06a879d
fix test_models
sshane Aug 10, 2024
81c1c05
fix unit tests
sshane Aug 10, 2024
b8a8b43
not here
sshane Aug 10, 2024
d4700d1
VehicleModel and controller still takes capnp CP since they get it fr…
sshane Aug 10, 2024
bc4954f
fix modeld test
sshane Aug 10, 2024
6f9ed71
more fix
sshane Aug 10, 2024
4359fa5
need to namespace to structs, since CarState is both class and struct
sshane Aug 10, 2024
ede08d4
this was never in the base class?!
sshane Aug 10, 2024
f615d11
clean that up again
sshane Aug 10, 2024
a6c4a32
fix import error
sshane Aug 10, 2024
e5efda9
cmts and more structs
sshane Aug 10, 2024
07bc45c
remove some more cereal from toyota + convert CarState to capnp
sshane Aug 10, 2024
df954ed
bruh this was wrong
sshane Aug 10, 2024
3a4ce84
replace more cereal
sshane Aug 10, 2024
48c0b73
EventName is one of the last things...
sshane Aug 10, 2024
eb52d70
replace a bunch more cereal.car
sshane Aug 10, 2024
c8b7d1c
missing imports
sshane Aug 10, 2024
83cb089
more
sshane Aug 10, 2024
daf3ff7
Merge remote-tracking branch 'upstream/master' into no-capnp-cars-simple
sshane Aug 10, 2024
5297c85
Merge remote-tracking branch 'upstream/master' into no-capnp-cars-simple
sshane Aug 10, 2024
777f629
can fix this typing now
sshane Aug 10, 2024
12d89d0
proper toyota+others CS typing!
sshane Aug 10, 2024
2c7baf3
mypy can detect return type of CS.update() now
sshane Aug 10, 2024
61b2446
fix redeclaration of cruise_buttons type
sshane Aug 10, 2024
7628608
mypy is only complaining about events now
sshane Aug 10, 2024
b7367c3
temp fix
sshane Aug 11, 2024
7bc96d1
add carControl struct
sshane Aug 11, 2024
037d1db
replace CarControl
sshane Aug 11, 2024
397a555
fine now
sshane Aug 11, 2024
36610e5
lol this was wrong too
sshane Aug 11, 2024
b51dd22
Merge remote-tracking branch 'upstream/master' into no-capnp-cars-simple
sshane Aug 12, 2024
5ac1f7b
fix crash
sshane Aug 13, 2024
a851b82
include my failed attempts at recursively converting to dataclass (do…
sshane Aug 13, 2024
09bb822
clean up
sshane Aug 13, 2024
ff2434f
try out attr.s for its converter (doesn't work recursively yet, but i…
sshane Aug 13, 2024
e5bed3c
Revert "try out attr.s for its converter (doesn't work recursively ye…
sshane Aug 13, 2024
5873989
test processes doesn't fail anymore (on toyota)!
sshane Aug 13, 2024
cfb242b
fix honda crash
sshane Aug 13, 2024
c1762af
stash
sshane Aug 13, 2024
7558a02
Revert "stash"
sshane Aug 14, 2024
e0b9e45
Merge remote-tracking branch 'upstream/master' into no-capnp-cars-simple
sshane Aug 14, 2024
6249420
remove a bunch more cereal!
sshane Aug 14, 2024
dff4aaa
LET'S GOOO
sshane Aug 14, 2024
134f523
fix these tests
sshane Aug 14, 2024
989d898
and these
sshane Aug 14, 2024
391445e
and that
sshane Aug 14, 2024
39cf327
stash, something is wrong with hyundai enable
sshane Aug 14, 2024
19d77b6
Revert "stash, something is wrong with hyundai enable"
sshane Aug 15, 2024
cfb8453
Merge remote-tracking branch 'upstream/master' into no-capnp-cars-simple
sshane Aug 15, 2024
39982ae
forgot these
sshane Aug 15, 2024
232b37c
remove cereal from fw_versions
sshane Aug 15, 2024
23d041e
Revert "remove cereal from fw_versions"
sshane Aug 15, 2024
cf62b18
Merge remote-tracking branch 'upstream/master' into no-capnp-cars-simple
sshane Aug 15, 2024
2bd260d
remove rest of the cereal exceptions!
sshane Aug 15, 2024
e97d4fa
Merge remote-tracking branch 'upstream/master' into no-capnp-cars-simple
sshane Aug 15, 2024
26c02c7
fix that
sshane Aug 15, 2024
377facf
add typing to radard since I didn't realize RI.update() switched from…
sshane Aug 15, 2024
610ee98
and here too!
sshane Aug 15, 2024
d98179d
add TODO for slots
sshane Aug 15, 2024
71b5073
needed CS to be capnp, fix comparisons, and type hint car_specific so…
sshane Aug 15, 2024
b4c4da6
Merge remote-tracking branch 'upstream/master' into no-capnp-cars-simple
sshane Aug 15, 2024
c547a96
remove the struct converter
sshane Aug 15, 2024
1a61723
save ~4-5% CPU at 100hz, we don't modify after so no need to deepcopy
sshane Aug 15, 2024
6f307cf
deepcopy -> copy: we can technically make a reference, but copy is al…
sshane Aug 15, 2024
d398f38
add non-copying asdict function
sshane Aug 16, 2024
a292276
should save ~3% CPU (still 4% above baseline)
sshane Aug 16, 2024
6d56b1a
fix that, no dict support
sshane Aug 16, 2024
7ad5227
~27% decrease in time for 20k iterations on 3X (3.37857 -> 2.4821s)
sshane Aug 16, 2024
b134771
give a better name
sshane Aug 16, 2024
f2b8897
fix
sshane Aug 16, 2024
a0ce77f
dont support none, capitalize
sshane Aug 16, 2024
f316334
sheesh, this called type() on every field
sshane Aug 16, 2024
c113ea3
remove CS.events, clean up
sshane Aug 16, 2024
db3914b
bump card %
sshane Aug 16, 2024
29e6ecb
this was a bug on master!
sshane Aug 16, 2024
297f5ab
add a which enum
sshane Aug 16, 2024
8cdb765
default to pid
sshane Aug 16, 2024
fa4965a
revert
sshane Aug 16, 2024
1840d54
update refs
sshane Aug 16, 2024
bd9fe5e
not needed, but consistent
sshane Aug 16, 2024
e3dcaf3
just Ecu
sshane Aug 16, 2024
b1f7227
don't need to do this in this pr
sshane Aug 16, 2024
a99f78d
clean up
sshane Aug 16, 2024
07531cc
Merge remote-tracking branch 'upstream/master' into no-capnp-cars-simple
sshane Aug 16, 2024
f4d61c7
no cast
sshane Aug 16, 2024
6d7e428
consistent typing
sshane Aug 16, 2024
95c10fe
rm
sshane Aug 16, 2024
e94b7c1
fix
sshane Aug 16, 2024
a5e363d
Merge remote-tracking branch 'upstream/master' into no-capnp-cars-simple
sshane Aug 16, 2024
18e11ac
can do this if we're desperate for the last few %
sshane Aug 16, 2024
0c11c6c
Revert "can do this if we're desperate for the last few %"
sshane Aug 16, 2024
d134be7
type this
sshane Aug 16, 2024
2f3347e
don't need to convert carControl
sshane Aug 16, 2024
83b9a65
i guess don't support set either
sshane Aug 16, 2024
92b8083
fix CP type hint
sshane Aug 16, 2024
efe78e2
simplify that
sshane Aug 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .importlinter
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
[importlinter]
root_packages =
openpilot
cereal
capnp

[importlinter:contract:1]
name = Forbid imports from openpilot.selfdrive.car to openpilot.system
type = forbidden
source_modules =
openpilot.selfdrive.car
forbidden_modules =
cereal
capnp
openpilot.common
openpilot.selfdrive.controls
openpilot.selfdrive.debug
Expand Down Expand Up @@ -62,4 +66,13 @@ ignore_imports =
openpilot.selfdrive.car.tests.test_car_interfaces -> openpilot.selfdrive.pandad
openpilot.selfdrive.car.tests.test_models -> openpilot.selfdrive.pandad
openpilot.selfdrive.car.tests.test_car_interfaces -> openpilot.selfdrive.test.fuzzy_generation
openpilot.selfdrive.car.tests.test_models -> capnp
openpilot.selfdrive.car.tests.test_car_interfaces -> cereal
openpilot.selfdrive.car.tests.test_car_interfaces -> cereal.messaging
openpilot.selfdrive.car.tests.test_car_interfaces -> openpilot.selfdrive.test.fuzzy_generation
openpilot.selfdrive.car.tests.test_models -> cereal
openpilot.selfdrive.car.tests.test_models -> cereal.messaging
openpilot.selfdrive.car.card -> cereal
openpilot.selfdrive.car.card -> cereal.messaging
openpilot.selfdrive.car.vin -> cereal.messaging
unmatched_ignore_imports_alerting = warn
34 changes: 34 additions & 0 deletions selfdrive/car/data_structures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from enum import StrEnum, auto


class Ecu(StrEnum):
eps = auto()
abs = auto()
fwdRadar = auto()
fwdCamera = auto()
engine = auto()
unknown = auto()
transmission = auto() # Transmission Control Module
hybrid = auto() # hybrid control unit, e.g. Chrysler's HCP, Honda's IMA Control Unit, Toyota's hybrid control computer
srs = auto() # airbag
gateway = auto() # can gateway
hud = auto() # heads up display
combinationMeter = auto() # instrument cluster
electricBrakeBooster = auto()
shiftByWire = auto()
adas = auto()
cornerRadar = auto()
hvac = auto()
parkingAdas = auto() # parking assist system ECU, e.g. Toyota's IPAS, Hyundai's RSPA, etc.
epb = auto() # electronic parking brake
telematics = auto()
body = auto() # body control module

# Toyota only
dsu = auto()

# Honda only
vsa = auto() # Vehicle Stability Assist
programmedFuelInjection = auto()

debug = auto()
sshane marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 1 addition & 2 deletions selfdrive/car/toyota/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
from dataclasses import dataclass, field
from enum import Enum, IntFlag

from cereal import car
from openpilot.selfdrive.car import CarSpecs, PlatformConfig, Platforms, AngleRateLimit, dbc_dict
from openpilot.selfdrive.car.data_structures import Ecu
from openpilot.selfdrive.car.conversions import Conversions as CV
from openpilot.selfdrive.car.docs_definitions import CarFootnote, CarDocs, Column, CarParts, CarHarness
from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries

Ecu = car.CarParams.Ecu
MIN_ACC_SPEED = 19. * CV.MPH_TO_MS
PEDAL_TRANSITION = 10. * CV.MPH_TO_MS

Expand Down
Loading