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

Proposed Car Abstraction Layer #27

Closed
geohot opened this issue Dec 11, 2016 · 6 comments
Closed

Proposed Car Abstraction Layer #27

geohot opened this issue Dec 11, 2016 · 6 comments

Comments

@geohot
Copy link
Contributor

geohot commented Dec 11, 2016

Anything obvious I'm forgetting?

using Cxx = import "c++.capnp";
$Cxx.namespace("cereal");

@0x8e2af1e708af8b8d;

# ******* main car state @ 100hz *******
# all speeds in m/s

struct CarState {
  errors @0: List(Error);

  # car speed
  vEgo @1 :Float32;       # best estimate of speed
  wheelSpeeds @2 :WheelSpeeds;

  # gas pedal, 0.0-1.0
  gas @3 :Float32;        # this is user + computer
  gasPressed @4 :Bool;    # this is user pedal only

  # brake pedal, 0.0-1.0
  brake @5 :Float32;      # this is user pedal only
  brakePressed @6 :Bool;  # this is user pedal only

  # steering wheel
  steeringAngle @7 :Float32;   # deg
  steeringTorque @8 :Float32;  # TODO: standardize units
  steeringPressed @9 :Bool;    # if the user is using the steering wheel

  # cruise state
  cruiseState @10 :CruiseState;

  # button presses
  buttonEvents @11 :List(ButtonEvent);

  # which packets this state came from
  canMonoTimes @12: List(UInt64);

  struct WheelSpeeds {
    # optional wheel speeds
    fl @0 :Float32;
    fr @1 :Float32;
    rl @2 :Float32;
    rr @3 :Float32;
  }

  struct CruiseState {
    enabled @0: Bool;
    speed @1: Float32;
  }

  enum Error {
    # TODO: copy from error list
    commIssue @0;
    steerUnavailable @1;
    brakeUnavailable @2;
    gasUnavailable @3;
    wrongGear @4;
    doorOpen @5;
    seatbeltNotLatched @6;
    espDisabled @7;
    wrongCarMode @8;
    steerTemporarilyUnavailable @9;
    reverseGear @10;
    # ...
  }

  # send on change
  struct ButtonEvent {
    pressed @0: Bool;
    type @1: Type;

    enum Type {
      unknown @0;
      leftBlinker @1;
      rightBlinker @2;
      accelCruise @3;
      decelCruise @4;
      cancel @5;
      altButton1 @6;
      altButton2 @7;
      altButton3 @8;
    }
  }
}

# ******* radar state @ 20hz *******

struct RadarState {
  errors @0: List(Error);
  points @1: List(RadarPoint);

  # which packets this state came from
  canMonoTimes @2: List(UInt64);

  enum Error {
    notValid @0;
  }

  # similar to LiveTracks
  # is one timestamp valid for all? I think so
  struct RadarPoint {
    trackId @0: UInt64;  # no trackId reuse

    # these 3 are the minimum required
    dRel @1: Float32; # m from the front bumper of the car
    yRel @2: Float32; # m
    vRel @3: Float32; # m/s

    # these are optional and valid if they are not NaN
    aRel @4: Float32; # m/s^2
    yvRel @5: Float32; # m/s
  }
}

# ******* car controls @ 100hz *******

struct CarControl {
  # must be true for any actuator commands to work
  enabled @0: Bool;

  # range from 0.0 - 1.0
  gas @1: Float32;
  brake @2: Float32;

  # range from -1.0 - 1.0
  steeringTorque @3 :Float32;

  cruiseControl @4: CruiseControl;
  hudControl @5: HUDControl;

  struct CruiseControl {
    cancel @0: Bool;
    override @1: Bool;
    speedOverride @2: Float32;
    accelOverride @3: Float32;
  }

  struct HUDControl {
    speedVisible @0: Bool;
    setSpeed @1: Float32;
    lanesVisible @2: Bool;
    leadVisible @3: Bool;
    visualAlert @4: VisualAlert;
    audibleAlert @5: AudibleAlert;

    enum VisualAlert {
      # these are the choices from the Honda
      # map as good as you can for your car
      none @0;
      fcw @1;
      steerRequired @2;
      brakePressed @3;
      wrongGear @4;
      seatbeltUnbuckled @5;
      speedTooHigh @6;
    }

    enum AudibleAlert {
      # these are the choices from the Honda
      # map as good as you can for your car
      none @0;
      beepSingle @1;
      beepTriple @2;
      beepRepeated @3;
      chimeSingle @4;
      chimeDouble @5;
      chimeRepeated @6;
      chimeContinuous @7;
    }
  }
}
@TheMutley
Copy link

  • Think about EV : braking is part regen and part hydraulic , no RPM, no gear ratio, etc..
  • Radar you can probably add angle of detection and direction of TrackID
  • Plausible to broadcast to radio with Bluetooth for any audible Sound ?
  • Might be interested in the stock LKA status and front cam information since some integration will leave it "running" ?

@geohot
Copy link
Contributor Author

geohot commented Dec 11, 2016

  • Good point about EVs, the controls software doesn't really need gearRatio and RPM, so I'll remove them and replace with bool gearReverse
  • angle = atan2(yRel, dRel)
  • The NEO itself can do sound, but it's not as reliable and doesn't lower the volume when it plays.
  • We remove the stock front cam, and that's how openpilot will be supported. Soon we will have support for cars that don't have stock cams.
  • Though along these lines we should probably add support for blind spot detection on cars that have it, that way we can do automatic lane change. Will add once we find such a car.

update: Updated, reverseGear is now an error and RPM and gearRatio are removed. Controls didn't use them, and humans drive totally fine without them. Our software should treat automatic transmissions as black boxes.

@TheMutley
Copy link

Thanks.

  • Could you bring us some clarifications on how the radar report it's trackIDs on the Honda/Acura? Does dRel represent the D and yRel represent the R like on this drawing :
    us07512516-20090331-d00000

  • Also , how the TrackIDs are sequenced? For example, on mine Track ID 1 is the obstacle in front of the vehicle, Track ID 2 is the obstacle in front of Track ID 1, Track ID 3 / 5 is an obstacle on the left lane , Track ID 4/6 is an obstacle on the right lane. Are they reported somewhat like this on the Honda ?

  • For the sound from the NEO, if you could do it like Waze does, at least on my car, it lower the music sound level and bring the Waze's notifications at the same level the music was. Pretty much like the alert sound does with the stock collision warning.

  • As for blind spot detection , I do have them on mine although I never looked for the CAN information. If they're supported , I will hunt the CAN data for sure!

  • One other thing you could add is the gap distance setting that some ACC has, usually 3-4 settings possible. Handy sometime to be able to change the gap.

@geohot
Copy link
Contributor Author

geohot commented Dec 29, 2016

dRel is the adjacent and yRel is the opposite on the right triangle to the car. The trackIds are sequential counting up.

That works if the NEO is playing the music only. Coming soon!

Yea, let me know re: BSI.

I don't like choices, more to qualify. I also feel the really short following distances supported on some cars are dangerous, since the user doesn't have time to react if the car messes up following closely.

@ingenieroariel
Copy link

I don't like choices, more to qualify. I also feel the really short following distances supported on some cars are dangerous, since the user doesn't have time to react if the car messes up following closely.

I agree with this thinking too. That said, with the stock Ford functionality at lower speeds cars behind me try to overtake me and then my car ends up leaving another big gap and it happens again. If it is not optional, hopefully openpilot maintains a safe distance in time units instead of meter units.

@geohot
Copy link
Contributor Author

geohot commented Jan 31, 2017

It's time units, yea.

@geohot geohot closed this as completed Jan 31, 2017
avolmensky pushed a commit to avolmensky/openpilot that referenced this issue Jun 10, 2019
* Improved seat belt status

Defined Passenger seat belt status as well as driver/passenger latched/unlatched

* Update honda_civic_touring_2016_can.dbc
avolmensky pushed a commit to avolmensky/openpilot that referenced this issue Jun 30, 2019
Declaration of function changed in 'sane can ids'.
xx979xx referenced this issue in xx979xx/openpilot Dec 7, 2019
pd0wm pushed a commit that referenced this issue Feb 5, 2020
ab32956 Merge pull request #27 from commaai/ublox-hw-status
2e7f4b9 Added ublox hw status
23abef4 add networkType to thermal
3f01dcf fix bad naming
4999e62 unconfusing and accessible to all
8f9aa8f add fingerprintSource to carParams
5794030 better put
06f8d15 standalone monitorstate (#23)
6eb1e36 qlog at model rate
c38fb57 LateralParams
0c45f20 add uncertainty event name

git-subtree-dir: cereal
git-subtree-split: ab32956
pd0wm pushed a commit that referenced this issue Feb 5, 2020
ab32956 Merge pull request #27 from commaai/ublox-hw-status
2e7f4b9 Added ublox hw status
23abef4 add networkType to thermal
3f01dcf fix bad naming
4999e62 unconfusing and accessible to all
8f9aa8f add fingerprintSource to carParams
5794030 better put
06f8d15 standalone monitorstate (#23)
6eb1e36 qlog at model rate
c38fb57 LateralParams
0c45f20 add uncertainty event name

git-subtree-dir: cereal
git-subtree-split: ab32956
pd0wm pushed a commit that referenced this issue Feb 5, 2020
ab32956 Merge pull request #27 from commaai/ublox-hw-status
2e7f4b9 Added ublox hw status
23abef4 add networkType to thermal
3f01dcf fix bad naming
4999e62 unconfusing and accessible to all
8f9aa8f add fingerprintSource to carParams
5794030 better put
06f8d15 standalone monitorstate (#23)
6eb1e36 qlog at model rate
c38fb57 LateralParams
0c45f20 add uncertainty event name

git-subtree-dir: cereal
git-subtree-split: ab32956
pd0wm pushed a commit that referenced this issue Feb 6, 2020
ab32956 Merge pull request #27 from commaai/ublox-hw-status
2e7f4b9 Added ublox hw status
23abef4 add networkType to thermal
3f01dcf fix bad naming
4999e62 unconfusing and accessible to all
8f9aa8f add fingerprintSource to carParams
5794030 better put
06f8d15 standalone monitorstate (#23)
6eb1e36 qlog at model rate
c38fb57 LateralParams
0c45f20 add uncertainty event name

git-subtree-dir: cereal
git-subtree-split: ab32956
pd0wm pushed a commit that referenced this issue Feb 6, 2020
ab32956 Merge pull request #27 from commaai/ublox-hw-status
2e7f4b9 Added ublox hw status
23abef4 add networkType to thermal
3f01dcf fix bad naming
4999e62 unconfusing and accessible to all
8f9aa8f add fingerprintSource to carParams
5794030 better put
06f8d15 standalone monitorstate (#23)
6eb1e36 qlog at model rate
c38fb57 LateralParams
0c45f20 add uncertainty event name

git-subtree-dir: cereal
git-subtree-split: ab32956
pd0wm pushed a commit that referenced this issue Feb 6, 2020
ab32956 Merge pull request #27 from commaai/ublox-hw-status
2e7f4b9 Added ublox hw status
23abef4 add networkType to thermal
3f01dcf fix bad naming
4999e62 unconfusing and accessible to all
8f9aa8f add fingerprintSource to carParams
5794030 better put
06f8d15 standalone monitorstate (#23)
6eb1e36 qlog at model rate
c38fb57 LateralParams
0c45f20 add uncertainty event name

git-subtree-dir: cereal
git-subtree-split: ab32956
JMPZ11 referenced this issue in JMPZ11/openpilot Sep 29, 2020
bd9a877 pulse desire and e2e
20c7fd6 Add subaru pre-Global safety mode
522ff85 Merge pull request commaai#31 from commaai/good_location_packet
ab07f22 deprecate
b03c2c5 already exists
166418c0 improvements
97373f9 or rigor in american
365abba rigour
25eaf9d add espDisabled to carState (#30)
bb13121 add honda ecus (#29)
eba4349 put liveLocation in qlogs
6c4735f add fixed fingerprintSource
4c50d26 GitHub actions (#25)
988783f Merge pull request #28 from commaai/power_monitoring
b43fd06 Added offroad power usage
ab32956 Merge pull request #27 from commaai/ublox-hw-status
2e7f4b9 Added ublox hw status
23abef4 add networkType to thermal
3f01dcf fix bad naming
4999e62 unconfusing and accessible to all
8f9aa8f add fingerprintSource to carParams
5794030 better put
06f8d15 standalone monitorstate (#23)
6eb1e36 qlog at model rate
c38fb57 LateralParams
0c45f20 add uncertainty event name
01942b8 add TODO
b74a456 don't hardcode the lists
ed5a4bf add face stds
396a2bb add can error counter to controlsState
c6b5c73 Switch default to msgq (#21)
a457ffa Fix indentation in readme.md
a1fc8c7 explicitly mention Python for syntax colouring (#20)
19e2393 Fix expected for cameraOdometry and liveCalibration
e7d2f97 Add radar comm issue error
db64cd4 Reserve safety #21 for VAG PQ35/PQ46/NMS (#19)
79d638d separate honda safety models between Bosch Giraffe and Bosch Nidec
2614a65 better name
b6b84cd add longitudinal
78f5934 Add canRxErrs to health
6758899 qlog liveCalibration
df80b87 add more stuff to fw log in CarParams
a87805a fix doxs
4746b20 got doxed
21cf3f5 build on mac
31ac47c Add carUnrecognized event
b8382bb steerLimitTimer should be car dependent
9a22968 add pa0 temp to ThermalData
f6f0f60 Add stock Fcw to carState
b608683 no l/r distinction for LDW
555f48d Add ldw alert
8e8b4a4 Remove plusFrame socket in favor of UiLayoutState
3410325 log stock AEB events
2219f2b Add warning about not using cython version of sec_since_boot
8f1a512 for legacy-testing reasons, better to define the used percent instead of avail
e86d954 adding low memory event
ad23834 remove TODO
d0962b3 log mem available and cpu perc in thermald
3b753be Implement error handling and exceptions (#18)
a7d5bb7 add explicit dependencies on services.h
1ba6467 fix linter
c7d215b Added communityFeatureDisallowed event
492140a Added communityFeature bit detection to CarParams
266a5fe log Panda fault types
347a866 Switch from polling on FIFOs to signal (#12)
e25bba7 no need to double build the objects
fe43a99 20Hz for radar time step is very standard
2aabf1e Added radar time step to car params
e8ae908 Generate capnp for java
57126a2 cereal_shared
da655cd Add uptime to health
f6a8e39 add test with multiple subscribers
84b3af5 comment out the debugging
4b9c942 added power save state to health packet
66be370 run python unittest in ci
52c6db8 Run scons in CI (#14)
9414615 do need it, but only for arm
2856c37 remove gnustl_shared
7f05ee6 fix apks
e3a6bde Revert "no more makefiles"
487fbd0 don't rely on BASEDIR, and add zmq library
223e37a no more makefiles
da2ed11 don't link the wrong one
fe9fe2a scons builds the python lib now
2f81135 err, it can't build services.h
57b03f8 now we shouldn't need that yaml crap everywhere
f8e5327 bridge builds with services.h
2b0cb60 noOutput safety mode is now called silent
83880d5 add msgq tests
bcad184 msgq: dont block when fifo does not exists
b4b26782 Default to zmq
473e291 fix compilation in docker
30aaadd msgq: try again when no timeout on poll but also no message
c4f2ad5 msgq: make sure read_fifos is initalized so we dont close random fds
4e513a85 msgq: dont clean up uninitialized sockerts
c008b63 also remove the fifo from disk
ef64eb2 MSGQ stability improvements when opening and closing lots of queues
e147abc Revert "Revert "deprecate irpwr""
932dc32 Revert "deprecate irpwr"
a684415 disengage
ec27e18 capnpc also generated the header files
ee52ab9 deprecate irpwr
301c74c8 Merge branch 'master' of github.com:commaai/cereal
6da7d55 add front frame
a5944eb add conflate parameter for SubSocket::create
ca8df17 Add fault status to health
ef4ded0 add conflate support in SubSocket constructor
7fd314a update scons build file
93d814e add saturated flags to indi and lqr logs
50302fe add steeringRateLimited to car.capnp
05e3513 add msgq readme
a6759a9 faster make
94b7377 Add struct to log FW version
64ce0b5 add scons build
dc9ad18 add debug print statement on SIGINT
4a61269 Merge pull request #10 from commaai/msgq
4873449 use recv one or none after poll
a054864 default to msgq
fbc4a4c oops bad number
5067cf4 add meta
cbd0286 fix export prefix and make shared library world readable
c273054 add c exports for jni usage
e77f41e zmq already sets the errno correctly
3196cf6 Fix service list path in bridge
d35515a add all msgq files, but dont use as default
a68a38f Don't delete context from python side only
bd46c22 Revert "zmq_ctx_term is blocking"
a1fc26b zmq_ctx_term is blocking
0902182 remote address support
21a3536 only delete subsocket when created by same object
34df735 remove extra underscore from __dealloc__
c8748f8 fix internal refs
79b2fbf fixups
23ad256 import messaging and services

git-subtree-dir: cereal
git-subtree-split: bd9a877
JMPZ11 referenced this issue in JMPZ11/openpilot Oct 11, 2020
bd9a877 pulse desire and e2e
20c7fd6 Add subaru pre-Global safety mode
522ff85 Merge pull request commaai#31 from commaai/good_location_packet
ab07f22 deprecate
b03c2c5 already exists
166418c improvements
97373f9 or rigor in american
365abba rigour
25eaf9d add espDisabled to carState (#30)
bb13121 add honda ecus (#29)
eba4349 put liveLocation in qlogs
6c4735f add fixed fingerprintSource
4c50d26 GitHub actions (#25)
988783f Merge pull request #28 from commaai/power_monitoring
b43fd06 Added offroad power usage
ab32956 Merge pull request #27 from commaai/ublox-hw-status
2e7f4b9 Added ublox hw status
23abef4 add networkType to thermal
3f01dcf fix bad naming
4999e62 unconfusing and accessible to all
8f9aa8f add fingerprintSource to carParams
5794030 better put
06f8d15 standalone monitorstate (#23)
6eb1e36 qlog at model rate
c38fb57 LateralParams
0c45f20 add uncertainty event name
01942b8 add TODO
b74a456 don't hardcode the lists
ed5a4bf add face stds
396a2bb add can error counter to controlsState
c6b5c73 Switch default to msgq (#21)
a457ffa Fix indentation in readme.md
a1fc8c7 explicitly mention Python for syntax colouring (#20)
19e2393 Fix expected for cameraOdometry and liveCalibration
e7d2f97 Add radar comm issue error
db64cd4 Reserve safety #21 for VAG PQ35/PQ46/NMS (#19)
79d638d separate honda safety models between Bosch Giraffe and Bosch Nidec
2614a65 better name
b6b84cd add longitudinal
78f5934 Add canRxErrs to health
6758899 qlog liveCalibration
df80b87 add more stuff to fw log in CarParams
a87805a fix doxs
4746b20 got doxed
21cf3f5 build on mac
31ac47c Add carUnrecognized event
b8382bb steerLimitTimer should be car dependent
9a22968 add pa0 temp to ThermalData
f6f0f60 Add stock Fcw to carState
b608683 no l/r distinction for LDW
555f48d Add ldw alert
8e8b4a4 Remove plusFrame socket in favor of UiLayoutState
3410325 log stock AEB events
2219f2b Add warning about not using cython version of sec_since_boot
8f1a512 for legacy-testing reasons, better to define the used percent instead of avail
e86d954 adding low memory event
ad23834 remove TODO
d0962b3 log mem available and cpu perc in thermald
3b753be Implement error handling and exceptions (#18)
a7d5bb7 add explicit dependencies on services.h
1ba6467 fix linter
c7d215b Added communityFeatureDisallowed event
492140a Added communityFeature bit detection to CarParams
266a5fe log Panda fault types
347a866 Switch from polling on FIFOs to signal (#12)
e25bba7 no need to double build the objects
fe43a99 20Hz for radar time step is very standard
2aabf1e Added radar time step to car params
e8ae908 Generate capnp for java
57126a2 cereal_shared
da655cd Add uptime to health
f6a8e39 add test with multiple subscribers
84b3af5 comment out the debugging
4b9c942 added power save state to health packet
66be370 run python unittest in ci
52c6db8 Run scons in CI (#14)
9414615 do need it, but only for arm
2856c37 remove gnustl_shared
7f05ee6 fix apks
e3a6bde Revert "no more makefiles"
487fbd0 don't rely on BASEDIR, and add zmq library
223e37a no more makefiles
da2ed11 don't link the wrong one
fe9fe2a scons builds the python lib now
2f81135 err, it can't build services.h
57b03f8 now we shouldn't need that yaml crap everywhere
f8e5327 bridge builds with services.h
2b0cb60 noOutput safety mode is now called silent
83880d5 add msgq tests
bcad184 msgq: dont block when fifo does not exists
b4b2678 Default to zmq
473e291 fix compilation in docker
30aaadd msgq: try again when no timeout on poll but also no message
c4f2ad5 msgq: make sure read_fifos is initalized so we dont close random fds
4e513a8 msgq: dont clean up uninitialized sockerts
c008b63 also remove the fifo from disk
ef64eb2 MSGQ stability improvements when opening and closing lots of queues
e147abc Revert "Revert "deprecate irpwr""
932dc32 Revert "deprecate irpwr"
a684415 disengage
ec27e18 capnpc also generated the header files
ee52ab9 deprecate irpwr
301c74c Merge branch 'master' of github.com:commaai/cereal
6da7d55 add front frame
a5944eb add conflate parameter for SubSocket::create
ca8df17 Add fault status to health
ef4ded0 add conflate support in SubSocket constructor
7fd314a update scons build file
93d814e add saturated flags to indi and lqr logs
50302fe add steeringRateLimited to car.capnp
05e3513 add msgq readme
a6759a9 faster make
94b7377 Add struct to log FW version
64ce0b5 add scons build
dc9ad18 add debug print statement on SIGINT
4a61269 Merge pull request #10 from commaai/msgq
4873449 use recv one or none after poll
a054864 default to msgq
fbc4a4c oops bad number
5067cf4 add meta
cbd0286 fix export prefix and make shared library world readable
c273054 add c exports for jni usage
e77f41e zmq already sets the errno correctly
3196cf6 Fix service list path in bridge
d35515a add all msgq files, but dont use as default
a68a38f Don't delete context from python side only
bd46c22 Revert "zmq_ctx_term is blocking"
a1fc26b zmq_ctx_term is blocking
0902182 remote address support
21a3536 only delete subsocket when created by same object
34df735 remove extra underscore from __dealloc__
c8748f8 fix internal refs
79b2fbf fixups
23ad256 import messaging and services

git-subtree-dir: cereal
git-subtree-split: bd9a877
weimou pushed a commit to SFtoLA/openpilot that referenced this issue May 6, 2021
nelsonjchen pushed a commit to nelsonjchen/openpilot that referenced this issue Sep 16, 2021
Fix commIssue due to frame drop and power draw (commaai#2689)
crwusiz pushed a commit to jmtechn-as/openpilot that referenced this issue Nov 12, 2023
carleeno pushed a commit to carleeno/openpilot that referenced this issue Aug 2, 2024
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

No branches or pull requests

3 participants