diff --git a/.gitignore b/.gitignore index 9bdfbc716..44294dde7 100644 --- a/.gitignore +++ b/.gitignore @@ -39,5 +39,6 @@ selfdrive/sensord/sensord one openpilot +notebooks xx diff --git a/README.md b/README.md index ba97ded04..23c81e430 100644 --- a/README.md +++ b/README.md @@ -58,69 +58,70 @@ Install openpilot on a neo device by entering ``https://openpilot.comma.ai`` dur Supported Cars ------ -| Make | Model | Supported Package | Lateral | Longitudinal | No Accel Below | No Steer Below | Giraffe | -| ---------------------| -------------------------| ---------------------| --------| ---------------| -----------------| ---------------|-------------------| -| Acura | ILX 2016-18 | AcuraWatch Plus | Yes | Yes | 25mph1| 25mph | Nidec | -| Acura | RDX 2016-18 | AcuraWatch Plus | Yes | Yes | 25mph1| 12mph | Nidec | -| Buick3 | Regal 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| -| Chevrolet3| Malibu 2017 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| -| Chevrolet3| Volt 2017-18 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| -| Cadillac3 | ATS 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| -| Chrysler | Pacifica 2017-18 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | FCA | -| Chrysler | Pacifica Hybrid 2017-18 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | FCA | -| Chrysler | Pacifica Hybrid 2019 | Adaptive Cruise | Yes | Stock | 0mph | 39mph | FCA | -| GMC3 | Acadia Denali 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| -| Holden3 | Astra 2017 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| -| Honda | Accord 2018-19 | All | Yes | Stock | 0mph | 3mph | Bosch | -| Honda | Accord Hybrid 2018-19 | All | Yes | Stock | 0mph | 3mph | Bosch | -| Honda | Civic Sedan/Coupe 2016-18| Honda Sensing | Yes | Yes | 0mph | 12mph | Nidec | -| Honda | Civic Sedan/Coupe 2019 | Honda Sensing | Yes | Stock | 0mph | 2mph | Bosch | -| Honda | Civic Hatchback 2017-19 | Honda Sensing | Yes | Stock | 0mph | 12mph | Bosch | -| Honda | CR-V 2015-16 | Touring | Yes | Yes | 25mph1| 12mph | Nidec | -| Honda | CR-V 2017-19 | Honda Sensing | Yes | Stock | 0mph | 12mph | Bosch | -| Honda | CR-V Hybrid 2017-2019 | Honda Sensing | Yes | Stock | 0mph | 12mph | Bosch | -| Honda | Fit 2018 | Honda Sensing | Yes | Yes | 25mph1| 12mph | Inverted Nidec | -| Honda | Odyssey 2018-19 | Honda Sensing | Yes | Yes | 25mph1| 0mph | Inverted Nidec | -| Honda | Passport 2019 | All | Yes | Yes | 25mph1| 12mph | Inverted Nidec | -| Honda | Pilot 2016-18 | Honda Sensing | Yes | Yes | 25mph1| 12mph | Nidec | -| Honda | Pilot 2019 | All | Yes | Yes | 25mph1| 12mph | Inverted Nidec | -| Honda | Ridgeline 2017-19 | Honda Sensing | Yes | Yes | 25mph1| 12mph | Nidec | -| Hyundai | Santa Fe 2019 | All | Yes | Stock | 0mph | 0mph | Custom6| -| Hyundai | Elantra 2017-19 | SCC + LKAS | Yes | Stock | 19mph | 34mph | Custom6| -| Hyundai | Genesis 2018 | All | Yes | Stock | 19mph | 34mph | Custom6| -| Jeep | Grand Cherokee 2016-18 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | FCA | -| Jeep | Grand Cherokee 2019 | Adaptive Cruise | Yes | Stock | 0mph | 39mph | FCA | -| Kia | Optima 2019 | SCC + LKAS | Yes | Stock | 0mph | 0mph | Custom6| -| Kia | Sorento 2018 | All | Yes | Stock | 0mph | 0mph | Custom6| -| Kia | Stinger 2018 | SCC + LKAS | Yes | Stock | 0mph | 0mph | Custom6| -| Lexus | ES Hybrid 2019 | All | Yes | Yes | 0mph | 0mph | Toyota | -| Lexus | RX Hybrid 2016-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | -| Subaru | Crosstrek 2018 | EyeSight | Yes | Stock | 0mph | 0mph | Custom4| -| Subaru | Impreza 2019 | EyeSight | Yes | Stock | 0mph | 0mph | Custom4| -| Toyota | Avalon 2016 | TSS-P | Yes | Yes2| 20mph1| 0mph | Toyota | -| Toyota | Avalon 2017-18 | All | Yes | Yes2| 20mph1| 0mph | Toyota | -| Toyota | Camry 2018-19 | All | Yes | Stock | 0mph5 | 0mph | Toyota | -| Toyota | Camry Hybrid 2018-19 | All | Yes | Stock | 0mph5 | 0mph | Toyota | -| Toyota | C-HR 2017-19 | All | Yes | Stock | 0mph | 0mph | Toyota | -| Toyota | C-HR Hybrid 2017-19 | All | Yes | Stock | 0mph | 0mph | Toyota | -| Toyota | Corolla 2017-19 | All | Yes | Yes2| 20mph1| 0mph | Toyota | -| Toyota | Corolla 2020 | All | Yes | Yes | 0mph | 0mph | Toyota | -| Toyota | Corolla Hatchback 2019 | All | Yes | Yes | 0mph | 0mph | Toyota | -| Toyota | Highlander 2017-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Highlander Hybrid 2017-19| All | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Prius 2016 | TSS-P | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Prius 2017-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Prius Prime 2017-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Rav4 2016 | TSS-P | Yes | Yes2| 20mph1| 0mph | Toyota | -| Toyota | Rav4 2017-18 | All | Yes | Yes2| 20mph1| 0mph | Toyota | -| Toyota | Rav4 2019 | All | Yes | Yes | 0mph | 0mph | Toyota | -| Toyota | Rav4 Hybrid 2016 | TSS-P | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Rav4 Hybrid 2017-18 | All | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Sienna 2018 | All | Yes | Yes2| 0mph | 0mph | Toyota | +| Make | Model (US Market Reference)| Supported Package | Lateral | Longitudinal | No Accel Below | No Steer Below | Giraffe | +| ---------------------| ---------------------------| ---------------------| --------| ---------------| -----------------| ---------------|-------------------| +| Acura | ILX 2016-18 | AcuraWatch Plus | Yes | Yes | 25mph1| 25mph | Nidec | +| Acura | RDX 2016-18 | AcuraWatch Plus | Yes | Yes | 25mph1| 12mph | Nidec | +| Buick3 | Regal 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| +| Chevrolet3| Malibu 2017 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| +| Chevrolet3| Volt 2017-18 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| +| Cadillac3 | ATS 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| +| Chrysler | Pacifica 2017-18 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | FCA | +| Chrysler | Pacifica Hybrid 2017-18 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | FCA | +| Chrysler | Pacifica Hybrid 2019 | Adaptive Cruise | Yes | Stock | 0mph | 39mph | FCA | +| GMC3 | Acadia Denali 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| +| Holden3 | Astra 2017 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| +| Honda | Accord 2018-19 | All | Yes | Stock | 0mph | 3mph | Bosch | +| Honda | Accord Hybrid 2018-19 | All | Yes | Stock | 0mph | 3mph | Bosch | +| Honda | Civic Sedan/Coupe 2016-18 | Honda Sensing | Yes | Yes | 0mph | 12mph | Nidec | +| Honda | Civic Sedan/Coupe 2019 | Honda Sensing | Yes | Stock | 0mph | 2mph | Bosch | +| Honda | Civic Hatchback 2017-19 | Honda Sensing | Yes | Stock | 0mph | 12mph | Bosch | +| Honda | CR-V 2015-16 | Touring | Yes | Yes | 25mph1| 12mph | Nidec | +| Honda | CR-V 2017-19 | Honda Sensing | Yes | Stock | 0mph | 12mph | Bosch | +| Honda | CR-V Hybrid 2017-2019 | Honda Sensing | Yes | Stock | 0mph | 12mph | Bosch | +| Honda | Odyssey 2018-19 | Honda Sensing | Yes | Yes | 25mph1| 0mph | Inverted Nidec | +| Honda | Passport 2019 | All | Yes | Yes | 25mph1| 12mph | Inverted Nidec | +| Honda | Pilot 2016-18 | Honda Sensing | Yes | Yes | 25mph1| 12mph | Nidec | +| Honda | Pilot 2019 | All | Yes | Yes | 25mph1| 12mph | Inverted Nidec | +| Honda | Ridgeline 2017-19 | Honda Sensing | Yes | Yes | 25mph1| 12mph | Nidec | +| Hyundai | Santa Fe 2019 | All | Yes | Stock | 0mph | 0mph | Custom6| +| Hyundai | Elantra 2017-19 | SCC + LKAS | Yes | Stock | 19mph | 34mph | Custom6| +| Hyundai | Genesis 2018 | All | Yes | Stock | 19mph | 34mph | Custom6| +| Jeep | Grand Cherokee 2016-18 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | FCA | +| Jeep | Grand Cherokee 2019 | Adaptive Cruise | Yes | Stock | 0mph | 39mph | FCA | +| Kia | Optima 2019 | SCC + LKAS | Yes | Stock | 0mph | 0mph | Custom6| +| Kia | Sorento 2018 | All | Yes | Stock | 0mph | 0mph | Custom6| +| Kia | Stinger 2018 | SCC + LKAS | Yes | Stock | 0mph | 0mph | Custom6| +| Lexus | ES Hybrid 2019 | All | Yes | Yes | 0mph | 0mph | Toyota | +| Lexus | RX Hybrid 2016-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | +| Lexus | IS 2017-2019 | All | Yes | Stock | 22mph | 0mph | Toyota | +| Lexus | IS Hybrid 2017 | All | Yes | Stock | 0mph | 0mph | Toyota | +| Subaru | Crosstrek 2018 | EyeSight | Yes | Stock | 0mph | 0mph | Custom4| +| Subaru | Impreza 2019 | EyeSight | Yes | Stock | 0mph | 0mph | Custom4| +| Toyota | Avalon 2016 | TSS-P | Yes | Yes2| 20mph1| 0mph | Toyota | +| Toyota | Avalon 2017-18 | All | Yes | Yes2| 20mph1| 0mph | Toyota | +| Toyota | Camry 2018-19 | All | Yes | Stock | 0mph5 | 0mph | Toyota | +| Toyota | Camry Hybrid 2018-19 | All | Yes | Stock | 0mph5 | 0mph | Toyota | +| Toyota | C-HR 2017-19 | All | Yes | Stock | 0mph | 0mph | Toyota | +| Toyota | C-HR Hybrid 2017-19 | All | Yes | Stock | 0mph | 0mph | Toyota | +| Toyota | Corolla 2017-19 | All | Yes | Yes2| 20mph1| 0mph | Toyota | +| Toyota | Corolla 2020 | All | Yes | Yes | 0mph | 0mph | Toyota | +| Toyota | Corolla Hatchback 2019 | All | Yes | Yes | 0mph | 0mph | Toyota | +| Toyota | Highlander 2017-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | +| Toyota | Highlander Hybrid 2017-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | +| Toyota | Prius 2016 | TSS-P | Yes | Yes2| 0mph | 0mph | Toyota | +| Toyota | Prius 2017-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | +| Toyota | Prius Prime 2017-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | +| Toyota | Rav4 2016 | TSS-P | Yes | Yes2| 20mph1| 0mph | Toyota | +| Toyota | Rav4 2017-18 | All | Yes | Yes2| 20mph1| 0mph | Toyota | +| Toyota | Rav4 2019 | All | Yes | Yes | 0mph | 0mph | Toyota | +| Toyota | Rav4 Hybrid 2016 | TSS-P | Yes | Yes2| 0mph | 0mph | Toyota | +| Toyota | Rav4 Hybrid 2017-18 | All | Yes | Yes2| 0mph | 0mph | Toyota | +| Toyota | Sienna 2018 | All | Yes | Yes2| 0mph | 0mph | Toyota | 1[Comma Pedal](https://community.comma.ai/wiki/index.php/Comma_Pedal) is used to provide stop-and-go capability to some of the openpilot-supported cars that don't currently support stop-and-go. Here is how to [build a Comma Pedal](https://medium.com/@jfrux/comma-pedal-building-with-macrofab-6328bea791e8). ***NOTE: The Comma Pedal is not officially supported by [comma.ai](https://comma.ai).***
-2When disconnecting the Driver Support Unit (DSU), otherwise longitudinal control is stock ACC. For DSU locations, see [Toyota Wiki page](https://community.comma.ai/wiki/index.php/Toyota).
-3[GM installation guide](https://zoneos.com/volt/).
+2When disconnecting the Driver Support Unit (DSU), otherwise longitudinal control is stock ACC. For DSU locations, see [Toyota Wiki page](https://community.comma.ai/wiki/index.php/Toyota). ***NOTE: disconnecting the DSU disables Automatic Emergency Braking (AEB).***
+3[GM installation guide](https://zoneos.com/volt/). ***NOTE: disconnecting the ASCM disables Automatic Emergency Braking (AEB).***
4Subaru Giraffe is DIY.
528mph for Camry 4CYL L, 4CYL LE and 4CYL SE which don't have Full-Speed Range Dynamic Radar Cruise Control.
6Open sourced [Hyundai Giraffe](https://github.com/commaai/neo/tree/master/giraffe/hyundai) is designed for the 2019 Sante Fe; pinout may differ for other Hyundais.
@@ -144,6 +145,7 @@ In Progress Cars - All Hyundai with SmartSense. - All Kia with SCC and LKAS. - All Chrysler, Jeep, Fiat with Adaptive Cruise Control and LaneSense. +- All Subaru with EyeSight. How can I add support for my car? ------ diff --git a/RELEASES.md b/RELEASES.md index d847bb3f0..14ddf78b6 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,13 @@ +Version 0.6.4 (2019-09-08) +======================== + * Forward stock AEB for Honda Nidec + * Improve lane centering on banked roads + * Always-on forward collision warning + * Always-on driver monitoring, except for right hand drive countries + * Driver monitoring learns the user's normal driving position + * Honda Fit support thanks to energee! + * Lexus IS support + Version 0.6.3 (2019-08-12) ======================== * Alert sounds from EON: requires NEOS update diff --git a/apk/ai.comma.plus.offroad.apk b/apk/ai.comma.plus.offroad.apk index 2e2e70deb..f81883e87 100644 Binary files a/apk/ai.comma.plus.offroad.apk and b/apk/ai.comma.plus.offroad.apk differ diff --git a/cereal/car.capnp b/cereal/car.capnp index 1e5e65f72..6eae99c3f 100644 --- a/cereal/car.capnp +++ b/cereal/car.capnp @@ -79,8 +79,11 @@ struct CarEvent @0x9b1657f34caf3ad3 { tooDistracted @54; posenetInvalid @55; soundsUnavailable @56; - manualSteeringRequired @57; - manualSteeringRequiredBlinkersOn @58; + preLaneChangeLeft @57; + preLaneChangeRight @58; + laneChange @59; + manualSteeringRequired @60; + manualSteeringRequiredBlinkersOn @61; } } @@ -302,6 +305,7 @@ struct CarParams { minEnableSpeed @7 :Float32; minSteerSpeed @8 :Float32; safetyModel @9 :SafetyModel; + safetyModelPassive @42 :SafetyModel = noOutput; safetyParam @10 :Int16; steerMaxBP @11 :List(Float32); @@ -345,6 +349,7 @@ struct CarParams { openpilotLongitudinalControl @37 :Bool; # is openpilot doing the longitudinal control? carVin @38 :Text; # VIN number queried during fingerprinting isPandaBlack @39: Bool; + dashcamOnly @41: Bool; struct LateralPIDTuning { kpBP @0 :List(Float32); @@ -400,6 +405,7 @@ struct CarParams { chrysler @9; tesla @10; subaru @11; + gmPassive @12; } enum SteerControlType { diff --git a/cereal/log.capnp b/cereal/log.capnp index e81cbcf8e..178e27869 100644 --- a/cereal/log.capnp +++ b/cereal/log.capnp @@ -443,7 +443,7 @@ struct ControlsState @0x97ff69c53601abf1 { alertSoundDEPRECATED @45 :Text; alertSound @56 :Car.CarControl.HUDControl.AudibleAlert; awarenessStatus @26 :Float32; - angleModelBias @27 :Float32; + angleModelBiasDEPRECATED @27 :Float32; gpsPlannerActive @40 :Bool; engageable @41 :Bool; # can OP be engaged? driverMonitoringOn @43 :Bool; @@ -517,8 +517,10 @@ struct ControlsState @0x97ff69c53601abf1 { steerAngle @1 :Float32; i @2 :Float32; output @3 :Float32; + lqrOutput @4 :Float32; } + } struct LiveEventData { @@ -528,6 +530,7 @@ struct LiveEventData { struct ModelData { frameId @0 :UInt32; + timestampEof @9 :UInt64; path @1 :PathData; leftLane @2 :PathData; @@ -698,6 +701,32 @@ struct PathPlan { sensorValid @14 :Bool; commIssue @15 :Bool; posenetValid @16 :Bool; + desire @17 :Desire; + laneChangeState @18 :LaneChangeState; + laneChangeDirection @19 :LaneChangeDirection; + + enum Desire { + none @0; + turnLeft @1; + turnRight @2; + laneChangeLeft @3; + laneChangeRight @4; + keepLeft @5; + keepRight @6; + } + + enum LaneChangeState { + off @0; + preLaneChange @1; + laneChangeStarting @2; + laneChangeFinishing @3; + } + + enum LaneChangeDirection { + none @0; + left @1; + right @2; + } } struct LiveLocationData { @@ -1727,6 +1756,8 @@ struct LiveMapData { } struct CameraOdometry { + frameId @4 :UInt32; + timestampEof @5 :UInt64; trans @0 :List(Float32); # m/s in device frame rot @1 :List(Float32); # rad/s in device frame transStd @2 :List(Float32); # std m/s in device frame diff --git a/common/api/__init__.py b/common/api/__init__.py index e457272a1..8eb981739 100644 --- a/common/api/__init__.py +++ b/common/api/__init__.py @@ -5,9 +5,10 @@ from datetime import datetime, timedelta from selfdrive.version import version class Api(object): - def __init__(self, dongle_id, private_key): + def __init__(self, dongle_id): self.dongle_id = dongle_id - self.private_key = private_key + with open('/persist/comma/id_rsa') as f: + self.private_key = f.read() def get(self, *args, **kwargs): return self.request('GET', *args, **kwargs) @@ -19,7 +20,14 @@ class Api(object): return api_get(endpoint, method=method, timeout=timeout, access_token=access_token, **params) def get_token(self): - return jwt.encode({'identity': self.dongle_id, 'exp': datetime.utcnow() + timedelta(hours=1)}, self.private_key, algorithm='RS256') + now = datetime.utcnow() + payload = { + 'identity': self.dongle_id, + 'nbf': now, + 'iat': now, + 'exp': now + timedelta(hours=1) + } + return jwt.encode(payload, self.private_key, algorithm='RS256') def api_get(endpoint, method='GET', timeout=None, access_token=None, **params): backend = "https://api.commadotai.com/" diff --git a/common/file_helpers.py b/common/file_helpers.py index 3300ae595..beeee8908 100644 --- a/common/file_helpers.py +++ b/common/file_helpers.py @@ -24,21 +24,12 @@ def rm_tree_or_link(path): shutil.rmtree(path) def get_tmpdir_on_same_filesystem(path): - # TODO(mgraczyk): HACK, we should actually check for which filesystem. normpath = os.path.normpath(path) parts = normpath.split("/") - if len(parts) > 1: - if parts[1].startswith("raid") or parts[1].startswith("datasets"): - if len(parts) > 2 and parts[2] == "runner": - return "/{}/runner/tmp".format(parts[1]) - elif len(parts) > 2 and parts[2] == "aws": - return "/{}/aws/tmp".format(parts[1]) - else: - return "/{}/tmp".format(parts[1]) - elif parts[1] == "aws": - return "/aws/tmp" - elif parts[1] == "scratch": - return "/scratch/tmp" + if len(parts) > 1 and parts[1] == "scratch": + return "/scratch/tmp" + elif len(parts) > 2 and parts[2] == "runner": + return "/{}/runner/tmp".format(parts[1]) return "/tmp" class AutoMoveTempdir(object): diff --git a/common/params.py b/common/params.py index 431b34735..3c8933b0a 100755 --- a/common/params.py +++ b/common/params.py @@ -27,6 +27,7 @@ import sys import shutil import fcntl import tempfile +import threading from enum import Enum @@ -63,10 +64,9 @@ keys = { "GitCommit": [TxType.PERSISTENT], "GitRemote": [TxType.PERSISTENT], "HasAcceptedTerms": [TxType.PERSISTENT], - "IsDriverMonitoringEnabled": [TxType.PERSISTENT], - "IsFcwEnabled": [TxType.PERSISTENT], "IsGeofenceEnabled": [TxType.PERSISTENT], "IsMetric": [TxType.PERSISTENT], + "IsRHD": [TxType.PERSISTENT], "IsUpdateAvailable": [TxType.PERSISTENT], "IsUploadRawEnabled": [TxType.PERSISTENT], "IsUploadVideoOverCellularEnabled": [TxType.PERSISTENT], @@ -102,6 +102,7 @@ keys = { "DragonBBUI": [TxType.PERSISTENT], # deprecated "DragonToyotaStockDSU": [TxType.PERSISTENT], "DragonLatCtrl": [TxType.PERSISTENT], + "DragonUISpeed": [TxType.PERSISTENT], "DragonUIEvent": [TxType.PERSISTENT], "DragonUIMaxSpeed": [TxType.PERSISTENT], "DragonUIFace": [TxType.PERSISTENT], @@ -119,6 +120,8 @@ keys = { "DragonCameraOffset": [TxType.PERSISTENT], "DragonUIVolumeBoost": [TxType.PERSISTENT], "DragonGreyPandaMode": [TxType.PERSISTENT], + "DragonDrivingUI": [TxType.PERSISTENT], + "DragonDisplaySteeringLimitAlert": [TxType.PERSISTENT], } @@ -383,6 +386,17 @@ class Params(object): write_db(self.db, key, dat) + +def put_nonblocking(key, val): + def f(key, val): + params = Params() + params.put(key, val) + + t = threading.Thread(target=f, args=(key, val)) + t.start() + return t + + if __name__ == "__main__": params = Params() if len(sys.argv) > 2: diff --git a/common/stat_live.py b/common/stat_live.py new file mode 100644 index 000000000..06b4f993b --- /dev/null +++ b/common/stat_live.py @@ -0,0 +1,73 @@ +import numpy as np + +class RunningStat(): + # tracks realtime mean and standard deviation without storing any data + def __init__(self, priors=None, max_trackable=-1): + self.max_trackable = max_trackable + if priors is not None: + # initialize from history + self.M = priors[0] + self.S = priors[1] + self.n = priors[2] + self.M_last = self.M + self.S_last = self.S + + else: + self.reset() + + def reset(self): + self.M = 0. + self.S = 0. + self.M_last = 0. + self.S_last = 0. + self.n = 0 + + def push_data(self, new_data): + # short term memory hack + if self.max_trackable < 0 or self.n < self.max_trackable: + self.n += 1 + if self.n == 0: + self.M_last = new_data + self.M = self.M_last + self.S_last = 0. + else: + self.M = self.M_last + (new_data - self.M_last) / self.n + self.S = self.S_last + (new_data - self.M_last) * (new_data - self.M); + self.M_last = self.M + self.S_last = self.S + + def mean(self): + return self.M + + def variance(self): + if self.n >= 2: + return self.S / (self.n - 1.) + else: + return 0 + + def std(self): + return np.sqrt(self.variance()) + + def params_to_save(self): + return [self.M, self.S, self.n] + +class RunningStatFilter(): + def __init__(self, raw_priors=None, filtered_priors=None, max_trackable=-1): + self.raw_stat = RunningStat(raw_priors, max_trackable) + self.filtered_stat = RunningStat(filtered_priors, max_trackable) + + def reset(self): + self.raw_stat.reset() + self.filtered_stat.reset() + + def push_and_update(self, new_data): + _std_last = self.raw_stat.std() + self.raw_stat.push_data(new_data) + _delta_std = self.raw_stat.std() - _std_last + if _delta_std<=0: + self.filtered_stat.push_data(new_data) + else: + pass + # self.filtered_stat.push_data(self.filtered_stat.mean()) + +# class SequentialBayesian(): \ No newline at end of file diff --git a/common/transformations/camera.py b/common/transformations/camera.py index 2e04c5ac2..a5c14bb4b 100644 --- a/common/transformations/camera.py +++ b/common/transformations/camera.py @@ -154,17 +154,40 @@ def rotate_img(img, eulers, crop=None, intrinsics=eon_intrinsics): W_border: size[1] - W_border] +def get_camera_frame_from_calib_frame(camera_frame_from_road_frame): + camera_frame_from_ground = camera_frame_from_road_frame[:, (0, 1, 3)] + calib_frame_from_ground = np.dot(eon_intrinsics, + get_view_frame_from_road_frame(0, 0, 0, 1.22))[:, (0, 1, 3)] + ground_from_calib_frame = np.linalg.inv(calib_frame_from_ground) + camera_frame_from_calib_frame = np.dot(camera_frame_from_ground, ground_from_calib_frame) + return camera_frame_from_calib_frame + + +def pretransform_from_calib(calib): + roll, pitch, yaw, height = calib + view_frame_from_road_frame = get_view_frame_from_road_frame(roll, pitch, yaw, height) + camera_frame_from_road_frame = np.dot(eon_intrinsics, view_frame_from_road_frame) + camera_frame_from_calib_frame = get_camera_frame_from_calib_frame(camera_frame_from_road_frame) + return np.linalg.inv(camera_frame_from_calib_frame) + + def transform_img(base_img, augment_trans=np.array([0,0,0]), augment_eulers=np.array([0,0,0]), from_intr=eon_intrinsics, to_intr=eon_intrinsics, - calib_rot_view=None, output_size=None, pretransform=None, - top_hacks=True): + top_hacks=False, + yuv=False, + alpha=1.0, + beta=0, + blur=0): import cv2 + if yuv: + base_img = cv2.cvtColor(base_img, cv2.COLOR_YUV2RGB_I420) + size = base_img.shape[:2] if not output_size: output_size = size[::-1] @@ -180,8 +203,6 @@ def transform_img(base_img, h*np.ones(4), h/quadrangle_norm[:,1])) rot = orient.rot_from_euler(augment_eulers) - if calib_rot_view is not None: - rot = calib_rot_view.dot(rot) to_extrinsics = np.hstack((rot.T, -augment_trans[:,None])) to_KE = to_intr.dot(to_extrinsics) warped_quadrangle_full = np.einsum('jk,ik->ij', to_KE, np.hstack((quadrangle_world, np.ones((4,1))))) @@ -202,7 +223,19 @@ def transform_img(base_img, M = M.dot(pretransform) augmented_rgb[:cyy] = cv2.warpPerspective(base_img, M, (output_size[0], cyy), borderMode=cv2.BORDER_REPLICATE) - return augmented_rgb + # brightness and contrast augment + augmented_rgb = np.clip((float(alpha)*augmented_rgb + beta), 0, 255).astype(np.uint8) + + # gaussian blur + if blur > 0: + augmented_rgb = cv2.GaussianBlur(augmented_rgb,(blur*2+1,blur*2+1),cv2.BORDER_DEFAULT) + + if yuv: + augmented_img = cv2.cvtColor(augmented_rgb, cv2.COLOR_RGB2YUV_I420) + else: + augmented_img = augmented_rgb + return augmented_img + def yuv_crop(frame, output_size, center=None): # output_size in camera coordinates so u,v diff --git a/common/transformations/model.py b/common/transformations/model.py index e832cb7ee..c13cc7e38 100644 --- a/common/transformations/model.py +++ b/common/transformations/model.py @@ -1,8 +1,8 @@ import numpy as np -from common.transformations.camera import eon_focal_length, \ - vp_from_ke, get_view_frame_from_road_frame, \ - FULL_FRAME_SIZE +from common.transformations.camera import (FULL_FRAME_SIZE, eon_focal_length, + get_view_frame_from_road_frame, + vp_from_ke) # segnet diff --git a/installer/updater/updater b/installer/updater/updater index 51886bd33..15858eabb 100755 Binary files a/installer/updater/updater and b/installer/updater/updater differ diff --git a/installer/updater/updater.cc b/installer/updater/updater.cc index 89ac7f635..e2d3e7dae 100644 --- a/installer/updater/updater.cc +++ b/installer/updater/updater.cc @@ -117,11 +117,19 @@ size_t download_file_write(void *ptr, size_t size, size_t nmeb, void *up) { return fwrite(ptr, size, nmeb, (FILE*)up); } -bool check_battery() { +int battery_capacity() { std::string bat_cap_s = util::read_file("/sys/class/power_supply/battery/capacity"); - int bat_cap = atoi(bat_cap_s.c_str()); + return atoi(bat_cap_s.c_str()); +} + +int battery_current() { std::string current_now_s = util::read_file("/sys/class/power_supply/battery/current_now"); - int current_now = atoi(current_now_s.c_str()); + return atoi(current_now_s.c_str()); +} + +bool check_battery() { + int bat_cap = battery_capacity(); + int current_now = battery_current(); return bat_cap > 35 || (current_now < 0 && bat_cap > 10); } @@ -163,6 +171,7 @@ struct Updater { // i hate state machines give me coroutines already enum UpdateState { CONFIRMATION, + LOW_BATTERY, RUNNING, ERROR, }; @@ -173,6 +182,12 @@ struct Updater { std::string error_text; + std::string low_battery_text; + std::string low_battery_title; + std::string low_battery_context; + std::string battery_cap_text; + int min_battery_cap = 35; + // button int b_x, b_w, b_y, b_h; int balt_x; @@ -296,6 +311,16 @@ struct Updater { state = ERROR; } + void set_battery_low() { + std::lock_guard guard(lock); + state = LOW_BATTERY; + } + + void set_running() { + std::lock_guard guard(lock); + state = RUNNING; + } + std::string stage_download(std::string url, std::string hash, std::string name) { std::string out_fn = UPDATE_DIR "/" + util::base_name(url); @@ -323,8 +348,14 @@ struct Updater { assert(curl); if (!check_battery()) { - set_error("Please plug power in to your EON and wait for charge"); - return; + set_battery_low(); + int battery_cap = battery_capacity(); + while(battery_cap < min_battery_cap) { + battery_cap = battery_capacity(); + battery_cap_text = std::to_string(battery_cap); + usleep(1000000); + } + set_running(); } if (!check_space()) { @@ -400,8 +431,14 @@ struct Updater { } if (!check_battery()) { - set_error("must have at least 35% battery to update"); - return; + set_battery_low(); + int battery_cap = battery_capacity(); + while(battery_cap < min_battery_cap) { + battery_cap = battery_capacity(); + battery_cap_text = std::to_string(battery_cap); + usleep(1000000); + } + set_running(); } if (!recovery_fn.empty()) { @@ -526,6 +563,27 @@ struct Updater { } } + void draw_battery_screen() { + low_battery_title = "Low Battery"; + low_battery_text = "Please connect EON to your charger. Update will continue once EON battery reaches 35%."; + low_battery_context = "Current battery charge: " + battery_cap_text + "%"; + + nvgFillColor(vg, nvgRGBA(255,255,255,255)); + nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); + + nvgFontFace(vg, "opensans_bold"); + nvgFontSize(vg, 120.0f); + nvgTextBox(vg, 110, 220, fb_w-240, low_battery_title.c_str(), NULL); + + nvgFontFace(vg, "opensans_regular"); + nvgFontSize(vg, 86.0f); + nvgTextBox(vg, 130, 380, fb_w-260, low_battery_text.c_str(), NULL); + + nvgFontFace(vg, "opensans_bold"); + nvgFontSize(vg, 86.0f); + nvgTextBox(vg, 130, 700, fb_w-260, low_battery_context.c_str(), NULL); + } + void draw_progress_screen() { // draw progress message nvgFontSize(vg, 64.0f); @@ -584,11 +642,14 @@ struct Updater { "Continue", "Connect to WiFi"); break; + case LOW_BATTERY: + draw_battery_screen(); + break; case RUNNING: draw_progress_screen(); break; case ERROR: - draw_ack_screen("There was an error.", ("ERROR: " + error_text + "\n\nYou will need to retry").c_str(), NULL, "exit"); + draw_ack_screen("There was an error", (error_text).c_str(), NULL, "Reboot"); break; } @@ -648,6 +709,7 @@ struct Updater { glDisable(GL_BLEND); eglSwapBuffers(display, surface); + assert(glGetError() == GL_NO_ERROR); // no simple way to do 30fps vsync with surfaceflinger... diff --git a/models/driving_model.dlc b/models/driving_model.dlc index 79181185f..3dc890079 100644 Binary files a/models/driving_model.dlc and b/models/driving_model.dlc differ diff --git a/opendbc/acura_ilx_2016_can_generated.dbc b/opendbc/acura_ilx_2016_can_generated.dbc index 75557b1e7..2a2a941a5 100644 --- a/opendbc/acura_ilx_2016_can_generated.dbc +++ b/opendbc/acura_ilx_2016_can_generated.dbc @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -123,7 +124,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -226,6 +227,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,6 +237,7 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; diff --git a/opendbc/acura_rdx_2018_can_generated.dbc b/opendbc/acura_rdx_2018_can_generated.dbc index 0fa62693c..48c9b3967 100644 --- a/opendbc/acura_rdx_2018_can_generated.dbc +++ b/opendbc/acura_rdx_2018_can_generated.dbc @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -123,7 +124,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -226,6 +227,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,6 +237,7 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; diff --git a/opendbc/chrysler_pacifica_2017_hybrid.dbc b/opendbc/chrysler_pacifica_2017_hybrid.dbc index be99769b5..a19219cbb 100644 --- a/opendbc/chrysler_pacifica_2017_hybrid.dbc +++ b/opendbc/chrysler_pacifica_2017_hybrid.dbc @@ -132,13 +132,12 @@ BO_ 705 AUTO_PARK_BUTTON: 8 XXX BO_ 719 AUTO_PARK_SIGNALS_1: 8 XXX SG_ AUTO_PARK_UNKNOWN_1 : 7|16@0+ (1,0) [0|31] "" XXX -BO_ 671 AUTO_PARK_SIGNALS_2: 8 XXX - SG_ AUTO_PARK_PARALLEL : 21|1@0+ (1,0) [0|1] "" XXX - SG_ AUTO_PARK_PERPENDICULAR_1 : 22|1@0+ (1,0) [0|1] "" XXX - SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX +BO_ 671 AUTO_PARK_REQUEST: 8 XXX SG_ AUTO_PARK_CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ AUTO_PARK_MAYBE_TURNING : 3|12@0+ (1,0) [0|1023] "" XXX - SG_ AUTO_PARK_TURNING_STATUS : 7|4@0+ (1,0) [0|15] "" XXX + SG_ AUTO_PARK_STATUS : 7|5@0+ (1,0) [0|15] "" XXX + SG_ AUTO_PARK_COUNTER : 55|4@0+ (1,0) [0|15] "" XXX + SG_ AUTO_PARK_MODE : 22|2@0+ (1,0) [0|3] "" XXX + SG_ AUTO_PARK_CMD : 2|11@0+ (1,-1024) [0|1] "NM" XXX BO_ 784 AUTO_PARK_LESS_INTERESTING: 8 XXX SG_ INCREASING_UNKNOWN : 55|8@0+ (1,0) [0|7] "" XXX @@ -393,10 +392,8 @@ CM_ SG_ 678 LKAS_LANE_LINES "0x01 transparent lines, 0x02 left white, 0x03 right CM_ SG_ 678 LKAS_ALERTS "(0x01, 0x02) lane sense off, (0x03, 0x04, 0x06) place hands on steering wheel, 0x07 lane departure detected + place hands on steering wheel, (0x08, 0x09) lane sense unavailable + clean front windshield, 0x0b lane sense and auto high beam unavailable + clean front windshield, 0x0c lane sense unavailable + service required, (0x00, 0x05, 0x0a, 0x0d, 0x0e, 0x0f) null"; CM_ SG_ 705 AUTO_PARK_TOGGLE_1 "set briefly when turning on or off self-parking"; CM_ SG_ 705 INCREASING_UNKNOWN "sometimes decreasing"; -CM_ SG_ 671 AUTO_PARK_PARALLEL "parallel parking mode"; -CM_ SG_ 671 AUTO_PARK_PERPENDICULAR_1 "perpendicular parking mode"; -CM_ SG_ 671 AUTO_PARK_MAYBE_TURNING "something with autopark turning the steering wheel maybe."; -CM_ SG_ 671 AUTO_PARK_TURNING_STATUS "0 when not steering. when steering starts, 4 for two packets, and then 5 for the rest"; +CM_ SG_ 671 AUTO_PARK_CMD "Request Appears to be in NM"; +CM_ SG_ 671 AUTO_PARK_STATUS "1 = IDLE / NO REQUEST 9 = START REQUEST 10 = REQUEST MODE 11 = REQUEST MODE"; CM_ SG_ 784 INCREASING_UNKNOWN "perhaps distance traveled"; CM_ SG_ 826 AUTO_PARK_GEAR_1 "Reverse=0, Forward=f"; CM_ SG_ 826 AUTO_PARK_GEAR_2 "Reverse=0, Forward=f"; diff --git a/opendbc/generator/honda/_bosch_2018.dbc b/opendbc/generator/honda/_bosch_2018.dbc index 302c254c2..8a7ff7656 100644 --- a/opendbc/generator/honda/_bosch_2018.dbc +++ b/opendbc/generator/honda/_bosch_2018.dbc @@ -33,6 +33,12 @@ NS_ : BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS @@ -114,15 +120,26 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON - SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX - SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX - SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM - SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX - SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (1,0) [0|0] "" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX @@ -169,16 +186,16 @@ BO_ 773 SEATBELT_STATUS: 7 BDY SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM - SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CAR_SPEED : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY @@ -196,8 +213,8 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX - SG_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX @@ -261,4 +278,8 @@ BO_ 891 STALK_STATUS_2: 8 XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; + VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; diff --git a/opendbc/generator/honda/_dual_can_nidec_2018.dbc b/opendbc/generator/honda/_dual_can_nidec_2018.dbc new file mode 100644 index 000000000..67c019c92 --- /dev/null +++ b/opendbc/generator/honda/_dual_can_nidec_2018.dbc @@ -0,0 +1,215 @@ +VERSION "" + + +NS_ : + NS_DESC_ + CM_ + BA_DEF_ + BA_ + VAL_ + CAT_DEF_ + CAT_ + FILTER + BA_DEF_DEF_ + EV_DATA_ + ENVVAR_DATA_ + SGTYPE_ + SGTYPE_VAL_ + BA_DEF_SGTYPE_ + BA_SGTYPE_ + SIG_TYPE_REF_ + VAL_TABLE_ + SIG_GROUP_ + SIG_VALTYPE_ + SIGTYPE_VALTYPE_ + BO_TX_BU_ + BA_DEF_REL_ + BA_REL_ + BA_DEF_DEF_REL_ + BU_SG_REL_ + BU_EV_REL_ + BU_BO_REL_ + SG_MUL_VAL_ + +BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON + +BO_ 344 ENGINE_DATA: 8 PCM + SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON + SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 380 POWERTRAIN_DATA: 8 PCM + SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON + SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON + SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "" EON + SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "" EON + SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "" EON + SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "" EON + SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON + SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 420 VSA_STATUS: 8 VSA + SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 432 STANDSTILL: 7 VSA + SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON + SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 464 WHEEL_SPEEDS: 8 VSA + SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 506 BRAKE_COMMAND: 8 ADAS + SG_ ZEROS_BOH : 7|12@0+ (1,0) [0|3] "" XXX + SG_ BRAKE_PUMP_REQUEST : 11|1@0+ (1,0) [0|1] "" EBCM + SG_ ZEROS_BOH2 : 10|3@0+ (1,0) [0|7] "" XXX + SG_ CRUISE_BOH2 : 23|3@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_BOH3 : 19|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM + SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_0X80 : 31|8@0+ (1,0) [0|1] "" EBCM + SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM + SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM + SG_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" EBCM + SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM + SG_ COMPUTER_BRAKE : 55|10@0+ (1,0) [0|1] "" EBCM + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM + +BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA + SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON + SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON + SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 773 SEATBELT_STATUS: 7 BDY + SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON + SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON + SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 777 LOCK_STATUS: 8 XXX + SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON + SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 780 ACC_HUD: 8 ADAS + SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY + SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY + SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY + SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY + SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY + SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY + SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY + SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY + SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY + SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY + SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY + SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY + SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY + SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY + SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY + SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY + +BO_ 804 CRUISE: 8 PCM + SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON + SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON + SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON + SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON + SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON + SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 829 LKAS_HUD: 5 ADAS + SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY + SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY + SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY + SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY + SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY + SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY + SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY + SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY + SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY + SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY + SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY + SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY + SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY + SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY + SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY + SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY + SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY + SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY + +BO_ 892 CRUISE_PARAMS: 8 PCM + SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +BO_ 1029 DOORS_STATUS: 8 BDY + SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON + SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; +CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; +CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; +CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; +CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; + + +VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; +VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; +VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; +VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; diff --git a/opendbc/generator/honda/_honda_2017.dbc b/opendbc/generator/honda/_honda_2017.dbc index ee9a1e648..d805d45e8 100644 --- a/opendbc/generator/honda/_honda_2017.dbc +++ b/opendbc/generator/honda/_honda_2017.dbc @@ -56,6 +56,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -101,7 +102,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -204,6 +205,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -213,6 +215,7 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; diff --git a/opendbc/generator/honda/honda_fit_hybrid_2018_can.dbc b/opendbc/generator/honda/honda_fit_hybrid_2018_can.dbc new file mode 100644 index 000000000..6b0a896b7 --- /dev/null +++ b/opendbc/generator/honda/honda_fit_hybrid_2018_can.dbc @@ -0,0 +1,111 @@ +CM_ "IMPORT _dual_can_nidec_2018.dbc" +CM_ "IMPORT _comma.dbc" + +BO_ 145 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" EON + +BO_ 228 STEERING_CONTROL: 5 ADAS + SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS + SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS + SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS + SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS + SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS + +BO_ 304 GAS_PEDAL_2: 8 PCM + SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 342 STEERING_SENSORS: 6 EPS + SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON + SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON + +BO_ 399 STEER_STATUS: 7 EPS + SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON + SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 419 GEARBOX: 8 PCM + SG_ GEAR : 7|8@0+ (1,0) [0|256] "" EON + SG_ GEAR_SHIFTER : 35|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 422 SCM_BUTTONS: 8 SCM + SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON + SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON + SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON + SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 487 BRAKE_PRESSURE: 4 VSA + SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" EON + SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" EON + SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON + +BO_ 545 ECON_STATUS: 5 XXX + SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" EON + SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EON + +BO_ 660 SCM_FEEDBACK: 8 SCM + SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON + SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON + SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 862 HIGHBEAM_CONTROL: 8 ADAS + SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY + SG_ ZEROS_BOH_2 : 48|4@1+ (1,0) [0|15] "" XXX + SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX + SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 884 STALK_STATUS: 8 XXX + SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON + SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON + SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON + SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +BO_ 891 WIPERS: 8 XXX + SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +BO_ 927 RADAR_HUD: 8 ADAS + SG_ ZEROS_BOH : 7|17@0+ (1,0) [0|127] "" BDY + SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|15] "" BDY + SG_ ZEROS_BOH2 : 31|8@0+ (1,0) [0|127] "" BDY + SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|15] "" BDY + SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|15] "" BDY + SG_ LEAD_SPEED : 39|9@0+ (1,0) [0|127] "" BDY + SG_ LEAD_STATE : 46|3@0+ (1,0) [0|127] "" BDY + SG_ LEAD_DISTANCE : 43|5@0+ (1,0) [0|31] "" BDY + SG_ ZEROS_BOH3 : 54|7@0+ (1,0) [0|127] "" BDY + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY + +CM_ SG_ 419 GEAR "10 = reverse, 11 = transition"; +CM_ SG_ 420 BRAKE_HOLD_RELATED "On when Brake Hold engaged"; + +VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; +VAL_ 419 GEAR_SHIFTER 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; +VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; +VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; +VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; + +CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/honda/honda_odyssey_extreme_edition_2018_china_can.dbc b/opendbc/generator/honda/honda_odyssey_extreme_edition_2018_china_can.dbc new file mode 100644 index 000000000..2d0d7e2b5 --- /dev/null +++ b/opendbc/generator/honda/honda_odyssey_extreme_edition_2018_china_can.dbc @@ -0,0 +1,76 @@ +CM_ "IMPORT _honda_2017.dbc" +CM_ "IMPORT _comma.dbc" + +BO_ 316 GAS_PEDAL: 8 PCM + SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON + +BO_ 342 STEERING_SENSORS: 6 EPS + SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON + SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON + SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON + +BO_ 399 STEER_STATUS: 7 EPS + SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-2985|2985] "tbd" EON + SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ STEER_STATUS : 43|4@0+ (1,0) [0|15] "" EON + SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + +BO_ 401 GEARBOX: 8 PCM + SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON + SG_ GEAR : 35|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 404 STEERING_CONTROL: 4 EON + SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS + SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS + SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EPS + SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EPS + SG_ STEER_TORQUE : 7|16@0- (-1,0) [-32767|32767] "" EPS + +BO_ 422 SCM_BUTTONS: 8 SCM + SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON + SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON + SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON + SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON + SG_ DRIVERS_DOOR_OPEN : 63|1@0+ (1,0) [0|1] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 450 EPB_STATUS: 8 XXX + SG_ EPB_BRAKE_AND_PULL : 6|1@0+ (1,0) [0|1] "" XXX + SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" XXX + SG_ EPB_STATE : 29|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + +BO_ 660 SCM_FEEDBACK: 8 SCM + SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON + SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON + SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 862 HIGHBEAM_CONTROL: 8 ADAS + SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY + SG_ ZEROS_BOH_2 : 48|4@1+ (1,0) [0|15] "" XXX + SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX + SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 1302 ODOMETER: 8 XXX + SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +CM_ SG_ 401 GEAR "10 = reverse, 11 = transition"; +VAL_ 399 STEER_STATUS 5 "fault" 4 "no_torque_alert_2" 2 "no_torque_alert_1" 0 "normal" ; +VAL_ 401 GEAR_SHIFTER 32 "L" 16 "S" 8 "D" 4 "N" 2 "R" 1 "P" ; +VAL_ 401 GEAR 7 "L" 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; +VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; +VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; +VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; diff --git a/opendbc/generator/toyota/_toyota_2017.dbc b/opendbc/generator/toyota/_toyota_2017.dbc index 9084d65b4..6a54ce22e 100644 --- a/opendbc/generator/toyota/_toyota_2017.dbc +++ b/opendbc/generator/toyota/_toyota_2017.dbc @@ -197,7 +197,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/generator/toyota/lexus_is_2018_pt.dbc b/opendbc/generator/toyota/lexus_is_2018_pt.dbc index aebf81a16..e1aff7c4f 100644 --- a/opendbc/generator/toyota/lexus_is_2018_pt.dbc +++ b/opendbc/generator/toyota/lexus_is_2018_pt.dbc @@ -30,6 +30,9 @@ BO_ 1009 PCM_CRUISE_ALT: 8 XXX SG_ CRUISE_STATE : 10|1@0+ (1,0) [0|1] "" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX +BO_ 1599 LIGHT_STALK_ISH: 8 SCM + SG_ AUTO_HIGH_BEAM : 19|1@0+ (1,0) [0|1] "" XXX + CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; diff --git a/opendbc/generator/toyota/lexus_is_hybrid_2017_pt.dbc b/opendbc/generator/toyota/lexus_is_hybrid_2017_pt.dbc deleted file mode 100644 index 8549f117e..000000000 --- a/opendbc/generator/toyota/lexus_is_hybrid_2017_pt.dbc +++ /dev/null @@ -1,41 +0,0 @@ -CM_ "IMPORT _toyota_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 581 GAS_PEDAL: 5 XXX - SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX - -BO_ 550 BRAKE_MODULE: 8 XXX - SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX - SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX - SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX - -BO_ 608 STEER_TORQUE_SENSOR: 8 XXX - SG_ STEER_TORQUE_EPS : 47|16@0- (1.0,0) [-20000|20000] "" XXX - SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX - SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 610 EPS_STATUS: 5 EPS - SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX - SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX - SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX - SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX - -BO_ 956 GEAR_PACKET: 8 XXX - SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX - -BO_ 1009 PCM_CRUISE_ISH: 8 XXX - SG_ MAIN_ON : 13|1@0+ (1,0) [0|3] "" XXX - SG_ CRUISE_STATE : 10|1@0+ (1,0) [0|1] "" XXX - SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX - -BO_ 1599 LIGHT_STALK_ISH: 8 SCM - SG_ AUTO_HIGH_BEAM : 19|1@0+ (1,0) [0|1] "" XXX - -CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; -CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; -CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; -CM_ SG_ 1009 SET_SPEED "units seem to be whatever the car is set to"; -VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; -VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; -VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; diff --git a/opendbc/honda_accord_lx15t_2018_can_generated.dbc b/opendbc/honda_accord_lx15t_2018_can_generated.dbc index 6159efb0e..3957c6124 100644 --- a/opendbc/honda_accord_lx15t_2018_can_generated.dbc +++ b/opendbc/honda_accord_lx15t_2018_can_generated.dbc @@ -37,6 +37,12 @@ NS_ : BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS @@ -118,15 +124,26 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON - SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX - SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX - SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM - SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX - SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (1,0) [0|0] "" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX @@ -173,16 +190,16 @@ BO_ 773 SEATBELT_STATUS: 7 BDY SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM - SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CAR_SPEED : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY @@ -200,8 +217,8 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX - SG_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX @@ -265,6 +282,10 @@ BO_ 891 STALK_STATUS_2: 8 XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; + VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; CM_ "honda_accord_lx15t_2018_can.dbc starts here" diff --git a/opendbc/honda_accord_s2t_2018_can_generated.dbc b/opendbc/honda_accord_s2t_2018_can_generated.dbc index 7b3e99bc8..7ce9a31ea 100644 --- a/opendbc/honda_accord_s2t_2018_can_generated.dbc +++ b/opendbc/honda_accord_s2t_2018_can_generated.dbc @@ -37,6 +37,12 @@ NS_ : BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS @@ -118,15 +124,26 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON - SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX - SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX - SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM - SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX - SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (1,0) [0|0] "" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX @@ -173,16 +190,16 @@ BO_ 773 SEATBELT_STATUS: 7 BDY SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM - SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CAR_SPEED : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY @@ -200,8 +217,8 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX - SG_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX @@ -265,6 +282,10 @@ BO_ 891 STALK_STATUS_2: 8 XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; + VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; CM_ "honda_accord_s2t_2018_can.dbc starts here" diff --git a/opendbc/honda_civic_hatchback_ex_2017_can_generated.dbc b/opendbc/honda_civic_hatchback_ex_2017_can_generated.dbc index 55f74cf99..d36e45c36 100644 --- a/opendbc/honda_civic_hatchback_ex_2017_can_generated.dbc +++ b/opendbc/honda_civic_hatchback_ex_2017_can_generated.dbc @@ -37,6 +37,12 @@ NS_ : BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS @@ -118,15 +124,26 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON - SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX - SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX - SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM - SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX - SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (1,0) [0|0] "" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX @@ -173,16 +190,16 @@ BO_ 773 SEATBELT_STATUS: 7 BDY SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM - SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CAR_SPEED : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY @@ -200,8 +217,8 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX - SG_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX @@ -265,6 +282,10 @@ BO_ 891 STALK_STATUS_2: 8 XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; + VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; CM_ "honda_civic_hatchback_ex_2017_can.dbc starts here" diff --git a/opendbc/honda_civic_touring_2016_can_generated.dbc b/opendbc/honda_civic_touring_2016_can_generated.dbc index a613aa067..22f4a0b9f 100644 --- a/opendbc/honda_civic_touring_2016_can_generated.dbc +++ b/opendbc/honda_civic_touring_2016_can_generated.dbc @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -123,7 +124,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -226,6 +227,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,6 +237,7 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; diff --git a/opendbc/honda_crv_ex_2017_can_generated.dbc b/opendbc/honda_crv_ex_2017_can_generated.dbc index 2a6449f52..f8d8438dc 100644 --- a/opendbc/honda_crv_ex_2017_can_generated.dbc +++ b/opendbc/honda_crv_ex_2017_can_generated.dbc @@ -37,6 +37,12 @@ NS_ : BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS @@ -118,15 +124,26 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON - SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX - SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX - SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM - SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX - SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (1,0) [0|0] "" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX @@ -173,16 +190,16 @@ BO_ 773 SEATBELT_STATUS: 7 BDY SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM - SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CAR_SPEED : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY @@ -200,8 +217,8 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX - SG_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX @@ -265,6 +282,10 @@ BO_ 891 STALK_STATUS_2: 8 XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; + VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; CM_ "honda_crv_ex_2017_can.dbc starts here" diff --git a/opendbc/honda_crv_hybrid_2019_can_generated.dbc b/opendbc/honda_crv_hybrid_2019_can_generated.dbc index 4fd8ae924..35036c6fe 100644 --- a/opendbc/honda_crv_hybrid_2019_can_generated.dbc +++ b/opendbc/honda_crv_hybrid_2019_can_generated.dbc @@ -37,6 +37,12 @@ NS_ : BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS @@ -118,15 +124,26 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON - SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX - SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX - SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM - SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX - SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (1,0) [0|0] "" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX @@ -173,16 +190,16 @@ BO_ 773 SEATBELT_STATUS: 7 BDY SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM - SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CAR_SPEED : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY @@ -200,8 +217,8 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX - SG_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX @@ -265,6 +282,10 @@ BO_ 891 STALK_STATUS_2: 8 XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; + VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; CM_ "honda_crv_hybrid_2019_can.dbc starts here" diff --git a/opendbc/honda_crv_touring_2016_can_generated.dbc b/opendbc/honda_crv_touring_2016_can_generated.dbc index 94e20b137..9b5075ba6 100644 --- a/opendbc/honda_crv_touring_2016_can_generated.dbc +++ b/opendbc/honda_crv_touring_2016_can_generated.dbc @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -123,7 +124,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -226,6 +227,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,6 +237,7 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; diff --git a/opendbc/honda_fit_ex_2018_can_generated.dbc b/opendbc/honda_fit_ex_2018_can_generated.dbc index 4103fa29c..de9aca953 100644 --- a/opendbc/honda_fit_ex_2018_can_generated.dbc +++ b/opendbc/honda_fit_ex_2018_can_generated.dbc @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -123,7 +124,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -226,6 +227,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,6 +237,7 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; diff --git a/opendbc/honda_fit_hybrid_2018_can_generated.dbc b/opendbc/honda_fit_hybrid_2018_can_generated.dbc new file mode 100644 index 000000000..8d3db09ec --- /dev/null +++ b/opendbc/honda_fit_hybrid_2018_can_generated.dbc @@ -0,0 +1,350 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT" + + +CM_ "Imported file _comma.dbc starts here" +BO_ 512 GAS_COMMAND: 6 EON + SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR + SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR + SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR + SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR + SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR + +BO_ 513 GAS_SENSOR: 6 INTERCEPTOR + SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" EON + SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" EON + SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON + SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON + +VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; + + +CM_ "Imported file _dual_can_nidec_2018.dbc starts here" +VERSION "" + + +NS_ : + NS_DESC_ + CM_ + BA_DEF_ + BA_ + VAL_ + CAT_DEF_ + CAT_ + FILTER + BA_DEF_DEF_ + EV_DATA_ + ENVVAR_DATA_ + SGTYPE_ + SGTYPE_VAL_ + BA_DEF_SGTYPE_ + BA_SGTYPE_ + SIG_TYPE_REF_ + VAL_TABLE_ + SIG_GROUP_ + SIG_VALTYPE_ + SIGTYPE_VALTYPE_ + BO_TX_BU_ + BA_DEF_REL_ + BA_REL_ + BA_DEF_DEF_REL_ + BU_SG_REL_ + BU_EV_REL_ + BU_BO_REL_ + SG_MUL_VAL_ + +BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON + +BO_ 344 ENGINE_DATA: 8 PCM + SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON + SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 380 POWERTRAIN_DATA: 8 PCM + SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON + SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON + SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "" EON + SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "" EON + SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "" EON + SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "" EON + SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON + SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 420 VSA_STATUS: 8 VSA + SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 432 STANDSTILL: 7 VSA + SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON + SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 464 WHEEL_SPEEDS: 8 VSA + SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 506 BRAKE_COMMAND: 8 ADAS + SG_ ZEROS_BOH : 7|12@0+ (1,0) [0|3] "" XXX + SG_ BRAKE_PUMP_REQUEST : 11|1@0+ (1,0) [0|1] "" EBCM + SG_ ZEROS_BOH2 : 10|3@0+ (1,0) [0|7] "" XXX + SG_ CRUISE_BOH2 : 23|3@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_BOH3 : 19|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM + SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_0X80 : 31|8@0+ (1,0) [0|1] "" EBCM + SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM + SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM + SG_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" EBCM + SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM + SG_ COMPUTER_BRAKE : 55|10@0+ (1,0) [0|1] "" EBCM + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM + +BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA + SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON + SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON + SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 773 SEATBELT_STATUS: 7 BDY + SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON + SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON + SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 777 LOCK_STATUS: 8 XXX + SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON + SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 780 ACC_HUD: 8 ADAS + SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY + SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY + SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY + SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY + SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY + SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY + SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY + SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY + SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY + SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY + SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY + SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY + SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY + SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY + SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY + SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY + +BO_ 804 CRUISE: 8 PCM + SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON + SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON + SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON + SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON + SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON + SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 829 LKAS_HUD: 5 ADAS + SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY + SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY + SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY + SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY + SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY + SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY + SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY + SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY + SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY + SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY + SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY + SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY + SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY + SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY + SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY + SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY + SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY + SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY + +BO_ 892 CRUISE_PARAMS: 8 PCM + SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +BO_ 1029 DOORS_STATUS: 8 BDY + SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON + SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; +CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; +CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; +CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; +CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; + + +VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; +VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; +VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; +VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; + +CM_ "honda_fit_hybrid_2018_can.dbc starts here" + + + +BO_ 145 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" EON + +BO_ 228 STEERING_CONTROL: 5 ADAS + SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS + SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS + SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS + SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS + SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS + +BO_ 304 GAS_PEDAL_2: 8 PCM + SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 342 STEERING_SENSORS: 6 EPS + SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON + SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON + +BO_ 399 STEER_STATUS: 7 EPS + SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON + SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 419 GEARBOX: 8 PCM + SG_ GEAR : 7|8@0+ (1,0) [0|256] "" EON + SG_ GEAR_SHIFTER : 35|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 422 SCM_BUTTONS: 8 SCM + SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON + SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON + SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON + SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 487 BRAKE_PRESSURE: 4 VSA + SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" EON + SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" EON + SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON + +BO_ 545 ECON_STATUS: 5 XXX + SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" EON + SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EON + +BO_ 660 SCM_FEEDBACK: 8 SCM + SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON + SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON + SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 862 HIGHBEAM_CONTROL: 8 ADAS + SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY + SG_ ZEROS_BOH_2 : 48|4@1+ (1,0) [0|15] "" XXX + SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX + SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 884 STALK_STATUS: 8 XXX + SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON + SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON + SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON + SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +BO_ 891 WIPERS: 8 XXX + SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +BO_ 927 RADAR_HUD: 8 ADAS + SG_ ZEROS_BOH : 7|17@0+ (1,0) [0|127] "" BDY + SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|15] "" BDY + SG_ ZEROS_BOH2 : 31|8@0+ (1,0) [0|127] "" BDY + SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|15] "" BDY + SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|15] "" BDY + SG_ LEAD_SPEED : 39|9@0+ (1,0) [0|127] "" BDY + SG_ LEAD_STATE : 46|3@0+ (1,0) [0|127] "" BDY + SG_ LEAD_DISTANCE : 43|5@0+ (1,0) [0|31] "" BDY + SG_ ZEROS_BOH3 : 54|7@0+ (1,0) [0|127] "" BDY + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY + +CM_ SG_ 419 GEAR "10 = reverse, 11 = transition"; +CM_ SG_ 420 BRAKE_HOLD_RELATED "On when Brake Hold engaged"; + +VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; +VAL_ 419 GEAR_SHIFTER 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; +VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; +VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; +VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; + +CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/honda_insight_ex_2019_can_generated.dbc b/opendbc/honda_insight_ex_2019_can_generated.dbc index cbeff828b..3cc764698 100644 --- a/opendbc/honda_insight_ex_2019_can_generated.dbc +++ b/opendbc/honda_insight_ex_2019_can_generated.dbc @@ -37,6 +37,12 @@ NS_ : BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS @@ -118,15 +124,26 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON - SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX - SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX - SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM - SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX - SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (1,0) [0|0] "" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX @@ -173,16 +190,16 @@ BO_ 773 SEATBELT_STATUS: 7 BDY SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM - SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CAR_SPEED : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY @@ -200,8 +217,8 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX - SG_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX @@ -265,6 +282,10 @@ BO_ 891 STALK_STATUS_2: 8 XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; + VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; CM_ "honda_insight_ex_2019_can.dbc starts here" diff --git a/opendbc/honda_odyssey_exl_2018_generated.dbc b/opendbc/honda_odyssey_exl_2018_generated.dbc index 1bc6e96c1..2899dba67 100644 --- a/opendbc/honda_odyssey_exl_2018_generated.dbc +++ b/opendbc/honda_odyssey_exl_2018_generated.dbc @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -123,7 +124,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -226,6 +227,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,6 +237,7 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; diff --git a/opendbc/honda_odyssey_extreme_edition_2018_china_can.dbc b/opendbc/honda_odyssey_extreme_edition_2018_china_can_generated.dbc similarity index 84% rename from opendbc/honda_odyssey_extreme_edition_2018_china_can.dbc rename to opendbc/honda_odyssey_extreme_edition_2018_china_can_generated.dbc index 6bdcaab04..f8565c03b 100644 --- a/opendbc/honda_odyssey_extreme_edition_2018_china_can.dbc +++ b/opendbc/honda_odyssey_extreme_edition_2018_china_can_generated.dbc @@ -1,48 +1,67 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT" + + +CM_ "Imported file _comma.dbc starts here" +BO_ 512 GAS_COMMAND: 6 EON + SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR + SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR + SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR + SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR + SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR + +BO_ 513 GAS_SENSOR: 6 INTERCEPTOR + SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" EON + SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" EON + SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON + SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON + +VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; + + +CM_ "Imported file _honda_2017.dbc starts here" VERSION "" NS_ : - NS_DESC_ - CM_ - BA_DEF_ - BA_ - VAL_ - CAT_DEF_ - CAT_ - FILTER - BA_DEF_DEF_ - EV_DATA_ - ENVVAR_DATA_ - SGTYPE_ - SGTYPE_VAL_ - BA_DEF_SGTYPE_ - BA_SGTYPE_ - SIG_TYPE_REF_ - VAL_TABLE_ - SIG_GROUP_ - SIG_VALTYPE_ - SIGTYPE_VALTYPE_ - BO_TX_BU_ - BA_DEF_REL_ - BA_REL_ - BA_DEF_DEF_REL_ - BU_SG_REL_ - BU_EV_REL_ - BU_BO_REL_ - SG_MUL_VAL_ - -BS_: - -BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON INTERCEPTOR + NS_DESC_ + CM_ + BA_DEF_ + BA_ + VAL_ + CAT_DEF_ + CAT_ + FILTER + BA_DEF_DEF_ + EV_DATA_ + ENVVAR_DATA_ + SGTYPE_ + SGTYPE_VAL_ + BA_DEF_SGTYPE_ + BA_SGTYPE_ + SIG_TYPE_REF_ + VAL_TABLE_ + SIG_GROUP_ + SIG_VALTYPE_ + SIGTYPE_VALTYPE_ + BO_TX_BU_ + BA_DEF_REL_ + BA_REL_ + BA_DEF_DEF_REL_ + BU_SG_REL_ + BU_EV_REL_ + BU_BO_REL_ + SG_MUL_VAL_ +BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - SG_ ZEROS : 23|16@0+ (1,0) [0|15000] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON @@ -57,6 +76,16 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON +BO_ 420 VSA_STATUS: 8 VSA + SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON + SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON @@ -79,38 +108,27 @@ BO_ 490 VEHICLE_DYNAMICS: 8 VSA BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM - SG_ ZEROS_BOH : 13|5@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_BOH2 : 23|3@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_BOH3 : 19|1@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM - SG_ SET_ME_0X80 : 31|8@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM + SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM - SG_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ ZEROS_BOH4 : 55|8@0+ (1,0) [0|0] "" EBCM + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX + SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM -BO_ 512 GAS_COMMAND: 6 EON - SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR - SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR - SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" INTERCEPTOR - SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" INTERCEPTOR - -BO_ 513 GAS_SENSOR: 6 INTERCEPTOR - SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" EON - SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" EON - SG_ STATE : 39|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON - BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON @@ -184,7 +202,7 @@ BO_ 829 LKAS_HUD: 5 ADAS SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY - SG_ BOH2 : 23|2@0+ (1,0) [0|4] "" BDY + SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY @@ -199,6 +217,35 @@ BO_ 892 CRUISE_PARAMS: 8 PCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON +BO_ 1029 DOORS_STATUS: 8 BDY + SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON + SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; +CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; +CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; +CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; +CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; +CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; + + +VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; +VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; +VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; +VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; +VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; + +CM_ "honda_odyssey_extreme_edition_2018_china_can.dbc starts here" + + + BO_ 316 GAS_PEDAL: 8 PCM SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON @@ -229,15 +276,6 @@ BO_ 404 STEERING_CONTROL: 4 EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EPS SG_ STEER_TORQUE : 7|16@0- (-1,0) [-32767|32767] "" EPS -BO_ 420 VSA_STATUS: 8 VSA - SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON - SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX - SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - BO_ 422 SCM_BUTTONS: 8 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON @@ -274,23 +312,7 @@ BO_ 1302 ODOMETER: 8 XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - - - -CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; -CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; -CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; -CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; -CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; -CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; -CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; CM_ SG_ 401 GEAR "10 = reverse, 11 = transition"; -VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; -VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; -VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; -VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; -VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; -VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; VAL_ 399 STEER_STATUS 5 "fault" 4 "no_torque_alert_2" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 401 GEAR_SHIFTER 32 "L" 16 "S" 8 "D" 4 "N" 2 "R" 1 "P" ; VAL_ 401 GEAR 7 "L" 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; diff --git a/opendbc/honda_pilot_touring_2017_can_generated.dbc b/opendbc/honda_pilot_touring_2017_can_generated.dbc index c19871b9e..223aa1b27 100644 --- a/opendbc/honda_pilot_touring_2017_can_generated.dbc +++ b/opendbc/honda_pilot_touring_2017_can_generated.dbc @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -123,7 +124,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -226,6 +227,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,6 +237,7 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; diff --git a/opendbc/honda_ridgeline_black_edition_2017_can_generated.dbc b/opendbc/honda_ridgeline_black_edition_2017_can_generated.dbc index 6d8186c19..8572b0b5e 100644 --- a/opendbc/honda_ridgeline_black_edition_2017_can_generated.dbc +++ b/opendbc/honda_ridgeline_black_edition_2017_can_generated.dbc @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -123,7 +124,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -226,6 +227,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,6 +237,7 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; diff --git a/opendbc/hyundai_kia_generic.dbc b/opendbc/hyundai_kia_generic.dbc index bb1c06e09..cb2e0b5d7 100644 --- a/opendbc/hyundai_kia_generic.dbc +++ b/opendbc/hyundai_kia_generic.dbc @@ -1421,3 +1421,26 @@ BO_ 512 EMS20: 6 EMS SG_ FCO : 0|16@1+ (0.128,0.0) [0.0|8388.48] "ul" CLU,CUBIS,FPCM,IBOX SG_ CF_Ems_PumpTPres : 16|8@1+ (3.137254902,0.0) [0.0|800.0] "kPa" FPCM,IBOX SG_ Split_Stat : 32|1@1+ (1.0,0.0) [0.0|1.0] "" FPCM + +BO_ 909 FCA11: 8 FCA + SG_ CF_VSM_Prefill : 0|1@1+ (1,0) [0|1] "" ESC + SG_ CF_VSM_HBACmd : 1|2@1+ (1,0) [0|3] "" ESC + SG_ CF_VSM_Warn : 3|2@1+ (1,0) [0|3] "" ACU,CLU,ESC + SG_ CF_VSM_BeltCmd : 5|3@1+ (1,0) [0|7] "" ESC + SG_ CR_VSM_DecCmd : 8|8@1+ (0.01,0) [0|2.55] "g" ESC + SG_ FCA_Status : 18|2@1+ (1,0) [0|3] "" ACU,CLU,ESC + SG_ FCA_CmdAct : 20|1@1+ (1,0) [0|1] "" ESC + SG_ FCA_StopReq : 21|1@1+ (1,0) [0|1] "" CLU,ESC + SG_ FCA_DrvSetStatus : 22|3@1+ (1,0) [0|7] "" CLU,ESC + SG_ CF_VSM_DecCmdAct : 31|1@1+ (1,0) [0|1] "" ESC + SG_ FCA_Failinfo : 32|3@1+ (1,0) [0|7] "" ACU,CLU,ESC + SG_ CR_FCA_Alive : 56|4@1+ (1,0) [0|15] "" ESC + SG_ CR_FCA_ChkSum : 60|4@1+ (1,0) [0|15] "" ESC + +BO_ 905 SCC14: 8 SCC + SG_ ComfortBandUpper : 0|6@1+ (0.02,0) [0|1.26] "m/s^2" ESC + SG_ ComfortBandLower : 6|6@1+ (0.02,0) [0|1.26] "m/s^2" ESC + SG_ JerkUpperLimit : 12|7@1+ (0.1,0) [0|12.7] "m/s^3" ESC + SG_ JerkLowerLimit : 19|7@1+ (0.1,0) [0|12.7] "m/s^3" ESC + SG_ SCCMode : 32|3@1+ (1,0) [0|7] "" ESC + diff --git a/opendbc/lexus_ct200h_2018_pt_generated.dbc b/opendbc/lexus_ct200h_2018_pt_generated.dbc index 6e41a0218..79706e0b1 100644 --- a/opendbc/lexus_ct200h_2018_pt_generated.dbc +++ b/opendbc/lexus_ct200h_2018_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/lexus_gs300h_2017_pt_generated.dbc b/opendbc/lexus_gs300h_2017_pt_generated.dbc index d6de09493..7dd2f7d5e 100644 --- a/opendbc/lexus_gs300h_2017_pt_generated.dbc +++ b/opendbc/lexus_gs300h_2017_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/lexus_is_2018_pt_generated.dbc b/opendbc/lexus_is_2018_pt_generated.dbc index 10a0096f0..c0b653f54 100644 --- a/opendbc/lexus_is_2018_pt_generated.dbc +++ b/opendbc/lexus_is_2018_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -353,12 +353,15 @@ BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX +BO_ 581 GAS_PEDAL_ALT: 5 XXX + SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX + BO_ 705 GAS_PEDAL: 8 XXX SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PEDAL : 55|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX - SG_ STEER_TORQUE_EPS : 47|16@0- (0.66,0) [-20000|20000] "" XXX + SG_ STEER_TORQUE_EPS : 47|16@0- (1.30,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX @@ -377,6 +380,9 @@ BO_ 1009 PCM_CRUISE_ALT: 8 XXX SG_ CRUISE_STATE : 10|1@0+ (1,0) [0|1] "" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX +BO_ 1599 LIGHT_STALK_ISH: 8 SCM + SG_ AUTO_HIGH_BEAM : 19|1@0+ (1,0) [0|1] "" XXX + CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; diff --git a/opendbc/lexus_is_hybrid_2017_pt_generated.dbc b/opendbc/lexus_is_hybrid_2017_pt_generated.dbc index 7477d231b..528e3d7bf 100644 --- a/opendbc/lexus_is_hybrid_2017_pt_generated.dbc +++ b/opendbc/lexus_is_hybrid_2017_pt_generated.dbc @@ -357,7 +357,7 @@ BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX - SG_ STEER_TORQUE_EPS : 47|16@0- (1.0,0) [-20000|20000] "" XXX + SG_ STEER_TORQUE_EPS : 47|16@0- (1.00,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX @@ -385,4 +385,4 @@ CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; CM_ SG_ 1009 SET_SPEED "units seem to be whatever the car is set to"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; -VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; +VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; \ No newline at end of file diff --git a/opendbc/lexus_rx_350_2016_pt_generated.dbc b/opendbc/lexus_rx_350_2016_pt_generated.dbc index b132c86dd..be989c1b2 100644 --- a/opendbc/lexus_rx_350_2016_pt_generated.dbc +++ b/opendbc/lexus_rx_350_2016_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/lexus_rx_hybrid_2017_pt_generated.dbc b/opendbc/lexus_rx_hybrid_2017_pt_generated.dbc index e11ee65b6..62fd8f913 100644 --- a/opendbc/lexus_rx_hybrid_2017_pt_generated.dbc +++ b/opendbc/lexus_rx_hybrid_2017_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/mazda_cx5_gt_2017.dbc b/opendbc/mazda_cx5_gt_2017.dbc index 3926e2dfb..971b13611 100644 --- a/opendbc/mazda_cx5_gt_2017.dbc +++ b/opendbc/mazda_cx5_gt_2017.dbc @@ -40,21 +40,21 @@ BO_ 117 STEER_RELATED: 8 XXX SG_ CTR : 7|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_1 : 48|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_2 : 49|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_3 : 55|1@0+ (1,0) [0|63] "" XXX - SG_ NEW_SIGNAL_4 : 54|4@0+ (1,0) [0|31] "" XXX SG_ NEW_SIGNAL_5 : 50|1@0+ (1,0) [0|1] "" XXX - SG_ STEER_TORQUE : 19|12@0+ (1,0) [0|255] "" XXX - SG_ STEER_ANGLE_2 : 39|16@0+ (1,0) [0|131071] "" XXX + SG_ NEW_SIGNAL_4 : 54|4@0+ (1,0) [0|31] "" XXX + SG_ NEW_SIGNAL_3 : 55|1@0+ (1,0) [0|63] "" XXX + SG_ STEER_ANGLE_2 : 39|16@0+ (0.1,-1800) [0|131071] "" XXX + SG_ STEER_TORQUE : 19|12@0+ (1,-2000) [0|255] "" XXX BO_ 118 RPM_RELATED: 8 XXX SG_ CTR : 7|8@0+ (1,0) [0|127] "" XXX SG_ NEW_SIGNAL_2 : 19|12@0+ (1,0) [0|4095] "" XXX BO_ 514 ENGINE_DATA: 8 XXX - SG_ RPM : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ CHKSUM : 56|8@1+ (1,0) [0|127] "" XXX - SG_ SPEED : 23|16@0+ (0.01,0) [0|32767] "KPH" XXX - SG_ PEDAL_GAS : 39|12@0+ (1,0) [0|255] "" XXX + SG_ PEDAL_GAS : 39|12@0+ (0.002778,0) [0|255] "%" XXX + SG_ CHKSUM : 63|8@0+ (1,0) [0|127] "" XXX + SG_ RPM : 7|16@0+ (0.25,0) [0|8500] "rpm" XXX + SG_ SPEED : 23|16@0+ (0.01,0) [0|32767] "kph" XXX BO_ 357 PEDALS: 8 XXX SG_ NEW_SIGNAL_6 : 31|4@0+ (1,0) [0|1] "" XXX @@ -71,28 +71,30 @@ BO_ 357 PEDALS: 8 XXX SG_ NO_BRAKE_2 : 15|1@0+ (1,0) [0|7] "" XXX BO_ 533 WHEEL_SPEEDS: 8 XXX - SG_ FL : 7|16@0+ (0.01,-100) [0|16383] "" XXX - SG_ RL : 39|16@0+ (0.01,-100) [0|15] "" XXX - SG_ RR : 55|16@0+ (0.01,-100) [0|65535] "" XXX - SG_ FR : 23|16@0+ (0.01,-100) [0|65535] "" XXX + SG_ FL : 7|16@0+ (0.01,-100) [0|16383] "kph" XXX + SG_ FR : 23|16@0+ (0.01,-100) [0|65535] "kph" XXX + SG_ RL : 39|16@0+ (0.01,-100) [0|15] "kph" XXX + SG_ RR : 55|16@0+ (0.01,-100) [0|65535] "kph" XXX BO_ 134 STEER2: 8 XXX - SG_ NEW_SIGNAL_2 : 48|3@1+ (1,0) [0|7] "" XXX SG_ CTR : 22|4@0+ (1,0) [0|7] "" XXX SG_ NEW_SIGNAL_4 : 23|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_5 : 18|3@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_7 : 24|3@1+ (1,0) [0|7] "" XXX SG_ CTR_2 : 28|3@1+ (1,0) [0|7] "" XXX - SG_ NEW_SIGNAL_1 : 63|2@0+ (1,0) [0|255] "" XXX + SG_ STEER_ANGLE_ROUGH : 26|11@0+ (1,-1000) [0|15] "" XXX + SG_ NEW_SIGNAL_5 : 18|3@0+ (1,0) [0|1] "" XXX SG_ STEER_ANGLE : 7|16@0+ (0.1,-1600) [-500|500] "deg" XXX - SG_ STEER_ANGLE_ROUGH : 39|8@0- (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_1 : 63|2@0+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_3 : 55|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 47|8@0+ (1,0) [0|7] "" XXX BO_ 576 STEER_TORQUE: 8 XXX - SG_ NEW_SIGNAL_2 : 39|8@0+ (1,0) [0|127] "" XXX - SG_ NEW_SIGNAL_1 : 20|4@1+ (1,0) [0|255] "" XXX - SG_ STEER_TORQUE_SENSOR : 7|16@0+ (0.5,-15000) [0|255] "" XXX + SG_ NEW_SIGNAL_1 : 23|4@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 47|1@0+ (1,0) [0|1] "" XXX - SG_ STEER_TORQUE_MOTOR : 46|20@0- (0.01,0) [-3000|3000] "deg/s" XXX + SG_ SENSOR1 : 39|8@0+ (1,-128) [0|127] "" XXX + SG_ STEER_TORQUE_MOTOR : 46|15@0- (0.1,0) [-3000|3000] "tbd" XXX + SG_ NEW_SIGNAL_2 : 62|4@0+ (1,0) [0|31] "" XXX + SG_ NEW_SIGNAL_4 : 15|8@0+ (1,0) [0|127] "" XXX + SG_ STEER_TORQUE_SENSOR : 7|8@0+ (1,-127) [-85|85] "" XXX BO_ 577 STEER_RATE: 8 XXX SG_ STEER_ANGLE_RATE : 23|16@0+ (0.25,-8192) [0|1] "deg/s" XXX @@ -119,6 +121,7 @@ BO_ 605 CAM_PEDESTRIAN: 8 XXX SG_ PED_BRAKE : 3|3@0+ (1,0) [0|7] "" XXX SG_ RST_CTR : 23|6@0+ (1,0) [0|63] "" XXX SG_ S1 : 29|4@0+ (1,0) [0|31] "" XXX + SG_ BRAKE_WARNING : 25|1@0+ (1,0) [0|1] "" XXX BO_ 578 CAM_LANETRACK: 8 XXX SG_ CHKSUM : 63|8@0+ (1,0) [0|255] "" XXX @@ -132,14 +135,15 @@ BO_ 578 CAM_LANETRACK: 8 XXX SG_ LINE1 : 3|10@0+ (1,-686) [0|1] "" XXX BO_ 579 CAM_LKAS: 8 XXX - SG_ LKAS_REQUEST : 3|12@0+ (1,-2048) [0|2048] "" XXX SG_ CTR : 7|4@0+ (1,0) [0|15] "" XXX SG_ ERR_BIT_1 : 16|1@0+ (1,0) [0|1] "" XXX SG_ CHKSUM : 63|8@0+ (1,0) [0|15] "" XXX SG_ LINE_NOT_VISIBLE : 19|1@0+ (1,0) [0|1] "" XXX - SG_ BIT_1 : 29|1@0+ (1,0) [0|1] "" XXX SG_ BIT_2 : 33|1@0+ (1,0) [0|1] "" XXX SG_ ERR_BIT_2 : 30|1@0+ (1,0) [0|1] "" XXX + SG_ BIT_1 : 29|1@0+ (1,0) [0|1] "" XXX + SG_ LDW : 23|1@0+ (1,0) [0|1] "" XXX + SG_ LKAS_REQUEST : 3|12@0+ (1,-2048) [0|2048] "" XXX BO_ 580 CAM_DISTANCE: 8 XXX SG_ S1 : 0|8@1+ (1,0) [0|127] "" XXX @@ -170,7 +174,17 @@ BO_ 863 CAM_STATUS: 8 XXX SG_ NEW_SIGNAL_6 : 0|3@1+ (1,0) [0|7] "" XXX SG_ FORWARD_COLLISION : 40|8@1+ (1,0) [0|7] "" XXX -BO_ 1157 CAM_Empty2: 8 XXX +BO_ 1157 CAM_SETTINGS: 8 XXX + SG_ NEW_SIGNAL_2 : 14|1@0+ (1,0) [0|1] "" XXX + SG_ SBS_WARNING_DISTANCE : 25|2@0+ (1,0) [0|127] "" XXX + SG_ SBS_SCBC : 28|2@0+ (1,0) [0|7] "" XXX + SG_ LKAS_ASSIT_TIMING : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LKAS_SENSETIVITY : 10|1@0+ (1,0) [0|1] "" XXX + SG_ ILKAS_NTERVENTION_ON2 : 17|1@0+ (1,0) [0|255] "" XXX + SG_ LANEE_DEPARTURE_ALERT : 16|2@0+ (1,0) [0|1] "" XXX + SG_ LKAS_INERVENTION_ON1 : 15|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_1 : 12|1@0+ (1,0) [0|7] "" XXX + SG_ WARNING : 11|1@0+ (1,0) [0|1] "" XXX BO_ 1160 CAM_Empty3: 8 XXX SG_ NEW_SIGNAL_1 : 47|24@0+ (1,0) [0|16777215] "" XXX @@ -189,6 +203,8 @@ BO_ 1088 CAM_LANEINFO: 8 XXX SG_ BIT1 : 6|1@0+ (1,0) [0|65535] "" XXX SG_ LINE_NOT_VISIBLE : 1|1@0+ (1,0) [0|1] "" XXX SG_ LINE_VISIBLE : 0|1@0+ (1,0) [0|3] "" XXX + SG_ LDW_WARN_RL : 58|1@0+ (1,0) [0|1] "" XXX + SG_ LDW_WARN_LL : 57|1@0+ (1,0) [0|1] "" XXX BO_ 1479 NEW_MSG_470: 8 XXX @@ -199,7 +215,6 @@ BO_ 1446 NEW_MSG_a600: 8 XXX BO_ 1416 MSG_18: 8 XXX BO_ 1086 DOORS: 8 XXX - SG_ DOOR_OPEN : 30|1@0+ (1,0) [0|255] "" XXX SG_ LEFTGATE : 32|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_3 : 53|1@0+ (1,0) [0|255] "" XXX SG_ KEYFOB_HORN : 2|1@0+ (1,0) [0|1] "" XXX @@ -211,6 +226,7 @@ BO_ 1086 DOORS: 8 XXX SG_ BL : 35|1@0+ (1,0) [0|1] "" XXX SG_ FR : 36|1@0+ (1,0) [0|1] "" XXX SG_ FL : 37|1@0+ (1,0) [0|255] "" XXX + SG_ DOORS_UNLOCKED : 30|1@0+ (1,0) [0|255] "" XXX BO_ 977 TWO_STATES: 8 XXX SG_ NEW_SIGNAL_1 : 50|1@1+ (1,0) [0|7] "" XXX @@ -232,6 +248,7 @@ BO_ 1085 MSG_12: 8 XXX BO_ 159 MSG_11: 8 XXX SG_ NEW_SIGNAL_1 : 50|4@1+ (1,0) [0|15] "" XXX + SG_ INCREASEING : 39|8@0+ (1,0) [0|255] "" XXX BO_ 1278 NEW_MSG_3: 8 XXX SG_ NEW_SIGNAL_2 : 23|8@0+ (1,0) [0|255] "" XXX @@ -247,7 +264,7 @@ BO_ 1277 NEW_MSG_10: 8 XXX SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX SG_ counter : 7|8@0+ (1,0) [0|255] "" XXX -BO_ 1275 MSG_2017_5: 8 XXX +BO_ 1275 2017_5: 8 XXX SG_ counter : 4|5@0+ (1,0) [0|255] "" XXX BO_ 1274 NEW_MSG_12: 8 XXX @@ -266,15 +283,18 @@ BO_ 1078 HVAC: 8 XXX SG_ NEW_SIGNAL_3 : 23|1@0+ (1,0) [0|65535] "" XXX SG_ NEW_SIGNAL_4 : 56|5@0+ (1,0) [0|255] "" XXX -BO_ 1056 NEW_MSG_13: 8 XXX - SG_ BIG_COUNTER_MAYBE : 55|16@0+ (1,0) [0|255] "" XXX +BO_ 1056 CHECK_AND_TEMP: 8 XXX SG_ NEW_SIGNAL_1 : 29|6@0+ (1,0) [0|255] "" XXX SG_ counter_or_GEAR : 15|8@0+ (1,0) [0|255] "" XXX - SG_ INCREASING : 7|8@0+ (1,0) [0|255] "" XXX SG_ CTR : 23|8@0+ (1,0) [0|255] "" XXX SG_ STANDSTILL : 32|1@0+ (1,0) [0|255] "" XXX + SG_ COOLANT_TEMP : 7|8@0+ (1,0) [0|255] "" XXX + SG_ LOW_ENGINE_OIL_PRESSURE : 43|1@0+ (1,0) [0|1] "" XXX + SG_ CHECK_FUEL_CAP : 40|1@0+ (1,0) [0|1] "" XXX + SG_ CHARGING_SYSTEM_MALFUNCTION : 38|1@0+ (1,0) [0|1] "" XXX + SG_ OUTDOOR_TEMP : 63|8@0+ (0.25,-63) [0|255] "cel" XXX -BO_ 1045 MOVING: 8 XXX +BO_ 1045 TRACTION: 8 XXX SG_ NEW_SIGNAL_2 : 20|1@0+ (1,0) [0|3] "" XXX SG_ CTR2 : 19|4@0+ (1,0) [0|31] "" XXX SG_ CTR3 : 8|4@1+ (1,0) [0|15] "" XXX @@ -282,6 +302,12 @@ BO_ 1045 MOVING: 8 XXX SG_ CTR1 : 53|6@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_1 : 54|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE : 55|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_WARNING : 2|1@0+ (1,0) [0|1] "" XXX + SG_ ABS_MALFUNCTION : 1|2@0+ (1,0) [0|3] "" XXX + SG_ DSC_OFF : 3|1@0+ (1,0) [0|1] "" XXX + SG_ TCS_DCS_MALFUNCTION : 6|2@0+ (1,0) [0|3] "" XXX + SG_ LOUD_BEEP : 28|1@0+ (1,0) [0|1] "" XXX + SG_ TPMS_WARNING_DOUBLE_BLINK : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1034 MSG_07: 8 XXX SG_ NEW_SIGNAL_1 : 6|3@0+ (1,0) [0|3] "" XXX @@ -315,17 +341,17 @@ BO_ 867 NEW_MSG_17: 8 XXX BO_ 130 STEER: 8 XXX SG_ NEW_SIGNAL_5 : 55|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_6 : 63|8@0+ (1,0) [0|255] "" XXX - SG_ CTR : 47|8@0+ (1,0) [0|255] "" XXX - SG_ CTR_2 : 35|4@0+ (1,0) [0|255] "" XXX + SG_ CTR : 47|4@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 23|16@0+ (0.05,-1600) [500|-500] "deg" XXX + SG_ CHKSUM_MAYBE : 39|8@0+ (1,0) [0|255] "" XXX -BO_ 120 NEW_MSG_18: 8 XXX +BO_ 120 BRAKE: 8 XXX SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 39|8@0+ (1,0) [0|255] "" XXX SG_ CTR : 55|8@0+ (1,0) [0|255] "" XXX + SG_ BRAKE_PRESSURE : 39|8@0+ (1,0) [0|255] "" XXX BO_ 304 GEAR_RELATED: 8 XXX SG_ NEW_SIGNAL_1 : 55|8@0+ (1,0) [0|255] "" XXX @@ -397,22 +423,24 @@ BO_ 154 BLINK_INFO: 8 XXX SG_ REAR_WIPER_ON : 0|1@0+ (1,0) [0|1] "" XXX SG_ WIPER_LO : 33|1@1+ (1,0) [0|31] "" XXX SG_ WIPER_HI : 34|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAMS : 5|2@0+ (1,0) [0|3] "" XXX + SG_ HIGH_BEAMS : 7|2@0+ (1,0) [0|3] "" XXX + SG_ LBEAM1 : 17|1@0+ (1,0) [0|1] "" XXX + SG_ LBEAM2 : 50|1@0+ (1,0) [0|1] "" XXX + SG_ LBEAM3 : 60|1@0+ (1,0) [0|1] "" XXX BO_ 145 TURN_SWITCH: 8 XXX - SG_ NEW_SIGNAL_1 : 37|1@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_2 : 36|1@0+ (1,0) [0|3] "" XXX - SG_ TURN : 38|1@0+ (1,0) [0|3] "" XXX - SG_ TURN_LEFT_SWITCH : 13|1@0+ (1,0) [0|255] "" XXX - SG_ TURN_RIGHT_SWITCH : 12|1@1+ (1,0) [0|3] "" XXX SG_ HAZARD : 10|1@0+ (1,0) [0|1] "" XXX + SG_ TURN_RIGHT_SWITCH : 12|1@0+ (1,0) [0|3] "" XXX + SG_ TURN_LEFT_SWITCH : 13|1@0+ (1,0) [0|255] "" XXX SG_ CTR : 27|4@0+ (1,0) [0|255] "" XXX + SG_ CHKSUM : 39|8@0+ (1,0) [0|15] "" XXX BO_ 80 MSG_04: 8 XXX SG_ NEW_SIGNAL_1 : 25|1@0+ (1,0) [0|1] "" XXX SG_ SIGNAL : 24|1@0+ (1,0) [0|1] "" XXX BO_ 978 MSG_03: 8 XXX - SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_4 : 31|8@0+ (1,0) [0|255] "" XXX @@ -420,6 +448,7 @@ BO_ 978 MSG_03: 8 XXX SG_ NEW_SIGNAL_6 : 47|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_7 : 55|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_8 : 63|8@0+ (1,0) [0|255] "" XXX + SG_ CTR : 1|2@0+ (1,0) [0|255] "" XXX BO_ 607 NEW_MSG_25: 8 XXX @@ -539,6 +568,8 @@ BO_ 540 CRZ_CTRL: 8 XXX SG_ ACC_GAS_MAYBE : 23|1@0+ (1,0) [0|31] "" XXX SG_ ACC_GAS_MAYBE2 : 29|1@0+ (1,0) [0|1] "" XXX SG_ CRZ_ACTIVE : 3|1@0+ (1,0) [0|1] "" XXX + SG_ HANDS_OFF_STEERING : 48|1@0+ (1,0) [0|1] "" XXX + SG_ HANDS_ON_STEER_WARN : 59|4@0+ (1,0) [0|255] "" XXX BO_ 539 CRZ_INFO: 8 XXX SG_ NEW_SIGNAL_1 : 17|1@0+ (1,0) [0|255] "" XXX @@ -546,10 +577,10 @@ BO_ 539 CRZ_INFO: 8 XXX SG_ NEW_SIGNAL_5 : 34|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_7 : 47|1@0+ (1,0) [0|255] "" XXX SG_ CTR1 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ CTR2 : 63|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 37|1@0+ (1,0) [0|255] "" XXX SG_ ACC_ACTIVE : 33|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_CMD : 31|10@0- (1,0) [0|1] "" XXX + SG_ CHKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 121 EPB: 8 XXX SG_ NEW_SIGNAL_1 : 4|4@0+ (1,0) [0|255] "" XXX @@ -565,30 +596,30 @@ BO_ 121 EPB: 8 XXX SG_ NEW_SIGNAL_11 : 45|1@0+ (1,0) [0|1] "" XXX SG_ EPB_ACTIVE : 29|1@0+ (1,0) [0|15] "" XXX -BO_ 1070 MSG_2017_1: 8 XXX +BO_ 1070 2017_1: 8 XXX -BO_ 1183 MSG_2017_2: 8 XXX +BO_ 1183 2017_2: 8 XXX -BO_ 1243 MSG_2017_3: 8 XXX +BO_ 1243 2017_3: 8 XXX SG_ NEW_SIGNAL_1 : 7|64@0+ (1,0) [0|18446744073709552000] "" XXX BO_ 1269 MSG_2017_4: 8 XXX SG_ NEW_SIGNAL_1 : 55|16@0+ (1,0) [0|18446744073709552000] "" XXX -BO_ 1178 MSG_2017_6: 8 XXX +BO_ 1178 2017_6: 8 XXX SG_ NEW_SIGNAL_1 : 7|64@0+ (1,0) [0|18446744073709552000] "" XXX -BO_ 1179 MSG_2017_7: 8 XXX +BO_ 1179 2017_7: 8 XXX SG_ NEW_SIGNAL_1 : 7|64@0+ (1,0) [0|18446744073709552000] "" XXX -BO_ 1435 MSG_2017_8: 8 XXX +BO_ 1435 2017_8: 8 XXX BO_ 253 NEW_MSG_7: 8 XXX SG_ NEW_SIGNAL_1 : 16|1@0+ (1,0) [0|65535] "" XXX - SG_ NEW_SIGNAL_2 : 41|1@0+ (1,0) [0|255] "" XXX SG_ CTR : 23|4@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_2 : 41|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 61|1@0+ (1,0) [0|255] "" XXX + SG_ CRZ_NOT_ACTIVE : 61|1@0+ (1,0) [0|255] "" XXX BO_ 359 NEW_MSG_11: 8 XXX SG_ NEW_SIGNAL_1 : 15|1@0+ (1,0) [0|255] "" XXX @@ -614,8 +645,10 @@ BO_ 512 NEW_MSG_30: 8 XXX SG_ NEW_SIGNAL_11 : 63|8@0+ (1,0) [0|255] "" XXX BO_ 515 MSG_01: 8 XXX - SG_ CTR : 39|8@0+ (1,0) [0|65535] "" XXX - SG_ CTR_2 : 47|8@0+ (1,0) [0|255] "" XXX + SG_ CTR : 39|4@0+ (1,0) [0|65535] "" XXX + SG_ CHKSUM : 47|8@0+ (1,0) [0|255] "" XXX + SG_ START1 : 6|1@0+ (1,0) [0|1] "" XXX + SG_ START2 : 28|5@0+ (1,0) [0|255] "" XXX BO_ 529 NEW_MSG_36: 8 XXX SG_ NEW_SIGNAL_1 : 22|5@0+ (1,0) [0|65535] "" XXX @@ -684,11 +717,44 @@ BO_ 1272 MSG_17: 8 XXX BO_ 1425 MSG_19: 8 XXX +BO_ 70 MOB1: 8 XXX + SG_ NEW_SIGNAL_1 : 1|3@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_2 : 14|6@0+ (1,0) [0|127] "" XXX + SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 30|6@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 38|6@0+ (1,0) [0|7] "" XXX + +BO_ 64 MOB2: 8 XXX + SG_ NEW_SIGNAL_1 : 7|2@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 10|3@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 16|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 24|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 35|4@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_6 : 0|3@1+ (1,0) [0|7] "" XXX + SG_ NEW_SIGNAL_7 : 13|3@0+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_8 : 15|2@0+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_9 : 19|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_10 : 31|6@0+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_11 : 37|1@0+ (1,0) [0|1] "" XXX + +BO_ 1171 MOB3: 8 XXX + +BO_ 1248 MOB4: 8 XXX + CM_ SG_ 605 PED_BRAKE "3: no brake, 4: brake"; +CM_ SG_ 605 BRAKE_WARNING "Flashing brake warning and audible alert for potential forward collision"; +CM_ SG_ 1157 SBS_WARNING_DISTANCE "1 far, 2 mid, 3 near"; +CM_ SG_ 1157 SBS_SCBC "1 off, 2 on"; +CM_ SG_ 1157 LKAS_ASSIT_TIMING "1 at, 0 before"; +CM_ SG_ 1157 LKAS_SENSETIVITY "0 low, 1 high"; +CM_ SG_ 1157 LANEE_DEPARTURE_ALERT "1 off, 2 on"; +CM_ SG_ 1157 WARNING "1 Rare, 0 often"; CM_ SG_ 1088 LANE_LINES "0 LKAS disabled, 1 no lines, 2 two lines, 3 left line, 4 right line"; +CM_ SG_ 1045 ABS_MALFUNCTION "off: 0, solid: 1, slow blink: 2, fast blink: 3"; CM_ SG_ 157 CAN_OFF "Disengage Cruise if enabled, if already disabled TURN it OFF "; CM_ SG_ 552 GEAR "0 P/N, 12 R, 2 D M1, 4 M2, 14 Shift"; CM_ SG_ 552 MORE_GEAR ""; +CM_ SG_ 540 HANDS_ON_STEER_WARN "0 no warning, b warning"; diff --git a/opendbc/subaru_crosstrek_2018.dbc b/opendbc/subaru_crosstrek_2018.dbc new file mode 100644 index 000000000..b766cdca8 --- /dev/null +++ b/opendbc/subaru_crosstrek_2018.dbc @@ -0,0 +1,369 @@ +VERSION "" + + +NS_ : + NS_DESC_ + CM_ + BA_DEF_ + BA_ + VAL_ + CAT_DEF_ + CAT_ + FILTER + BA_DEF_DEF_ + EV_DATA_ + ENVVAR_DATA_ + SGTYPE_ + SGTYPE_VAL_ + BA_DEF_SGTYPE_ + BA_SGTYPE_ + SIG_TYPE_REF_ + VAL_TABLE_ + SIG_GROUP_ + SIG_VALTYPE_ + SIGTYPE_VALTYPE_ + BO_TX_BU_ + BA_DEF_REL_ + BA_REL_ + BA_DEF_DEF_REL_ + BU_SG_REL_ + BU_EV_REL_ + BU_BO_REL_ + SG_MUL_VAL_ + +BS_: + +BU_: XXX X + + +BO_ 2 Steering: 8 XXX + SG_ Counter : 25|3@1+ (1,0) [0|7] "" XXX + SG_ Checksum : 32|8@1+ (1,0) [0|255] "" XXX + SG_ Steering_Angle : 7|16@0- (0.1,0) [0|65535] "" XXX + +BO_ 64 Throttle: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Off_Accel : 60|4@1+ (1,0) [0|7] "" XXX + SG_ NEW_SIGNAL_3 : 56|4@1+ (1,0) [0|255] "" XXX + SG_ Throttle_Cruise : 40|8@1+ (1,0) [0|255] "" XXX + SG_ Throttle_Combo : 55|8@1+ (1,0) [0|255] "" XXX + SG_ Throttle_Pedal : 32|8@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 48|7@1+ (1,0) [0|1] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|255] "" XXX + SG_ Engine_RPM : 16|12@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_1 : 12|4@1+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_4 : 28|5@1+ (1,0) [0|1] "" XXX + +BO_ 65 NEW_MSG_1: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_4 : 32|12@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 16|12@1+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_5 : 31|1@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_6 : 48|8@1+ (1,0) [0|63] "" XXX + SG_ NEW_SIGNAL_7 : 59|2@0+ (1,0) [0|255] "" XXX + +BO_ 72 NEW_MSG_2: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_3 : 40|16@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 38|3@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 16|8@1+ (1,0) [0|255] "" XXX + +BO_ 316 NEW_MSG_3: 8 XXX + +BO_ 326 Cruise_Buttons: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Signal1 : 12|30@1+ (1,0) [0|1073741823] "" XXX + SG_ Main : 42|1@1+ (1,0) [0|1] "" XXX + SG_ set : 43|1@1+ (1,0) [0|1] "" XXX + SG_ Resume : 44|1@1+ (1,0) [0|1] "" XXX + SG_ Signal2 : 45|19@1+ (1,0) [0|524287] "" XXX + +BO_ 315 G_Sensor: 8 XXX + SG_ longitudinal : 63|8@0- (1,0) [0|255] "" XXX + SG_ Latitudinal : 48|8@1- (1,0) [0|255] "" XXX + +BO_ 314 Wheel_Speeds: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ FR : 12|13@1+ (0.057,0) [0|255] "kph" XXX + SG_ RR : 25|13@1+ (0.057,0) [0|255] "kph" XXX + SG_ FL : 51|13@1+ (0.057,0) [0|255] "kph" XXX + SG_ RL : 38|13@1+ (0.057,0) [0|255] "kph" XXX + +BO_ 73 NEW_MSG_5: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_1 : 32|8@1+ (1,0) [0|4095] "" XXX + SG_ NEW_SIGNAL_2 : 24|8@1+ (1,0) [0|127] "" XXX + +BO_ 280 NEW_MSG_6: 8 XXX + SG_ NEW_SIGNAL_1 : 12|12@1- (1,0) [0|4095] "" XXX + SG_ NEW_SIGNAL_2 : 48|8@1- (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 61|1@1+ (1,0) [0|7] "" XXX + SG_ NEW_SIGNAL_4 : 40|4@1+ (1,0) [0|255] "" XXX + +BO_ 281 Steering_Torque: 8 XXX + SG_ checksum : 0|8@1+ (1,0) [0|3] "" XXX + SG_ counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Steer_Torque_Sensor : 16|11@1- (-1,0) [0|3] "" XXX + SG_ Steering_Angle : 32|16@1- (-0.0217,0) [0|255] "" X + SG_ Steer_Torque_Output : 48|11@1- (-1,0) [0|31] "" XXX + +BO_ 312 Brake_Pressure_L_R: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|31] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|3] "" XXX + SG_ Brake_2 : 56|8@1+ (1,0) [0|255] "" XXX + SG_ Brake_1 : 48|8@1+ (1,0) [0|255] "" XXX + +BO_ 313 Brake_Pedal: 8 XXX + SG_ Brake_Pedal_On : 34|1@1+ (1,0) [0|7] "" XXX + SG_ Brake_Pedal : 36|12@1+ (1,0) [0|65535] "" XXX + +BO_ 290 ES_LKAS: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ LKAS_Output : 16|13@1- (-1,0) [0|3] "" XXX + SG_ LKAS_Request : 29|1@0+ (1,0) [0|3] "" XXX + SG_ SET_1 : 12|1@0+ (1,0) [0|3] "" XXX + +BO_ 722 NEW_MSG_10: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_1 : 27|3@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 56|2@1+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_5 : 45|2@0+ (1,0) [0|3] "" XXX + +BO_ 544 ES_Brake: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Brake_Pressure : 16|16@1+ (1,0) [0|255] "" XXX + SG_ __Status : 36|4@1+ (1,0) [0|63] "" XXX + +BO_ 545 ES_Distance: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Signal1 : 12|20@1+ (1,0) [0|15] "" XXX + SG_ Signal2 : 32|24@1+ (1,0) [0|15] "" XXX + SG_ ACC_Cancel : 56|1@1+ (1,0) [0|1] "" XXX + SG_ ACC_Set : 57|1@1+ (1,0) [0|1] "" XXX + SG_ ACC_Resume : 58|1@1+ (1,0) [0|1] "" XXX + SG_ Signal3 : 59|5@1+ (1,0) [0|1] "" XXX + +BO_ 546 ES_Status: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ RPM : 16|12@1+ (1,0) [0|255] "" XXX + SG_ Cruise_Activated : 29|1@0+ (1,0) [0|3] "" XXX + SG_ Cruise_Brake : 30|1@1+ (1,0) [0|3] "" XXX + +BO_ 554 ES_Blank: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ SET_65535 : 39|16@1+ (1,0) [0|16777215] "" XXX + SG_ SET_1 : 13|1@1+ (1,0) [0|7] "" XXX + +BO_ 557 NEW_MSG_14: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + +BO_ 576 CruiseControl: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_5 : 42|1@1+ (1,0) [0|3] "" XXX + SG_ Cruise_On : 40|1@1+ (1,0) [0|3] "" XXX + SG_ Cruise_Activated : 41|1@1+ (1,0) [0|3] "" XXX + +BO_ 577 NEW_MSG_16: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_1 : 16|12@1+ (1,0) [0|255] "" XXX + +BO_ 552 NEW_MSG_17: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_1 : 48|1@1+ (1,0) [0|3] "" XXX + +BO_ 912 Dashlights: 8 XXX + SG_ NEW_SIGNAL_1 : 32|1@1+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_2 : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ RIGHT_BLINKER : 51|1@1+ (1,0) [0|1] "" XXX + SG_ LEFT_BLINKER : 50|1@1+ (1,0) [0|3] "" XXX + SG_ SEATBELT_FL : 48|1@1+ (1,0) [0|1] "" XXX + +BO_ 940 BodyInfo: 8 XXX + SG_ DASH_BTN_LIGHTS : 56|1@0+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_FL : 32|1@1+ (1,0) [0|255] "" XXX + SG_ DOOR_OPEN_FR : 33|1@1+ (1,0) [0|3] "" XXX + SG_ DOOR_OPEN_RL : 34|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RR : 35|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_TRUNK : 36|1@0+ (1,0) [0|1] "" XXX + SG_ FOG_LIGHTS2 : 60|1@1+ (1,0) [0|1] "" XXX + SG_ Highbeam : 58|1@1+ (1,0) [0|1] "" XXX + SG_ Lowbeam : 57|1@1+ (1,0) [0|3] "" XXX + +BO_ 801 ES_DashStatus: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|7] "" XXX + SG_ NEW_SIGNAL_10 : 49|2@1+ (1,0) [0|3] "" XXX + SG_ Brake_Pedal : 51|1@1+ (1,0) [0|3] "" XXX + SG_ Cruise_Set_Speed : 40|8@1+ (1,0) [0|255] "" XXX + SG_ Cruise_Activated : 36|1@1+ (1,0) [0|3] "" XXX + SG_ Cruise_Disengaged : 35|1@1+ (1,0) [0|3] "" XXX + SG_ Far_Distance : 56|4@1+ (1,0) [0|15] "" XXX + SG_ Car_Follow : 52|1@1+ (1,0) [0|3] "" XXX + SG_ ACC_Distance : 28|3@1+ (1,0) [0|3] "" XXX + SG_ ACC_Hold : 60|4@1+ (1,0) [0|15] "" XXX + +BO_ 802 ES_LKAS_State: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Keep_Hands_On_Wheel : 12|1@1+ (1,0) [0|1] "" XXX + SG_ Empty_Box : 13|1@1+ (1,0) [0|1] "" XXX + SG_ Signal1 : 14|3@1+ (1,0) [0|7] "" XXX + SG_ LKAS_ACTIVE : 17|1@1+ (1,0) [0|3] "" XXX + SG_ Signal2 : 18|5@1+ (1,0) [0|7] "" XXX + SG_ Backward_Speed_Limit_Menu : 23|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_ENABLE_3 : 24|1@1+ (1,0) [0|1] "" XXX + SG_ Signal3 : 25|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_ENABLE_2 : 26|1@1+ (1,0) [0|1] "" XXX + SG_ Signal4 : 27|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Left_Line_Visible : 28|1@1+ (1,0) [0|1] "" XXX + SG_ Signal6 : 29|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Right_Line_Visible : 30|1@1+ (1,0) [0|1] "" XXX + SG_ Signal7 : 31|1@1+ (1,0) [0|1] "" XXX + SG_ FCW_Cont_Beep : 32|1@1+ (1,0) [0|1] "" XXX + SG_ FCW_Repeated_Beep : 33|1@1+ (1,0) [0|1] "" XXX + SG_ Throttle_Management_Activated : 34|1@1+ (1,0) [0|1] "" XXX + SG_ Right_Depart : 36|1@1+ (1,0) [0|3] "" XXX + SG_ Signal5 : 37|27@1+ (1,0) [0|1] "" XXX + SG_ Vehicle_In_Front_Has_Moved : 35|1@1+ (1,0) [0|1] "" XXX + +BO_ 805 ES_NEW_MSG_22: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_3 : 22|2@1+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_1 : 14|1@1+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_4 : 15|1@1+ (1,0) [0|3] "" XXX + +BO_ 808 NEW_MSG_23: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + +BO_ 837 NEW_MSG_24: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_3 : 40|8@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 32|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_5 : 24|8@1+ (1,0) [0|255] "" XXX + +BO_ 838 NEW_MSG_25: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_3 : 16|8@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 40|1@1+ (1,0) [0|3] "" XXX + +BO_ 842 NEW_MSG_26: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_3 : 32|8@1+ (1,0) [0|255] "" XXX + +BO_ 915 NEW_MSG_27: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_3 : 16|8@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 32|9@1+ (1,0) [0|255] "" XXX + +BO_ 1788 NEW_MSG_28: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_3 : 40|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_4 : 48|8@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 16|8@1+ (1,0) [0|255] "" XXX + +BO_ 816 NEW_MSG_29: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + +BO_ 826 NEW_MSG_30: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + +BO_ 839 NEW_MSG_31: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + +BO_ 2015 NEW_MSG_32: 8 XXX + SG_ NEW_SIGNAL_2 : 16|8@1+ (1,0) [0|255] "" XXX + +BO_ 2024 NEW_MSG_33: 8 XXX + SG_ NEW_SIGNAL_1 : 24|8@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 0|3@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_3 : 16|8@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 32|8@1+ (1,0) [0|255] "" XXX + +BO_ 1614 NEW_MSG_34: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + +BO_ 1617 NEW_MSG_35: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + +BO_ 1632 NEW_MSG_36: 8 XXX + SG_ NEW_SIGNAL_1 : 55|16@0+ (1,0) [0|255] "" XXX + +BO_ 1650 NEW_MSG_37: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + +BO_ 1657 NEW_MSG_38: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + +BO_ 1658 NEW_MSG_39: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_3 : 33|1@1+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_4 : 31|1@0+ (1,0) [0|3] "" XXX + +BO_ 1677 Dash_State: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_3 : 16|4@1+ (1,0) [0|15] "" XXX + SG_ Units : 29|3@1+ (1,0) [0|7] "" XXX + +BO_ 1743 NEW_MSG_41: 8 XXX + SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + +BO_ 1785 NEW_MSG_42: 8 XXX + SG_ NEW_SIGNAL_1 : 0|4@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 21|1@1+ (1,0) [0|31] "" XXX + SG_ NEW_SIGNAL_3 : 17|1@1+ (1,0) [0|7] "" XXX + +BO_ 1759 NEW_MSG_43: 8 XXX + SG_ NEW_SIGNAL_1 : 17|1@1+ (1,0) [0|3] "" XXX + +BO_ 1786 NEW_MSG_44: 8 XXX + SG_ NEW_SIGNAL_1 : 0|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_2 : 16|8@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 8|8@1+ (1,0) [0|15] "" XXX + +BO_ 1787 NEW_MSG_45: 8 XXX + SG_ NEW_SIGNAL_1 : 0|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_2 : 8|8@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 16|8@1+ (1,0) [0|255] "" XXX + + + + +CM_ SG_ 940 FOG_LIGHTS2 "yellow fog light in the dash"; +CM_ SG_ 940 Highbeam "01 = low beam, 11 = high beam"; +CM_ SG_ 801 ACC_Hold "0 = No Hold, 3 = Hold"; +CM_ SG_ 802 Vehicle_In_Front_Has_Moved "Crosstrek 2018 = car in front has moved"; +CM_ SG_ 805 NEW_SIGNAL_3 "always 3"; +CM_ SG_ 805 NEW_SIGNAL_4 "always 1"; +CM_ SG_ 1677 Units "1 = imperial, 6 = metric"; diff --git a/opendbc/subaru_global_2017.dbc b/opendbc/subaru_global_2017.dbc index 0e2c87f81..39823f904 100644 --- a/opendbc/subaru_global_2017.dbc +++ b/opendbc/subaru_global_2017.dbc @@ -43,14 +43,16 @@ BO_ 2 Steering: 8 XXX BO_ 64 Throttle: 8 XXX SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|255] "" XXX SG_ Off_Accel : 60|4@1+ (1,0) [0|7] "" XXX SG_ NEW_SIGNAL_3 : 56|4@1+ (1,0) [0|255] "" XXX - SG_ Engine_RPM : 16|12@1+ (1,0) [0|255] "" XXX SG_ Throttle_Cruise : 40|8@1+ (1,0) [0|255] "" XXX SG_ Throttle_Combo : 55|8@1+ (1,0) [0|255] "" XXX SG_ Throttle_Pedal : 32|8@1+ (1,0) [0|255] "" XXX - + SG_ NEW_SIGNAL_2 : 48|7@1+ (1,0) [0|1] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|255] "" XXX + SG_ Engine_RPM : 16|12@1+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_1 : 12|4@1+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_4 : 28|5@1+ (1,0) [0|1] "" XXX BO_ 65 NEW_MSG_1: 8 XXX SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX @@ -358,6 +360,7 @@ BO_ 1787 NEW_MSG_45: 8 XXX CM_ SG_ 940 FOG_LIGHTS2 "yellow fog light in the dash"; CM_ SG_ 940 Highbeam "01 = low beam, 11 = high beam"; +CM_ SG_ 802 Traffic_light_Ahead "Crosstrek 2018 = car in front has moved"; CM_ SG_ 805 NEW_SIGNAL_3 "always 3"; CM_ SG_ 805 NEW_SIGNAL_4 "always 1"; CM_ SG_ 1677 Units "1 = imperial, 6 = metric"; diff --git a/opendbc/toyota_2017_ref_pt.dbc b/opendbc/toyota_2017_ref_pt.dbc index 2622c9f42..0c23d05d0 100644 --- a/opendbc/toyota_2017_ref_pt.dbc +++ b/opendbc/toyota_2017_ref_pt.dbc @@ -384,11 +384,187 @@ BO_ 1043 AVN1S31: 8 CGW SG_ GMTDIF_M : 50|6@0+ (1,0) [0|0] "minute" Vector__XXX SG_ SUMMERTM : 60|1@0+ (1,0) [0|0] "" Vector__XXX +BO_ 1075054137 BDB1F01_14: 8 CGW + SG_ BDBF01ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ BDBF01IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ SALR : 23|6@0+ (1,0) [0|0] "" Vector__XXX + SG_ HDCY_BDB : 17|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ AARE_B : 31|4@0+ (1,0) [0|0] "" Vector__XXX + SG_ I_SEN_B : 27|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ INTSET_B : 26|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ INCSET_B : 25|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ ISSD_BDB : 39|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ SEID : 37|3@0+ (1,0) [0|0] "" Vector__XXX + SG_ WS_ID : 44|3@0+ (1,0) [0|0] "" Vector__XXX + SG_ WS_SWON : 41|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ WS_DATA : 55|16@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1075185211 BDB1F03_16: 8 CGW + SG_ BDBF03ID : 7|8@0+ (1,0) [0|0] "" DS1,FCM,MAV + SG_ BDBF03IF : 15|8@0+ (1,0) [0|0] "" DS1,FCM + SG_ TRIP_CNT : 23|16@0+ (1,0) [0|0] "trip" AFS,BSR,CSR,DS1,FCM,MAV + SG_ TIME_CNT : 39|32@0+ (100,0) [0|0] "ms" AFS,BSR,CSR,DS1,FCM,MAV + +BO_ 1074791968 BDB1S01_10: 8 CGW + SG_ BDB01_ID : 7|8@0+ (1,0) [0|0] "" FCM,MAV + SG_ BDB01_IF : 15|8@0+ (1,0) [0|0] "" FCM + SG_ LX : 23|16@0+ (0.2,0) [0|0] "ms" FCM + SG_ ADIM : 39|2@0+ (1,0) [0|0] "" AFS,BSR,CSR + SG_ IG_BDB : 37|1@0+ (1,0) [0|0] "" AFS,MAV + SG_ ACC_BDB : 36|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ SKSW : 46|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ DCTY : 45|1@0+ (1,0) [0|0] "" FCM,MAV,SCS + SG_ PCTY : 44|1@0+ (1,0) [0|0] "" MAV,SCS + SG_ RRCY : 43|1@0+ (1,0) [0|0] "" MAV,SCS + SG_ RLCY : 42|1@0+ (1,0) [0|0] "" MAV,SCS + SG_ BCTY : 41|1@0+ (1,0) [0|0] "" MAV,SCS + SG_ PSW : 51|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ SRBZ : 49|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ DBKL : 63|2@0+ (1,0) [0|0] "" FCM + SG_ PKB_BDB : 60|1@0+ (1,0) [0|0] "" CSR + SG_ SREXIST : 59|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ SRPOS : 58|3@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1074857505 BDB1S02_11: 8 CGW + SG_ BDB02_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ BDB02_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ LUD : 23|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ TRNKOPN : 45|3@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1074923042 BDB1S03_12: 8 CGW + SG_ BDB03_ID : 7|8@0+ (1,0) [0|0] "" DS1,FCM + SG_ BDB03_IF : 15|8@0+ (1,0) [0|0] "" DS1,FCM + SG_ LTS : 23|4@0+ (1,0) [0|0] "" Vector__XXX + SG_ PANL : 19|1@0+ (1,0) [0|0] "" BSR,CSR + SG_ UDRL : 31|1@0+ (1,0) [0|0] "" AFS + SG_ HEDH : 30|1@0+ (1,0) [0|0] "" AFS,DS1,FCM + SG_ HEDL : 29|1@0+ (1,0) [0|0] "" AFS,DS1 + SG_ TAIL : 28|1@0+ (1,0) [0|0] "" AFS,BSR,CSR,DS1 + SG_ FFOG : 27|1@0+ (1,0) [0|0] "" DS1 + SG_ RFOG : 26|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ SB_IND : 39|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ SB_OK : 37|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ RTRRQ : 35|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ SRWARN : 51|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ PWWARN : 50|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ WEL_REQ : 48|1@0+ (1,0) [0|0] "" AFS + SG_ DRPBZ_R : 62|3@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1075381795 BDB1S04_19: 8 CGW + SG_ BDB04_ID : 7|8@0+ (1,0) [0|0] "" MAV + SG_ BDB04_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ MRMV_R : 23|2@0+ (1,0) [0|0] "" MAV + SG_ RSEL : 21|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ LSEL : 20|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ MHR : 19|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ MHL : 18|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ MVU : 17|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ MVD : 16|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ GHSW : 31|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ GCTY : 30|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ GHOPN : 42|3@0+ (1,0) [0|0] "" Vector__XXX + SG_ ABIF : 55|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ FLSHRQ : 63|3@0+ (1,0) [0|0] "" Vector__XXX + SG_ SB_ADV : 60|2@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1074988600 BDB1S05_13: 8 CGW + SG_ BDB05_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ BDB05_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ PARK : 23|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ TSWB : 21|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ LSWD : 20|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ LSWP : 19|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ LSWR : 18|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ LSWL : 17|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ LSWB : 16|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ DRVKS_R : 31|3@0+ (1,0) [0|0] "" Vector__XXX + SG_ PWDRD : 39|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ PWDRP : 37|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ PWDRR : 35|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ PWDRL : 33|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ DKLS : 43|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ BKLS : 54|3@0+ (1,0) [0|0] "" Vector__XXX + SG_ KIDSCN_R : 51|7@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1075250736 BDB1S06_17: 8 CGW + SG_ BDB06_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ BDB06_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ TBSW : 25|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ WBZF : 39|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ WVOL : 42|3@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1075316273 BDB1S07_18: 8 CGW + SG_ BDB07_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ BDB07_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ WCD : 23|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ W1D : 31|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ W2D : 39|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ W3D : 47|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ BDB7SUM1 : 55|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ BDB7SUM2 : 63|8@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1075447332 BDB1S08_1A: 8 CGW + SG_ BDB08_ID : 7|8@0+ (1,0) [0|0] "" DS1,FCM,MAV + SG_ BDB08_IF : 15|8@0+ (1,0) [0|0] "" DS1,FCM + SG_ DEST_BDB : 23|8@0+ (1,0) [0|0] "" AFS,BSR,CSR,DS1,FCM,MAV + SG_ DS_PACK1 : 31|8@0+ (1,0) [0|0] "" AFS,BSR,DS1,FCM,MAV + SG_ DS_PACK2 : 39|8@0+ (1,0) [0|0] "" AFS,BSR,DS1,FCM,MAV + SG_ STRG_WHL : 47|2@0+ (1,0) [0|0] "" AFS,CSR,DS1,FCM,MAV + SG_ DEICER : 40|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ KEYPLATE : 55|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ DBLLCK : 62|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ U2OP_CST : 61|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ U2OP_DFT : 60|1@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1075643943 BDB1S11_1D: 8 CGW + SG_ BDB11_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ BDB11_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ BDBREQ11 : 23|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ BDBREQ12 : 31|8@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1083704892 BDB1S17_98: 8 CGW + SG_ BDB17_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ BDB17_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ CHABASE1 : 23|8@0+ (1,0) [0|0] "" AFS + SG_ CHABASE2 : 31|8@0+ (1,0) [0|0] "" AFS + SG_ CHABASE3 : 39|8@0+ (1,0) [0|0] "" AFS + SG_ CHA_NO1 : 47|4@0+ (1,0) [0|0] "" AFS + SG_ CHA_NO2 : 43|4@0+ (1,0) [0|0] "" AFS + SG_ CHA_NO3 : 55|4@0+ (1,0) [0|0] "" AFS + SG_ SP_BODY : 63|5@0+ (1,0) [0|0] "" AFS + +BO_ 1083770429 BDB1S18_99: 8 CGW + SG_ BDB18_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ BDB18_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ POP_NAME : 23|8@0+ (1,0) [0|0] "" AFS + SG_ BODY : 31|8@0+ (1,0) [0|0] "" AFS + SG_ GEAR : 39|8@0+ (1,0) [0|0] "" AFS + SG_ GRADE : 47|8@0+ (1,0) [0|0] "" AFS + SG_ ENGINE : 55|8@0+ (1,0) [0|0] "" AFS + BO_ 1020 BDB1S19: 8 CGW SG_ SOLAR_R : 23|9@0+ (100,0) [0|0] "" Vector__XXX SG_ SOLAR_L : 39|9@0+ (100,0) [0|0] "" Vector__XXX SG_ N_LX : 55|13@0+ (1,0) [0|0] "" Vector__XXX +BO_ 1083835966 BDB1S20_9A: 8 CGW + SG_ BDB20_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ BDB20_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ RNBDYC : 31|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ RNBDYD : 39|32@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1083901503 BDB1S21_9B: 8 CGW + SG_ BDB21_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ BDB21_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ RFOG_SW : 22|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ FFOG_SW : 21|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ HF_SW : 20|1@0+ (1,0) [0|0] "" AFS + SG_ HU_SW : 19|1@0+ (1,0) [0|0] "" AFS + SG_ AUTO_SW : 18|1@0+ (1,0) [0|0] "" AFS + SG_ HEAD_SW : 17|1@0+ (1,0) [0|0] "" AFS + SG_ TAIL_SW : 16|1@0+ (1,0) [0|0] "" AFS + SG_ DRL_OFF : 24|1@0+ (1,0) [0|0] "" Vector__XXX + BO_ 1005 BGM1S01: 2 CGW SG_ WCAA : 7|1@0+ (1,0) [0|0] "" Vector__XXX SG_ R_DISP : 1|1@0+ (1,0) [0|0] "" Vector__XXX @@ -438,6 +614,9 @@ BO_ 918 CSR1S01: 7 CSR SG_ MUTE : 49|1@0+ (1,0) [0|0] "" Vector__XXX SG_ BZ_OFF : 48|1@0+ (1,0) [0|0] "" Vector__XXX +BO_ 1087768273 DMS1S02_D6: 8 CGW + SG_ SS_MODE : 25|2@0+ (1,0) [0|0] "" Vector__XXX + BO_ 869 DS11D70: 7 DS1 SG_ D_TRGJDG : 7|4@0+ (1,0) [0|0] "" Vector__XXX SG_ D_RESSW : 3|1@0+ (1,0) [0|0] "" Vector__XXX @@ -1066,6 +1245,102 @@ BO_ 1263 MAV1N01: 8 MAV SG_ MAVSNG : 15|1@0+ (1,0) [0|0] "" CGW SG_ MAVSPF : 23|16@0+ (1,0) [0|0] "" CGW +BO_ 1075840528 MET1S01_20: 8 CGW + SG_ MET01_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ MET01_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ MET_SPD : 23|8@0+ (1,0) [0|0] "km/h" CSR + SG_ RHEOSTAT : 30|7@0+ (1,0) [0|0] "%" Vector__XXX + SG_ TAIL_CN : 39|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ ILL_OF : 37|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ UNIT_TMP : 33|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ IN_FC : 47|16@0+ (0.1,0) [0|0] "Note" Vector__XXX + SG_ UNIT_0 : 63|3@0+ (1,0) [0|0] "" Vector__XXX + SG_ SP_TL : 60|4@0+ (1,0) [0|0] "" Vector__XXX + SG_ MET_TC : 56|1@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1075906065 MET1S02_21: 8 CGW + SG_ MET02_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ MET02_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ MET_DEST : 23|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ ODO_UNIT : 29|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ OMRS : 27|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ UNIT_CH : 26|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ ODO : 39|32@0+ (1,0) [0|0] "km/mile" Vector__XXX + +BO_ 1076037145 MET1S04_23: 8 CGW + SG_ MET04_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ MET04_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ AF_FC : 23|16@0+ (0.1,0) [0|0] "Note" Vector__XXX + SG_ UNIT_3 : 39|3@0+ (1,0) [0|0] "" Vector__XXX + SG_ RANGE : 47|16@0+ (1,0) [0|0] "Note" Vector__XXX + SG_ UNIT_4 : 63|2@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1076102682 MET1S05_24: 8 CGW + SG_ MET05_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ MET05_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ TO_SP : 23|16@0+ (0.1,0) [0|0] "km/h,MPH" Vector__XXX + SG_ UNIT_5 : 39|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ TO_FC : 47|16@0+ (0.1,0) [0|0] "MPGEkm/lEl/100kmEkm/gallon" Vector__XXX + SG_ UNIT_6 : 63|3@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1076299282 MET1S08_27: 8 CGW + SG_ MET08_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ MET08_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ TO_DT : 23|16@0+ (1,0) [0|0] "km,mile" Vector__XXX + SG_ UNIT_10 : 39|2@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1076364819 MET1S09_28: 8 CGW + SG_ MET09_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ MET09_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ WASH : 21|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ BLVW : 20|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ C_CW : 31|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ ENGW : 29|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ ABSW : 28|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ VSCW : 27|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ OPW : 37|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ OLW : 36|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ LW : 35|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ FSRS : 33|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ HALW : 46|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ BRW : 43|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ TIRW : 42|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ FWW : 40|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ SUSW : 53|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ LKAW : 61|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ MET_PCSW : 59|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ WTPW : 57|1@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1076430356 MET1S10_29: 8 CGW + SG_ MET10_ID : 7|8@0+ (1,0) [0|0] "" DS1,FCM + SG_ MET10_IF : 15|8@0+ (1,0) [0|0] "" DS1,FCM + SG_ OM_MLG : 23|7@0+ (100,0) [0|0] "miles" Vector__XXX + SG_ PR_OM_FL : 16|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ TNS : 29|2@0+ (1,0) [0|0] "" AFS,BSR,DS1,FCM + SG_ HZS : 27|1@0+ (1,0) [0|0] "" AFS,FCM + +BO_ 1076495893 MET1S11_2A: 8 CGW + SG_ MET11_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ MET11_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ UNIT_CH2 : 23|2@0+ (1,0) [0|0] "" FCM + SG_ TOLER_A : 21|6@0+ (0.002,0.94) [0|0] "" FCM + SG_ CDISP_EX : 31|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ TOLER_B : 29|6@0- (0.2,0) [0|0] "km/h" FCM + SG_ TRIP_B : 39|32@0+ (0.1,0) [0|0] "km/MILE" Vector__XXX + +BO_ 1076561430 MET1S12_2B: 8 CGW + SG_ MET12_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ MET12_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ ESLW : 19|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ CSOW : 24|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ LHLW : 37|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ SMBW : 33|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ KDSW : 32|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ OMRW : 46|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ BSDW : 54|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ MTSW : 48|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ ATSW : 63|1@0+ (1,0) [0|0] "" Vector__XXX + BO_ 992 MET1S18: 8 CGW SG_ M_LANG : 7|6@0+ (1,0) [0|0] "" Vector__XXX SG_ M_LNG_ST : 1|2@0+ (1,0) [0|0] "" Vector__XXX @@ -1077,6 +1352,35 @@ BO_ 992 MET1S18: 8 CGW SG_ M_LNGDB6 : 55|8@0+ (1,0) [0|0] "" Vector__XXX SG_ M_LNGDB7 : 63|7@0+ (1,0) [0|0] "" Vector__XXX +BO_ 1075840755 MET1S22_20: 8 CGW + SG_ ID6F320 : 7|8@0+ (1,0) [0|0] "" DS1,FCM + SG_ IF6F320 : 15|8@0+ (1,0) [0|0] "" DS1,FCM + SG_ TSR_OSM : 22|2@0+ (1,0) [0|0] "" FCM + SG_ TSR_OSL : 20|2@0+ (1,0) [0|0] "" FCM + SG_ TSR_SNM : 18|2@0+ (1,0) [0|0] "" FCM + SG_ TSR_MAIN : 16|1@0+ (1,0) [0|0] "" FCM + SG_ LDAMCUS : 31|2@0+ (1,0) [0|0] "" FCM + SG_ LDAMSW : 29|2@0+ (1,0) [0|0] "" FCM + SG_ FCMUSER : 27|1@0+ (1,0) [0|0] "" FCM + SG_ FCMMCUS : 26|2@0+ (1,0) [0|0] "" FCM + SG_ FCMMSW : 24|1@0+ (1,0) [0|0] "" FCM + SG_ BSMMSW : 37|1@0+ (1,0) [0|0] "" BSR + SG_ CSRMSW : 34|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ PCSMCUS : 41|1@0+ (1,0) [0|0] "" DS1 + SG_ PCSMSW : 40|1@0+ (1,0) [0|0] "" DS1 + SG_ LKACTCSW : 51|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ LDA_SFB : 50|3@0+ (1,0) [0|0] "" FCM + +BO_ 1088685760 PMN1F03_E4: 8 CGW + SG_ PMNF03ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ PMNF03IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ PSSW_PMN : 17|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ PSW_PMN : 31|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ KCC_PMN : 29|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ PMOD_PMN : 27|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ MOD_EIG : 39|3@0+ (1,0) [0|0] "" Vector__XXX + SG_ SWBZ_EIG : 36|1@0+ (1,0) [0|0] "" Vector__XXX + BO_ 1193 SCS1D50: 8 SCS SG_ DRSCS01 : 7|8@0+ (1,0) [0|0] "" Vector__XXX SG_ DRSCS02 : 15|8@0+ (1,0) [0|0] "" Vector__XXX @@ -1111,7 +1415,7 @@ BO_ 917 SCS1S90: 4 SCS SG_ LAR_HS : 18|2@0+ (1,0) [0|0] "" Vector__XXX SG_ AVSNI : 16|1@0+ (1,0) [0|0] "" Vector__XXX -BO_ 37 Steering_Angle_sensor: 8 CGW +BO_ 37 STR1S01: 8 CGW SG_ STS3 : 7|1@0+ (1,0) [0|0] "" AFS,BSR,DS1,FCM,MAV SG_ STS2 : 6|1@0+ (1,0) [0|0] "" AFS,DS1,FCM,KSS,MAV,SCS SG_ STS1 : 5|1@0+ (1,0) [0|0] "" AFS,BSR,DS1,FCM,KSS,MAV,SCS @@ -1129,7 +1433,7 @@ BO_ 1059 STR1S02: 1 CGW SG_ SFR : 5|1@0+ (1,0) [0|0] "" MAV SG_ STRWVG : 4|1@0+ (1,0) [0|0] "" AFS,BSR,DS1,FCM -BO_ 170 Wheel_speeds: 8 CGW +BO_ 170 VSC1F01: 8 CGW SG_ VXFREF : 7|1@0+ (1,0) [0|0] "" AFS,FCM,MAV SG_ VXFR : 6|15@0+ (0.01,-67.67) [0|0] "km/h" AFS,BSR,DS1,FCM,KSS,MAV,SCS SG_ VXFLEF : 23|1@0+ (1,0) [0|0] "" AFS,FCM,MAV @@ -1154,7 +1458,7 @@ BO_ 426 VSC1F02: 6 CGW SG_ VXRLHDS : 22|1@0+ (1,0) [0|0] "" FCM,KSS,MAV,SCS SG_ VSCF02SM : 47|8@0+ (1,0) [0|0] "" AFS,DS1,FCM,MAV -BO_ 550 Brake_module: 8 CGW +BO_ 550 VSC1F06: 8 CGW SG_ VSCF01FG : 7|2@0+ (1,0) [0|0] "" Vector__XXX SG_ AHCURQ : 4|1@0+ (1,0) [0|0] "" Vector__XXX SG_ PMCF : 3|1@0+ (1,0) [0|0] "" DS1 @@ -1172,7 +1476,7 @@ BO_ 550 Brake_module: 8 CGW SG_ FSTP : 60|1@0+ (1,0) [0|0] "" DS1 SG_ ABSACT : 59|1@0+ (1,0) [0|0] "" DS1,FCM,MAV -BO_ 180 Speed : 8 CGW +BO_ 180 VSC1S03: 8 CGW SG_ SP1P : 39|6@0+ (1,0) [0|0] "" DS1,FCM SG_ SP1S : 33|1@0+ (1,0) [0|0] "" BSR,DS1,FCM,MAV SG_ SP1 : 47|16@0- (0.01,0) [0|0] "km/h" BSR,DS1,FCM,MAV @@ -1292,7 +1596,7 @@ BO_ 544 VSC2F07: 4 CGW SG_ DAC_CND : 9|2@0+ (1,0) [0|0] "" Vector__XXX SG_ VSC2F07S : 31|8@0+ (1,0) [0|0] "" DS1,FCM -BO_ 36 Kinematics: 8 CGW +BO_ 36 YGS1S03: 8 CGW SG_ YRS11S : 7|1@0+ (1,0) [0|0] "" DS1,FCM,MAV SG_ YRS14S : 6|1@0+ (1,0) [0|0] "" DS1,FCM,MAV SG_ YRS21S : 5|1@0+ (1,0) [0|0] "" DS1,FCM,MAV @@ -1311,3 +1615,24 @@ BO_ 36 Kinematics: 8 CGW SG_ YR_DIF : 55|8@0+ (0.244,-31) [0|0] "deg/sec" DS1,FCM,MAV SG_ YGS03SUM : 63|8@0+ (1,0) [0|0] "" DS1,FCM,MAV +BO_ 1073743490 YGW1S01_0: 8 CGW + SG_ YGW01_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ YGW01_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ YR_STSW : 22|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ YR_EGST : 20|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ YR_DRLK : 18|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ YR_KLEG : 16|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ YR_HZRD : 26|3@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1073743491 YGW1S02_0: 8 CGW + SG_ YGW02_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ YGW02_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ YR_DEFOG : 19|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ YR_ARCON : 17|2@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1073743494 YGW1S05_0: 8 CGW + SG_ YGW05_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ YGW05_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX + SG_ YI_IMO_E : 23|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ YI_UREQ : 16|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ YI_RE : 47|16@0+ (1,0) [0|0] "" Vector__XXX \ No newline at end of file diff --git a/opendbc/toyota_avalon_2017_pt_generated.dbc b/opendbc/toyota_avalon_2017_pt_generated.dbc index 7749d9610..8111fbaa4 100644 --- a/opendbc/toyota_avalon_2017_pt_generated.dbc +++ b/opendbc/toyota_avalon_2017_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/toyota_camry_hybrid_2018_pt_generated.dbc b/opendbc/toyota_camry_hybrid_2018_pt_generated.dbc index e2561f18c..ecc6b774f 100644 --- a/opendbc/toyota_camry_hybrid_2018_pt_generated.dbc +++ b/opendbc/toyota_camry_hybrid_2018_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/toyota_corolla_2017_pt_generated.dbc b/opendbc/toyota_corolla_2017_pt_generated.dbc index e0a405dea..19e6e5ea3 100644 --- a/opendbc/toyota_corolla_2017_pt_generated.dbc +++ b/opendbc/toyota_corolla_2017_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/toyota_highlander_2017_pt_generated.dbc b/opendbc/toyota_highlander_2017_pt_generated.dbc index f5063df3f..c22a331a6 100644 --- a/opendbc/toyota_highlander_2017_pt_generated.dbc +++ b/opendbc/toyota_highlander_2017_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/toyota_highlander_hybrid_2018_pt_generated.dbc b/opendbc/toyota_highlander_hybrid_2018_pt_generated.dbc index 193735a0f..31b534002 100644 --- a/opendbc/toyota_highlander_hybrid_2018_pt_generated.dbc +++ b/opendbc/toyota_highlander_hybrid_2018_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/toyota_nodsu_hybrid_pt_generated.dbc b/opendbc/toyota_nodsu_hybrid_pt_generated.dbc index 14193330a..abd3af8db 100644 --- a/opendbc/toyota_nodsu_hybrid_pt_generated.dbc +++ b/opendbc/toyota_nodsu_hybrid_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/toyota_nodsu_pt_generated.dbc b/opendbc/toyota_nodsu_pt_generated.dbc index 8d304954b..6e14a2c51 100644 --- a/opendbc/toyota_nodsu_pt_generated.dbc +++ b/opendbc/toyota_nodsu_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/toyota_prius_2017_pt_generated.dbc b/opendbc/toyota_prius_2017_pt_generated.dbc index 9b02b364e..f29b7c078 100644 --- a/opendbc/toyota_prius_2017_pt_generated.dbc +++ b/opendbc/toyota_prius_2017_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/toyota_rav4_2017_pt_generated.dbc b/opendbc/toyota_rav4_2017_pt_generated.dbc index 5825028db..de8e55b73 100644 --- a/opendbc/toyota_rav4_2017_pt_generated.dbc +++ b/opendbc/toyota_rav4_2017_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/toyota_rav4_hybrid_2017_pt_generated.dbc b/opendbc/toyota_rav4_hybrid_2017_pt_generated.dbc index 6004bfd94..a78e78c7f 100644 --- a/opendbc/toyota_rav4_hybrid_2017_pt_generated.dbc +++ b/opendbc/toyota_rav4_hybrid_2017_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/opendbc/toyota_sienna_xle_2018_pt_generated.dbc b/opendbc/toyota_sienna_xle_2018_pt_generated.dbc index 3bff57f44..d427b1bef 100644 --- a/opendbc/toyota_sienna_xle_2018_pt_generated.dbc +++ b/opendbc/toyota_sienna_xle_2018_pt_generated.dbc @@ -231,7 +231,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX diff --git a/panda/.gitignore b/panda/.gitignore index 70d010fab..397996a0b 100644 --- a/panda/.gitignore +++ b/panda/.gitignore @@ -4,6 +4,7 @@ *.o *.so *.d +*.dump a.out *~ .#* @@ -12,4 +13,5 @@ pandacan.egg-info/ board/obj/ examples/output.csv .DS_Store +.vscode nosetests.xml diff --git a/panda/VERSION b/panda/VERSION index 5beebea89..880b85159 100644 --- a/panda/VERSION +++ b/panda/VERSION @@ -1 +1 @@ -v1.4.3 \ No newline at end of file +v1.4.7 \ No newline at end of file diff --git a/panda/board/board.h b/panda/board/board.h index 5379f9464..154f32132 100644 --- a/panda/board/board.h +++ b/panda/board/board.h @@ -48,8 +48,12 @@ void detect_configuration(void) { has_external_debug_serial = detect_with_pull(GPIOA, 3, PULL_DOWN); #ifdef PANDA - // check if the ESP is trying to put me in boot mode - is_entering_bootmode = !detect_with_pull(GPIOB, 0, PULL_UP); + if(hw_type == HW_TYPE_WHITE_PANDA) { + // check if the ESP is trying to put me in boot mode + is_entering_bootmode = !detect_with_pull(GPIOB, 0, PULL_UP); + } else { + is_entering_bootmode = 0; + } #else is_entering_bootmode = 0; #endif @@ -58,4 +62,4 @@ void detect_configuration(void) { // ///// Board functions ///// // bool board_has_gps(void) { return ((hw_type == HW_TYPE_GREY_PANDA) || (hw_type == HW_TYPE_BLACK_PANDA)); -} +} \ No newline at end of file diff --git a/panda/board/board_declarations.h b/panda/board/board_declarations.h index 7a44113f6..cc93ec7c9 100644 --- a/panda/board/board_declarations.h +++ b/panda/board/board_declarations.h @@ -24,7 +24,7 @@ struct board { }; // ******************* Definitions ******************** -// These should match the enum in cereal/log.capnp +// These should match the enums in cereal/log.capnp and __init__.py #define HW_TYPE_UNKNOWN 0U #define HW_TYPE_WHITE_PANDA 1U #define HW_TYPE_GREY_PANDA 2U @@ -54,4 +54,4 @@ struct board { #define CAN_MODE_OBD_CAN2 3U // ********************* Globals ********************** -uint8_t usb_power_mode = USB_POWER_NONE; \ No newline at end of file +uint8_t usb_power_mode = USB_POWER_NONE; diff --git a/panda/board/boards/black.h b/panda/board/boards/black.h index 0372aa3d0..62b3b6740 100644 --- a/panda/board/boards/black.h +++ b/panda/board/boards/black.h @@ -23,8 +23,9 @@ void black_enable_can_transciever(uint8_t transciever, bool enabled) { } void black_enable_can_transcievers(bool enabled) { - for(uint8_t i=1; i<=4U; i++) + for(uint8_t i=1U; i<=4U; i++){ black_enable_can_transciever(i, enabled); + } } void black_set_led(uint8_t color, bool enabled) { @@ -43,26 +44,41 @@ void black_set_led(uint8_t color, bool enabled) { } } -void black_set_usb_power_mode(uint8_t mode){ +void black_set_gps_load_switch(bool enabled) { + set_gpio_output(GPIOC, 12, enabled); +} + +void black_set_usb_load_switch(bool enabled) { + set_gpio_output(GPIOB, 1, !enabled); +} + +void black_set_usb_power_mode(uint8_t mode) { usb_power_mode = mode; - puts("Trying to set USB power mode on black panda. This is not supported.\n"); + if (mode == USB_POWER_NONE) { + black_set_usb_load_switch(false); + } else { + black_set_usb_load_switch(true); + } } void black_set_esp_gps_mode(uint8_t mode) { switch (mode) { case ESP_GPS_DISABLED: - // ESP OFF + // GPS OFF set_gpio_output(GPIOC, 14, 0); set_gpio_output(GPIOC, 5, 0); + black_set_gps_load_switch(false); break; case ESP_GPS_ENABLED: - // ESP ON + // GPS ON set_gpio_output(GPIOC, 14, 1); set_gpio_output(GPIOC, 5, 1); + black_set_gps_load_switch(true); break; case ESP_GPS_BOOTMODE: set_gpio_output(GPIOC, 14, 1); set_gpio_output(GPIOC, 5, 0); + black_set_gps_load_switch(true); break; default: puts("Invalid ESP/GPS mode\n"); @@ -132,9 +148,11 @@ void black_init(void) { // C8: FAN aka TIM3_CH3 set_gpio_alternate(GPIOC, 8, GPIO_AF2_TIM3); - // C12: GPS load switch. Turn on permanently for now - set_gpio_output(GPIOC, 12, true); - //set_gpio_output(GPIOC, 12, false); //TODO: stupid inverted switch on prototype + // Turn on GPS load switch. + black_set_gps_load_switch(true); + + // Turn on USB load switch. + black_set_usb_load_switch(true); // Initialize harness harness_init(); diff --git a/panda/board/boards/white.h b/panda/board/boards/white.h index a4e65d67b..46668c3a8 100644 --- a/panda/board/boards/white.h +++ b/panda/board/boards/white.h @@ -285,6 +285,13 @@ void white_init(void) { // Set normal CAN mode white_set_can_mode(CAN_MODE_NORMAL); + + // Setup ignition interrupts + SYSCFG->EXTICR[1] = SYSCFG_EXTICR1_EXTI1_PA; + EXTI->IMR |= (1U << 1); + EXTI->RTSR |= (1U << 1); + EXTI->FTSR |= (1U << 1); + NVIC_EnableIRQ(EXTI1_IRQn); } const harness_configuration white_harness_config = { diff --git a/panda/board/bootstub.c b/panda/board/bootstub.c index 9644326d4..3b6b1e875 100644 --- a/panda/board/bootstub.c +++ b/panda/board/bootstub.c @@ -63,7 +63,7 @@ extern void *_app_start[]; // BOUNTY: $200 coupon on shop.comma.ai or $100 check. int main(void) { - __disable_irq(); + disable_interrupts(); clock_init(); detect_configuration(); detect_board_type(); diff --git a/panda/board/drivers/can.h b/panda/board/drivers/can.h index 2d7728134..d0d706497 100644 --- a/panda/board/drivers/can.h +++ b/panda/board/drivers/can.h @@ -62,7 +62,7 @@ int can_overflow_cnt = 0; bool can_pop(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { bool ret = 0; - enter_critical_section(); + ENTER_CRITICAL(); if (q->w_ptr != q->r_ptr) { *elem = q->elems[q->r_ptr]; if ((q->r_ptr + 1U) == q->fifo_size) { @@ -72,7 +72,7 @@ bool can_pop(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { } ret = 1; } - exit_critical_section(); + EXIT_CRITICAL(); return ret; } @@ -81,7 +81,7 @@ bool can_push(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { bool ret = false; uint32_t next_w_ptr; - enter_critical_section(); + ENTER_CRITICAL(); if ((q->w_ptr + 1U) == q->fifo_size) { next_w_ptr = 0; } else { @@ -92,7 +92,7 @@ bool can_push(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { q->w_ptr = next_w_ptr; ret = true; } - exit_critical_section(); + EXIT_CRITICAL(); if (!ret) { can_overflow_cnt++; #ifdef DEBUG @@ -103,10 +103,10 @@ bool can_push(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { } void can_clear(can_ring *q) { - enter_critical_section(); + ENTER_CRITICAL(); q->w_ptr = 0; q->r_ptr = 0; - exit_critical_section(); + EXIT_CRITICAL(); } // assign CAN numbering @@ -124,7 +124,7 @@ uint8_t bus_lookup[] = {0,1,2}; uint8_t can_num_lookup[] = {0,1,2,-1}; int8_t can_forwarding[] = {-1,-1,-1,-1}; uint32_t can_speed[] = {5000, 5000, 5000, 333}; -#define CAN_MAX 3 +#define CAN_MAX 3U #define CANIF_FROM_CAN_NUM(num) (cans[num]) #define CAN_NUM_FROM_CANIF(CAN) ((CAN)==CAN1 ? 0 : ((CAN) == CAN2 ? 1 : 2)) @@ -158,9 +158,10 @@ void can_init(uint8_t can_number) { } void can_init_all(void) { - for (int i=0; i < CAN_MAX; i++) { + for (uint8_t i=0U; i < CAN_MAX; i++) { can_init(i); } + current_board->enable_can_transcievers(true); } void can_flip_buses(uint8_t bus1, uint8_t bus2){ @@ -248,7 +249,7 @@ void can_set_obd(uint8_t harness_orientation, bool obd){ // CAN error void can_sce(CAN_TypeDef *CAN) { - enter_critical_section(); + ENTER_CRITICAL(); #ifdef DEBUG if (CAN==CAN1) puts("CAN1: "); @@ -271,7 +272,7 @@ void can_sce(CAN_TypeDef *CAN) { can_err_cnt += 1; llcan_clear_send(CAN); - exit_critical_section(); + EXIT_CRITICAL(); } // ***************************** CAN ***************************** @@ -279,7 +280,7 @@ void can_sce(CAN_TypeDef *CAN) { void process_can(uint8_t can_number) { if (can_number != 0xffU) { - enter_critical_section(); + ENTER_CRITICAL(); CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number); uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); @@ -327,7 +328,7 @@ void process_can(uint8_t can_number) { } } - exit_critical_section(); + EXIT_CRITICAL(); } } diff --git a/panda/board/drivers/llgpio.h b/panda/board/drivers/llgpio.h index a89c8a8e2..9304cbe01 100644 --- a/panda/board/drivers/llgpio.h +++ b/panda/board/drivers/llgpio.h @@ -11,42 +11,52 @@ #define OUTPUT_TYPE_OPEN_DRAIN 1U void set_gpio_mode(GPIO_TypeDef *GPIO, unsigned int pin, unsigned int mode) { + ENTER_CRITICAL(); uint32_t tmp = GPIO->MODER; tmp &= ~(3U << (pin * 2U)); tmp |= (mode << (pin * 2U)); GPIO->MODER = tmp; + EXIT_CRITICAL(); } void set_gpio_output(GPIO_TypeDef *GPIO, unsigned int pin, bool enabled) { + ENTER_CRITICAL(); if (enabled) { GPIO->ODR |= (1U << pin); } else { GPIO->ODR &= ~(1U << pin); } set_gpio_mode(GPIO, pin, MODE_OUTPUT); + EXIT_CRITICAL(); } void set_gpio_output_type(GPIO_TypeDef *GPIO, unsigned int pin, unsigned int output_type){ + ENTER_CRITICAL(); if(output_type == OUTPUT_TYPE_OPEN_DRAIN) { GPIO->OTYPER |= (1U << pin); } else { GPIO->OTYPER &= ~(1U << pin); } + EXIT_CRITICAL(); } void set_gpio_alternate(GPIO_TypeDef *GPIO, unsigned int pin, unsigned int mode) { + ENTER_CRITICAL(); uint32_t tmp = GPIO->AFR[pin >> 3U]; tmp &= ~(0xFU << ((pin & 7U) * 4U)); tmp |= mode << ((pin & 7U) * 4U); GPIO->AFR[pin >> 3] = tmp; set_gpio_mode(GPIO, pin, MODE_ALTERNATE); + EXIT_CRITICAL(); } void set_gpio_pullup(GPIO_TypeDef *GPIO, unsigned int pin, unsigned int mode) { + ENTER_CRITICAL(); uint32_t tmp = GPIO->PUPDR; tmp &= ~(3U << (pin * 2U)); tmp |= (mode << (pin * 2U)); GPIO->PUPDR = tmp; + EXIT_CRITICAL(); } int get_gpio_input(GPIO_TypeDef *GPIO, unsigned int pin) { diff --git a/panda/board/drivers/uart.h b/panda/board/drivers/uart.h index 5c5452483..451150d1a 100644 --- a/panda/board/drivers/uart.h +++ b/panda/board/drivers/uart.h @@ -74,7 +74,7 @@ uart_ring *get_ring_by_number(int a) { // ***************************** serial port ***************************** void uart_ring_process(uart_ring *q) { - enter_critical_section(); + ENTER_CRITICAL(); // TODO: check if external serial is connected int sr = q->uart->SR; @@ -108,7 +108,7 @@ void uart_ring_process(uart_ring *q) { // set dropped packet flag? } - exit_critical_section(); + EXIT_CRITICAL(); } // interrupt boilerplate @@ -121,13 +121,13 @@ void UART5_IRQHandler(void) { uart_ring_process(&lin1_ring); } bool getc(uart_ring *q, char *elem) { bool ret = false; - enter_critical_section(); + ENTER_CRITICAL(); if (q->w_ptr_rx != q->r_ptr_rx) { if (elem != NULL) *elem = q->elems_rx[q->r_ptr_rx]; q->r_ptr_rx = (q->r_ptr_rx + 1U) % FIFO_SIZE; ret = true; } - exit_critical_section(); + EXIT_CRITICAL(); return ret; } @@ -136,14 +136,14 @@ bool injectc(uart_ring *q, char elem) { int ret = false; uint16_t next_w_ptr; - enter_critical_section(); + ENTER_CRITICAL(); next_w_ptr = (q->w_ptr_rx + 1U) % FIFO_SIZE; if (next_w_ptr != q->r_ptr_rx) { q->elems_rx[q->w_ptr_rx] = elem; q->w_ptr_rx = next_w_ptr; ret = true; } - exit_critical_section(); + EXIT_CRITICAL(); return ret; } @@ -152,14 +152,14 @@ bool putc(uart_ring *q, char elem) { bool ret = false; uint16_t next_w_ptr; - enter_critical_section(); + ENTER_CRITICAL(); next_w_ptr = (q->w_ptr_tx + 1U) % FIFO_SIZE; if (next_w_ptr != q->r_ptr_tx) { q->elems_tx[q->w_ptr_tx] = elem; q->w_ptr_tx = next_w_ptr; ret = true; } - exit_critical_section(); + EXIT_CRITICAL(); uart_ring_process(q); @@ -185,12 +185,12 @@ void uart_send_break(uart_ring *u) { } void clear_uart_buff(uart_ring *q) { - enter_critical_section(); + ENTER_CRITICAL(); q->w_ptr_tx = 0; q->r_ptr_tx = 0; q->w_ptr_rx = 0; q->r_ptr_rx = 0; - exit_critical_section(); + EXIT_CRITICAL(); } // ***************************** start UART code ***************************** @@ -215,7 +215,7 @@ char usart1_dma[USART1_DMA_LEN]; void uart_dma_drain(void) { uart_ring *q = &esp_ring; - enter_critical_section(); + ENTER_CRITICAL(); if ((DMA2->HISR & DMA_HISR_TCIF5) || (DMA2->HISR & DMA_HISR_HTIF5) || (DMA2_Stream5->NDTR != USART1_DMA_LEN)) { // disable DMA @@ -245,7 +245,7 @@ void uart_dma_drain(void) { q->uart->CR3 |= USART_CR3_DMAR; } - exit_critical_section(); + EXIT_CRITICAL(); } void DMA2_Stream5_IRQHandler(void) { diff --git a/panda/board/gpio.h b/panda/board/gpio.h index 1acf0288a..f33196e8f 100644 --- a/panda/board/gpio.h +++ b/panda/board/gpio.h @@ -20,6 +20,12 @@ void jump_to_bootloader(void) { } void early(void) { + // Reset global critical depth + global_critical_depth = 0; + + // neccesary for DFU flashing on a non-power cycled white panda + enable_interrupts(); + // after it's been in the bootloader, things are initted differently, so we reset if ((enter_bootloader_mode != BOOT_NORMAL) && (enter_bootloader_mode != ENTER_BOOTLOADER_MAGIC) && diff --git a/panda/board/libc.h b/panda/board/libc.h index 83adb9c09..f8d9dbce2 100644 --- a/panda/board/libc.h +++ b/panda/board/libc.h @@ -42,24 +42,26 @@ int memcmp(const void * ptr1, const void * ptr2, unsigned int num) { // ********************* IRQ helpers ********************* -int interrupts_enabled = 0; +volatile bool interrupts_enabled = false; + void enable_interrupts(void) { - interrupts_enabled = 1; + interrupts_enabled = true; __enable_irq(); } -int critical_depth = 0; -void enter_critical_section(void) { +void disable_interrupts(void) { + interrupts_enabled = false; __disable_irq(); - // this is safe because interrupts are disabled - critical_depth += 1; } -void exit_critical_section(void) { - // this is safe because interrupts are disabled - critical_depth -= 1; - if ((critical_depth == 0) && interrupts_enabled) { - __enable_irq(); +uint8_t global_critical_depth = 0U; +#define ENTER_CRITICAL() \ + __disable_irq(); \ + global_critical_depth += 1U; + +#define EXIT_CRITICAL() \ + global_critical_depth -= 1U; \ + if ((global_critical_depth == 0U) && interrupts_enabled) { \ + __enable_irq(); \ } -} diff --git a/panda/board/main.c b/panda/board/main.c index 7473b0775..dcf6e668b 100644 --- a/panda/board/main.c +++ b/panda/board/main.c @@ -78,9 +78,11 @@ void started_interrupt_handler(uint8_t interrupt_line) { // jenky debounce delay(100000); - // set power savings mode here - int power_save_state = current_board->check_ignition() ? POWER_SAVE_STATUS_DISABLED : POWER_SAVE_STATUS_ENABLED; - set_power_save_state(power_save_state); + // set power savings mode here if on EON build + #ifdef EON + int power_save_state = current_board->check_ignition() ? POWER_SAVE_STATUS_DISABLED : POWER_SAVE_STATUS_ENABLED; + set_power_save_state(power_save_state); + #endif } EXTI->PR = (1U << interrupt_line); } @@ -100,14 +102,6 @@ void EXTI3_IRQHandler(void) { started_interrupt_handler(3); } -void started_interrupt_init(void) { - SYSCFG->EXTICR[1] = SYSCFG_EXTICR1_EXTI1_PA; - EXTI->IMR |= (1U << 1); - EXTI->RTSR |= (1U << 1); - EXTI->FTSR |= (1U << 1); - NVIC_EnableIRQ(EXTI1_IRQn); -} - // ****************************** safety mode ****************************** // this is the only way to leave silent mode @@ -116,30 +110,29 @@ void set_safety_mode(uint16_t mode, int16_t param) { if (err == -1) { puts("Error: safety set mode failed\n"); } else { - if (mode == SAFETY_NOOUTPUT) { - can_silent = ALL_CAN_SILENT; - } else { - can_silent = ALL_CAN_LIVE; - } - switch (mode) { case SAFETY_NOOUTPUT: set_intercept_relay(false); if(hw_type == HW_TYPE_BLACK_PANDA){ current_board->set_can_mode(CAN_MODE_NORMAL); } + can_silent = ALL_CAN_SILENT; break; case SAFETY_ELM327: set_intercept_relay(false); + heartbeat_counter = 0U; if(hw_type == HW_TYPE_BLACK_PANDA){ current_board->set_can_mode(CAN_MODE_OBD_CAN2); } + can_silent = ALL_CAN_LIVE; break; default: set_intercept_relay(true); + heartbeat_counter = 0U; if(hw_type == HW_TYPE_BLACK_PANDA){ current_board->set_can_mode(CAN_MODE_NORMAL); } + can_silent = ALL_CAN_LIVE; break; } if (safety_ignition_hook() != -1) { @@ -289,11 +282,14 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) // so it's blocked over wifi switch (setup->b.wValue.w) { case 0: - if (hardwired) { - puts("-> entering bootloader\n"); - enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; - NVIC_SystemReset(); - } + // only allow bootloader entry on debug builds + #ifdef ALLOW_DEBUG + if (hardwired) { + puts("-> entering bootloader\n"); + enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; + NVIC_SystemReset(); + } + #endif break; case 1: puts("-> entering softloader\n"); @@ -464,7 +460,10 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) break; // **** 0xe6: set USB power case 0xe6: - if (setup->b.wValue.w == 1U) { + if (setup->b.wValue.w == 0U) { + puts("user setting NONE mode\n"); + current_board->set_usb_power_mode(USB_POWER_NONE); + } else if (setup->b.wValue.w == 1U) { puts("user setting CDP mode\n"); current_board->set_usb_power_mode(USB_POWER_CDP); } else if (setup->b.wValue.w == 2U) { @@ -610,11 +609,10 @@ void TIM3_IRQHandler(void) { pending_can_live = 0; } #ifdef DEBUG - //TODO: re-enable - //puts("** blink "); - //puth(can_rx_q.r_ptr); puts(" "); puth(can_rx_q.w_ptr); puts(" "); - //puth(can_tx1_q.r_ptr); puts(" "); puth(can_tx1_q.w_ptr); puts(" "); - //puth(can_tx2_q.r_ptr); puts(" "); puth(can_tx2_q.w_ptr); puts("\n"); + puts("** blink "); + puth(can_rx_q.r_ptr); puts(" "); puth(can_rx_q.w_ptr); puts(" "); + puth(can_tx1_q.r_ptr); puts(" "); puth(can_tx1_q.w_ptr); puts(" "); + puth(can_tx2_q.r_ptr); puts(" "); puth(can_tx2_q.w_ptr); puts("\n"); #endif // set green LED to be controls allowed @@ -645,7 +643,7 @@ void TIM3_IRQHandler(void) { int main(void) { // shouldn't have interrupts here, but just in case - __disable_irq(); + disable_interrupts(); // init early devices clock_init(); @@ -730,11 +728,6 @@ int main(void) { /*if (current_board->check_ignition()) { set_power_save_state(POWER_SAVE_STATUS_ENABLED); }*/ - - if (hw_type != HW_TYPE_BLACK_PANDA) { - // interrupt on started line - started_interrupt_init(); - } #endif // 48mhz / 65536 ~= 732 / 732 = 1 diff --git a/panda/board/pedal/main.c b/panda/board/pedal/main.c index 194370fa3..b6cfa5164 100644 --- a/panda/board/pedal/main.c +++ b/panda/board/pedal/main.c @@ -55,18 +55,18 @@ void debug_ring_callback(uart_ring *ring) { } } -int usb_cb_ep1_in(uint8_t *usbdata, int len, bool hardwired) { +int usb_cb_ep1_in(void *usbdata, int len, bool hardwired) { UNUSED(usbdata); UNUSED(len); UNUSED(hardwired); return 0; } -void usb_cb_ep2_out(uint8_t *usbdata, int len, bool hardwired) { +void usb_cb_ep2_out(void *usbdata, int len, bool hardwired) { UNUSED(usbdata); UNUSED(len); UNUSED(hardwired); } -void usb_cb_ep3_out(uint8_t *usbdata, int len, bool hardwired) { +void usb_cb_ep3_out(void *usbdata, int len, bool hardwired) { UNUSED(usbdata); UNUSED(len); UNUSED(hardwired); @@ -299,7 +299,7 @@ void pedal(void) { } int main(void) { - __disable_irq(); + disable_interrupts(); // init devices clock_init(); @@ -307,6 +307,9 @@ int main(void) { detect_configuration(); detect_board_type(); + // init board + current_board->init(); + #ifdef PEDAL_USB // enable USB usb_init(); @@ -331,7 +334,7 @@ int main(void) { watchdog_init(); puts("**** INTERRUPTS ON ****\n"); - __enable_irq(); + enable_interrupts(); // main pedal loop while (1) { diff --git a/panda/board/power_saving.h b/panda/board/power_saving.h index 94ebbb53c..0a926c119 100644 --- a/panda/board/power_saving.h +++ b/panda/board/power_saving.h @@ -28,6 +28,13 @@ void set_power_save_state(int state) { // Switch CAN transcievers current_board->enable_can_transcievers(enable); + // Switch EPS/GPS + if (enable) { + current_board->set_esp_gps_mode(ESP_GPS_ENABLED); + } else { + current_board->set_esp_gps_mode(ESP_GPS_DISABLED); + } + if(hw_type != HW_TYPE_BLACK_PANDA){ // turn on GMLAN set_gpio_output(GPIOB, 14, enable); diff --git a/panda/board/safety.h b/panda/board/safety.h index 6b2b5a045..e542dde8e 100644 --- a/panda/board/safety.h +++ b/panda/board/safety.h @@ -13,6 +13,7 @@ #include "safety/safety_hyundai.h" #include "safety/safety_chrysler.h" #include "safety/safety_subaru.h" +#include "safety/safety_mazda.h" #include "safety/safety_elm327.h" const safety_hooks *current_hooks = &nooutput_hooks; @@ -55,6 +56,8 @@ typedef struct { #define SAFETY_TESLA 8U #define SAFETY_CHRYSLER 9U #define SAFETY_SUBARU 10U +#define SAFETY_GM_PASSIVE 11U +#define SAFETY_MAZDA 12U #define SAFETY_GM_ASCM 0x1334U #define SAFETY_TOYOTA_IPAS 0x1335U #define SAFETY_ALLOUTPUT 0x1337U @@ -71,7 +74,9 @@ const safety_hook_config safety_hook_registry[] = { {SAFETY_HYUNDAI, &hyundai_hooks}, {SAFETY_CHRYSLER, &chrysler_hooks}, {SAFETY_SUBARU, &subaru_hooks}, + {SAFETY_MAZDA, &mazda_hooks}, {SAFETY_TOYOTA_IPAS, &toyota_ipas_hooks}, + {SAFETY_GM_PASSIVE, &gm_passive_hooks}, {SAFETY_GM_ASCM, &gm_ascm_hooks}, {SAFETY_TESLA, &tesla_hooks}, {SAFETY_ALLOUTPUT, &alloutput_hooks}, diff --git a/panda/board/safety/safety_gm.h b/panda/board/safety/safety_gm.h index 9ca5ca323..3cef57924 100644 --- a/panda/board/safety/safety_gm.h +++ b/panda/board/safety/safety_gm.h @@ -231,6 +231,20 @@ static int gm_ign_hook(void) { return gm_ignition_started; } +// All sending is disallowed. +// The only difference from "no output" model +// is using GM ignition hook. + +static void gm_passive_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { + int bus_number = GET_BUS(to_push); + int addr = GET_ADDR(to_push); + + if ((addr == 0x1F1) && (bus_number == 0)) { + bool ign = (GET_BYTE(to_push, 0) & 0x20) != 0; + gm_ignition_started = ign; + } +} + const safety_hooks gm_hooks = { .init = gm_init, .rx = gm_rx_hook, @@ -239,3 +253,12 @@ const safety_hooks gm_hooks = { .ignition = gm_ign_hook, .fwd = default_fwd_hook, }; + +const safety_hooks gm_passive_hooks = { + .init = gm_init, + .rx = gm_passive_rx_hook, + .tx = nooutput_tx_hook, + .tx_lin = nooutput_tx_lin_hook, + .ignition = gm_ign_hook, + .fwd = default_fwd_hook, +}; diff --git a/panda/board/safety/safety_honda.h b/panda/board/safety/safety_honda.h index de2153dd3..5121e71cf 100644 --- a/panda/board/safety/safety_honda.h +++ b/panda/board/safety/safety_honda.h @@ -8,16 +8,19 @@ // brake > 0mph const int HONDA_GAS_INTERCEPTOR_THRESHOLD = 328; // ratio between offset and gain from dbc file -int honda_brake_prev = 0; +int honda_brake = 0; int honda_gas_prev = 0; +bool honda_brake_pressed_prev = false; bool honda_moving = false; bool honda_bosch_hardware = false; bool honda_alt_brake_msg = false; +bool honda_fwd_brake = false; static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { int addr = GET_ADDR(to_push); //int len = GET_LEN(to_push); + int bus = GET_BUS(to_push); // sample speed if (addr == 0x158) { @@ -51,11 +54,11 @@ static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { // exit controls on rising edge of brake press or on brake press when speed > 0 bool is_user_brake_msg = honda_alt_brake_msg ? ((addr) == 0x1BE) : ((addr) == 0x17C); if (is_user_brake_msg) { - int brake = honda_alt_brake_msg ? (GET_BYTE((to_push), 0) & 0x10) : (GET_BYTE((to_push), 6) & 0x20); - if (brake && (!(honda_brake_prev) || honda_moving)) { + bool brake_pressed = honda_alt_brake_msg ? (GET_BYTE((to_push), 0) & 0x10) : (GET_BYTE((to_push), 6) & 0x20); + if (brake_pressed && (!(honda_brake_pressed_prev) || honda_moving)) { controls_allowed = 0; } - honda_brake_prev = brake; + honda_brake_pressed_prev = brake_pressed; } // exit controls on rising edge of gas press if interceptor (0x201 w/ len = 6) @@ -81,6 +84,20 @@ static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { honda_gas_prev = gas; } } + if ((bus == 2) && (addr == 0x1FA)) { + bool honda_stock_aeb = GET_BYTE(to_push, 3) & 0x20; + int honda_stock_brake = (GET_BYTE(to_push, 0) << 2) + ((GET_BYTE(to_push, 1) >> 6) & 0x3); + + // Forward AEB when stock braking is higher than openpilot braking + // only stop forwarding when AEB event is over + if (!honda_stock_aeb) { + honda_fwd_brake = false; + } else if (honda_stock_brake >= honda_brake) { + honda_fwd_brake = true; + } else { + // Leave honda forward brake as is + } + } } // all commands: gas, brake and steering @@ -98,18 +115,21 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // disallow actuator commands if gas or brake (with vehicle moving) are pressed // and the the latching controls_allowed flag is True int pedal_pressed = honda_gas_prev || (gas_interceptor_prev > HONDA_GAS_INTERCEPTOR_THRESHOLD) || - (honda_brake_prev && honda_moving); + (honda_brake_pressed_prev && honda_moving); bool current_controls_allowed = controls_allowed && !(pedal_pressed); // BRAKE: safety check - if (addr == 0x1FA) { - int brake = (GET_BYTE(to_send, 0) << 2) + (GET_BYTE(to_send, 1) & 0x3); + if ((addr == 0x1FA) && (bus == 0)) { + honda_brake = (GET_BYTE(to_send, 0) << 2) + ((GET_BYTE(to_send, 1) >> 6) & 0x3); if (!current_controls_allowed || !long_controls_allowed) { - if (brake != 0) { + if (honda_brake != 0) { tx = 0; } } - if (brake > 255) { + if (honda_brake > 255) { + tx = 0; + } + if (honda_fwd_brake) { tx = 0; } } @@ -175,9 +195,12 @@ static int honda_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { if (bus_num == 2) { // block stock lkas messages and stock acc messages (if OP is doing ACC) int addr = GET_ADDR(to_fwd); - int is_lkas_msg = (addr == 0xE4) || (addr == 0x194) || (addr == 0x33D); - int is_acc_msg = (addr == 0x1FA) || (addr == 0x30C) || (addr == 0x39F); - int block_fwd = is_lkas_msg || (is_acc_msg && long_controls_allowed); + bool is_lkas_msg = (addr == 0xE4) || (addr == 0x194) || (addr == 0x33D); + bool is_acc_hud_msg = (addr == 0x30C) || (addr == 0x39F); + bool is_brake_msg = addr == 0x1FA; + bool block_fwd = is_lkas_msg || + (is_acc_hud_msg && long_controls_allowed) || + (is_brake_msg && long_controls_allowed && !honda_fwd_brake); if (!block_fwd) { bus_fwd = 0; } diff --git a/panda/board/safety/safety_mazda.h b/panda/board/safety/safety_mazda.h new file mode 100644 index 000000000..63fbcdfd6 --- /dev/null +++ b/panda/board/safety/safety_mazda.h @@ -0,0 +1,169 @@ + +// CAN msgs we care about +#define MAZDA_LKAS 0x243 +#define MAZDA_LANEINFO 0x440 +#define MAZDA_CRZ_CTRL 0x21c +#define MAZDA_WHEEL_SPEED 0x215 +#define MAZDA_STEER_TORQUE 0x240 + +// CAN bus numbers +#define MAZDA_MAIN 0 +#define MAZDA_AUX 1 +#define MAZDA_CAM 2 + +#define MAZDA_MAX_STEER 2048 + +// max delta torque allowed for real time checks +#define MAZDA_MAX_RT_DELTA 940 +// 250ms between real time checks +#define MAZDA_RT_INTERVAL 250000 +#define MAZDA_MAX_RATE_UP 10 +#define MAZDA_MAX_RATE_DOWN 25 +#define MAZDA_DRIVER_TORQUE_ALLOWANCE 15 +#define MAZDA_DRIVER_TORQUE_FACTOR 1 + + +int mazda_cruise_engaged_last = 0; +int mazda_rt_torque_last = 0; +int mazda_desired_torque_last = 0; +uint32_t mazda_ts_last = 0; +struct sample_t mazda_torque_driver; // last few driver torques measured + +// track msgs coming from OP so that we know what CAM msgs to drop and what to forward +int mazda_op_lkas_detected = 0; +int mazda_op_laneinfo_detected = 0; + +int mazda_forward_cam = 0; +int mazda_giraffe_switch_2_on = 0; + +void mazda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { + int bus = GET_BUS(to_push); + int addr = GET_ADDR(to_push); + + if ((addr == MAZDA_STEER_TORQUE) && (bus == MAZDA_MAIN)) { + int torque_driver_new = GET_BYTE(to_push, 0) - 127; + // update array of samples + update_sample(&mazda_torque_driver, torque_driver_new); + } + + // enter controls on rising edge of ACC, exit controls on ACC off + if ((addr == MAZDA_CRZ_CTRL) && (bus == MAZDA_MAIN)) { + int cruise_engaged = GET_BYTE(to_push, 0) & 8; + if (cruise_engaged != 0) { + if (!mazda_cruise_engaged_last) { + controls_allowed = 1; + } + } + else { + controls_allowed = 0; + } + mazda_cruise_engaged_last = cruise_engaged; + } + + // we have msgs on bus MAZDA_CAM + if (bus == MAZDA_CAM) { + // the stock CAM is connected + if (addr == MAZDA_LKAS) { + mazda_forward_cam = 1; + } + // if we see wheel speed msgs on MAZDA_CAM bus then giraffe switch 2 is high + // (hardware passthru) + if (addr == MAZDA_WHEEL_SPEED) { + mazda_giraffe_switch_2_on = 1; + } + } +} + +static int mazda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { + int tx = 1; + int addr = GET_ADDR(to_send); + int bus = GET_BUS(to_send); + + // Check if msg is sent on the main BUS + if (bus == MAZDA_MAIN) { + if ((addr == MAZDA_LKAS) && !mazda_op_lkas_detected){ + mazda_op_lkas_detected = 1; + } + if ((addr == MAZDA_LANEINFO) && !mazda_op_laneinfo_detected){ + mazda_op_laneinfo_detected = 1; + } + + // steer cmd checks + if (addr == MAZDA_LKAS) { + int desired_torque = (((GET_BYTE(to_send, 0) & 0x0f) << 8) | GET_BYTE(to_send, 1)) - MAZDA_MAX_STEER; + bool violation = 0; + uint32_t ts = TIM2->CNT; + + if (controls_allowed) { + + // *** global torque limit check *** + violation |= max_limit_check(desired_torque, MAZDA_MAX_STEER, -MAZDA_MAX_STEER); + + // *** torque rate limit check *** + int desired_torque_last = mazda_desired_torque_last; + violation |= driver_limit_check(desired_torque, desired_torque_last, &mazda_torque_driver, + MAZDA_MAX_STEER, MAZDA_MAX_RATE_UP, MAZDA_MAX_RATE_DOWN, + MAZDA_DRIVER_TORQUE_ALLOWANCE, MAZDA_DRIVER_TORQUE_FACTOR); + // used next time + mazda_desired_torque_last = desired_torque; + + // *** torque real time rate limit check *** + violation |= rt_rate_limit_check(desired_torque, mazda_rt_torque_last, MAZDA_MAX_RT_DELTA); + + // every RT_INTERVAL set the new limits + uint32_t ts_elapsed = get_ts_elapsed(ts, mazda_ts_last); + if (ts_elapsed > ((uint32_t) MAZDA_RT_INTERVAL)) { + mazda_rt_torque_last = desired_torque; + mazda_ts_last = ts; + } + } + + // no torque if controls is not allowed + if (!controls_allowed && (desired_torque != 0)) { + violation = 1; + } + + // reset to 0 if either controls is not allowed or there's a violation + if (violation || !controls_allowed) { + mazda_desired_torque_last = 0; + mazda_rt_torque_last = 0; + mazda_ts_last = ts; + } + + if (violation) { + tx = 0; + } + } + } + return tx; +} + +static int mazda_fwd_hook(int bus, CAN_FIFOMailBox_TypeDef *to_fwd) { + int bus_fwd = -1; + if (mazda_forward_cam && !mazda_giraffe_switch_2_on) { + int addr = GET_ADDR(to_fwd); + if (bus == MAZDA_MAIN) { + bus_fwd = MAZDA_CAM; + } + else if (bus == MAZDA_CAM) { + // drop stock CAM_LKAS and CAM_LANEINFI if OP is sending them + if (!((addr == MAZDA_LKAS) && mazda_op_lkas_detected) && + !((addr == MAZDA_LANEINFO) && mazda_op_laneinfo_detected)) { + bus_fwd = MAZDA_MAIN; + } + } + else { + bus_fwd = -1; + } + } + return bus_fwd; +} + +const safety_hooks mazda_hooks = { + .init = nooutput_init, + .rx = mazda_rx_hook, + .tx = mazda_tx_hook, + .tx_lin = nooutput_tx_lin_hook, + .ignition = default_ign_hook, + .fwd = mazda_fwd_hook, +}; diff --git a/panda/board/safety/safety_subaru.h b/panda/board/safety/safety_subaru.h index 3eda8369b..5b482973e 100644 --- a/panda/board/safety/safety_subaru.h +++ b/panda/board/safety/safety_subaru.h @@ -14,21 +14,22 @@ int subaru_desired_torque_last = 0; uint32_t subaru_ts_last = 0; struct sample_t subaru_torque_driver; // last few driver torques measured - static void subaru_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { int bus = GET_BUS(to_push); int addr = GET_ADDR(to_push); - if ((addr == 0x119) && (bus == 0)){ - int torque_driver_new = ((GET_BYTES_04(to_push) >> 16) & 0x7FF); + if (((addr == 0x119) || (addr == 0x371)) && (bus == 0)){ + int bit_shift = (addr == 0x119) ? 16 : 29; + int torque_driver_new = ((GET_BYTES_04(to_push) >> bit_shift) & 0x7FF); torque_driver_new = to_signed(torque_driver_new, 11); // update array of samples update_sample(&subaru_torque_driver, torque_driver_new); } // enter controls on rising edge of ACC, exit controls on ACC off - if ((addr == 0x240) && (bus == 0)) { - int cruise_engaged = GET_BYTE(to_push, 5) & 2; + if (((addr == 0x240) || (addr == 0x144)) && (bus == 0)) { + int bit_shift = (addr == 0x240) ? 9 : 17; + int cruise_engaged = ((GET_BYTES_48(to_push) >> bit_shift) & 1); if (cruise_engaged && !subaru_cruise_engaged_last) { controls_allowed = 1; } @@ -44,8 +45,9 @@ static int subaru_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int addr = GET_ADDR(to_send); // steer cmd checks - if (addr == 0x122) { - int desired_torque = ((GET_BYTES_04(to_send) >> 16) & 0x1FFF); + if ((addr == 0x122) || (addr == 0x164)) { + int bit_shift = (addr == 0x122) ? 16 : 8; + int desired_torque = ((GET_BYTES_04(to_send) >> bit_shift) & 0x1FFF); bool violation = 0; uint32_t ts = TIM2->CNT; desired_torque = to_signed(desired_torque, 13); @@ -102,8 +104,8 @@ static int subaru_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { bus_fwd = 2; // Camera CAN } if (bus_num == 2) { + // 290 is LKAS for Global Platform // 356 is LKAS for outback 2015 - // 356 is LKAS for Global Platform // 545 is ES_Distance // 802 is ES_LKAS int addr = GET_ADDR(to_fwd); diff --git a/panda/board/safety/safety_toyota.h b/panda/board/safety/safety_toyota.h index 2e6f275d4..4e5bbe195 100644 --- a/panda/board/safety/safety_toyota.h +++ b/panda/board/safety/safety_toyota.h @@ -54,7 +54,8 @@ static void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { } // enter controls on rising edge of ACC, exit controls on ACC off - if (addr == 0x1D2) { + controls_allowed = 1; + if (false) { // 5th bit is CRUISE_ACTIVE int cruise_engaged = GET_BYTE(to_push, 0) & 0x20; if (!cruise_engaged) { diff --git a/panda/board/spi_flasher.h b/panda/board/spi_flasher.h index 4eab35671..b1bba71d4 100644 --- a/panda/board/spi_flasher.h +++ b/panda/board/spi_flasher.h @@ -183,7 +183,7 @@ void CAN1_RX0_IRQHandler(void) { if ((CAN->sFIFOMailBox[0].RIR>>21) == CAN_BL_INPUT) { uint8_t dat[8]; for (int i = 0; i < 8; i++) { - dat[0] = GET_BYTE(&CAN->sFIFOMailBox[0], i); + dat[i] = GET_BYTE(&CAN->sFIFOMailBox[0], i); } uint8_t odat[8]; uint8_t type = dat[0] & 0xF0; @@ -307,7 +307,7 @@ void soft_flasher_start(void) { // green LED on for flashing current_board->set_led(LED_GREEN, 1); - __enable_irq(); + enable_interrupts(); uint64_t cnt = 0; diff --git a/panda/python/__init__.py b/panda/python/__init__.py index e83a4a169..573d6f159 100644 --- a/panda/python/__init__.py +++ b/panda/python/__init__.py @@ -135,6 +135,12 @@ class Panda(object): REQUEST_IN = usb1.ENDPOINT_IN | usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE REQUEST_OUT = usb1.ENDPOINT_OUT | usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE + HW_TYPE_UNKNOWN = '\x00' + HW_TYPE_WHITE_PANDA = '\x01' + HW_TYPE_GREY_PANDA = '\x02' + HW_TYPE_BLACK_PANDA = '\x03' + HW_TYPE_PEDAL = '\x04' + def __init__(self, serial=None, claim=True): self._serial = serial self._handle = None @@ -363,11 +369,14 @@ class Panda(object): def get_type(self): return self._handle.controlRead(Panda.REQUEST_IN, 0xc1, 0, 0, 0x40) + def is_white(self): + return self.get_type() == Panda.HW_TYPE_WHITE_PANDA + def is_grey(self): - return self.get_type() == "\x02" + return self.get_type() == Panda.HW_TYPE_GREY_PANDA def is_black(self): - return self.get_type() == "\x03" + return self.get_type() == Panda.HW_TYPE_BLACK_PANDA def get_serial(self): dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd0, 0, 0, 0x20) @@ -470,6 +479,7 @@ class Panda(object): break except (usb1.USBErrorIO, usb1.USBErrorOverflow): print("CAN: BAD RECV, RETRYING") + time.sleep(0.1) return parse_can_buffer(dat) def can_clear(self, bus): diff --git a/panda/tests/automated/1_program.py b/panda/tests/automated/1_program.py index 1e0beb8ae..6b8a3ad48 100644 --- a/panda/tests/automated/1_program.py +++ b/panda/tests/automated/1_program.py @@ -1,15 +1,13 @@ import os from panda import Panda -from helpers import panda_color_to_serial, test_white_and_grey +from helpers import panda_type_to_serial, test_white_and_grey, test_all_pandas, panda_connect_and_init -@test_white_and_grey -@panda_color_to_serial -def test_recover(serial=None): - p = Panda(serial=serial) +@test_all_pandas +@panda_connect_and_init +def test_recover(p): assert p.recover(timeout=30) -@test_white_and_grey -@panda_color_to_serial -def test_flash(serial=None): - p = Panda(serial=serial) +@test_all_pandas +@panda_connect_and_init +def test_flash(p): p.flash() diff --git a/panda/tests/automated/2_usb_to_can.py b/panda/tests/automated/2_usb_to_can.py index 9e3e07aa4..f0411b32c 100644 --- a/panda/tests/automated/2_usb_to_can.py +++ b/panda/tests/automated/2_usb_to_can.py @@ -4,16 +4,11 @@ import sys import time from panda import Panda from nose.tools import assert_equal, assert_less, assert_greater -from helpers import time_many_sends, connect_wo_esp, test_white_and_grey, panda_color_to_serial - -SPEED_NORMAL = 500 -SPEED_GMLAN = 33.3 - -@test_white_and_grey -@panda_color_to_serial -def test_can_loopback(serial=None): - p = connect_wo_esp(serial) +from helpers import SPEED_NORMAL, SPEED_GMLAN, time_many_sends, test_white_and_grey, panda_type_to_serial, test_all_pandas, panda_connect_and_init +@test_all_pandas +@panda_connect_and_init +def test_can_loopback(p): # enable output mode p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) @@ -26,9 +21,6 @@ def test_can_loopback(serial=None): busses = [0,1,2] for bus in busses: - # send heartbeat - p.send_heartbeat() - # set bus 0 speed to 250 p.set_can_speed_kbps(bus, 250) @@ -47,17 +39,12 @@ def test_can_loopback(serial=None): assert 0x1aa == sr[0][0] == lb[0][0] assert "message" == sr[0][2] == lb[0][2] -@test_white_and_grey -@panda_color_to_serial -def test_safety_nooutput(serial=None): - p = connect_wo_esp(serial) - +@test_all_pandas +@panda_connect_and_init +def test_safety_nooutput(p): # enable output mode p.set_safety_mode(Panda.SAFETY_NOOUTPUT) - # send heartbeat - p.send_heartbeat() - # enable CAN loopback mode p.set_can_loopback(True) @@ -69,11 +56,9 @@ def test_safety_nooutput(serial=None): r = p.can_recv() assert len(r) == 0 -@test_white_and_grey -@panda_color_to_serial -def test_reliability(serial=None): - p = connect_wo_esp(serial) - +@test_all_pandas +@panda_connect_and_init +def test_reliability(p): LOOP_COUNT = 100 MSG_COUNT = 100 @@ -82,17 +67,11 @@ def test_reliability(serial=None): p.set_can_loopback(True) p.set_can_speed_kbps(0, 1000) - # send heartbeat - p.send_heartbeat() - addrs = range(100, 100+MSG_COUNT) ts = [(j, 0, "\xaa"*8, 0) for j in addrs] # 100 loops for i in range(LOOP_COUNT): - # send heartbeat - p.send_heartbeat() - st = time.time() p.can_send_many(ts) @@ -115,17 +94,12 @@ def test_reliability(serial=None): sys.stdout.write("P") sys.stdout.flush() -@test_white_and_grey -@panda_color_to_serial -def test_throughput(serial=None): - p = connect_wo_esp(serial) - +@test_all_pandas +@panda_connect_and_init +def test_throughput(p): # enable output mode p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - # send heartbeat - p.send_heartbeat() - # enable CAN loopback mode p.set_can_loopback(True) @@ -134,9 +108,6 @@ def test_throughput(serial=None): p.set_can_speed_kbps(0, speed) time.sleep(0.05) - # send heartbeat - p.send_heartbeat() - comp_kbps = time_many_sends(p, 0) # bit count from https://en.wikipedia.org/wiki/CAN_bus @@ -147,19 +118,15 @@ def test_throughput(serial=None): print("loopback 100 messages at speed %d, comp speed is %.2f, percent %.2f" % (speed, comp_kbps, saturation_pct)) @test_white_and_grey -@panda_color_to_serial -def test_gmlan(serial=None): - p = connect_wo_esp(serial) - +@panda_type_to_serial +@panda_connect_and_init +def test_gmlan(p): if p.legacy: return # enable output mode p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - # send heartbeat - p.send_heartbeat() - # enable CAN loopback mode p.set_can_loopback(True) @@ -169,9 +136,6 @@ def test_gmlan(serial=None): # set gmlan on CAN2 for bus in [Panda.GMLAN_CAN2, Panda.GMLAN_CAN3, Panda.GMLAN_CAN2, Panda.GMLAN_CAN3]: - # send heartbeat - p.send_heartbeat() - p.set_gmlan(bus) comp_kbps_gmlan = time_many_sends(p, 3) assert_greater(comp_kbps_gmlan, 0.8 * SPEED_GMLAN) @@ -185,27 +149,20 @@ def test_gmlan(serial=None): print("%d: %.2f kbps vs %.2f kbps" % (bus, comp_kbps_gmlan, comp_kbps_normal)) @test_white_and_grey -@panda_color_to_serial -def test_gmlan_bad_toggle(serial=None): - p = connect_wo_esp(serial) - +@panda_type_to_serial +@panda_connect_and_init +def test_gmlan_bad_toggle(p): if p.legacy: return # enable output mode p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - # send heartbeat - p.send_heartbeat() - # enable CAN loopback mode p.set_can_loopback(True) # GMLAN_CAN2 for bus in [Panda.GMLAN_CAN2, Panda.GMLAN_CAN3]: - # send heartbeat - p.send_heartbeat() - p.set_gmlan(bus) comp_kbps_gmlan = time_many_sends(p, 3) assert_greater(comp_kbps_gmlan, 0.6 * SPEED_GMLAN) @@ -213,9 +170,6 @@ def test_gmlan_bad_toggle(serial=None): # normal for bus in [Panda.GMLAN_CAN2, Panda.GMLAN_CAN3]: - # send heartbeat - p.send_heartbeat() - p.set_gmlan(None) comp_kbps_normal = time_many_sends(p, bus) assert_greater(comp_kbps_normal, 0.6 * SPEED_NORMAL) @@ -223,10 +177,9 @@ def test_gmlan_bad_toggle(serial=None): # this will fail if you have hardware serial connected -@test_white_and_grey -@panda_color_to_serial -def test_serial_debug(serial=None): - p = connect_wo_esp(serial) +@test_all_pandas +@panda_connect_and_init +def test_serial_debug(p): junk = p.serial_read(Panda.SERIAL_DEBUG) p.call_control_api(0xc0) assert(p.serial_read(Panda.SERIAL_DEBUG).startswith("can ")) diff --git a/panda/tests/automated/3_wifi.py b/panda/tests/automated/3_wifi.py index 1251663ba..2e9c81f3f 100644 --- a/panda/tests/automated/3_wifi.py +++ b/panda/tests/automated/3_wifi.py @@ -2,46 +2,44 @@ from __future__ import print_function import os import time from panda import Panda -from helpers import connect_wifi, test_white, test_white_and_grey, panda_color_to_serial +from helpers import connect_wifi, test_white, test_all_pandas, panda_type_to_serial, panda_connect_and_init import requests -@test_white_and_grey -@panda_color_to_serial -def test_get_serial(serial=None): - p = Panda(serial) +@test_all_pandas +@panda_connect_and_init +def test_get_serial(p): print(p.get_serial()) -@test_white_and_grey -@panda_color_to_serial -def test_get_serial_in_flash_mode(serial=None): - p = Panda(serial) +@test_all_pandas +@panda_connect_and_init +def test_get_serial_in_flash_mode(p): p.reset(enter_bootstub=True) assert(p.bootstub) print(p.get_serial()) p.reset() @test_white -@panda_color_to_serial -def test_connect_wifi(serial=None): - connect_wifi(serial) +@panda_type_to_serial +def test_connect_wifi(serials=None): + connect_wifi(serials[0]) @test_white -@panda_color_to_serial -def test_flash_wifi(serial=None): - connect_wifi(serial) +@panda_type_to_serial +def test_flash_wifi(serials=None): + connect_wifi(serials[0]) assert Panda.flash_ota_wifi(release=False), "OTA Wifi Flash Failed" - connect_wifi(serial) + connect_wifi(serials[0]) @test_white -@panda_color_to_serial -def test_wifi_flash_st(serial=None): - connect_wifi(serial) +@panda_type_to_serial +def test_wifi_flash_st(serials=None): + connect_wifi(serials[0]) assert Panda.flash_ota_st(), "OTA ST Flash Failed" connected = False st = time.time() while not connected and (time.time() - st) < 20: try: - p = Panda(serial=serial) + p = Panda(serial=serials[0]) p.get_serial() connected = True except: @@ -51,9 +49,9 @@ def test_wifi_flash_st(serial=None): assert False, "Panda failed to connect on USB after flashing" @test_white -@panda_color_to_serial -def test_webpage_fetch(serial=None): - connect_wifi(serial) +@panda_type_to_serial +def test_webpage_fetch(serials=None): + connect_wifi(serials[0]) r = requests.get("http://192.168.0.10/") print(r.text) diff --git a/panda/tests/automated/4_wifi_functionality.py b/panda/tests/automated/4_wifi_functionality.py index ab9bed700..ee9857d09 100644 --- a/panda/tests/automated/4_wifi_functionality.py +++ b/panda/tests/automated/4_wifi_functionality.py @@ -1,38 +1,32 @@ from __future__ import print_function import time from panda import Panda -from helpers import time_many_sends, connect_wifi, test_white, panda_color_to_serial +from helpers import time_many_sends, connect_wifi, test_white, panda_type_to_serial from nose.tools import timed, assert_equal, assert_less, assert_greater @test_white -@panda_color_to_serial -def test_get_serial_wifi(serial=None): - connect_wifi(serial) +@panda_type_to_serial +def test_get_serial_wifi(serials=None): + connect_wifi(serials[0]) p = Panda("WIFI") print(p.get_serial()) @test_white -@panda_color_to_serial -def test_throughput(serial=None): - connect_wifi(serial) - p = Panda(serial) +@panda_type_to_serial +def test_throughput(serials=None): + connect_wifi(serials[0]) + p = Panda(serials[0]) # enable output mode p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - # send heartbeat - p.send_heartbeat() - # enable CAN loopback mode p.set_can_loopback(True) p = Panda("WIFI") for speed in [100,250,500,750,1000]: - # send heartbeat - p.send_heartbeat() - # set bus 0 speed to speed p.set_can_speed_kbps(0, speed) time.sleep(0.1) @@ -47,23 +41,17 @@ def test_throughput(serial=None): print("WIFI loopback 100 messages at speed %d, comp speed is %.2f, percent %.2f" % (speed, comp_kbps, saturation_pct)) @test_white -@panda_color_to_serial -def test_recv_only(serial=None): - connect_wifi(serial) - p = Panda(serial) +@panda_type_to_serial +def test_recv_only(serials=None): + connect_wifi(serials[0]) + p = Panda(serials[0]) p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - # send heartbeat - p.send_heartbeat() - p.set_can_loopback(True) pwifi = Panda("WIFI") # TODO: msg_count=1000 drops packets, is this fixable? for msg_count in [10,100,200]: - # send heartbeat - p.send_heartbeat() - speed = 500 p.set_can_speed_kbps(0, speed) comp_kbps = time_many_sends(p, 0, pwifi, msg_count) diff --git a/panda/tests/automated/5_wifi_udp.py b/panda/tests/automated/5_wifi_udp.py index d55baa659..8b62cf082 100644 --- a/panda/tests/automated/5_wifi_udp.py +++ b/panda/tests/automated/5_wifi_udp.py @@ -1,16 +1,16 @@ from __future__ import print_function import sys import time -from helpers import time_many_sends, connect_wifi, test_white, panda_color_to_serial +from helpers import time_many_sends, connect_wifi, test_white, panda_type_to_serial from panda import Panda, PandaWifiStreaming from nose.tools import timed, assert_equal, assert_less, assert_greater @test_white -@panda_color_to_serial -def test_udp_doesnt_drop(serial=None): - connect_wifi(serial) +@panda_type_to_serial +def test_udp_doesnt_drop(serials=None): + connect_wifi(serials[0]) - p = Panda(serial) + p = Panda(serials[0]) p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) p.set_can_loopback(True) diff --git a/panda/tests/automated/6_two_panda.py b/panda/tests/automated/6_two_panda.py index 09cf1861f..8b308ce50 100644 --- a/panda/tests/automated/6_two_panda.py +++ b/panda/tests/automated/6_two_panda.py @@ -1,21 +1,18 @@ from __future__ import print_function +import os import time +import random from panda import Panda from nose.tools import assert_equal, assert_less, assert_greater -from helpers import time_many_sends, test_two_panda, panda_color_to_serial +from helpers import time_many_sends, test_two_panda, test_two_black_panda, panda_type_to_serial, clear_can_buffers, panda_connect_and_init @test_two_panda -@panda_color_to_serial -def test_send_recv(serial_sender=None, serial_reciever=None): - p_send = Panda(serial_sender) - p_recv = Panda(serial_reciever) - +@panda_type_to_serial +@panda_connect_and_init +def test_send_recv(p_send, p_recv): p_send.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + p_recv.set_safety_mode(Panda.SAFETY_ALLOUTPUT) p_send.set_can_loopback(False) - - # send heartbeat - p_send.send_heartbeat() - p_recv.set_can_loopback(False) assert not p_send.legacy @@ -30,9 +27,6 @@ def test_send_recv(serial_sender=None, serial_reciever=None): for bus in busses: for speed in [100, 250, 500, 750, 1000]: - # send heartbeat - p_send.send_heartbeat() - p_send.set_can_speed_kbps(bus, speed) p_recv.set_can_speed_kbps(bus, speed) time.sleep(0.05) @@ -46,18 +40,12 @@ def test_send_recv(serial_sender=None, serial_reciever=None): print("two pandas bus {}, 100 messages at speed {:4d}, comp speed is {:7.2f}, percent {:6.2f}".format(bus, speed, comp_kbps, saturation_pct)) @test_two_panda -@panda_color_to_serial -def test_latency(serial_sender=None, serial_reciever=None): - p_send = Panda(serial_sender) - p_recv = Panda(serial_reciever) - - # send heartbeat - p_send.send_heartbeat() - p_recv.send_heartbeat() - +@panda_type_to_serial +@panda_connect_and_init +def test_latency(p_send, p_recv): p_send.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + p_recv.set_safety_mode(Panda.SAFETY_ALLOUTPUT) p_send.set_can_loopback(False) - p_recv.set_can_loopback(False) assert not p_send.legacy @@ -72,29 +60,17 @@ def test_latency(serial_sender=None, serial_reciever=None): p_recv.can_recv() p_send.can_recv() - # send heartbeat - p_send.send_heartbeat() - p_recv.send_heartbeat() - busses = [0,1,2] for bus in busses: for speed in [100, 250, 500, 750, 1000]: - # send heartbeat - p_send.send_heartbeat() - p_recv.send_heartbeat() - p_send.set_can_speed_kbps(bus, speed) p_recv.set_can_speed_kbps(bus, speed) time.sleep(0.1) + #clear can buffers - r = [1] - while len(r) > 0: - r = p_send.can_recv() - r = [1] - while len(r) > 0: - r = p_recv.can_recv() - time.sleep(0.05) + clear_can_buffers(p_send) + clear_can_buffers(p_recv) latencies = [] comp_kbps_list = [] @@ -137,3 +113,83 @@ def test_latency(serial_sender=None, serial_reciever=None): print("two pandas bus {}, {} message average at speed {:4d}, latency is {:5.3f}ms, comp speed is {:7.2f}, percent {:6.2f}"\ .format(bus, num_messages, speed, average_latency, average_comp_kbps, average_saturation_pct)) + +@test_two_black_panda +@panda_type_to_serial +@panda_connect_and_init +def test_black_loopback(panda0, panda1): + # disable safety modes + panda0.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + panda1.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + + # disable loopback + panda0.set_can_loopback(False) + panda1.set_can_loopback(False) + + # clear stuff + panda0.can_send_many([(0x1ba, 0, "testmsg", 0)]*10) + time.sleep(0.05) + panda0.can_recv() + panda1.can_recv() + + # test array (send bus, sender obd, reciever obd, expected busses) + test_array = [ + (0, False, False, [0]), + (1, False, False, [1]), + (2, False, False, [2]), + (0, False, True, [0, 1]), + (1, False, True, []), + (2, False, True, [2]), + (0, True, False, [0]), + (1, True, False, [0]), + (2, True, False, [2]), + (0, True, True, [0, 1]), + (1, True, True, [0, 1]), + (2, True, True, [2]) + ] + + # test functions + def get_test_string(): + return b"test"+os.urandom(10) + + def _test_buses(send_panda, recv_panda, _test_array): + for send_bus, send_obd, recv_obd, recv_buses in _test_array: + print("\nSend bus:", send_bus, " Send OBD:", send_obd, " Recv OBD:", recv_obd) + + # set OBD on pandas + send_panda.set_gmlan(True if send_obd else None) + recv_panda.set_gmlan(True if recv_obd else None) + + # clear buffers + clear_can_buffers(send_panda) + clear_can_buffers(recv_panda) + + # send the characters + at = random.randint(1, 2000) + st = get_test_string()[0:8] + send_panda.can_send(at, st, send_bus) + time.sleep(0.1) + + # check for receive + cans_echo = send_panda.can_recv() + cans_loop = recv_panda.can_recv() + + loop_buses = [] + for loop in cans_loop: + print(" Loop on bus", str(loop[3])) + loop_buses.append(loop[3]) + if len(cans_loop) == 0: + print(" No loop") + + # test loop buses + recv_buses.sort() + loop_buses.sort() + assert recv_buses == loop_buses + print(" TEST PASSED") + print("\n") + + # test both orientations + print("***************** TESTING (0 --> 1) *****************") + _test_buses(panda0, panda1, test_array) + print("***************** TESTING (1 --> 0) *****************") + _test_buses(panda1, panda0, test_array) \ No newline at end of file diff --git a/panda/tests/automated/helpers.py b/panda/tests/automated/helpers.py index 9e92f56bf..c9e0c6762 100644 --- a/panda/tests/automated/helpers.py +++ b/panda/tests/automated/helpers.py @@ -4,43 +4,41 @@ import time import random import subprocess import requests +import thread from functools import wraps from panda import Panda from nose.tools import timed, assert_equal, assert_less, assert_greater from parameterized import parameterized, param -test_white_and_grey = parameterized([param(panda_color="White"), - param(panda_color="Grey")]) -test_white = parameterized([param(panda_color="White")]) -test_grey = parameterized([param(panda_color="Grey")]) -test_two_panda = parameterized([param(panda_color=["Grey", "White"]), - param(panda_color=["White", "Grey"])]) +SPEED_NORMAL = 500 +SPEED_GMLAN = 33.3 -_serials = {} -def get_panda_serial(is_grey=None): - global _serials - if is_grey not in _serials: - for serial in Panda.list(): - p = Panda(serial=serial) - if is_grey is None or p.is_grey() == is_grey: - _serials[is_grey] = serial - return serial - raise IOError("Panda not found. is_grey: {}".format(is_grey)) - else: - return _serials[is_grey] - -def connect_wo_esp(serial=None): - # connect to the panda - p = Panda(serial=serial) - - # power down the ESP - p.set_esp_power(False) - - # clear old junk - while len(p.can_recv()) > 0: - pass - - return p +test_all_types = parameterized([ + param(panda_type=Panda.HW_TYPE_WHITE_PANDA), + param(panda_type=Panda.HW_TYPE_GREY_PANDA), + param(panda_type=Panda.HW_TYPE_BLACK_PANDA) + ]) +test_all_pandas = parameterized( + Panda.list() + ) +test_white_and_grey = parameterized([ + param(panda_type=Panda.HW_TYPE_WHITE_PANDA), + param(panda_type=Panda.HW_TYPE_GREY_PANDA) + ]) +test_white = parameterized([ + param(panda_type=Panda.HW_TYPE_WHITE_PANDA) + ]) +test_grey = parameterized([ + param(panda_type=Panda.HW_TYPE_GREY_PANDA) + ]) +test_two_panda = parameterized([ + param(panda_type=[Panda.HW_TYPE_GREY_PANDA, Panda.HW_TYPE_WHITE_PANDA]), + param(panda_type=[Panda.HW_TYPE_WHITE_PANDA, Panda.HW_TYPE_GREY_PANDA]), + param(panda_type=[Panda.HW_TYPE_BLACK_PANDA, Panda.HW_TYPE_BLACK_PANDA]) + ]) +test_two_black_panda = parameterized([ + param(panda_type=[Panda.HW_TYPE_BLACK_PANDA, Panda.HW_TYPE_BLACK_PANDA]) + ]) def connect_wifi(serial=None): p = Panda(serial=serial) @@ -170,23 +168,93 @@ def time_many_sends(p, bus, precv=None, msg_count=100, msg_id=None, two_pandas=F return comp_kbps - -def panda_color_to_serial(fn): +_panda_serials = None +def panda_type_to_serial(fn): @wraps(fn) - def wrapper(panda_color=None, **kwargs): - pandas_is_grey = [] - if panda_color is not None: - if not isinstance(panda_color, list): - panda_color = [panda_color] - panda_color = [s.lower() for s in panda_color] - for p in panda_color: - if p is None: - pandas_is_grey.append(None) - elif p in ["grey", "gray"]: - pandas_is_grey.append(True) - elif p in ["white"]: - pandas_is_grey.append(False) - else: - raise ValueError("Invalid Panda Color {}".format(p)) - return fn(*[get_panda_serial(is_grey) for is_grey in pandas_is_grey], **kwargs) + def wrapper(panda_type=None, **kwargs): + # Change panda_types to a list + if panda_type is not None: + if not isinstance(panda_type, list): + panda_type = [panda_type] + + # If not done already, get panda serials and their type + global _panda_serials + if _panda_serials == None: + _panda_serials = [] + for serial in Panda.list(): + p = Panda(serial=serial) + _panda_serials.append((serial, p.get_type())) + p.close() + + # Find a panda with the correct types and add the corresponding serial + serials = [] + for p_type in panda_type: + found = False + for serial, pt in _panda_serials: + # Never take the same panda twice + if (pt == p_type) and (serial not in serials): + serials.append(serial) + found = True + break + if not found: + raise IOError("No unused panda found for type: {}".format(p_type)) + return fn(serials, **kwargs) return wrapper + +def heartbeat_thread(p): + while True: + try: + p.send_heartbeat() + time.sleep(1) + except: + break + +def panda_connect_and_init(fn): + @wraps(fn) + def wrapper(panda_serials=None, **kwargs): + # Change panda_serials to a list + if panda_serials is not None: + if not isinstance(panda_serials, list): + panda_serials = [panda_serials] + + # Connect to pandas + pandas = [] + for panda_serial in panda_serials: + pandas.append(Panda(serial=panda_serial)) + + # Initialize pandas + for panda in pandas: + panda.set_can_loopback(False) + panda.set_gmlan(None) + panda.set_esp_power(False) + for bus, speed in [(0, SPEED_NORMAL), (1, SPEED_NORMAL), (2, SPEED_NORMAL), (3, SPEED_GMLAN)]: + panda.set_can_speed_kbps(bus, speed) + clear_can_buffers(panda) + thread.start_new_thread(heartbeat_thread, (panda,)) + + # Run test function + ret = fn(*pandas, **kwargs) + + # Close all connections + for panda in pandas: + panda.close() + + # Return test function result + return ret + return wrapper + +def clear_can_buffers(panda): + # clear tx buffers + for i in range(4): + panda.can_clear(i) + + # clear rx buffers + panda.can_clear(0xFFFF) + r = [1] + st = time.time() + while len(r) > 0: + r = panda.can_recv() + time.sleep(0.05) + if (time.time() - st) > 10: + print("Unable to clear can buffers for panda ", panda.get_serial()) + assert False \ No newline at end of file diff --git a/panda/tests/black_loopback_test.py b/panda/tests/black_loopback_test.py index 8683561a4..d16ac21af 100755 --- a/panda/tests/black_loopback_test.py +++ b/panda/tests/black_loopback_test.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Loopback test between black panda (+ harness and power) and white/grey panda +# Loopback test between two black pandas (+ harness and power) # Tests all buses, including OBD CAN, which is on the same bus as CAN0 in this test. # To be sure, the test should be run with both harness orientations @@ -33,81 +33,70 @@ def run_test(sleep_duration): pandas[0] = Panda(pandas[0]) pandas[1] = Panda(pandas[1]) - # find out which one is black + # find out the hardware types type0 = pandas[0].get_type() type1 = pandas[1].get_type() - - black_panda = None - other_panda = None - if type0 == "\x03" and type1 != "\x03": - black_panda = pandas[0] - other_panda = pandas[1] - elif type0 != "\x03" and type1 == "\x03": - black_panda = pandas[1] - other_panda = pandas[0] - else: - print("Connect white/grey and black panda to run this test!") + if type0 != "\x03" or type1 != "\x03": + print("Connect two black pandas to run this test!") assert False - # disable safety modes - black_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - other_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + for panda in pandas: + # disable safety modes + panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - # test health packet - print("black panda health", black_panda.health()) - print("other panda health", other_panda.health()) + # test health packet + print("panda health", panda.health()) - # test black -> other - test_buses(black_panda, other_panda, True, [(0, False, [0]), (1, False, [1]), (2, False, [2]), (1, True, [0])], sleep_duration) - test_buses(black_panda, other_panda, False, [(0, False, [0]), (1, False, [1]), (2, False, [2]), (0, True, [0, 1])], sleep_duration) + # setup test array (send bus, sender obd, reciever obd, expected busses) + test_array = [ + (0, False, False, [0]), + (1, False, False, [1]), + (2, False, False, [2]), + (0, False, True, [0, 1]), + (1, False, True, []), + (2, False, True, [2]), + (0, True, False, [0]), + (1, True, False, [0]), + (2, True, False, [2]), + (0, True, True, [0, 1]), + (1, True, True, [0, 1]), + (2, True, True, [2]) + ] + + # test both orientations + print("***************** TESTING (0 --> 1) *****************") + test_buses(pandas[0], pandas[1], test_array, sleep_duration) + print("***************** TESTING (1 --> 0) *****************") + test_buses(pandas[1], pandas[0], test_array, sleep_duration) -def test_buses(black_panda, other_panda, direction, test_array, sleep_duration): - if direction: - print("***************** TESTING (BLACK --> OTHER) *****************") - else: - print("***************** TESTING (OTHER --> BLACK) *****************") - - for send_bus, obd, recv_buses in test_array: - black_panda.send_heartbeat() - other_panda.send_heartbeat() - print("\ntest can: ", send_bus, " OBD: ", obd) +def test_buses(send_panda, recv_panda, test_array, sleep_duration): + for send_bus, send_obd, recv_obd, recv_buses in test_array: + send_panda.send_heartbeat() + recv_panda.send_heartbeat() + print("\nSend bus:", send_bus, " Send OBD:", send_obd, " Recv OBD:", recv_obd) - # set OBD on black panda - black_panda.set_gmlan(True if obd else None) + # set OBD on pandas + send_panda.set_gmlan(True if send_obd else None) + recv_panda.set_gmlan(True if recv_obd else None) # clear and flush - if direction: - black_panda.can_clear(send_bus) - else: - other_panda.can_clear(send_bus) - + send_panda.can_clear(send_bus) for recv_bus in recv_buses: - if direction: - other_panda.can_clear(recv_bus) - else: - black_panda.can_clear(recv_bus) - - black_panda.can_recv() - other_panda.can_recv() + recv_panda.can_clear(recv_bus) + send_panda.can_recv() + recv_panda.can_recv() # send the characters at = random.randint(1, 2000) st = get_test_string()[0:8] - if direction: - black_panda.can_send(at, st, send_bus) - else: - other_panda.can_send(at, st, send_bus) + send_panda.can_send(at, st, send_bus) time.sleep(0.1) # check for receive - if direction: - cans_echo = black_panda.can_recv() - cans_loop = other_panda.can_recv() - else: - cans_echo = other_panda.can_recv() - cans_loop = black_panda.can_recv() + cans_echo = send_panda.can_recv() + cans_loop = recv_panda.can_recv() loop_buses = [] for loop in cans_loop: diff --git a/panda/tests/black_white_loopback_test.py b/panda/tests/black_white_loopback_test.py new file mode 100755 index 000000000..7e1213439 --- /dev/null +++ b/panda/tests/black_white_loopback_test.py @@ -0,0 +1,169 @@ +#!/usr/bin/env python + +# Loopback test between black panda (+ harness and power) and white/grey panda +# Tests all buses, including OBD CAN, which is on the same bus as CAN0 in this test. +# To be sure, the test should be run with both harness orientations + +from __future__ import print_function +import os +import sys +import time +import random +import argparse + +from hexdump import hexdump +from itertools import permutations + +sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) +from panda import Panda + +def get_test_string(): + return b"test"+os.urandom(10) + +counter = 0 +nonzero_bus_errors = 0 +zero_bus_errors = 0 +content_errors = 0 + +def run_test(sleep_duration): + global counter, nonzero_bus_errors, zero_bus_errors, content_errors + + pandas = Panda.list() + print(pandas) + + # make sure two pandas are connected + if len(pandas) != 2: + print("Connect white/grey and black panda to run this test!") + assert False + + # connect + pandas[0] = Panda(pandas[0]) + pandas[1] = Panda(pandas[1]) + + # find out which one is black + type0 = pandas[0].get_type() + type1 = pandas[1].get_type() + + black_panda = None + other_panda = None + + if type0 == "\x03" and type1 != "\x03": + black_panda = pandas[0] + other_panda = pandas[1] + elif type0 != "\x03" and type1 == "\x03": + black_panda = pandas[1] + other_panda = pandas[0] + else: + print("Connect white/grey and black panda to run this test!") + assert False + + # disable safety modes + black_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + other_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + + # test health packet + print("black panda health", black_panda.health()) + print("other panda health", other_panda.health()) + + # test black -> other + while True: + test_buses(black_panda, other_panda, True, [(0, False, [0]), (1, False, [1]), (2, False, [2]), (1, True, [0])], sleep_duration) + test_buses(black_panda, other_panda, False, [(0, False, [0]), (1, False, [1]), (2, False, [2]), (0, True, [0, 1])], sleep_duration) + counter += 1 + print("Number of cycles:", counter, "Non-zero bus errors:", nonzero_bus_errors, "Zero bus errors:", zero_bus_errors, "Content errors:", content_errors) + + # Toggle relay + black_panda.set_safety_mode(Panda.SAFETY_NOOUTPUT) + time.sleep(1) + black_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + time.sleep(1) + + +def test_buses(black_panda, other_panda, direction, test_array, sleep_duration): + global nonzero_bus_errors, zero_bus_errors, content_errors + + if direction: + print("***************** TESTING (BLACK --> OTHER) *****************") + else: + print("***************** TESTING (OTHER --> BLACK) *****************") + + for send_bus, obd, recv_buses in test_array: + black_panda.send_heartbeat() + other_panda.send_heartbeat() + print("\ntest can: ", send_bus, " OBD: ", obd) + + # set OBD on black panda + black_panda.set_gmlan(True if obd else None) + + # clear and flush + if direction: + black_panda.can_clear(send_bus) + else: + other_panda.can_clear(send_bus) + + for recv_bus in recv_buses: + if direction: + other_panda.can_clear(recv_bus) + else: + black_panda.can_clear(recv_bus) + + black_panda.can_recv() + other_panda.can_recv() + + # send the characters + at = random.randint(1, 2000) + st = get_test_string()[0:8] + if direction: + black_panda.can_send(at, st, send_bus) + else: + other_panda.can_send(at, st, send_bus) + time.sleep(0.1) + + # check for receive + if direction: + cans_echo = black_panda.can_recv() + cans_loop = other_panda.can_recv() + else: + cans_echo = other_panda.can_recv() + cans_loop = black_panda.can_recv() + + loop_buses = [] + for loop in cans_loop: + if (loop[0] != at) or (loop[2] != st): + content_errors += 1 + + print(" Loop on bus", str(loop[3])) + loop_buses.append(loop[3]) + if len(cans_loop) == 0: + print(" No loop") + if not os.getenv("NOASSERT"): + assert False + + # test loop buses + recv_buses.sort() + loop_buses.sort() + if(recv_buses != loop_buses): + if len(loop_buses) == 0: + zero_bus_errors += 1 + else: + nonzero_bus_errors += 1 + if not os.getenv("NOASSERT"): + assert False + else: + print(" TEST PASSED") + + time.sleep(sleep_duration) + print("\n") + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-n", type=int, help="Number of test iterations to run") + parser.add_argument("-sleep", type=int, help="Sleep time between tests", default=0) + args = parser.parse_args() + + if args.n is None: + while True: + run_test(sleep_duration=args.sleep) + else: + for i in range(args.n): + run_test(sleep_duration=args.sleep) diff --git a/panda/tests/black_white_relay_endurance.py b/panda/tests/black_white_relay_endurance.py new file mode 100755 index 000000000..8868b9848 --- /dev/null +++ b/panda/tests/black_white_relay_endurance.py @@ -0,0 +1,175 @@ +#!/usr/bin/env python + +# Loopback test between black panda (+ harness and power) and white/grey panda +# Tests all buses, including OBD CAN, which is on the same bus as CAN0 in this test. +# To be sure, the test should be run with both harness orientations + +from __future__ import print_function +import os +import sys +import time +import random +import argparse + +from hexdump import hexdump +from itertools import permutations + +sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) +from panda import Panda + +def get_test_string(): + return b"test"+os.urandom(10) + +counter = 0 +nonzero_bus_errors = 0 +zero_bus_errors = 0 +content_errors = 0 + +def run_test(sleep_duration): + global counter, nonzero_bus_errors, zero_bus_errors, content_errors + + pandas = Panda.list() + print(pandas) + + # make sure two pandas are connected + if len(pandas) != 2: + print("Connect white/grey and black panda to run this test!") + assert False + + # connect + pandas[0] = Panda(pandas[0]) + pandas[1] = Panda(pandas[1]) + + # find out which one is black + type0 = pandas[0].get_type() + type1 = pandas[1].get_type() + + black_panda = None + other_panda = None + + if type0 == "\x03" and type1 != "\x03": + black_panda = pandas[0] + other_panda = pandas[1] + elif type0 != "\x03" and type1 == "\x03": + black_panda = pandas[1] + other_panda = pandas[0] + else: + print("Connect white/grey and black panda to run this test!") + assert False + + # disable safety modes + black_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + other_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + + # test health packet + print("black panda health", black_panda.health()) + print("other panda health", other_panda.health()) + + # test black -> other + start_time = time.time() + temp_start_time = start_time + while True: + test_buses(black_panda, other_panda, True, [(0, False, [0]), (1, False, [1]), (2, False, [2]), (1, True, [0])], sleep_duration) + test_buses(black_panda, other_panda, False, [(0, False, [0]), (1, False, [1]), (2, False, [2]), (0, True, [0, 1])], sleep_duration) + counter += 1 + + runtime = time.time() - start_time + print("Number of cycles:", counter, "Non-zero bus errors:", nonzero_bus_errors, "Zero bus errors:", zero_bus_errors, "Content errors:", content_errors, "Runtime: ", runtime) + + if (time.time() - temp_start_time) > 3600*6: + # Toggle relay + black_panda.set_safety_mode(Panda.SAFETY_NOOUTPUT) + time.sleep(1) + black_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + time.sleep(1) + temp_start_time = time.time() + + +def test_buses(black_panda, other_panda, direction, test_array, sleep_duration): + global nonzero_bus_errors, zero_bus_errors, content_errors + + if direction: + print("***************** TESTING (BLACK --> OTHER) *****************") + else: + print("***************** TESTING (OTHER --> BLACK) *****************") + + for send_bus, obd, recv_buses in test_array: + black_panda.send_heartbeat() + other_panda.send_heartbeat() + print("\ntest can: ", send_bus, " OBD: ", obd) + + # set OBD on black panda + black_panda.set_gmlan(True if obd else None) + + # clear and flush + if direction: + black_panda.can_clear(send_bus) + else: + other_panda.can_clear(send_bus) + + for recv_bus in recv_buses: + if direction: + other_panda.can_clear(recv_bus) + else: + black_panda.can_clear(recv_bus) + + black_panda.can_recv() + other_panda.can_recv() + + # send the characters + at = random.randint(1, 2000) + st = get_test_string()[0:8] + if direction: + black_panda.can_send(at, st, send_bus) + else: + other_panda.can_send(at, st, send_bus) + time.sleep(0.1) + + # check for receive + if direction: + cans_echo = black_panda.can_recv() + cans_loop = other_panda.can_recv() + else: + cans_echo = other_panda.can_recv() + cans_loop = black_panda.can_recv() + + loop_buses = [] + for loop in cans_loop: + if (loop[0] != at) or (loop[2] != st): + content_errors += 1 + + print(" Loop on bus", str(loop[3])) + loop_buses.append(loop[3]) + if len(cans_loop) == 0: + print(" No loop") + if not os.getenv("NOASSERT"): + assert False + + # test loop buses + recv_buses.sort() + loop_buses.sort() + if(recv_buses != loop_buses): + if len(loop_buses) == 0: + zero_bus_errors += 1 + else: + nonzero_bus_errors += 1 + if not os.getenv("NOASSERT"): + assert False + else: + print(" TEST PASSED") + + time.sleep(sleep_duration) + print("\n") + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-n", type=int, help="Number of test iterations to run") + parser.add_argument("-sleep", type=int, help="Sleep time between tests", default=0) + args = parser.parse_args() + + if args.n is None: + while True: + run_test(sleep_duration=args.sleep) + else: + for i in range(args.n): + run_test(sleep_duration=args.sleep) diff --git a/panda/tests/black_white_relay_test.py b/panda/tests/black_white_relay_test.py new file mode 100755 index 000000000..21a2ef6d7 --- /dev/null +++ b/panda/tests/black_white_relay_test.py @@ -0,0 +1,145 @@ +#!/usr/bin/env python + +# Relay test with loopback between black panda (+ harness and power) and white/grey panda +# Tests the relay switching multiple times / second by looking at the buses on which loop occurs. + +from __future__ import print_function +import os +import sys +import time +import random +import argparse + +from hexdump import hexdump +from itertools import permutations + +sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) +from panda import Panda + +def get_test_string(): + return b"test"+os.urandom(10) + +counter = 0 +open_errors = 0 +closed_errors = 0 +content_errors = 0 + +def run_test(sleep_duration): + global counter, open_errors, closed_errors, content_errors + + pandas = Panda.list() + #pandas = ["540046000c51363338383037", "07801b800f51363038363036"] + print(pandas) + + # make sure two pandas are connected + if len(pandas) != 2: + print("Connect white/grey and black panda to run this test!") + assert False + + # connect + pandas[0] = Panda(pandas[0]) + pandas[1] = Panda(pandas[1]) + + # find out which one is black + type0 = pandas[0].get_type() + type1 = pandas[1].get_type() + + black_panda = None + other_panda = None + + if type0 == "\x03" and type1 != "\x03": + black_panda = pandas[0] + other_panda = pandas[1] + elif type0 != "\x03" and type1 == "\x03": + black_panda = pandas[1] + other_panda = pandas[0] + else: + print("Connect white/grey and black panda to run this test!") + assert False + + # disable safety modes + black_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + other_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + + # test health packet + print("black panda health", black_panda.health()) + print("other panda health", other_panda.health()) + + # test black -> other + while True: + # Switch on relay + black_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + time.sleep(0.05) + + if not test_buses(black_panda, other_panda, (0, False, [0])): + open_errors += 1 + print("Open error") + assert False + + # Switch off relay + black_panda.set_safety_mode(Panda.SAFETY_NOOUTPUT) + time.sleep(0.05) + + if not test_buses(black_panda, other_panda, (0, False, [0, 2])): + closed_errors += 1 + print("Close error") + assert False + + counter += 1 + print("Number of cycles:", counter, "Open errors:", open_errors, "Closed errors:", closed_errors, "Content errors:", content_errors) + +def test_buses(black_panda, other_panda, test_obj): + global content_errors + send_bus, obd, recv_buses = test_obj + + black_panda.send_heartbeat() + other_panda.send_heartbeat() + + # Set OBD on send panda + other_panda.set_gmlan(True if obd else None) + + # clear and flush + other_panda.can_clear(send_bus) + + for recv_bus in recv_buses: + black_panda.can_clear(recv_bus) + + black_panda.can_recv() + other_panda.can_recv() + + # send the characters + at = random.randint(1, 2000) + st = get_test_string()[0:8] + other_panda.can_send(at, st, send_bus) + time.sleep(0.05) + + # check for receive + cans_echo = other_panda.can_recv() + cans_loop = black_panda.can_recv() + + loop_buses = [] + for loop in cans_loop: + if (loop[0] != at) or (loop[2] != st): + content_errors += 1 + loop_buses.append(loop[3]) + + # test loop buses + recv_buses.sort() + loop_buses.sort() + if(recv_buses != loop_buses): + return False + else: + return True + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-n", type=int, help="Number of test iterations to run") + parser.add_argument("-sleep", type=int, help="Sleep time between tests", default=0) + args = parser.parse_args() + + if args.n is None: + while True: + run_test(sleep_duration=args.sleep) + else: + for i in range(args.n): + run_test(sleep_duration=args.sleep) diff --git a/panda/tests/debug_console.py b/panda/tests/debug_console.py index 0238ed789..e341b266c 100755 --- a/panda/tests/debug_console.py +++ b/panda/tests/debug_console.py @@ -12,33 +12,38 @@ setcolor = ["\033[1;32;40m", "\033[1;31;40m"] unsetcolor = "\033[00m" if __name__ == "__main__": - port_number = int(os.getenv("PORT", 0)) - claim = os.getenv("CLAIM") is not None - - serials = Panda.list() - if os.getenv("SERIAL"): - serials = filter(lambda x: x==os.getenv("SERIAL"), serials) - - pandas = list(map(lambda x: Panda(x, claim=claim), serials)) - - if not len(pandas): - sys.exit("no pandas found") - - if os.getenv("BAUD") is not None: - for panda in pandas: - panda.set_uart_baud(port_number, int(os.getenv("BAUD"))) - while True: - for i, panda in enumerate(pandas): + try: + port_number = int(os.getenv("PORT", 0)) + claim = os.getenv("CLAIM") is not None + + serials = Panda.list() + if os.getenv("SERIAL"): + serials = filter(lambda x: x==os.getenv("SERIAL"), serials) + + pandas = list(map(lambda x: Panda(x, claim=claim), serials)) + + if not len(pandas): + sys.exit("no pandas found") + + if os.getenv("BAUD") is not None: + for panda in pandas: + panda.set_uart_baud(port_number, int(os.getenv("BAUD"))) + while True: - ret = panda.serial_read(port_number) - if len(ret) > 0: - sys.stdout.write(setcolor[i] + str(ret) + unsetcolor) - sys.stdout.flush() - else: - break - if select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []): - ln = sys.stdin.readline() - if claim: - panda.serial_write(port_number, ln) - time.sleep(0.01) + for i, panda in enumerate(pandas): + while True: + ret = panda.serial_read(port_number) + if len(ret) > 0: + sys.stdout.write(setcolor[i] + str(ret) + unsetcolor) + sys.stdout.flush() + else: + break + if select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []): + ln = sys.stdin.readline() + if claim: + panda.serial_write(port_number, ln) + time.sleep(0.01) + except: + print("panda disconnected!") + time.sleep(0.5); diff --git a/panda/tests/health_test.py b/panda/tests/health_test.py new file mode 100755 index 000000000..1042c860d --- /dev/null +++ b/panda/tests/health_test.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +import time +from panda import Panda + +if __name__ == "__main__": + panda_serials = Panda.list() + pandas = [] + for ps in panda_serials: + pandas.append(Panda(serial=ps)) + if len(pandas) == 0: + print("No pandas connected") + assert False + + while True: + for panda in pandas: + print(panda.health()) + print("\n") + time.sleep(0.5) + diff --git a/panda/tests/safety/libpandasafety_py.py b/panda/tests/safety/libpandasafety_py.py index 888bd36e9..bb332e52b 100644 --- a/panda/tests/safety/libpandasafety_py.py +++ b/panda/tests/safety/libpandasafety_py.py @@ -57,8 +57,9 @@ void set_toyota_rt_torque_last(int t); void init_tests_honda(void); bool get_honda_moving(void); -int get_honda_brake_prev(void); +bool get_honda_brake_pressed_prev(void); int get_honda_gas_prev(void); +void set_honda_fwd_brake(bool); void set_honda_alt_brake_msg(bool); void set_honda_bosch_hardware(bool); int get_honda_bosch_hardware(void); diff --git a/panda/tests/safety/test.c b/panda/tests/safety/test.c index 7cd9b86d8..d92eb8680 100644 --- a/panda/tests/safety/test.c +++ b/panda/tests/safety/test.c @@ -227,8 +227,8 @@ bool get_honda_moving(void){ return honda_moving; } -int get_honda_brake_prev(void){ - return honda_brake_prev; +bool get_honda_brake_pressed_prev(void){ + return honda_brake_pressed_prev; } int get_honda_gas_prev(void){ @@ -247,6 +247,10 @@ int get_honda_bosch_hardware(void) { return honda_bosch_hardware; } +void set_honda_fwd_brake(bool c){ + honda_fwd_brake = c; +} + void init_tests(void){ // get HW_TYPE from env variable set in test.sh hw_type = atoi(getenv("HW_TYPE")); @@ -315,8 +319,9 @@ void init_tests_subaru(void){ void init_tests_honda(void){ init_tests(); honda_moving = false; - honda_brake_prev = 0; + honda_brake_pressed_prev = false; honda_gas_prev = 0; + honda_fwd_brake = false; } void set_gmlan_digital_output(int to_set){ diff --git a/panda/tests/safety/test_honda.py b/panda/tests/safety/test_honda.py index f16030843..f2f593897 100755 --- a/panda/tests/safety/test_honda.py +++ b/panda/tests/safety/test_honda.py @@ -64,7 +64,7 @@ class TestHondaSafety(unittest.TestCase): def _send_brake_msg(self, brake): to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') to_send[0].RIR = 0x1FA << 21 - to_send[0].RDLR = ((brake & 0x3) << 8) | ((brake & 0x3FF) >> 2) + to_send[0].RDLR = ((brake & 0x3) << 14) | ((brake & 0x3FF) >> 2) return to_send @@ -112,9 +112,9 @@ class TestHondaSafety(unittest.TestCase): self.assertEqual(1, self.safety.get_honda_moving()) def test_prev_brake(self): - self.assertFalse(self.safety.get_honda_brake_prev()) + self.assertFalse(self.safety.get_honda_brake_pressed_prev()) self.safety.safety_rx_hook(self._brake_msg(True)) - self.assertTrue(self.safety.get_honda_brake_prev()) + self.assertTrue(self.safety.get_honda_brake_pressed_prev()) def test_disengage_on_brake(self): self.safety.set_controls_allowed(1) @@ -204,17 +204,22 @@ class TestHondaSafety(unittest.TestCase): self.safety.set_gas_interceptor_detected(False) def test_brake_safety_check(self): - for long_controls_allowed in [0, 1]: - self.safety.set_long_controls_allowed(long_controls_allowed) - for brake in np.arange(0, MAX_BRAKE + 10, 1): - for controls_allowed in [True, False]: - self.safety.set_controls_allowed(controls_allowed) - if controls_allowed and long_controls_allowed: - send = MAX_BRAKE >= brake >= 0 - else: - send = brake == 0 - self.assertEqual(send, self.safety.safety_tx_hook(self._send_brake_msg(brake))) + for fwd_brake in [False, True]: + self.safety.set_honda_fwd_brake(fwd_brake) + for long_controls_allowed in [0, 1]: + self.safety.set_long_controls_allowed(long_controls_allowed) + for brake in np.arange(0, MAX_BRAKE + 10, 1): + for controls_allowed in [True, False]: + self.safety.set_controls_allowed(controls_allowed) + if fwd_brake: + send = False # block openpilot brake msg when fwd'ing stock msg + elif controls_allowed and long_controls_allowed: + send = MAX_BRAKE >= brake >= 0 + else: + send = brake == 0 + self.assertEqual(send, self.safety.safety_tx_hook(self._send_brake_msg(brake))) self.safety.set_long_controls_allowed(True) + self.safety.set_honda_fwd_brake(False) def test_gas_interceptor_safety_check(self): for long_controls_allowed in [0, 1]: @@ -252,27 +257,33 @@ class TestHondaSafety(unittest.TestCase): buss = range(0x0, 0x3) msgs = range(0x1, 0x800) long_controls_allowed = [0, 1] + fwd_brake = [False, True] self.safety.set_honda_bosch_hardware(0) - for l in long_controls_allowed: - self.safety.set_long_controls_allowed(l) - blocked_msgs = [0xE4, 0x194, 0x33D] - if l: - blocked_msgs += [0x1FA ,0x30C, 0x39F] - for b in buss: - for m in msgs: - if b == 0: - fwd_bus = 2 - elif b == 1: - fwd_bus = -1 - elif b == 2: - fwd_bus = -1 if m in blocked_msgs else 0 + for f in fwd_brake: + self.safety.set_honda_fwd_brake(f) + for l in long_controls_allowed: + self.safety.set_long_controls_allowed(l) + blocked_msgs = [0xE4, 0x194, 0x33D] + if l: + blocked_msgs += [0x30C, 0x39F] + if not f: + blocked_msgs += [0x1FA] + for b in buss: + for m in msgs: + if b == 0: + fwd_bus = 2 + elif b == 1: + fwd_bus = -1 + elif b == 2: + fwd_bus = -1 if m in blocked_msgs else 0 - # assume len 8 - self.assertEqual(fwd_bus, self.safety.safety_fwd_hook(b, self._send_msg(b, m, 8))) + # assume len 8 + self.assertEqual(fwd_bus, self.safety.safety_fwd_hook(b, self._send_msg(b, m, 8))) self.safety.set_long_controls_allowed(True) + self.safety.set_honda_fwd_brake(False) diff --git a/phonelibs/boringssl/LICENSE b/phonelibs/boringssl/LICENSE new file mode 100644 index 000000000..2f4dfcdb0 --- /dev/null +++ b/phonelibs/boringssl/LICENSE @@ -0,0 +1,274 @@ +BoringSSL is a fork of OpenSSL. As such, large parts of it fall under OpenSSL +licensing. Files that are completely new have a Google copyright and an ISC +license. This license is reproduced at the bottom of this file. + +Contributors to BoringSSL are required to follow the CLA rules for Chromium: +https://cla.developers.google.com/clas + +Files in third_party/ have their own licenses, as described therein. The MIT +license, for third_party/fiat, which, unlike other third_party directories, is +compiled into non-test libraries, is included below. + +The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the +OpenSSL License and the original SSLeay license apply to the toolkit. See below +for the actual license texts. Actually both licenses are BSD-style Open Source +licenses. In case of any license issues related to OpenSSL please contact +openssl-core@openssl.org. + +The following are Google-internal bug numbers where explicit permission from +some authors is recorded for use of their work. (This is purely for our own +record keeping.) + 27287199 + 27287880 + 27287883 + + OpenSSL License + --------------- + +/* ==================================================================== + * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + + Original SSLeay License + ----------------------- + +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + + +ISC license used for completely new code in BoringSSL: + +/* Copyright (c) 2015, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + + +The code in third_party/fiat carries the MIT license: + +Copyright (c) 2015-2016 the fiat-crypto authors (see +https://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +The code in third_party/sike also carries the MIT license: + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE + + +Licenses for support code +------------------------- + +Parts of the TLS test suite are under the Go license. This code is not included +in BoringSSL (i.e. libcrypto and libssl) when compiled, however, so +distributing code linked against BoringSSL does not trigger this license: + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +BoringSSL uses the Chromium test infrastructure to run a continuous build, +trybots etc. The scripts which manage this, and the script for generating build +metadata, are under the Chromium license. Distributing code linked against +BoringSSL does not trigger this license. + +Copyright 2015 The Chromium Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/phonelibs/bzip2/LICENSE b/phonelibs/bzip2/LICENSE new file mode 100644 index 000000000..cc614178c --- /dev/null +++ b/phonelibs/bzip2/LICENSE @@ -0,0 +1,42 @@ + +-------------------------------------------------------------------------- + +This program, "bzip2", the associated library "libbzip2", and all +documentation, are copyright (C) 1996-2010 Julian R Seward. All +rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + +3. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + +4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Julian Seward, jseward@bzip.org +bzip2/libbzip2 version 1.0.6 of 6 September 2010 + +-------------------------------------------------------------------------- diff --git a/phonelibs/hierarchy/lib/_hierarchy.so b/phonelibs/hierarchy/lib/_hierarchy.so deleted file mode 100755 index 367b71775..000000000 Binary files a/phonelibs/hierarchy/lib/_hierarchy.so and /dev/null differ diff --git a/phonelibs/libyuv/LICENSE b/phonelibs/libyuv/LICENSE new file mode 100644 index 000000000..c911747a6 --- /dev/null +++ b/phonelibs/libyuv/LICENSE @@ -0,0 +1,29 @@ +Copyright 2011 The LibYuv Project Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + * Neither the name of Google nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/phonelibs/openblas/libopenblas.so b/phonelibs/openblas/libopenblas.so deleted file mode 120000 index 7a792bc90..000000000 --- a/phonelibs/openblas/libopenblas.so +++ /dev/null @@ -1 +0,0 @@ -libopenblas_armv8p-r0.2.19.so \ No newline at end of file diff --git a/phonelibs/openblas/libopenblas_armv8p-r0.2.19.so b/phonelibs/openblas/libopenblas_armv8p-r0.2.19.so deleted file mode 100755 index ace58c8a1..000000000 Binary files a/phonelibs/openblas/libopenblas_armv8p-r0.2.19.so and /dev/null differ diff --git a/phonelibs/yaml-cpp/LICENSE b/phonelibs/yaml-cpp/LICENSE new file mode 100644 index 000000000..991fdbbe7 --- /dev/null +++ b/phonelibs/yaml-cpp/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2008-2015 Jesse Beder. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/run_docker_tests.sh b/run_docker_tests.sh index dfee5f866..21549ab08 100755 --- a/run_docker_tests.sh +++ b/run_docker_tests.sh @@ -13,4 +13,4 @@ docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && pyt docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && python -m unittest discover selfdrive/loggerd' docker run --rm -v "$(pwd)"/selfdrive/test/tests/plant/out:/tmp/openpilot/selfdrive/test/tests/plant/out tmppilot /bin/sh -c 'cd /tmp/openpilot/selfdrive/test/tests/plant && OPTEST=1 ./test_longitudinal.py' docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && cd /tmp/openpilot/selfdrive/test/tests/process_replay/ && ./test_processes.py' -docker run --rm tmppilot /bin/sh -c 'mkdir -p /data/params && cd /tmp/openpilot/ && make -C cereal && cd /tmp/openpilot/selfdrive/test/ && ./test_car_models_openpilot.py' +docker run --rm tmppilot /bin/sh -c 'mkdir -p /data/params && cd /tmp/openpilot/ && make -C cereal && cd /tmp/openpilot/selfdrive/test/ && ./test_car_models.py' diff --git a/selfdrive/assets/sounds/disengaged.wav b/selfdrive/assets/sounds/disengaged.wav index 655aa3126..3aa8e51e6 100644 Binary files a/selfdrive/assets/sounds/disengaged.wav and b/selfdrive/assets/sounds/disengaged.wav differ diff --git a/selfdrive/assets/sounds/engaged.wav b/selfdrive/assets/sounds/engaged.wav index b33e8181f..1451f937f 100644 Binary files a/selfdrive/assets/sounds/engaged.wav and b/selfdrive/assets/sounds/engaged.wav differ diff --git a/selfdrive/assets/sounds/error.wav b/selfdrive/assets/sounds/error.wav index 309eaef8a..e805181ae 100644 Binary files a/selfdrive/assets/sounds/error.wav and b/selfdrive/assets/sounds/error.wav differ diff --git a/selfdrive/assets/sounds/warning_1.wav b/selfdrive/assets/sounds/warning_1.wav index 920c11846..43ca74cc5 100644 Binary files a/selfdrive/assets/sounds/warning_1.wav and b/selfdrive/assets/sounds/warning_1.wav differ diff --git a/selfdrive/assets/sounds/warning_2.wav b/selfdrive/assets/sounds/warning_2.wav index f5ed8521d..e9709d9fd 100644 Binary files a/selfdrive/assets/sounds/warning_2.wav and b/selfdrive/assets/sounds/warning_2.wav differ diff --git a/selfdrive/athena/athenad.py b/selfdrive/athena/athenad.py index 6aa84d106..4f1059930 100755 --- a/selfdrive/athena/athenad.py +++ b/selfdrive/athena/athenad.py @@ -1,6 +1,5 @@ #!/usr/bin/env python2.7 import json -import jwt import os import random import re @@ -13,7 +12,6 @@ import traceback import zmq import requests import six.moves.queue -from datetime import datetime, timedelta from functools import partial from jsonrpc import JSONRPCResponseManager, dispatcher from websocket import create_connection, WebSocketTimeoutException, ABNF @@ -104,9 +102,7 @@ def startLocalProxy(global_end_event, remote_ws_uri, local_port): params = Params() dongle_id = params.get("DongleId") - private_key = open("/persist/comma/id_rsa").read() - identity_token = jwt.encode({'identity':dongle_id, 'exp': datetime.utcnow() + timedelta(hours=1)}, private_key, algorithm='RS256') - + identity_token = Api(dongle_id).get_token() ws = create_connection(remote_ws_uri, cookie="jwt=" + identity_token, enable_multithread=True) @@ -232,8 +228,7 @@ def main(gctx=None): crash.bind_extra(version=version, dirty=dirty, is_eon=True) crash.install() - private_key = open("/persist/comma/id_rsa").read() - api = Api(dongle_id, private_key) + api = Api(dongle_id) conn_retries = 0 while 1: diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc index f4ca033f5..8468238f3 100644 --- a/selfdrive/boardd/boardd.cc +++ b/selfdrive/boardd/boardd.cc @@ -43,6 +43,7 @@ #define SAFETY_TESLA 8 #define SAFETY_CHRYSLER 9 #define SAFETY_SUBARU 10 +#define SAFETY_GM_PASSIVE 11 #define SAFETY_TOYOTA_IPAS 0x1335 #define SAFETY_TOYOTA_NOLIMITS 0x1336 #define SAFETY_ALLOUTPUT 0x1337 @@ -135,6 +136,9 @@ void *safety_setter_thread(void *s) { case cereal::CarParams::SafetyModel::GM: safety_setting = SAFETY_GM; break; + case cereal::CarParams::SafetyModel::GM_PASSIVE: + safety_setting = SAFETY_GM_PASSIVE; + break; case cereal::CarParams::SafetyModel::HONDA_BOSCH: safety_setting = SAFETY_HONDA_BOSCH; break; diff --git a/selfdrive/can/libdbc_py.py b/selfdrive/can/libdbc_py.py index 61cf8cd05..fbf36a3d4 100644 --- a/selfdrive/can/libdbc_py.py +++ b/selfdrive/can/libdbc_py.py @@ -82,7 +82,7 @@ void* can_init(int bus, const char* dbc_name, int can_update(void* can, uint64_t sec, bool wait); -size_t can_query(void* can, uint64_t sec, bool *out_can_valid, size_t out_values_size, SignalValue* out_values); +size_t can_query_latest(void* can, bool *out_can_valid, size_t out_values_size, SignalValue* out_values); const DBC* dbc_lookup(const char* dbc_name); diff --git a/selfdrive/can/parser.cc b/selfdrive/can/parser.cc index 69b30fb51..830e8b14c 100644 --- a/selfdrive/can/parser.cc +++ b/selfdrive/can/parser.cc @@ -330,7 +330,7 @@ class CANParser { } } - void update_string(uint64_t sec, std::string data) { + void update_string(std::string data) { // format for board, make copy due to alignment issues, will be freed on out of scope auto amsg = kj::heapArray((data.length() / sizeof(capnp::word)) + 1); memcpy(amsg.begin(), data.data(), data.length()); @@ -339,10 +339,12 @@ class CANParser { capnp::FlatArrayMessageReader cmsg(amsg); cereal::Event::Reader event = cmsg.getRoot(); - auto cans = event.getCan(); - UpdateCans(sec, cans); + last_sec = event.getLogMonoTime(); - UpdateValid(sec); + auto cans = event.getCan(); + UpdateCans(last_sec, cans); + + UpdateValid(last_sec); } int update(uint64_t sec, bool wait) { @@ -381,17 +383,18 @@ class CANParser { UpdateCans(sec, cans); } + last_sec = sec; UpdateValid(sec); zmq_msg_close(&msg); return result; } - std::vector query(uint64_t sec) { + std::vector query_latest() { std::vector ret; for (const auto& kv : message_states) { const auto& state = kv.second; - if (sec != 0 && state.seen != sec) continue; + if (last_sec != 0 && state.seen != last_sec) continue; for (int i=0; iupdate(sec, wait); } -void can_update_string(void *can, uint64_t sec, const char* dat, int len) { +void can_update_string(void *can, const char* dat, int len) { CANParser* cp = (CANParser*)can; - cp->update_string(sec, std::string(dat, len)); + cp->update_string(std::string(dat, len)); } -size_t can_query(void* can, uint64_t sec, bool *out_can_valid, size_t out_values_size, SignalValue* out_values) { +size_t can_query_latest(void* can, bool *out_can_valid, size_t out_values_size, SignalValue* out_values) { CANParser* cp = (CANParser*)can; if (out_can_valid) { *out_can_valid = cp->can_valid; } - const std::vector values = cp->query(sec); + const std::vector values = cp->query_latest(); if (out_values) { std::copy(values.begin(), values.begin()+std::min(out_values_size, values.size()), out_values); } return values.size(); }; -void can_query_vector(void* can, uint64_t sec, bool *out_can_valid, std::vector &values) { +void can_query_latest_vector(void* can, bool *out_can_valid, std::vector &values) { CANParser* cp = (CANParser*)can; if (out_can_valid) { *out_can_valid = cp->can_valid; } - values = cp->query(sec); + values = cp->query_latest(); }; } diff --git a/selfdrive/can/parser_pyx.pxd b/selfdrive/can/parser_pyx.pxd index ac619707a..6b1e50ce6 100644 --- a/selfdrive/can/parser_pyx.pxd +++ b/selfdrive/can/parser_pyx.pxd @@ -67,9 +67,9 @@ ctypedef void* (*can_init_with_vectors_func)(int bus, const char* dbc_name, const char* tcp_addr, int timeout) ctypedef int (*can_update_func)(void* can, uint64_t sec, bool wait); -ctypedef void (*can_update_string_func)(void* can, uint64_t sec, const char* dat, int len); -ctypedef size_t (*can_query_func)(void* can, uint64_t sec, bool *out_can_valid, size_t out_values_size, SignalValue* out_values); -ctypedef void (*can_query_vector_func)(void* can, uint64_t sec, bool *out_can_valid, vector[SignalValue] &values) +ctypedef void (*can_update_string_func)(void* can, const char* dat, int len); +ctypedef size_t (*can_query_latest_func)(void* can, bool *out_can_valid, size_t out_values_size, SignalValue* out_values); +ctypedef void (*can_query_latest_vector_func)(void* can, bool *out_can_valid, vector[SignalValue] &values) cdef class CANParser: cdef: @@ -79,7 +79,7 @@ cdef class CANParser: can_init_with_vectors_func can_init_with_vectors can_update_func can_update can_update_string_func can_update_string - can_query_vector_func can_query_vector + can_query_latest_vector_func can_query_latest_vector map[string, uint32_t] msg_name_to_address map[uint32_t, string] address_to_msg_name vector[SignalValue] can_values @@ -91,4 +91,4 @@ cdef class CANParser: bool can_valid int can_invalid_cnt - cdef unordered_set[uint32_t] update_vl(self, uint64_t sec) + cdef unordered_set[uint32_t] update_vl(self) diff --git a/selfdrive/can/parser_pyx.pyx b/selfdrive/can/parser_pyx.pyx index c6f1f58e0..4f9297096 100644 --- a/selfdrive/can/parser_pyx.pyx +++ b/selfdrive/can/parser_pyx.pyx @@ -18,7 +18,7 @@ cdef class CANParser: self.dbc_lookup = dlsym(libdbc, 'dbc_lookup') self.can_update = dlsym(libdbc, 'can_update') self.can_update_string = dlsym(libdbc, 'can_update_string') - self.can_query_vector = dlsym(libdbc, 'can_query_vector') + self.can_query_latest_vector = dlsym(libdbc, 'can_query_latest_vector') if checks is None: checks = [] @@ -72,14 +72,14 @@ cdef class CANParser: message_options_v.push_back(mpo) self.can = self.can_init_with_vectors(bus, dbc_name, message_options_v, signal_options_v, sendcan, tcp_addr, timeout) - self.update_vl(0) + self.update_vl() - cdef unordered_set[uint32_t] update_vl(self, uint64_t sec): + cdef unordered_set[uint32_t] update_vl(self): cdef string sig_name cdef unordered_set[uint32_t] updated_val cdef bool valid = False - self.can_query_vector(self.can, sec, &valid, self.can_values) + self.can_query_latest_vector(self.can, &valid, self.can_values) # Update invalid flag self.can_invalid_cnt += 1 @@ -100,20 +100,20 @@ cdef class CANParser: return updated_val - def update_string(self, uint64_t sec, dat): - self.can_update_string(self.can, sec, dat, len(dat)) - return self.update_vl(sec) + def update_string(self, dat): + self.can_update_string(self.can, dat, len(dat)) + return self.update_vl() - def update_strings(self, uint64_t sec, strings): + def update_strings(self, strings): updated_vals = set() for s in strings: - updated_val = self.update_string(sec, s) + updated_val = self.update_string(s) updated_vals.update(updated_val) return updated_vals def update(self, uint64_t sec, bool wait): r = (self.can_update(self.can, sec, wait) >= 0) - updated_val = self.update_vl(sec) + updated_val = self.update_vl() return r, updated_val diff --git a/selfdrive/can/tests/parser_old.py b/selfdrive/can/tests/parser_old.py index 5a899efa5..ccf613ab3 100644 --- a/selfdrive/can/tests/parser_old.py +++ b/selfdrive/can/tests/parser_old.py @@ -71,12 +71,12 @@ class CANParser(object): self.p_can_valid = ffi.new("bool*") - value_count = libdbc.can_query(self.can, 0, self.p_can_valid, 0, ffi.NULL) + value_count = libdbc.can_query_latest(self.can, self.p_can_valid, 0, ffi.NULL) self.can_values = ffi.new("SignalValue[%d]" % value_count) self.update_vl(0) def update_vl(self, sec): - can_values_len = libdbc.can_query(self.can, sec, self.p_can_valid, len(self.can_values), self.can_values) + can_values_len = libdbc.can_query_latest(self.can, self.p_can_valid, len(self.can_values), self.can_values) assert can_values_len <= len(self.can_values) self.can_invalid_cnt += 1 diff --git a/selfdrive/can/tests/test_packer_toyota.py b/selfdrive/can/tests/test_packer_toyota.py index f5f0e8a7f..fc53399ee 100644 --- a/selfdrive/can/tests/test_packer_toyota.py +++ b/selfdrive/can/tests/test_packer_toyota.py @@ -47,32 +47,34 @@ class TestPackerMethods(unittest.TestCase): self.assertEqual(m_old, m) steer = (random.randint(0, 2) % 2 == 0) + chime = random.randint(1, 65536) left_line = (random.randint(0, 2) % 2 == 0) right_line = (random.randint(0, 2) % 2 == 0) left_lane_depart = (random.randint(0, 2) % 2 == 0) right_lane_depart = (random.randint(0, 2) % 2 == 0) - m_old = create_ui_command(self.cp_old, steer, left_line, right_line, left_lane_depart, right_lane_depart) - m = create_ui_command(self.cp, steer, left_line, right_line, left_lane_depart, right_lane_depart) + m_old = create_ui_command(self.cp_old, steer, chime, left_line, right_line, left_lane_depart, right_lane_depart) + m = create_ui_command(self.cp, steer, chime, left_line, right_line, left_lane_depart, right_lane_depart) self.assertEqual(m_old, m) def test_performance(self): n1 = sec_since_boot() recursions = 100000 steer = (random.randint(0, 2) % 2 == 0) + chime = random.randint(1, 65536) left_line = (random.randint(0, 2) % 2 == 0) right_line = (random.randint(0, 2) % 2 == 0) left_lane_depart = (random.randint(0, 2) % 2 == 0) right_lane_depart = (random.randint(0, 2) % 2 == 0) for _ in xrange(recursions): - create_ui_command(self.cp_old, steer, left_line, right_line, left_lane_depart, right_lane_depart) + create_ui_command(self.cp_old, steer, chime, left_line, right_line, left_lane_depart, right_lane_depart) n2 = sec_since_boot() elapsed_old = n2 - n1 # print('Old API, elapsed time: {} secs'.format(elapsed_old)) n1 = sec_since_boot() for _ in xrange(recursions): - create_ui_command(self.cp, steer, left_line, right_line, left_lane_depart, right_lane_depart) + create_ui_command(self.cp, steer, chime, left_line, right_line, left_lane_depart, right_lane_depart) n2 = sec_since_boot() elapsed_new = n2 - n1 # print('New API, elapsed time: {} secs'.format(elapsed_new)) diff --git a/selfdrive/can/tests/test_parser.py b/selfdrive/can/tests/test_parser.py index 53c95ce91..ff3cbddf7 100755 --- a/selfdrive/can/tests/test_parser.py +++ b/selfdrive/can/tests/test_parser.py @@ -58,16 +58,15 @@ def run_route(route): route_ok = True - t = 0 for msg in lr: if msg.which() == 'can': - t += DT + t = msg.logMonoTime msg_bytes = msg.as_builder().to_bytes() can.send(msg_bytes) _, updated_old = parser_old.update(t, True) _, updated_new = parser_new.update(t, True) - updated_string = parser_string.update_string(t, msg_bytes) + updated_string = parser_string.update_string(msg_bytes) if updated_old != updated_new: route_ok = False diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py index d74892993..127a10fc3 100644 --- a/selfdrive/car/car_helpers.py +++ b/selfdrive/car/car_helpers.py @@ -1,13 +1,23 @@ import os +import zmq from cereal import car -from common.params import Params +from common.params import Params, put_nonblocking from common.vin import get_vin, VIN_UNKNOWN from common.basedir import BASEDIR from common.fingerprints import eliminate_incompatible_cars, all_known_cars from selfdrive.swaglog import cloudlog import selfdrive.messaging as messaging import pickle -import selfdrive.crash as crash + + +def get_one_can(logcan): + while True: + try: + can = messaging.recv_one(logcan) + if len(can.can) > 0: + return can + except zmq.error.Again: + continue def get_startup_alert(car_recognized, controller_available): @@ -80,55 +90,56 @@ def fingerprint(logcan, sendcan, is_panda_black): cloudlog.warning("VIN %s", vin) Params().put("CarVin", vin) + finger = {i: {} for i in range(0, 4)} # collect on all buses + candidate_cars = {i: all_known_cars() for i in [0, 1]} # attempt fingerprint on both bus 0 and 1 + frame = 0 + frame_fingerprint = 10 # 0.1s + car_fingerprint = None + done = False + if params.get("DragonCacheCar") == "1" and params.get("DragonCachedFP") != "" and params.get("DragonCachedModel") != "": car_fingerprint = pickle.loads(params.get("DragonCachedModel")) finger = pickle.loads(params.get("DragonCachedFP")) vin = pickle.loads(params.get("DragonCachedVIN")) - else: - finger = {i: {} for i in range(0, 4)} # collect on all buses - candidate_cars = {i: all_known_cars() for i in [0, 1]} # attempt fingerprint on both bus 0 and 1 - frame = 0 - frame_fingerprint = 10 # 0.1s - car_fingerprint = None - done = False + done = True - while not done: - a = messaging.recv_one(logcan) + while not done: + a = get_one_can(logcan) - for can in a.can: - # need to independently try to fingerprint both bus 0 and 1 to work - # for the combo black_panda and honda_bosch. Ignore extended messages - # and VIN query response. - # Include bus 2 for toyotas to disambiguate cars using camera messages - # (ideally should be done for all cars but we can't for Honda Bosch) - for b in candidate_cars: - if (can.src == b or (only_toyota_left(candidate_cars[b]) and can.src == 2)) and \ - can.address < 0x800 and can.address not in [0x7df, 0x7e0, 0x7e8]: - finger[can.src][can.address] = len(can.dat) - candidate_cars[b] = eliminate_incompatible_cars(can, candidate_cars[b]) - - # if we only have one car choice and the time since we got our first - # message has elapsed, exit + for can in a.can: + # need to independently try to fingerprint both bus 0 and 1 to work + # for the combo black_panda and honda_bosch. Ignore extended messages + # and VIN query response. + # Include bus 2 for toyotas to disambiguate cars using camera messages + # (ideally should be done for all cars but we can't for Honda Bosch) for b in candidate_cars: - # Toyota needs higher time to fingerprint, since DSU does not broadcast immediately - if only_toyota_left(candidate_cars[b]): - frame_fingerprint = 100 # 1s - if len(candidate_cars[b]) == 1: - if frame > frame_fingerprint: - # fingerprint done - car_fingerprint = candidate_cars[b][0] + if (can.src == b or (only_toyota_left(candidate_cars[b]) and can.src == 2)) and \ + can.address < 0x800 and can.address not in [0x7df, 0x7e0, 0x7e8]: + finger[can.src][can.address] = len(can.dat) + candidate_cars[b] = eliminate_incompatible_cars(can, candidate_cars[b]) - # bail if no cars left or we've been waiting for more than 2s - failed = all(len(cc) == 0 for cc in candidate_cars.itervalues()) or frame > 200 - succeeded = car_fingerprint is not None - done = failed or succeeded + # if we only have one car choice and the time since we got our first + # message has elapsed, exit + for b in candidate_cars: + # Toyota needs higher time to fingerprint, since DSU does not broadcast immediately + if only_toyota_left(candidate_cars[b]): + frame_fingerprint = 100 # 1s + if len(candidate_cars[b]) == 1: + if frame > frame_fingerprint: + # fingerprint done + car_fingerprint = candidate_cars[b][0] - frame += 1 + # bail if no cars left or we've been waiting for more than 2s + failed = all(len(cc) == 0 for cc in candidate_cars.itervalues()) or frame > 200 + succeeded = car_fingerprint is not None + done = failed or succeeded - if succeeded: - params.put("DragonCachedModel", pickle.dumps(car_fingerprint)) - params.put("DragonCachedFP", pickle.dumps(finger)) - params.put("DragonCachedVIN", pickle.dumps(vin)) + frame += 1 + + if succeeded: + put_nonblocking("DragonCachedModel", pickle.dumps(car_fingerprint)) + put_nonblocking("DragonCachedFP", pickle.dumps(finger)) + put_nonblocking("DragonCachedVIN", pickle.dumps(vin)) cloudlog.warning("fingerprinted %s", car_fingerprint) return car_fingerprint, finger, vin @@ -141,12 +152,6 @@ def get_car(logcan, sendcan, is_panda_black=False): if candidate is None: cloudlog.warning("car doesn't match any fingerprints: %r", fingerprints) candidate = "mock" - else: - cloudlog.warning("car does match fingerprint: %r", fingerprints) - try: - crash.capture_warning("fingerprinted %s" % candidate) - except: # fixes occasional travis errors - pass CarInterface, CarController = interfaces[candidate] car_params = CarInterface.get_params(candidate, fingerprints[0], vin, is_panda_black) diff --git a/selfdrive/car/chrysler/carcontroller.py b/selfdrive/car/chrysler/carcontroller.py index dac43ca95..2ddc4bdaf 100644 --- a/selfdrive/car/chrysler/carcontroller.py +++ b/selfdrive/car/chrysler/carcontroller.py @@ -31,7 +31,7 @@ class CarController(object): self.packer = CANPacker(dbc_name) - def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, hud_alert): + def update(self, enabled, CS, actuators, pcm_cancel_cmd, hud_alert): # this seems needed to avoid steering faults and to force the sync with the EPS counter frame = CS.lkas_counter if self.prev_frame == frame: diff --git a/selfdrive/car/chrysler/carstate.py b/selfdrive/car/chrysler/carstate.py index 6368847c8..13ea25b59 100644 --- a/selfdrive/car/chrysler/carstate.py +++ b/selfdrive/car/chrysler/carstate.py @@ -1,20 +1,22 @@ +from cereal import car from selfdrive.can.parser import CANParser from selfdrive.car.chrysler.values import DBC, STEER_THRESHOLD from common.kalman.simple_kalman import KF1D +GearShifter = car.CarState.GearShifter def parse_gear_shifter(can_gear): if can_gear == 0x1: - return "park" + return GearShifter.park elif can_gear == 0x2: - return "reverse" + return GearShifter.reverse elif can_gear == 0x3: - return "neutral" + return GearShifter.neutral elif can_gear == 0x4: - return "drive" + return GearShifter.drive elif can_gear == 0x5: - return "low" - return "unknown" + return GearShifter.low + return GearShifter.unknown def get_can_parser(CP): diff --git a/selfdrive/car/chrysler/interface.py b/selfdrive/car/chrysler/interface.py index c43c6c08a..e470b3c1d 100755 --- a/selfdrive/car/chrysler/interface.py +++ b/selfdrive/car/chrysler/interface.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from common.realtime import sec_since_boot from cereal import car from selfdrive.config import Conversions as CV from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event @@ -8,13 +7,14 @@ from selfdrive.car.chrysler.carstate import CarState, get_can_parser, get_camera from selfdrive.car.chrysler.values import ECU, check_ecu_msgs, CAR from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness +GearShifter = car.CarState.GearShifter +ButtonType = car.CarState.ButtonEvent.Type class CarInterface(object): def __init__(self, CP, CarController): self.CP = CP self.VM = VehicleModel(CP) - self.frame = 0 self.gas_pressed_prev = False self.brake_pressed_prev = False self.cruise_enabled_prev = False @@ -115,8 +115,8 @@ class CarInterface(object): # returns a car.CarState def update(self, c, can_strings): # ******************* do can recv ******************* - self.cp.update_strings(int(sec_since_boot() * 1e9), can_strings) - self.cp_cam.update_strings(int(sec_since_boot() * 1e9), can_strings) + self.cp.update_strings(can_strings) + self.cp_cam.update_strings(can_strings) self.CS.update(self.cp, self.cp_cam) @@ -160,8 +160,6 @@ class CarInterface(object): ret.cruiseState.speed = self.CS.v_cruise_pcm * CV.KPH_TO_MS ret.cruiseState.available = self.CS.main_on ret.cruiseState.speedOffset = 0. - # ignore standstill in hybrid rav4, since pcm allows to restart without - # receiving any special command ret.cruiseState.standstill = False # TODO: button presses @@ -169,13 +167,13 @@ class CarInterface(object): if self.CS.left_blinker_on != self.CS.prev_left_blinker_on: be = car.CarState.ButtonEvent.new_message() - be.type = 'leftBlinker' + be.type = ButtonType.leftBlinker be.pressed = self.CS.left_blinker_on != 0 buttonEvents.append(be) if self.CS.right_blinker_on != self.CS.prev_right_blinker_on: be = car.CarState.ButtonEvent.new_message() - be.type = 'rightBlinker' + be.type = ButtonType.rightBlinker be.pressed = self.CS.right_blinker_on != 0 buttonEvents.append(be) @@ -193,7 +191,7 @@ class CarInterface(object): # events events = [] - if not (ret.gearShifter in ('drive', 'low')): + if not (ret.gearShifter in (GearShifter.drive, GearShifter.low)): events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE])) if ret.doorOpen: events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE])) @@ -203,7 +201,7 @@ class CarInterface(object): events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE])) if not self.CS.main_on: events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE])) - if ret.gearShifter == 'reverse': + if ret.gearShifter == GearShifter.reverse: events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) if self.CS.steer_error: events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT])) @@ -236,8 +234,6 @@ class CarInterface(object): if (self.CS.frame == -1): return [] # if we haven't seen a frame 220, then do not update. - self.frame = self.CS.frame - can_sends = self.CC.update(c.enabled, self.CS, self.frame, - c.actuators, c.cruiseControl.cancel, c.hudControl.visualAlert) + can_sends = self.CC.update(c.enabled, self.CS, c.actuators, c.cruiseControl.cancel, c.hudControl.visualAlert) return can_sends diff --git a/selfdrive/car/chrysler/radar_interface.py b/selfdrive/car/chrysler/radar_interface.py index 43f5c6105..815d2c3e4 100755 --- a/selfdrive/car/chrysler/radar_interface.py +++ b/selfdrive/car/chrysler/radar_interface.py @@ -2,7 +2,6 @@ import os from selfdrive.can.parser import CANParser from cereal import car -from common.realtime import sec_since_boot RADAR_MSGS_C = range(0x2c2, 0x2d4+2, 2) # c_ messages 706,...,724 RADAR_MSGS_D = range(0x2a2, 0x2b4+2, 2) # d_ messages @@ -55,8 +54,7 @@ class RadarInterface(object): self.trigger_msg = LAST_MSG def update(self, can_strings): - tm = int(sec_since_boot() * 1e9) - vls = self.rcp.update_strings(tm, can_strings) + vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: diff --git a/selfdrive/car/ford/carcontroller.py b/selfdrive/car/ford/carcontroller.py new file mode 100644 index 000000000..3566fd5e7 --- /dev/null +++ b/selfdrive/car/ford/carcontroller.py @@ -0,0 +1,87 @@ +from cereal import car +from selfdrive.car.ford.fordcan import make_can_msg, create_steer_command, create_lkas_ui, \ + spam_cancel_button +from selfdrive.can.packer import CANPacker + + +MAX_STEER_DELTA = 1 +TOGGLE_DEBUG = False + +class CarController(object): + def __init__(self, dbc_name, enable_camera, vehicle_model): + self.packer = CANPacker(dbc_name) + self.enable_camera = enable_camera + self.enabled_last = False + self.main_on_last = False + self.vehicle_model = vehicle_model + self.generic_toggle_last = 0 + self.steer_alert_last = False + self.lkas_action = 0 + + def update(self, enabled, CS, frame, actuators, visual_alert, pcm_cancel): + + can_sends = [] + steer_alert = visual_alert == car.CarControl.HUDControl.VisualAlert.steerRequired + + apply_steer = actuators.steer + + if self.enable_camera: + + if pcm_cancel: + #print "CANCELING!!!!" + can_sends.append(spam_cancel_button(self.packer)) + + if (frame % 3) == 0: + + curvature = self.vehicle_model.calc_curvature(actuators.steerAngle*3.1415/180., CS.v_ego) + + # The use of the toggle below is handy for trying out the various LKAS modes + if TOGGLE_DEBUG: + self.lkas_action += int(CS.generic_toggle and not self.generic_toggle_last) + self.lkas_action &= 0xf + else: + self.lkas_action = 5 # 4 and 5 seem the best. 8 and 9 seem to aggressive and laggy + + can_sends.append(create_steer_command(self.packer, apply_steer, enabled, + CS.lkas_state, CS.angle_steers, curvature, self.lkas_action)) + self.generic_toggle_last = CS.generic_toggle + + if (frame % 100) == 0: + + can_sends.append(make_can_msg(973, '\x00\x00\x00\x00\x00\x00\x00\x00', 0, False)) + #can_sends.append(make_can_msg(984, '\x00\x00\x00\x00\x80\x45\x60\x30', 0, False)) + + if (frame % 100) == 0 or (self.enabled_last != enabled) or (self.main_on_last != CS.main_on) or \ + (self.steer_alert_last != steer_alert): + can_sends.append(create_lkas_ui(self.packer, CS.main_on, enabled, steer_alert)) + + if (frame % 200) == 0: + can_sends.append(make_can_msg(1875, '\x80\xb0\x55\x55\x78\x90\x00\x00', 1, False)) + + if (frame % 10) == 0: + + can_sends.append(make_can_msg(1648, '\x00\x00\x00\x40\x00\x00\x50\x00', 1, False)) + can_sends.append(make_can_msg(1649, '\x10\x10\xf1\x70\x04\x00\x00\x00', 1, False)) + + can_sends.append(make_can_msg(1664, '\x00\x00\x03\xe8\x00\x01\xa9\xb2', 1, False)) + can_sends.append(make_can_msg(1674, '\x08\x00\x00\xff\x0c\xfb\x6a\x08', 1, False)) + can_sends.append(make_can_msg(1675, '\x00\x00\x3b\x60\x37\x00\x00\x00', 1, False)) + can_sends.append(make_can_msg(1690, '\x70\x00\x00\x55\x86\x1c\xe0\x00', 1, False)) + + can_sends.append(make_can_msg(1910, '\x06\x4b\x06\x4b\x42\xd3\x11\x30', 1, False)) + can_sends.append(make_can_msg(1911, '\x48\x53\x37\x54\x48\x53\x37\x54', 1, False)) + can_sends.append(make_can_msg(1912, '\x31\x34\x47\x30\x38\x31\x43\x42', 1, False)) + can_sends.append(make_can_msg(1913, '\x31\x34\x47\x30\x38\x32\x43\x42', 1, False)) + can_sends.append(make_can_msg(1969, '\xf4\x40\x00\x00\x00\x00\x00\x00', 1, False)) + can_sends.append(make_can_msg(1971, '\x0b\xc0\x00\x00\x00\x00\x00\x00', 1, False)) + + static_msgs = range(1653, 1658) + for addr in static_msgs: + cnt = (frame % 10) + 1 + can_sends.append(make_can_msg(addr, chr(cnt<<4) + '\x00\x00\x00\x00\x00\x00\x00', 1, False)) + + self.enabled_last = enabled + self.main_on_last = CS.main_on + self.steer_alert_last = steer_alert + + return can_sends diff --git a/selfdrive/car/ford/fordcan.py b/selfdrive/car/ford/fordcan.py new file mode 100644 index 000000000..a55f29896 --- /dev/null +++ b/selfdrive/car/ford/fordcan.py @@ -0,0 +1,54 @@ +from common.numpy_fast import clip +from selfdrive.car.ford.values import MAX_ANGLE + + +def make_can_msg(addr, dat, alt, cks=False): + return [addr, 0, dat, alt] + + +def create_steer_command(packer, angle_cmd, enabled, lkas_state, angle_steers, curvature, lkas_action): + """Creates a CAN message for the Ford Steer Command.""" + + #if enabled and lkas available: + if enabled and lkas_state in [2,3]: #and (frame % 500) >= 3: + action = lkas_action + else: + action = 0xf + angle_cmd = angle_steers/MAX_ANGLE + + angle_cmd = clip(angle_cmd * MAX_ANGLE, - MAX_ANGLE, MAX_ANGLE) + + values = { + "Lkas_Action": action, + "Lkas_Alert": 0xf, # no alerts + "Lane_Curvature": clip(curvature, -0.01, 0.01), # is it just for debug? + #"Lane_Curvature": 0, # is it just for debug? + "Steer_Angle_Req": angle_cmd + } + return packer.make_can_msg("Lane_Keep_Assist_Control", 0, values) + + +def create_lkas_ui(packer, main_on, enabled, steer_alert): + """Creates a CAN message for the Ford Steer Ui.""" + + if not main_on: + lines = 0xf + elif enabled: + lines = 0x3 + else: + lines = 0x6 + + values = { + "Set_Me_X80": 0x80, + "Set_Me_X45": 0x45, + "Set_Me_X30": 0x30, + "Lines_Hud": lines, + "Hands_Warning_W_Chime": steer_alert, + } + return packer.make_can_msg("Lane_Keep_Assist_Ui", 0, values) + +def spam_cancel_button(packer): + values = { + "Cancel": 1 + } + return packer.make_can_msg("Steering_Buttons", 0, values) diff --git a/selfdrive/car/ford/interface.py b/selfdrive/car/ford/interface.py index 59acc8432..efc7301f3 100755 --- a/selfdrive/car/ford/interface.py +++ b/selfdrive/car/ford/interface.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from common.realtime import sec_since_boot from cereal import car from selfdrive.swaglog import cloudlog from selfdrive.config import Conversions as CV @@ -48,6 +47,7 @@ class CarInterface(object): ret.isPandaBlack = is_panda_black ret.safetyModel = car.CarParams.SafetyModel.ford + ret.dashcamOnly = True # pedal ret.enableCruise = True @@ -108,7 +108,7 @@ class CarInterface(object): # returns a car.CarState def update(self, c, can_strings): # ******************* do can recv ******************* - self.cp.update_strings(int(sec_since_boot() * 1e9), can_strings) + self.cp.update_strings(can_strings) self.CS.update(self.cp) diff --git a/selfdrive/car/ford/radar_interface.py b/selfdrive/car/ford/radar_interface.py index 04cab9c66..be408da03 100755 --- a/selfdrive/car/ford/radar_interface.py +++ b/selfdrive/car/ford/radar_interface.py @@ -3,7 +3,6 @@ import os import numpy as np from selfdrive.can.parser import CANParser from cereal import car -from common.realtime import sec_since_boot RADAR_MSGS = range(0x500, 0x540) @@ -32,8 +31,7 @@ class RadarInterface(object): self.updated_messages = set() def update(self, can_strings): - tm = int(sec_since_boot() * 1e9) - vls = self.rcp.update_strings(tm, can_strings) + vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index f5f641836..b3e82e5e6 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -1,6 +1,5 @@ #!/usr/bin/env python from cereal import car -from common.realtime import sec_since_boot from selfdrive.config import Conversions as CV from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET from selfdrive.controls.lib.vehicle_model import VehicleModel @@ -9,6 +8,7 @@ from selfdrive.car.gm.values import DBC, CAR, STOCK_CONTROL_MSGS, \ from selfdrive.car.gm.carstate import CarState, CruiseButtons, get_powertrain_can_parser from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness +ButtonType = car.CarState.ButtonEvent.Type class CanBus(object): def __init__(self): @@ -62,6 +62,7 @@ class CarInterface(object): ret.enableCamera = not any(x for x in STOCK_CONTROL_MSGS[candidate] if x in fingerprint) or is_panda_black ret.openpilotLongitudinalControl = ret.enableCamera tire_stiffness_factor = 0.444 # not optimized yet + ret.safetyModelPassive = car.CarParams.SafetyModel.gmPassive if candidate == CAR.VOLT: # supports stop and go, but initial engage must be above 18mph (which include conservatism) @@ -172,7 +173,7 @@ class CarInterface(object): # returns a car.CarState def update(self, c, can_strings): - self.pt_cp.update_strings(int(sec_since_boot() * 1e9), can_strings) + self.pt_cp.update_strings(can_strings) self.CS.update(self.pt_cp) @@ -225,19 +226,19 @@ class CarInterface(object): # blinkers if self.CS.left_blinker_on != self.CS.prev_left_blinker_on: be = car.CarState.ButtonEvent.new_message() - be.type = 'leftBlinker' + be.type = ButtonType.leftBlinker be.pressed = self.CS.left_blinker_on buttonEvents.append(be) if self.CS.right_blinker_on != self.CS.prev_right_blinker_on: be = car.CarState.ButtonEvent.new_message() - be.type = 'rightBlinker' + be.type = ButtonType.rightBlinker be.pressed = self.CS.right_blinker_on buttonEvents.append(be) if self.CS.cruise_buttons != self.CS.prev_cruise_buttons: be = car.CarState.ButtonEvent.new_message() - be.type = 'unknown' + be.type = ButtonType.unknown if self.CS.cruise_buttons != CruiseButtons.UNPRESS: be.pressed = True but = self.CS.cruise_buttons @@ -246,13 +247,13 @@ class CarInterface(object): but = self.CS.prev_cruise_buttons if but == CruiseButtons.RES_ACCEL: if not (cruiseEnabled and self.CS.standstill): - be.type = 'accelCruise' # Suppress resume button if we're resuming from stop so we don't adjust speed. + be.type = ButtonType.accelCruise # Suppress resume button if we're resuming from stop so we don't adjust speed. elif but == CruiseButtons.DECEL_SET: - be.type = 'decelCruise' + be.type = ButtonType.decelCruise elif but == CruiseButtons.CANCEL: - be.type = 'cancel' + be.type = ButtonType.cancel elif but == CruiseButtons.MAIN: - be.type = 'altButton3' + be.type = ButtonType.altButton3 buttonEvents.append(be) ret.buttonEvents = buttonEvents @@ -302,10 +303,10 @@ class CarInterface(object): # handle button presses for b in ret.buttonEvents: # do enable on both accel and decel buttons - if b.type in ["accelCruise", "decelCruise"] and not b.pressed: + if b.type in [ButtonType.accelCruise, ButtonType.decelCruise] and not b.pressed: events.append(create_event('buttonEnable', [ET.ENABLE])) # do disable on button down - if b.type == "cancel" and b.pressed: + if b.type == ButtonType.cancel and b.pressed: events.append(create_event('buttonCancel', [ET.USER_DISABLE])) ret.events = events diff --git a/selfdrive/car/gm/radar_interface.py b/selfdrive/car/gm/radar_interface.py index 6788e1ce7..4f54c8275 100755 --- a/selfdrive/car/gm/radar_interface.py +++ b/selfdrive/car/gm/radar_interface.py @@ -6,7 +6,6 @@ from cereal import car from selfdrive.can.parser import CANParser from selfdrive.car.gm.interface import CanBus from selfdrive.car.gm.values import DBC, CAR -from common.realtime import sec_since_boot RADAR_HEADER_MSG = 1120 SLOT_1_MSG = RADAR_HEADER_MSG + 1 @@ -60,8 +59,7 @@ class RadarInterface(object): time.sleep(0.05) # nothing to do return car.RadarData.new_message() - tm = int(sec_since_boot() * 1e9) - vls = self.rcp.update_strings(tm, can_strings) + vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: diff --git a/selfdrive/car/honda/carstate.py b/selfdrive/car/honda/carstate.py index ee807f658..720500663 100644 --- a/selfdrive/car/honda/carstate.py +++ b/selfdrive/car/honda/carstate.py @@ -1,3 +1,4 @@ +from cereal import car from common.numpy_fast import interp from common.kalman.simple_kalman import KF1D from selfdrive.can.can_define import CANDefine @@ -5,10 +6,12 @@ from selfdrive.can.parser import CANParser from selfdrive.config import Conversions as CV from selfdrive.car.honda.values import CAR, DBC, STEER_THRESHOLD, SPEED_FACTOR, HONDA_BOSCH +GearShifter = car.CarState.GearShifter + def parse_gear_shifter(gear, vals): - val_to_capnp = {'P': 'park', 'R': 'reverse', 'N': 'neutral', - 'D': 'drive', 'S': 'sport', 'L': 'low'} + val_to_capnp = {'P': GearShifter.park, 'R': GearShifter.reverse, 'N': GearShifter.neutral, + 'D': GearShifter.drive, 'S': GearShifter.sport, 'L': GearShifter.low} try: return val_to_capnp[vals[gear]] except KeyError: diff --git a/selfdrive/car/honda/hondacan.py b/selfdrive/car/honda/hondacan.py index c1a318cf2..cb867baf5 100644 --- a/selfdrive/car/honda/hondacan.py +++ b/selfdrive/car/honda/hondacan.py @@ -47,7 +47,7 @@ def create_brake_command(packer, apply_brake, pump_on, pcm_override, pcm_cancel_ "FCW": fcw << 1, "AEB_REQ_1": 0, "AEB_REQ_2": 0, - "AEB": 0, + "AEB_STATUS": 0, } bus = get_pt_bus(car_fingerprint, is_panda_black) return packer.make_can_msg("BRAKE_COMMAND", bus, values, idx) diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index 388cb266e..4fb3efdfc 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -3,7 +3,7 @@ import os import numpy as np from cereal import car from common.numpy_fast import clip, interp -from common.realtime import sec_since_boot, DT_CTRL +from common.realtime import DT_CTRL, sec_since_boot from selfdrive.swaglog import cloudlog from selfdrive.config import Conversions as CV from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET, get_events @@ -17,6 +17,8 @@ params = Params() A_ACC_MAX = max(_A_CRUISE_MAX_V_FOLLOWING) +ButtonType = car.CarState.ButtonEvent.Type +GearShifter = car.CarState.GearShifter def compute_gb_honda(accel, speed): creep_brake = 0.0 @@ -388,8 +390,8 @@ class CarInterface(object): self.ts_last_check = ts # ******************* do can recv ******************* - self.cp.update_strings(int(sec_since_boot() * 1e9), can_strings) - self.cp_cam.update_strings(int(sec_since_boot() * 1e9), can_strings) + self.cp.update_strings(can_strings) + self.cp_cam.update_strings(can_strings) self.CS.update(self.cp, self.cp_cam) @@ -452,19 +454,19 @@ class CarInterface(object): if self.CS.left_blinker_on != self.CS.prev_left_blinker_on: be = car.CarState.ButtonEvent.new_message() - be.type = 'leftBlinker' + be.type = ButtonType.leftBlinker be.pressed = self.CS.left_blinker_on != 0 buttonEvents.append(be) if self.CS.right_blinker_on != self.CS.prev_right_blinker_on: be = car.CarState.ButtonEvent.new_message() - be.type = 'rightBlinker' + be.type = ButtonType.rightBlinker be.pressed = self.CS.right_blinker_on != 0 buttonEvents.append(be) if self.CS.cruise_buttons != self.CS.prev_cruise_buttons: be = car.CarState.ButtonEvent.new_message() - be.type = 'unknown' + be.type = ButtonType.unknown if self.CS.cruise_buttons != 0: be.pressed = True but = self.CS.cruise_buttons @@ -472,18 +474,18 @@ class CarInterface(object): be.pressed = False but = self.CS.prev_cruise_buttons if but == CruiseButtons.RES_ACCEL: - be.type = 'accelCruise' + be.type = ButtonType.accelCruise elif but == CruiseButtons.DECEL_SET: - be.type = 'decelCruise' + be.type = ButtonType.decelCruise elif but == CruiseButtons.CANCEL: - be.type = 'cancel' + be.type = ButtonType.cancel elif but == CruiseButtons.MAIN: - be.type = 'altButton3' + be.type = ButtonType.altButton3 buttonEvents.append(be) if self.CS.cruise_setting != self.CS.prev_cruise_setting: be = car.CarState.ButtonEvent.new_message() - be.type = 'unknown' + be.type = ButtonType.unknown if self.CS.cruise_setting != 0: be.pressed = True but = self.CS.cruise_setting @@ -491,7 +493,7 @@ class CarInterface(object): be.pressed = False but = self.CS.prev_cruise_setting if but == 1: - be.type = 'altButton1' + be.type = ButtonType.altButton1 # TODO: more buttons? buttonEvents.append(be) ret.buttonEvents = buttonEvents @@ -511,7 +513,7 @@ class CarInterface(object): events.append(create_event('steerTempUnavailable', [ET.WARNING])) if self.CS.brake_error: events.append(create_event('brakeUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT])) - if not ret.gearShifter == 'drive': + if not ret.gearShifter == GearShifter.drive: events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE])) if ret.doorOpen: events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE])) @@ -521,7 +523,7 @@ class CarInterface(object): events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE])) if not self.CS.main_on or self.CS.cruise_mode: events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE])) - if ret.gearShifter == 'reverse': + if ret.gearShifter == GearShifter.reverse: events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) if self.CS.brake_hold and self.CS.CP.carFingerprint not in HONDA_BOSCH: events.append(create_event('brakeHold', [ET.NO_ENTRY, ET.USER_DISABLE])) @@ -561,7 +563,7 @@ class CarInterface(object): for b in ret.buttonEvents: # do enable on both accel and decel buttons - if b.type in ["accelCruise", "decelCruise"] and not b.pressed: + if b.type in [ButtonType.accelCruise, ButtonType.decelCruise] and not b.pressed: self.last_enable_pressed = cur_time enable_pressed = True diff --git a/selfdrive/car/honda/radar_interface.py b/selfdrive/car/honda/radar_interface.py index f8cecd6de..6943d3563 100755 --- a/selfdrive/car/honda/radar_interface.py +++ b/selfdrive/car/honda/radar_interface.py @@ -3,7 +3,6 @@ import os import time from cereal import car from selfdrive.can.parser import CANParser -from common.realtime import sec_since_boot def _create_nidec_can_parser(): dbc_f = 'acura_ilx_2016_nidec.dbc' @@ -38,11 +37,11 @@ class RadarInterface(object): # in Bosch radar and we are only steering for now, so sleep 0.05s to keep # radard at 20Hz and return no points if self.radar_off_can: - time.sleep(0.05) + if 'NO_RADAR_SLEEP' not in os.environ: + time.sleep(0.05) return car.RadarData.new_message() - tm = int(sec_since_boot() * 1e9) - vls = self.rcp.update_strings(tm, can_strings) + vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: diff --git a/selfdrive/car/honda/values.py b/selfdrive/car/honda/values.py index 6c73719be..959b392e1 100644 --- a/selfdrive/car/honda/values.py +++ b/selfdrive/car/honda/values.py @@ -103,7 +103,7 @@ FINGERPRINTS = { 57: 3, 148: 8, 228: 5, 229: 4, 304: 8, 342: 6, 344: 8, 380: 8, 399: 7, 411: 5, 419: 8, 420: 8, 427: 3, 432: 7, 440: 8, 450: 8, 463: 8, 464: 8, 476: 4, 490: 8, 506: 8, 507: 1, 542: 7, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 817: 4, 819: 7, 821: 5, 825: 4, 829: 5, 837: 5, 856: 7, 862: 8, 871: 8, 881: 8, 882: 4, 884: 8, 891: 8, 892: 8, 905: 8, 923: 2, 927: 8, 929: 8, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1029: 8, 1036: 8, 1052: 8, 1064: 7, 1088: 8, 1089: 8, 1092: 1, 1108: 8, 1110: 8, 1125: 8, 1296: 8, 1302: 8, 1600: 5, 1601: 8, 1612: 5, 1613: 5, 1614: 5, 1616: 5, 1619: 5, 1623: 5, 1668: 5 }], CAR.ODYSSEY_CHN: [{ - 57: 3, 145: 8, 316: 8, 342: 6, 344: 8, 380: 8, 398: 3, 399: 7, 401: 8, 404: 4, 411: 5, 420: 8, 422: 8, 423: 2, 426: 8, 432: 7, 450: 8, 464: 8, 490: 8, 506: 8, 507: 1, 597: 8, 610: 8, 611: 8, 612: 8, 617: 8, 660: 8, 661: 4, 773: 7, 780: 8, 804: 8, 808: 8, 829: 5, 862: 8, 884: 7, 892: 8, 923: 2, 929: 8, 1030: 5, 1137: 8, 1302: 8, 1348: 5, 1361: 5, 1365: 5, 1600: 5, 1601: 8, 1639: 8 + 57: 3, 145: 8, 316: 8, 342: 6, 344: 8, 380: 8, 398: 3, 399: 7, 401: 8, 404: 4, 411: 5, 420: 8, 422: 8, 423: 2, 426: 8, 432: 7, 450: 8, 464: 8, 490: 8, 506: 8, 507: 1, 512: 6, 513: 6, 597: 8, 610: 8, 611: 8, 612: 8, 617: 8, 660: 8, 661: 4, 773: 7, 780: 8, 804: 8, 808: 8, 829: 5, 862: 8, 884: 7, 892: 8, 923: 2, 929: 8, 1030: 5, 1137: 8, 1302: 8, 1348: 5, 1361: 5, 1365: 5, 1600: 5, 1601: 8, 1639: 8 }, # Odyssey from Shell { @@ -150,7 +150,7 @@ DBC = { CAR.CRV_HYBRID: dbc_dict('honda_crv_hybrid_2019_can_generated', None), CAR.FIT: dbc_dict('honda_fit_ex_2018_can_generated', 'acura_ilx_2016_nidec'), CAR.ODYSSEY: dbc_dict('honda_odyssey_exl_2018_generated', 'acura_ilx_2016_nidec'), - CAR.ODYSSEY_CHN: dbc_dict('honda_odyssey_extreme_edition_2018_china_can', 'acura_ilx_2016_nidec'), + CAR.ODYSSEY_CHN: dbc_dict('honda_odyssey_extreme_edition_2018_china_can_generated', 'acura_ilx_2016_nidec'), CAR.PILOT: dbc_dict('honda_pilot_touring_2017_can_generated', 'acura_ilx_2016_nidec'), CAR.PILOT_2019: dbc_dict('honda_pilot_touring_2017_can_generated', 'acura_ilx_2016_nidec'), CAR.RIDGELINE: dbc_dict('honda_ridgeline_black_edition_2017_can_generated', 'acura_ilx_2016_nidec'), diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index be92371f1..b39f07d6f 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -1,6 +1,5 @@ #!/usr/bin/env python from cereal import car -from common.realtime import sec_since_boot from selfdrive.config import Conversions as CV from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event from selfdrive.controls.lib.vehicle_model import VehicleModel @@ -8,6 +7,8 @@ from selfdrive.car.hyundai.carstate import CarState, get_can_parser, get_camera_ from selfdrive.car.hyundai.values import CAMERA_MSGS, CAR, get_hud_alerts, FEATURES from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness +GearShifter = car.CarState.GearShifter +ButtonType = car.CarState.ButtonEvent.Type class CarInterface(object): def __init__(self, CP, CarController): @@ -154,8 +155,8 @@ class CarInterface(object): # returns a car.CarState def update(self, c, can_strings): # ******************* do can recv ******************* - self.cp.update_strings(int(sec_since_boot() * 1e9), can_strings) - self.cp_cam.update_strings(int(sec_since_boot() * 1e9), can_strings) + self.cp.update_strings(can_strings) + self.cp_cam.update_strings(can_strings) self.CS.update(self.cp, self.cp_cam) # create message @@ -212,13 +213,13 @@ class CarInterface(object): if self.CS.left_blinker_on != self.CS.prev_left_blinker_on: be = car.CarState.ButtonEvent.new_message() - be.type = 'leftBlinker' + be.type = ButtonType.leftBlinker be.pressed = self.CS.left_blinker_on != 0 buttonEvents.append(be) if self.CS.right_blinker_on != self.CS.prev_right_blinker_on: be = car.CarState.ButtonEvent.new_message() - be.type = 'rightBlinker' + be.type = ButtonType.rightBlinker be.pressed = self.CS.right_blinker_on != 0 buttonEvents.append(be) @@ -236,7 +237,7 @@ class CarInterface(object): self.low_speed_alert = False events = [] - if not ret.gearShifter == 'drive': + if not ret.gearShifter == GearShifter.drive: events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE])) if ret.doorOpen: events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE])) @@ -246,12 +247,11 @@ class CarInterface(object): events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE])) if not self.CS.main_on: events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE])) - if ret.gearShifter == 'reverse': + if ret.gearShifter == GearShifter.reverse: events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) if self.CS.steer_error: events.append(create_event('steerTempUnavailable', [ET.NO_ENTRY, ET.WARNING])) - # enable request in prius is simple, as we activate when Toyota is active (rising edge) if ret.cruiseState.enabled and not self.cruise_enabled_prev: events.append(create_event('pcmEnable', [ET.ENABLE])) elif not ret.cruiseState.enabled: diff --git a/selfdrive/car/hyundai/radar_interface.py b/selfdrive/car/hyundai/radar_interface.py index 1d7772fd3..04c100594 100644 --- a/selfdrive/car/hyundai/radar_interface.py +++ b/selfdrive/car/hyundai/radar_interface.py @@ -1,7 +1,7 @@ #!/usr/bin/env python -from cereal import car +import os import time - +from cereal import car class RadarInterface(object): def __init__(self, CP): @@ -11,6 +11,8 @@ class RadarInterface(object): def update(self, can_strings): ret = car.RadarData.new_message() - time.sleep(0.05) # radard runs on RI updates + + if 'NO_RADAR_SLEEP' not in os.environ: + time.sleep(0.05) # radard runs on RI updates return ret diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index c5fe0062a..5c91c9546 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -1,6 +1,5 @@ #!/usr/bin/env python from cereal import car -from common.realtime import sec_since_boot from selfdrive.config import Conversions as CV from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET from selfdrive.controls.lib.vehicle_model import VehicleModel @@ -8,6 +7,7 @@ from selfdrive.car.subaru.values import CAR from selfdrive.car.subaru.carstate import CarState, get_powertrain_can_parser, get_camera_can_parser from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness +ButtonType = car.CarState.ButtonEvent.Type class CarInterface(object): def __init__(self, CP, CarController): @@ -42,6 +42,7 @@ class CarInterface(object): ret = car.CarParams.new_message() ret.carName = "subaru" + ret.radarOffCan = True ret.carFingerprint = candidate ret.carVin = vin ret.isPandaBlack = is_panda_black @@ -96,8 +97,8 @@ class CarInterface(object): # returns a car.CarState def update(self, c, can_strings): - self.pt_cp.update_strings(int(sec_since_boot() * 1e9), can_strings) - self.cam_cp.update_strings(int(sec_since_boot() * 1e9), can_strings) + self.pt_cp.update_strings(can_strings) + self.cam_cp.update_strings(can_strings) self.CS.update(self.pt_cp, self.cam_cp) @@ -144,18 +145,18 @@ class CarInterface(object): # blinkers if self.CS.left_blinker_on != self.CS.prev_left_blinker_on: be = car.CarState.ButtonEvent.new_message() - be.type = 'leftBlinker' + be.type = ButtonType.leftBlinker be.pressed = self.CS.left_blinker_on buttonEvents.append(be) if self.CS.right_blinker_on != self.CS.prev_right_blinker_on: be = car.CarState.ButtonEvent.new_message() - be.type = 'rightBlinker' + be.type = ButtonType.rightBlinker be.pressed = self.CS.right_blinker_on buttonEvents.append(be) be = car.CarState.ButtonEvent.new_message() - be.type = 'accelCruise' + be.type = ButtonType.accelCruise buttonEvents.append(be) diff --git a/selfdrive/car/subaru/radar_interface.py b/selfdrive/car/subaru/radar_interface.py index 0f8108771..6c4e7a16a 100644 --- a/selfdrive/car/subaru/radar_interface.py +++ b/selfdrive/car/subaru/radar_interface.py @@ -1,7 +1,7 @@ #!/usr/bin/env python -from cereal import car +import os import time - +from cereal import car class RadarInterface(object): def __init__(self, CP): @@ -10,8 +10,9 @@ class RadarInterface(object): self.delay = 0.1 def update(self, can_strings): - ret = car.RadarData.new_message() - time.sleep(0.05) # radard runs on RI updates + + if 'NO_RADAR_SLEEP' not in os.environ: + time.sleep(0.05) # radard runs on RI updates return ret diff --git a/selfdrive/car/toyota/carcontroller.py b/selfdrive/car/toyota/carcontroller.py index 4b4168ba7..b03dc42a1 100644 --- a/selfdrive/car/toyota/carcontroller.py +++ b/selfdrive/car/toyota/carcontroller.py @@ -5,8 +5,8 @@ from selfdrive.car import create_gas_command from selfdrive.car.toyota.toyotacan import make_can_msg, create_video_target,\ create_steer_command, create_ui_command, \ create_ipas_steer_command, create_accel_command, \ - create_fcw_command -from selfdrive.car.toyota.values import ECU, STATIC_MSGS, TSS2_CAR + create_acc_cancel_command, create_fcw_command +from selfdrive.car.toyota.values import CAR, ECU, STATIC_MSGS, TSS2_CAR from selfdrive.can.packer import CANPacker from common.params import Params params = Params() @@ -258,7 +258,11 @@ class CarController(object): # accel cmd comes from DSU, but we can spam can to cancel the system even if we are using lat only control if (frame % 3 == 0 and ECU.DSU in self.fake_ecus) or (pcm_cancel_cmd and ECU.CAM in self.fake_ecus): lead = lead or CS.v_ego < 12. # at low speed we always assume the lead is present do ACC can be engaged - if ECU.DSU in self.fake_ecus: + + # Lexus IS uses a different cancellation message + if pcm_cancel_cmd and CS.CP.carFingerprint in [CAR.LEXUS_IS, CAR.LEXUS_ISH]: + can_sends.append(create_acc_cancel_command(self.packer)) + elif ECU.DSU in self.fake_ecus: can_sends.append(create_accel_command(self.packer, apply_accel, pcm_cancel_cmd, self.standstill_req, lead)) else: can_sends.append(create_accel_command(self.packer, 0, pcm_cancel_cmd, False, lead)) @@ -285,8 +289,12 @@ class CarController(object): else: send_ui = False + # disengage msg causes a bad fault sound so play a good sound instead + if pcm_cancel_cmd: + send_ui = True + if (frame % 100 == 0 or send_ui) and ECU.CAM in self.fake_ecus: - can_sends.append(create_ui_command(self.packer, steer, left_line, right_line, left_lane_depart, right_lane_depart)) + can_sends.append(create_ui_command(self.packer, steer, pcm_cancel_cmd, left_line, right_line, left_lane_depart, right_lane_depart)) if frame % 100 == 0 and ECU.DSU in self.fake_ecus and self.car_fingerprint not in TSS2_CAR: can_sends.append(create_fcw_command(self.packer, fcw)) diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index 15e3c633c..9c6f592b5 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -1,18 +1,21 @@ import numpy as np +from cereal import car from common.kalman.simple_kalman import KF1D from selfdrive.can.can_define import CANDefine from selfdrive.can.parser import CANParser from selfdrive.config import Conversions as CV from selfdrive.car.toyota.values import CAR, DBC, STEER_THRESHOLD, TSS2_CAR, NO_DSU_CAR +GearShifter = car.CarState.GearShifter + from common.realtime import sec_since_boot from common.params import Params params = Params() def parse_gear_shifter(gear, vals): - val_to_capnp = {'P': 'park', 'R': 'reverse', 'N': 'neutral', - 'D': 'drive', 'B': 'brake'} + val_to_capnp = {'P': GearShifter.park, 'R': GearShifter.reverse, 'N': GearShifter.neutral, + 'D': GearShifter.drive, 'B': GearShifter.brake} try: return val_to_capnp[vals[gear]] except KeyError: @@ -26,7 +29,6 @@ def get_can_parser(CP): ("STEER_ANGLE", "STEER_ANGLE_SENSOR", 0), ("GEAR", "GEAR_PACKET", 0), ("BRAKE_PRESSED", "BRAKE_MODULE", 0), - ("GAS_PEDAL", "GAS_PEDAL", 0), ("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0), ("WHEEL_SPEED_FR", "WHEEL_SPEEDS", 0), ("WHEEL_SPEED_RL", "WHEEL_SPEEDS", 0), @@ -45,7 +47,9 @@ def get_can_parser(CP): ("STEER_TORQUE_EPS", "STEER_TORQUE_SENSOR", 0), ("TURN_SIGNALS", "STEERING_LEVERS", 3), # 3 is no blinkers ("LKA_STATE", "EPS_STATUS", 0), + ("IPAS_STATE", "EPS_STATUS", 1), ("BRAKE_LIGHTS_ACC", "ESP_CONTROL", 0), + ("AUTO_HIGH_BEAM", "LIGHT_STALK", 0), ] checks = [ @@ -56,35 +60,37 @@ def get_can_parser(CP): ("EPS_STATUS", 25), ] - if CP.carFingerprint in NO_DSU_CAR: - signals += [("STEER_ANGLE", "STEER_TORQUE_SENSOR", 0)] - if CP.carFingerprint == CAR.LEXUS_ISH: + signals.append(("GAS_PEDAL", "GAS_PEDAL_ALT", 0)) + signals.append(("MAIN_ON", "PCM_CRUISE_ALT", 0)) + signals.append(("SET_SPEED", "PCM_CRUISE_ALT", 0)) checks += [ ("BRAKE_MODULE", 50), - ("GAS_PEDAL", 50), - ("PCM_CRUISE_ISH", 1), - ] - - signals += [ - ("MAIN_ON", "PCM_CRUISE_ISH", 0), - ("SET_SPEED", "PCM_CRUISE_ISH", 0), - ("AUTO_HIGH_BEAM", "LIGHT_STALK_ISH", 0), + ("GAS_PEDAL_ALT", 50), + ("PCM_CRUISE_ALT", 1), ] else: + signals += [ + ("GAS_PEDAL", "GAS_PEDAL", 0), + ] checks += [ ("BRAKE_MODULE", 40), ("GAS_PEDAL", 33), - ("PCM_CRUISE_2", 33), - ] - signals += [ - ("MAIN_ON", "PCM_CRUISE_2", 0), - ("SET_SPEED", "PCM_CRUISE_2", 0), - ("LOW_SPEED_LOCKOUT", "PCM_CRUISE_2", 0), - ("IPAS_STATE", "EPS_STATUS", 1), - ("AUTO_HIGH_BEAM", "LIGHT_STALK", 0), ] + if CP.carFingerprint == CAR.LEXUS_IS: + signals.append(("MAIN_ON", "DSU_CRUISE", 0)) + signals.append(("SET_SPEED", "DSU_CRUISE", 0)) + checks.append(("DSU_CRUISE", 5)) + else: + signals.append(("MAIN_ON", "PCM_CRUISE_2", 0)) + signals.append(("SET_SPEED", "PCM_CRUISE_2", 0)) + signals.append(("LOW_SPEED_LOCKOUT", "PCM_CRUISE_2", 0)) + checks.append(("PCM_CRUISE_2", 33)) + + if CP.carFingerprint in NO_DSU_CAR: + signals += [("STEER_ANGLE", "STEER_TORQUE_SENSOR", 0)] + if CP.carFingerprint == CAR.PRIUS: signals += [("STATE", "AUTOPARK_STATUS", 0)] @@ -152,6 +158,8 @@ class CarState(object): self.brake_pressed = cp.vl["BRAKE_MODULE"]['BRAKE_PRESSED'] if self.CP.enableGasInterceptor: self.pedal_gas = (cp.vl["GAS_SENSOR"]['INTERCEPTOR_GAS'] + cp.vl["GAS_SENSOR"]['INTERCEPTOR_GAS2']) / 2. + elif self.CP.carFingerprint == CAR.LEXUS_ISH: + self.pedal_gas = cp.vl["GAS_PEDAL_ALT"]['GAS_PEDAL'] else: self.pedal_gas = cp.vl["GAS_PEDAL"]['GAS_PEDAL'] self.car_gas = self.pedal_gas @@ -189,8 +197,10 @@ class CarState(object): self.angle_steers_rate = cp.vl["STEER_ANGLE_SENSOR"]['STEER_RATE'] can_gear = int(cp.vl["GEAR_PACKET"]['GEAR']) self.gear_shifter = parse_gear_shifter(can_gear, self.shifter_values) - if self.CP.carFingerprint == CAR.LEXUS_ISH: - self.main_on = cp.vl["PCM_CRUISE_ISH"]['MAIN_ON'] + if self.CP.carFingerprint == CAR.LEXUS_IS: + self.main_on = cp.vl["DSU_CRUISE"]['MAIN_ON'] + elif self.CP.carFingerprint == CAR.LEXUS_ISH: + self.main_on = cp.vl["PCM_CRUISE_ALT"]['MAIN_ON'] else: self.main_on = cp.vl["PCM_CRUISE_2"]['MAIN_ON'] self.left_blinker_on = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 1 @@ -199,10 +209,7 @@ class CarState(object): # 2 is standby, 10 is active. TODO: check that everything else is really a faulty state self.steer_state = cp.vl["EPS_STATUS"]['LKA_STATE'] self.steer_error = cp.vl["EPS_STATUS"]['LKA_STATE'] not in [1, 5] - if self.CP.carFingerprint == CAR.LEXUS_ISH: - self.ipas_active = False - else: - self.ipas_active = cp.vl['EPS_STATUS']['IPAS_STATE'] == 3 + self.ipas_active = cp.vl['EPS_STATUS']['IPAS_STATE'] == 3 self.brake_error = 0 self.steer_torque_driver = cp.vl["STEER_TORQUE_SENSOR"]['STEER_TORQUE_DRIVER'] self.steer_torque_motor = cp.vl["STEER_TORQUE_SENSOR"]['STEER_TORQUE_EPS'] @@ -210,15 +217,20 @@ class CarState(object): self.steer_override = abs(self.steer_torque_driver) > STEER_THRESHOLD self.user_brake = 0 - if self.CP.carFingerprint == CAR.LEXUS_ISH: - self.v_cruise_pcm = cp.vl["PCM_CRUISE_ISH"]['SET_SPEED'] - # ish does not have curise status value (always 0), so we use curise_active value instead - self.pcm_acc_status = cp.vl["PCM_CRUISE"]['CRUISE_ACTIVE'] + if self.CP.carFingerprint == CAR.LEXUS_IS: + self.v_cruise_pcm = cp.vl["DSU_CRUISE"]['SET_SPEED'] + self.low_speed_lockout = False + elif self.CP.carFingerprint == CAR.LEXUS_ISH: + self.v_cruise_pcm = cp.vl["PCM_CRUISE_ALT"]['SET_SPEED'] self.low_speed_lockout = False else: self.v_cruise_pcm = cp.vl["PCM_CRUISE_2"]['SET_SPEED'] - self.pcm_acc_status = cp.vl["PCM_CRUISE"]['CRUISE_STATE'] self.low_speed_lockout = cp.vl["PCM_CRUISE_2"]['LOW_SPEED_LOCKOUT'] == 2 + if self.CP.carFingerprint == CAR.LEXUS_ISH: + # Lexus ISH does not have curise status value (always 0), so we use curise_active value instead + self.pcm_acc_status = cp.vl["PCM_CRUISE"]['CRUISE_ACTIVE'] + else: + self.pcm_acc_status = cp.vl["PCM_CRUISE"]['CRUISE_STATE'] self.pcm_acc_active = bool(cp.vl["PCM_CRUISE"]['CRUISE_ACTIVE']) self.brake_lights = bool(cp.vl["ESP_CONTROL"]['BRAKE_LIGHTS_ACC'] or self.brake_pressed) if self.CP.carFingerprint == CAR.PRIUS: @@ -230,10 +242,10 @@ class CarState(object): if self.dragon_toyota_stock_dsu and self.generic_toggle and self.main_on: enable_acc = True - if not self.gear_shifter == 'drive' or not self.seatbelt or not self.door_all_closed: - enable_acc = False + if not self.gear_shifter == GearShifter.drive or not self.seatbelt or not self.door_all_closed: + enable_acc = False self.pcm_acc_active = enable_acc if self.standstill: self.pcm_acc_status = 7 else: - self.pcm_acc_status = 1 \ No newline at end of file + self.pcm_acc_status = 1 diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index cfa971e4d..0b3e77eb6 100755 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -1,16 +1,19 @@ #!/usr/bin/env python -from common.realtime import sec_since_boot from cereal import car from selfdrive.config import Conversions as CV from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event from selfdrive.controls.lib.vehicle_model import VehicleModel from selfdrive.car.toyota.carstate import CarState, get_can_parser, get_cam_can_parser -from selfdrive.car.toyota.values import ECU, check_ecu_msgs, CAR, NO_STOP_TIMER_CAR +from selfdrive.car.toyota.values import ECU, check_ecu_msgs, CAR, NO_STOP_TIMER_CAR, TSS2_CAR from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness from selfdrive.swaglog import cloudlog +from common.realtime import sec_since_boot from common.params import Params params = Params() +ButtonType = car.CarState.ButtonEvent.Type +GearShifter = car.CarState.GearShifter + class CarInterface(object): def __init__(self, CP, CarController): self.CP = CP @@ -215,15 +218,25 @@ class CarInterface(object): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.05]] ret.lateralTuning.pid.kf = 0.00007818594 + elif candidate == CAR.LEXUS_IS: + stop_and_go = False + ret.safetyParam = 66 + ret.wheelbase = 2.79908 + ret.steerRatio = 13.3 + tire_stiffness_factor = 0.444 + ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.05]] + ret.lateralTuning.pid.kf = 0.00006 + elif candidate == CAR.LEXUS_ISH: - stop_and_go = True - ret.safetyParam = 100 - ret.wheelbase = 2.80 # in spec - ret.steerRatio = 13.3 # in spec - tire_stiffness_factor = 0.444 # from camry - ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG # in spec, mean of is300 (1680 kg) / is300h (1720 kg) / is350 (1685 kg) - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.19], [0.04]] - ret.lateralTuning.pid.kf = 0.00006 # from camry + stop_and_go = True # set to true because it's a hybrid + ret.safetyParam = 130 + ret.wheelbase = 2.79908 + ret.steerRatio = 13.3 + tire_stiffness_factor = 0.444 + ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.05]] + ret.lateralTuning.pid.kf = 0.00006 ret.steerRateCost = 1. ret.centerToFront = ret.wheelbase * 0.44 @@ -254,8 +267,8 @@ class CarInterface(object): ret.brakeMaxBP = [0.] ret.brakeMaxV = [1.] - ret.enableCamera = not check_ecu_msgs(fingerprint, ECU.CAM) or is_panda_black - ret.enableDsu = not check_ecu_msgs(fingerprint, ECU.DSU) + ret.enableCamera = not check_ecu_msgs(fingerprint, ECU.CAM, candidate) or is_panda_black + ret.enableDsu = not check_ecu_msgs(fingerprint, ECU.DSU, candidate) or (is_panda_black and candidate in TSS2_CAR) ret.enableApgs = False #not check_ecu_msgs(fingerprint, ECU.APGS) ret.openpilotLongitudinalControl = ret.enableCamera and ret.enableDsu cloudlog.warn("ECU Camera Simulated: %r", ret.enableCamera) @@ -296,11 +309,11 @@ class CarInterface(object): self.ts_last_check = ts # ******************* do can recv ******************* - self.cp.update_strings(int(sec_since_boot() * 1e9), can_strings) + self.cp.update_strings(can_strings) # run the cam can update for 10s as we just need to know if the camera is alive if self.frame < 1000: - self.cp_cam.update_strings(int(sec_since_boot() * 1e9), can_strings) + self.cp_cam.update_strings(can_strings) self.CS.update(self.cp) @@ -361,13 +374,13 @@ class CarInterface(object): buttonEvents = [] if self.CS.left_blinker_on != self.CS.prev_left_blinker_on: be = car.CarState.ButtonEvent.new_message() - be.type = 'leftBlinker' + be.type = ButtonType.leftBlinker be.pressed = self.CS.left_blinker_on != 0 buttonEvents.append(be) if self.CS.right_blinker_on != self.CS.prev_right_blinker_on: be = car.CarState.ButtonEvent.new_message() - be.type = 'rightBlinker' + be.type = ButtonType.rightBlinker be.pressed = self.CS.right_blinker_on != 0 buttonEvents.append(be) @@ -385,7 +398,7 @@ class CarInterface(object): if self.cp_cam.can_valid: self.forwarding_camera = True - if not ret.gearShifter == 'drive' and self.CP.enableDsu: + if not ret.gearShifter == GearShifter.drive and self.CP.enableDsu: events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE])) if ret.doorOpen: events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE])) @@ -395,7 +408,7 @@ class CarInterface(object): events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE])) if not self.CS.main_on and self.CP.enableDsu: events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE])) - if ret.gearShifter == 'reverse' and self.CP.enableDsu: + if ret.gearShifter == GearShifter.reverse and self.CP.enableDsu: events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) if (self.CS.left_blinker_on or self.CS.right_blinker_on) and self.dragon_enable_steering_on_signal: events.append(create_event('manualSteeringRequiredBlinkersOn', [ET.WARNING])) diff --git a/selfdrive/car/toyota/radar_interface.py b/selfdrive/car/toyota/radar_interface.py index 4e0a0e809..0a1ce07ea 100755 --- a/selfdrive/car/toyota/radar_interface.py +++ b/selfdrive/car/toyota/radar_interface.py @@ -3,7 +3,6 @@ import os import time from selfdrive.can.parser import CANParser from cereal import car -from common.realtime import sec_since_boot from selfdrive.car.toyota.values import NO_DSU_CAR, DBC, TSS2_CAR def _create_radar_can_parser(car_fingerprint): @@ -58,8 +57,7 @@ class RadarInterface(object): time.sleep(0.05) return car.RadarData.new_message() - tm = int(sec_since_boot() * 1e9) - vls = self.rcp.update_strings(tm, can_strings) + vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: diff --git a/selfdrive/car/toyota/toyotacan.py b/selfdrive/car/toyota/toyotacan.py index 35ba67452..b886b1c67 100644 --- a/selfdrive/car/toyota/toyotacan.py +++ b/selfdrive/car/toyota/toyotacan.py @@ -95,6 +95,18 @@ def create_accel_command(packer, accel, pcm_cancel, standstill_req, lead): return packer.make_can_msg("ACC_CONTROL", 0, values) +def create_acc_cancel_command(packer): + values = { + "GAS_RELEASED": 0, + "CRUISE_ACTIVE": 0, + "STANDSTILL_ON": 0, + "ACCEL_NET": 0, + "CRUISE_STATE": 0, + "CANCEL_REQ": 1, + } + return packer.make_can_msg("PCM_CRUISE", 0, values) + + def create_fcw_command(packer, fcw): values = { "FCW": fcw, @@ -105,7 +117,7 @@ def create_fcw_command(packer, fcw): return packer.make_can_msg("ACC_HUD", 0, values) -def create_ui_command(packer, steer, left_line, right_line, left_lane_depart, right_lane_depart): +def create_ui_command(packer, steer, chime, left_line, right_line, left_lane_depart, right_lane_depart): values = { "RIGHT_LINE": 3 if right_lane_depart else 1 if right_line else 2, "LEFT_LINE": 3 if left_lane_depart else 1 if left_line else 2, @@ -117,7 +129,7 @@ def create_ui_command(packer, steer, left_line, right_line, left_lane_depart, ri "SET_ME_X01": 1, "SET_ME_X01_2": 1, "REPEATED_BEEPS": 0, - "TWO_BEEPS": 0, + "TWO_BEEPS": chime, "LDA_ALERT": steer, } return packer.make_can_msg("LKAS_HUD", 0, values) diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index 415edf70e..272c0af02 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -17,7 +17,9 @@ class CAR: COROLLA_TSS2 = "TOYOTA COROLLA TSS2 2019" LEXUS_ESH_TSS2 = "LEXUS ES 300H 2019" SIENNA = "TOYOTA SIENNA XLE 2018" - LEXUS_ISH = "LEXUS IS HYBRID 2017" + LEXUS_IS = "LEXUS IS300 2018" + LEXUS_ISH = "LEXUS IS300h 2017" + class ECU: CAM = 0 # camera @@ -28,25 +30,19 @@ class ECU: # addr: (ecu, cars, bus, 1/freq*100, vl) STATIC_MSGS = [ (0x130, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 1, 100, '\x00\x00\x00\x00\x00\x00\x38'), - (0x130, ECU.CAM, (CAR.LEXUS_ISH), 1, 100, '\x00\x00\x03\xff\x00\x00\x3a'), - (0x240, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.LEXUS_ISH), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), - (0x241, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.LEXUS_ISH), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), - (0x244, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.LEXUS_ISH), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), + (0x240, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), + (0x241, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), + (0x244, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), (0x245, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), - (0x245, ECU.CAM, (CAR.LEXUS_ISH), 1, 5, '\x00\x10\x01\x00'), (0x248, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 1, 5, '\x00\x00\x00\x00\x00\x00\x01'), - (0x248, ECU.CAM, (CAR.LEXUS_ISH), 1, 5, '\x00\x01\x00\x00\x00\x00\x00'), (0x367, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 0, 40, '\x06\x00'), - (0x367, ECU.CAM, (CAR.LEXUS_ISH), 0, 40, '\x02\x00'), - (0x414, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.LEXUS_ISH), 0, 100, '\x00\x00\x00\x00\x00\x00\x17\x00'), + (0x414, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 0, 100, '\x00\x00\x00\x00\x00\x00\x17\x00'), (0x466, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.HIGHLANDER, CAR.HIGHLANDERH), 1, 100, '\x20\x20\xAD'), (0x466, ECU.CAM, (CAR.COROLLA, CAR.AVALON), 1, 100, '\x24\x20\xB1'), - (0x466, ECU.CAM, (CAR.LEXUS_ISH), 1, 100, '\x41\x20\xce'), - (0x489, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.LEXUS_ISH), 0, 100, '\x00\x00\x00\x00\x00\x00\x00'), - (0x48a, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.LEXUS_ISH), 0, 100, '\x00\x00\x00\x00\x00\x00\x00'), + (0x489, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 0, 100, '\x00\x00\x00\x00\x00\x00\x00'), + (0x48a, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 0, 100, '\x00\x00\x00\x00\x00\x00\x00'), (0x48b, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 0, 100, '\x66\x06\x08\x0a\x02\x00\x00\x00'), - (0x48b, ECU.CAM, (CAR.LEXUS_ISH), 0, 100, '\x66\x07\x0a\x0f\x01\x00\x00\x00'), - (0x4d3, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.AVALON, CAR.LEXUS_ISH), 0, 100, '\x1C\x00\x00\x01\x00\x00\x00\x00'), + (0x4d3, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.AVALON), 0, 100, '\x1C\x00\x00\x01\x00\x00\x00\x00'), (0x128, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.AVALON), 1, 3, '\xf4\x01\x90\x83\x00\x37'), (0x128, ECU.DSU, (CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.SIENNA), 1, 3, '\x03\x00\x20\x00\x00\x52'), @@ -83,15 +79,13 @@ ECU_FINGERPRINT = { } -def check_ecu_msgs(fingerprint, ecu): - # return True if fingerprint contains messages normally sent by a given ecu - return ECU_FINGERPRINT[ecu] in fingerprint +def check_ecu_msgs(fingerprint, ecu, car): + # return True if the reference car fingerprint doesn't contain the ecu fingerprint msg or + # fingerprint contains messages normally sent by a given ecu + return any(ECU_FINGERPRINT[ecu] not in finger for finger in FINGERPRINTS[car]) or ECU_FINGERPRINT[ecu] in fingerprint FINGERPRINTS = { - CAR.LEXUS_ISH: [{ - 36: 8, 37: 8, 170: 8, 180: 8, 295: 8, 296: 8, 400: 6, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 581: 5, 608: 8, 610: 5, 643: 7, 713: 8, 740: 5, 800: 8, 836: 8, 845: 5, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 913: 8, 916: 3, 918: 7, 921: 7, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 3, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1009: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1168: 1, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1187: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1208: 8, 1212: 8, 1227: 8, 1232: 8, 1235: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 - }], CAR.RAV4: [{ 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 512: 6, 513: 6, 547: 8, 548: 8, 552: 4, 562: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 4, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1596: 8, 1597: 8, 1600: 8, 1656: 8, 1664: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2015: 8, 2024: 8 }], @@ -118,8 +112,9 @@ FINGERPRINTS = { 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 512: 6, 513:6, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 5, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 800: 8, 810: 2, 812: 3, 814: 8, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 6, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1071: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1595: 8, 1777: 8, 1779: 8, 1808: 8, 1810: 8, 1816: 8, 1818: 8, 1840: 8, 1848: 8, 1904: 8, 1912: 8, 1940: 8, 1941: 8, 1948: 8, 1949: 8, 1952: 8, 1956: 8, 1960: 8, 1964: 8, 1986: 8, 1990: 8, 1994: 8, 1998: 8, 2004: 8, 2012: 8 }, # RX450HL + # TODO: get proper fingerprint in stock mode { - 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 512: 6, 513: 6, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 5, 643: 7, 658: 8, 713: 8, 742: 8, 743: 8, 800: 8, 810: 2, 812: 3, 814: 8, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 6, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1056: 8, 1057: 8, 1059: 1, 1063: 8, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1228: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 512: 6, 513: 6, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 5, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 800: 8, 810: 2, 812: 3, 814: 8, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 6, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1056: 8, 1057: 8, 1059: 1, 1063: 8, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1228: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, # RX540H 2019 with color hud { @@ -137,8 +132,9 @@ FINGERPRINTS = { 36: 8, 37: 8, 119: 6, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 891: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1816: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, #XSE and SE + # TODO: get proper fingerprint in stock mode { - 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 761: 8, 764: 8, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 888: 8, 889: 8, 891: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1816: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 888: 8, 889: 8, 891: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1816: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }], CAR.CAMRYH: [ #SE, LE and LE with Blindspot Monitor @@ -179,8 +175,9 @@ FINGERPRINTS = { { 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 565: 8, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 764: 8, 765: 8, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 889: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 987: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1076: 8, 1077: 8, 1082: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1696: 8, 1745: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8 }], - CAR.COROLLA_TSS2: [{ - # hatch 2019+ and sedan 2020+ + CAR.COROLLA_TSS2: [ + # hatch 2019+ and sedan 2020+ + { 36: 8, 37: 8, 114: 5, 170: 8, 180: 8, 186: 4, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 705: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 764: 8, 765: 8, 800: 8, 810: 2, 812: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1235: 8, 1237: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1595: 8, 1649: 8, 1745: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1809: 8, 1816: 8, 1817: 8, 1840: 8, 1848: 8, 1904: 8, 1912: 8, 1940: 8, 1941: 8, 1948: 8, 1949: 8, 1952: 8, 1960: 8, 1981: 8, 1986: 8, 1990: 8, 1994: 8, 1998: 8, 2004: 8 }, { @@ -198,6 +195,16 @@ FINGERPRINTS = { CAR.SIENNA: [{ 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 548: 8, 550: 8, 552: 4, 562: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 764: 8, 800: 8, 824: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 888: 8, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 1, 918: 7, 921: 8, 933: 8, 944: 6, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1160: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1200: 8, 1201: 8, 1202: 8, 1203: 8, 1212: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1656: 8, 1664: 8, 1666: 8, 1667: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }], + CAR.LEXUS_IS: [ + # IS300 2018 + { + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 400: 6, 426: 6, 452: 8, 464: 8, 466: 8, 467: 5, 544: 4, 550: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 740: 5, 800: 8, 836: 8, 845: 5, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 913: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1008: 2, 1009: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1168: 1, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1184: 8, 1185: 8, 1186: 8, 1187: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1208: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1584: 8, 1589: 8, 1590: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1648: 8, 1666: 8, 1667: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }], + CAR.LEXUS_ISH: [ + # IS300H 2017 + { + 36: 8, 37: 8, 170: 8, 180: 8, 295: 8, 296: 8, 400: 6, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 581: 5, 608: 8, 610: 5, 643: 7, 713: 8, 740: 5, 800: 8, 836: 8, 845: 5, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 913: 8, 916: 3, 918: 7, 921: 7, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 3, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1009: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1168: 1, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1187: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1208: 8, 1212: 8, 1227: 8, 1232: 8, 1235: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }], } STEER_THRESHOLD = 100 @@ -219,9 +226,10 @@ DBC = { CAR.COROLLA_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), CAR.LEXUS_ESH_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), CAR.SIENNA: dbc_dict('toyota_sienna_xle_2018_pt_generated', 'toyota_adas'), - CAR.LEXUS_ISH: dbc_dict('lexus_is_hybrid_2017_pt_generated', 'toyota_adas'), + CAR.LEXUS_IS: dbc_dict('lexus_is_2018_pt_generated', 'toyota_adas'), + CAR.LEXUS_ISH: dbc_dict('lexus_is_2018_pt_generated', 'toyota_adas'), } NO_DSU_CAR = [CAR.CHR, CAR.CHRH, CAR.CAMRY, CAR.CAMRYH, CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.LEXUS_ESH_TSS2] TSS2_CAR = [CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.LEXUS_ESH_TSS2] -NO_STOP_TIMER_CAR = [CAR.RAV4H, CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.LEXUS_ESH_TSS2, CAR.SIENNA, CAR.LEXUS_ISH] # no resume button press required +NO_STOP_TIMER_CAR = [CAR.RAV4H, CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.LEXUS_ESH_TSS2, CAR.SIENNA] # no resume button press required diff --git a/selfdrive/common/touch.c b/selfdrive/common/touch.c index 9117154b0..4527cb532 100644 --- a/selfdrive/common/touch.c +++ b/selfdrive/common/touch.c @@ -69,14 +69,15 @@ int touch_poll(TouchState *s, int* out_x, int* out_y, int timeout) { return -1; } - switch (event.type) { + switch (event.type) { case EV_ABS: if (event.code == ABS_MT_POSITION_X) { s->last_x = event.value; } else if (event.code == ABS_MT_POSITION_Y) { s->last_y = event.value; + } else if (event.code == ABS_MT_TRACKING_ID && event.value != -1) { + up = true; } - up = true; break; default: break; @@ -98,7 +99,7 @@ int touch_read(TouchState *s, int* out_x, int* out_y) { return -1; } bool up = false; - switch (event.type) { + switch (event.type) { case EV_ABS: if (event.code == ABS_MT_POSITION_X) { s->last_x = event.value; @@ -117,4 +118,3 @@ int touch_read(TouchState *s, int* out_x, int* out_y) { } return up; } - diff --git a/selfdrive/common/version.h b/selfdrive/common/version.h index d17343827..10517c679 100644 --- a/selfdrive/common/version.h +++ b/selfdrive/common/version.h @@ -1 +1 @@ -#define COMMA_VERSION "0.6.3-release" +#define COMMA_VERSION "0.6.4-release" diff --git a/selfdrive/config.py b/selfdrive/config.py index 751a84e28..6c2296273 100644 --- a/selfdrive/config.py +++ b/selfdrive/config.py @@ -17,7 +17,8 @@ class Conversions: LB_TO_KG = 0.453592 -RADAR_TO_CENTER = 2.7 # RADAR is ~ 2.7m ahead from center of car +RADAR_TO_CENTER = 2.7 # (deprecated) RADAR is ~ 2.7m ahead from center of car +RADAR_TO_CAMERA = 1.52 # RADAR is ~ 1.5m ahead from center of mesh frame class UIParams: lidar_x, lidar_y, lidar_zoom = 384, 960, 6 diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index e4f79638a..808a5309a 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -6,12 +6,12 @@ from cereal import car, log from common.numpy_fast import clip from common.realtime import sec_since_boot, set_realtime_priority, Ratekeeper, DT_CTRL from common.profiler import Profiler -from common.params import Params +from common.params import Params, put_nonblocking import selfdrive.messaging as messaging from selfdrive.config import Conversions as CV from selfdrive.services import service_list from selfdrive.boardd.boardd import can_list_to_can_capnp -from selfdrive.car.car_helpers import get_car, get_startup_alert +from selfdrive.car.car_helpers import get_car, get_startup_alert, get_one_can from selfdrive.controls.lib.lane_planner import CAMERA_OFFSET from selfdrive.controls.lib.drive_helpers import get_events, \ create_event, \ @@ -26,6 +26,7 @@ from selfdrive.controls.lib.alertmanager import AlertManager from selfdrive.controls.lib.vehicle_model import VehicleModel from selfdrive.controls.lib.driver_monitor import DriverStatus, MAX_TERMINAL_ALERTS from selfdrive.controls.lib.planner import LON_MPC_STEP +from selfdrive.controls.lib.gps_helpers import is_rhd_region from selfdrive.locationd.calibration_helpers import Calibration, Filter ThermalStatus = log.ThermalData.ThermalStatus @@ -50,10 +51,6 @@ def events_to_bytes(events): ret.append(e.to_bytes()) return ret -def wait_for_can(logcan): - print("Waiting for CAN messages...") - while len(messaging.recv_one(logcan).can) == 0: - pass def data_sample(CI, CC, sm, can_sock, cal_status, cal_perc, overtemp, free_space, low_battery, driver_status, state, mismatch_counter, params): @@ -85,6 +82,12 @@ def data_sample(CI, CC, sm, can_sock, cal_status, cal_perc, overtemp, free_space if free_space: events.append(create_event('outOfSpace', [ET.NO_ENTRY])) + # GPS coords RHD parsing, once every restart + if sm.updated['gpsLocation'] and not driver_status.is_rhd_region_checked: + is_rhd = is_rhd_region(sm['gpsLocation'].latitude, sm['gpsLocation'].longitude) + driver_status.is_rhd_region = is_rhd + driver_status.is_rhd_region_checked = True + put_nonblocking("IsRHD", str(int(is_rhd))) # Handle calibration if sm.updated['liveCalibration']: @@ -118,7 +121,7 @@ def data_sample(CI, CC, sm, can_sock, cal_status, cal_perc, overtemp, free_space # Driver monitoring if sm.updated['driverMonitoring']: - driver_status.get_pose(sm['driverMonitoring'], params, cal_rpy) + driver_status.get_pose(sm['driverMonitoring'], cal_rpy, CS.vEgo, enabled) # if driver_status.terminal_alert_cnt >= MAX_TERMINAL_ALERTS: # events.append(create_event("tooDistracted", [ET.NO_ENTRY])) @@ -214,7 +217,7 @@ def state_transition(frame, CS, CP, state, events, soft_disable_timer, v_cruise_ def state_control(frame, rcv_frame, plan, path_plan, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last, - AM, rk, driver_status, LaC, LoC, VM, read_only, is_metric, cal_perc, dragon_lat_control): + AM, rk, driver_status, LaC, LoC, VM, read_only, is_metric, cal_perc, dragon_lat_control, dragon_display_steering_limit_alert): """Given the state, this function returns an actuators packet""" actuators = car.CarControl.Actuators.new_message() @@ -264,8 +267,9 @@ def state_control(frame, rcv_frame, plan, path_plan, CS, CP, state, events, v_cr actuators.steer, actuators.steerAngle, lac_log = LaC.update(active, CS.vEgo, CS.steeringAngle, CS.steeringRate, CS.steeringTorqueEps, CS.steeringPressed, CP, VM, path_plan) # Send a "steering required alert" if saturation count has reached the limit - if dragon_lat_control and LaC.sat_flag and CP.steerLimitAlert: - AM.add(frame, "steerSaturated", enabled) + if dragon_display_steering_limit_alert: + if dragon_lat_control and LaC.sat_flag and CP.steerLimitAlert: + AM.add(frame, "steerSaturated", enabled) # Parse permanent warnings to display constantly for e in get_events(events, [ET.PERMANENT]): @@ -283,9 +287,8 @@ def state_control(frame, rcv_frame, plan, path_plan, CS, CP, state, events, v_cr return actuators, v_cruise_kph, driver_status, v_acc_sol, a_acc_sol, lac_log -def data_send(sm, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, carstate, - carcontrol, carevents, carparams, controlsstate, sendcan, AM, driver_status, - LaC, LoC, read_only, start_time, v_acc, a_acc, lac_log, events_prev): +def data_send(sm, pm, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, AM, + driver_status, LaC, LoC, read_only, start_time, v_acc, a_acc, lac_log, events_prev): """Send actuators and hud commands to the car, send controlsstate and MPC logging""" CC = car.CarControl.new_message() @@ -324,7 +327,7 @@ def data_send(sm, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, ca if not read_only: # send car controls over can can_sends = CI.apply(CC) - sendcan.send(can_list_to_can_capnp(can_sends, msgtype='sendcan', valid=CS.canValid)) + pm.send('sendcan', can_list_to_can_capnp(can_sends, msgtype='sendcan', valid=CS.canValid)) force_decel = driver_status.awareness < 0. @@ -341,7 +344,7 @@ def data_send(sm, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, ca "alertType": AM.alert_type, "alertSound": AM.audible_alert, "awarenessStatus": max(driver_status.awareness, 0.0) if isEnabled(state) else 0.0, - "driverMonitoringOn": bool(driver_status.monitor_on and driver_status.face_detected), + "driverMonitoringOn": bool(driver_status.face_detected), "canMonoTimes": list(CS.canMonoTimes), "planMonoTime": sm.logMonoTime['plan'], "pathPlanMonoTime": sm.logMonoTime['pathPlan'], @@ -364,7 +367,6 @@ def data_send(sm, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, ca "vTargetLead": float(v_acc), "aTarget": float(a_acc), "jerkFactor": float(sm['plan'].jerkFactor), - "angleModelBias": 0., "gpsPlannerActive": sm['plan'].gpsPlannerActive, "vCurvature": sm['plan'].vCurvature, "decelForModel": sm['plan'].longitudinalPlanSource == log.Plan.LongitudinalPlanSource.model, @@ -380,7 +382,7 @@ def data_send(sm, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, ca dat.controlsState.lateralControlState.lqrState = lac_log elif CP.lateralTuning.which() == 'indi': dat.controlsState.lateralControlState.indiState = lac_log - controlsstate.send(dat.to_bytes()) + pm.send('controlsState', dat) # carState cs_send = messaging.new_message() @@ -388,7 +390,7 @@ def data_send(sm, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, ca cs_send.valid = CS.canValid cs_send.carState = CS cs_send.carState.events = events - carstate.send(cs_send.to_bytes()) + pm.send('carState', cs_send) # carEvents - logged every second or on change events_bytes = events_to_bytes(events) @@ -396,26 +398,26 @@ def data_send(sm, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, ca ce_send = messaging.new_message() ce_send.init('carEvents', len(events)) ce_send.carEvents = events - carevents.send(ce_send.to_bytes()) + pm.send('carEvents', ce_send) # carParams - logged every 50 seconds (> 1 per segment) if (sm.frame % int(50. / DT_CTRL) == 0): cp_send = messaging.new_message() cp_send.init('carParams') cp_send.carParams = CP - carparams.send(cp_send.to_bytes()) + pm.send('carParams', cp_send) # carControl cc_send = messaging.new_message() cc_send.init('carControl') cc_send.valid = CS.canValid cc_send.carControl = CC - carcontrol.send(cc_send.to_bytes()) + pm.send('carControl', cc_send) return CC, events_bytes -def controlsd_thread(gctx=None): +def controlsd_thread(sm=None, pm=None, can_sock=None): gc.disable() # start the loop @@ -423,39 +425,35 @@ def controlsd_thread(gctx=None): params = Params() - # Pub Sockets - sendcan = messaging.pub_sock(service_list['sendcan'].port) - controlsstate = messaging.pub_sock(service_list['controlsState'].port) - carstate = messaging.pub_sock(service_list['carState'].port) - carcontrol = messaging.pub_sock(service_list['carControl'].port) - carevents = messaging.pub_sock(service_list['carEvents'].port) - carparams = messaging.pub_sock(service_list['carParams'].port) - is_metric = params.get("IsMetric") == "1" passive = params.get("Passive") != "0" - sm = messaging.SubMaster(['thermal', 'health', 'liveCalibration', 'driverMonitoring', 'plan', 'pathPlan']) + # Pub/Sub Sockets + if pm is None: + pm = messaging.PubMaster(['sendcan', 'controlsState', 'carState', 'carControl', 'carEvents', 'carParams']) - logcan = messaging.sub_sock(service_list['can'].port) + if sm is None: + sm = messaging.SubMaster(['thermal', 'health', 'liveCalibration', 'driverMonitoring', 'plan', 'pathPlan', \ + 'gpsLocation'], ignore_alive=['gpsLocation']) + + if can_sock is None: + can_timeout = None if os.environ.get('NO_CAN_TIMEOUT', False) else 100 + can_sock = messaging.sub_sock(service_list['can'].port, timeout=can_timeout) # wait for health and CAN packets hw_type = messaging.recv_one(sm.sock['health']).health.hwType is_panda_black = hw_type == log.HealthData.HwType.blackPanda - wait_for_can(logcan) + print("Waiting for CAN messages...") + get_one_can(can_sock) - CI, CP = get_car(logcan, sendcan, is_panda_black) - logcan.close() - - # TODO: Use the logcan socket from above, but that will currenly break the tests - can_timeout = None if os.environ.get('NO_CAN_TIMEOUT', False) else 100 - can_sock = messaging.sub_sock(service_list['can'].port, timeout=can_timeout) + CI, CP = get_car(can_sock, pm.sock['sendcan'], is_panda_black) car_recognized = CP.carName != 'mock' # If stock camera is disconnected, we loaded car controls and it's not chffrplus controller_available = CP.enableCamera and CI.CC is not None and not passive - read_only = not car_recognized or not controller_available + read_only = not car_recognized or not controller_available or CP.dashcamOnly if read_only: - CP.safetyModel = car.CarParams.SafetyModel.elm327 # diagnostic only + CP.safetyModel = CP.safetyModelPassive # Write CarParams for radard and boardd safety mode params.put("CarParams", CP.to_bytes()) @@ -478,6 +476,9 @@ def controlsd_thread(gctx=None): LaC = LatControlLQR(CP) driver_status = DriverStatus() + is_rhd = params.get("IsRHD") + if is_rhd is not None: + driver_status.is_rhd = bool(int(is_rhd)) state = State.disabled soft_disable_timer = 0 @@ -505,6 +506,8 @@ def controlsd_thread(gctx=None): # dragonpilot ts_last_check = 0. dragon_toyota_stock_dsu = False + dragon_lat_control = True + dragon_display_steering_limit_alert = True while True: # dragonpilot, don't check for param too often as it's a kernel call @@ -512,6 +515,7 @@ def controlsd_thread(gctx=None): if ts - ts_last_check > 3.: dragon_toyota_stock_dsu = False if params.get("DragonToyotaStockDSU") == "0" else True dragon_lat_control = False if params.get("DragonLatCtrl") == "0" else True + dragon_display_steering_limit_alert = False if params.get("DragonDisplaySteeringLimitAlert") == "0" else True ts_last_check = ts start_time = sec_since_boot() @@ -557,21 +561,21 @@ def controlsd_thread(gctx=None): # Compute actuators (runs PID loops and lateral MPC) actuators, v_cruise_kph, driver_status, v_acc, a_acc, lac_log = \ state_control(sm.frame, sm.rcv_frame, sm['plan'], sm['pathPlan'], CS, CP, state, events, v_cruise_kph, v_cruise_kph_last, AM, rk, - driver_status, LaC, LoC, VM, read_only, is_metric, cal_perc, dragon_lat_control) + driver_status, LaC, LoC, VM, read_only, is_metric, cal_perc, dragon_lat_control, dragon_display_steering_limit_alert) prof.checkpoint("State Control") # Publish data - CC, events_prev = data_send(sm, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, carstate, carcontrol, carevents, carparams, - controlsstate, sendcan, AM, driver_status, LaC, LoC, read_only, start_time, v_acc, a_acc, lac_log, events_prev) + CC, events_prev = data_send(sm, pm, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, AM, driver_status, LaC, + LoC, read_only, start_time, v_acc, a_acc, lac_log, events_prev) prof.checkpoint("Sent") rk.monitor_time() prof.display() -def main(gctx=None): - controlsd_thread(gctx) +def main(sm=None, pm=None, logcan=None): + controlsd_thread(sm, pm, logcan) if __name__ == "__main__": diff --git a/selfdrive/controls/lib/drive_helpers.py b/selfdrive/controls/lib/drive_helpers.py index 9c1144b96..a3580a8a9 100644 --- a/selfdrive/controls/lib/drive_helpers.py +++ b/selfdrive/controls/lib/drive_helpers.py @@ -59,26 +59,6 @@ def get_steer_max(CP, v_ego): return interp(v_ego, CP.steerMaxBP, CP.steerMaxV) -def learn_angle_model_bias(lateral_control, v_ego, angle_model_bias, c_poly, c_prob, angle_steers, steer_override): - # simple integral controller that learns how much steering offset to put to have the car going straight - # while being in the middle of the lane - min_offset = -5. # deg - max_offset = 5. # deg - alpha = 1. / 36000. # correct by 1 deg in 2 mins, at 30m/s, with 50cm of error, at 20Hz - min_learn_speed = 1. - - # learn less at low speed or when turning - slow_factor = 1. / (1. + 0.02 * abs(angle_steers) * v_ego) - alpha_v = alpha * c_prob * (max(v_ego - min_learn_speed, 0.)) * slow_factor - - # only learn if lateral control is active and if driver is not overriding: - if lateral_control and not steer_override: - angle_model_bias += c_poly[3] * alpha_v - angle_model_bias = clip(angle_model_bias, min_offset, max_offset) - - return angle_model_bias - - def update_v_cruise(v_cruise_kph, buttonEvents, enabled): # handle button presses. TODO: this should be in state_control, but a decelCruise press # would have the effect of both enabling and changing speed is checked after the state transition diff --git a/selfdrive/controls/lib/driver_monitor.py b/selfdrive/controls/lib/driver_monitor.py index 635714101..40f835e9a 100644 --- a/selfdrive/controls/lib/driver_monitor.py +++ b/selfdrive/controls/lib/driver_monitor.py @@ -1,16 +1,17 @@ import numpy as np -from common.realtime import sec_since_boot, DT_CTRL, DT_DMON +from common.realtime import DT_CTRL, DT_DMON from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET from common.filter_simple import FirstOrderFilter +from common.stat_live import RunningStatFilter from common.params import Params params = Params() -_Timer = int(params.get("DragonSteeringMonitorTimer")) * 60 -_AWARENESS_TIME = _Timer if _Timer > 0 else 86400 -_AWARENESS_PRE_TIME_TILL_TERMINAL = 20. # a first alert is issued 20s before expiration -_AWARENESS_PROMPT_TIME_TILL_TERMINAL = 5. # a second alert is issued 5s before start decelerating the car -_DISTRACTED_TIME = 10. -_DISTRACTED_PRE_TIME_TILL_TERMINAL = 7. -_DISTRACTED_PROMPT_TIME_TILL_TERMINAL = 5. + +_AWARENESS_TIME = 100. # 1.6 minutes limit without user touching steering wheels make the car enter a terminal status +_AWARENESS_PRE_TIME_TILL_TERMINAL = 25. # a first alert is issued 25s before expiration +_AWARENESS_PROMPT_TIME_TILL_TERMINAL = 15. # a second alert is issued 15s before start decelerating the car +_DISTRACTED_TIME = 11. +_DISTRACTED_PRE_TIME_TILL_TERMINAL = 8. +_DISTRACTED_PROMPT_TIME_TILL_TERMINAL = 6. _FACE_THRESHOLD = 0.4 _EYE_THRESHOLD = 0.4 @@ -20,8 +21,15 @@ _METRIC_THRESHOLD = 0.4 _PITCH_POS_ALLOWANCE = 0.04 # 0.08 # rad, to not be too sensitive on positive pitch _PITCH_NATURAL_OFFSET = 0.12 # 0.1 # people don't seem to look straight when they drive relaxed, rather a bit up _YAW_NATURAL_OFFSET = 0.08 # people don't seem to look straight when they drive relaxed, rather a bit to the right (center of car) + _DISTRACTED_FILTER_TS = 0.25 # 0.6Hz -_VARIANCE_FILTER_TS = 20. # 0.008Hz + +_POSE_CALIB_MIN_SPEED = 13 # 30 mph +_POSE_OFFSET_MIN_COUNT = 600 # valid data counts before calibration completes, 1 seg is 600 counts +_POSE_OFFSET_MAX_COUNT = 3600 # stop deweighting new data after 6 min, aka "short term memory" + +_RECOVERY_FACTOR_MAX = 5. # relative to minus step change +_RECOVERY_FACTOR_MIN = 1.25 # relative to minus step change MAX_TERMINAL_ALERTS = 3 # not allowed to engage after 3 terminal alerts @@ -38,7 +46,6 @@ def head_orientation_from_descriptor(angles_desc, pos_desc, rpy_calib): # the output of these angles are in device frame # so from driver's perspective, pitch is up and yaw is right - # TODO: calibrate based on position pitch_prnet = angles_desc[0] yaw_prnet = angles_desc[1] roll_prnet = angles_desc[2] @@ -54,76 +61,89 @@ def head_orientation_from_descriptor(angles_desc, pos_desc, rpy_calib): # no calib for roll pitch -= rpy_calib[1] yaw -= rpy_calib[2] - return np.array([roll, pitch, yaw]) - -class _DriverPose(): +class DriverPose(): def __init__(self): self.yaw = 0. self.pitch = 0. self.roll = 0. - self.yaw_offset = 0. - self.pitch_offset = 0. + self.pitch_offseter = RunningStatFilter(max_trackable=_POSE_OFFSET_MAX_COUNT) + self.yaw_offseter = RunningStatFilter(max_trackable=_POSE_OFFSET_MAX_COUNT) -class _DriverBlink(): +class DriverBlink(): def __init__(self): self.left_blink = 0. self.right_blink = 0. - - -def _monitor_hysteresis(variance_level, monitor_valid_prev): - var_thr = 0.63 if monitor_valid_prev else 0.37 - return variance_level < var_thr - class DriverStatus(): - def __init__(self, monitor_on=False): - self.pose = _DriverPose() - self.blink = _DriverBlink() - self.monitor_on = monitor_on - self.monitor_param_on = monitor_on - self.monitor_valid = True # variance needs to be low + def __init__(self): + self.pose = DriverPose() + self.pose_calibrated = self.pose.pitch_offseter.filtered_stat.n > _POSE_OFFSET_MIN_COUNT and \ + self.pose.yaw_offseter.filtered_stat.n > _POSE_OFFSET_MIN_COUNT + self.blink = DriverBlink() self.awareness = 1. + self.awareness_active = 1. + self.awareness_passive = 1. self.driver_distracted = False self.driver_distraction_filter = FirstOrderFilter(0., _DISTRACTED_FILTER_TS, DT_DMON) - self.variance_high = False - self.variance_filter = FirstOrderFilter(0., _VARIANCE_FILTER_TS, DT_DMON) - self.ts_last_check = 0. self.face_detected = False self.terminal_alert_cnt = 0 self.step_change = 0. - self._set_timers(self.monitor_on) + self.active_monitoring_mode = True + self.threshold_prompt = _DISTRACTED_PROMPT_TIME_TILL_TERMINAL / _DISTRACTED_TIME + + self.is_rhd_region = False + self.is_rhd_region_checked = False # dragonpilot - self.dp_last_check = 0. - self.dragon_enable_driver_safety_check = True + self.awareness_time = float(params.get("DragonSteeringMonitorTimer")) + self.awareness_time = 86400 if self.awareness_time <= 0. else self.awareness_time * 60. + self.dragon_enable_driver_safety_check = False if params.get("DragonEnableDriverSafetyCheck") == "0" else True - def _reset_filters(self): - self.driver_distraction_filter.x = 0. - self.variance_filter.x = 0. - self.monitor_valid = True + self._set_timers(active_monitoring=True) def _set_timers(self, active_monitoring): + if self.active_monitoring_mode and self.awareness <= self.threshold_prompt: + if active_monitoring: + self.step_change = DT_CTRL / _DISTRACTED_TIME + else: + self.step_change = 0. + return # no exploit after orange alert + elif self.awareness <= 0.: + return + if active_monitoring: # when falling back from passive mode to active mode, reset awareness to avoid false alert - if self.step_change == DT_CTRL / _AWARENESS_TIME: - self.awareness = 1. + if not self.active_monitoring_mode: + self.awareness_passive = self.awareness + self.awareness = self.awareness_active + self.threshold_pre = _DISTRACTED_PRE_TIME_TILL_TERMINAL / _DISTRACTED_TIME self.threshold_prompt = _DISTRACTED_PROMPT_TIME_TILL_TERMINAL / _DISTRACTED_TIME self.step_change = DT_CTRL / _DISTRACTED_TIME + self.active_monitoring_mode = True else: - self.threshold_pre = _AWARENESS_PRE_TIME_TILL_TERMINAL / _AWARENESS_TIME - self.threshold_prompt = _AWARENESS_PROMPT_TIME_TILL_TERMINAL / _AWARENESS_TIME - self.step_change = DT_CTRL / _AWARENESS_TIME + if self.active_monitoring_mode: + self.awareness_active = self.awareness + self.awareness = self.awareness_passive + + self.threshold_pre = _AWARENESS_PRE_TIME_TILL_TERMINAL / self.awareness_time + self.threshold_prompt = _AWARENESS_PROMPT_TIME_TILL_TERMINAL / self.awareness_time + self.step_change = DT_CTRL / self.awareness_time + self.active_monitoring_mode = False def _is_driver_distracted(self, pose, blink): - # TODO: natural pose calib of each driver - pitch_error = pose.pitch - _PITCH_NATURAL_OFFSET - yaw_error = pose.yaw - _YAW_NATURAL_OFFSET - # add positive pitch allowance - if pitch_error > 0.: - pitch_error = max(pitch_error - _PITCH_POS_ALLOWANCE, 0.) + if not self.pose_calibrated: + pitch_error = pose.pitch - _PITCH_NATURAL_OFFSET + yaw_error = pose.yaw - _YAW_NATURAL_OFFSET + # add positive pitch allowance + if pitch_error > 0.: + pitch_error = max(pitch_error - _PITCH_POS_ALLOWANCE, 0.) + else: + pitch_error = pose.pitch - self.pose.pitch_offseter.filtered_stat.mean() + yaw_error = pose.yaw - self.pose.yaw_offseter.filtered_stat.mean() + pitch_error *= _PITCH_WEIGHT pose_metric = np.sqrt(yaw_error**2 + pitch_error**2) @@ -134,84 +154,70 @@ class DriverStatus(): else: return DistractedType.NOT_DISTRACTED - - def get_pose(self, driver_monitoring, params, cal_rpy): + def get_pose(self, driver_monitoring, cal_rpy, car_speed, op_engaged): + # 10 Hz if len(driver_monitoring.faceOrientation) == 0 or len(driver_monitoring.facePosition) == 0: return self.pose.roll, self.pose.pitch, self.pose.yaw = head_orientation_from_descriptor(driver_monitoring.faceOrientation, driver_monitoring.facePosition, cal_rpy) self.blink.left_blink = driver_monitoring.leftBlinkProb * (driver_monitoring.leftEyeProb>_EYE_THRESHOLD) self.blink.right_blink = driver_monitoring.rightBlinkProb * (driver_monitoring.rightEyeProb>_EYE_THRESHOLD) - self.face_detected = driver_monitoring.faceProb > _FACE_THRESHOLD + self.face_detected = driver_monitoring.faceProb > _FACE_THRESHOLD and not self.is_rhd_region self.driver_distracted = self._is_driver_distracted(self.pose, self.blink)>0 # first order filters self.driver_distraction_filter.update(self.driver_distracted) - monitor_param_on_prev = self.monitor_param_on + # update offseter + # only update when driver is actively driving the car above a certain speed + if self.face_detected and car_speed>_POSE_CALIB_MIN_SPEED and not op_engaged: + self.pose.pitch_offseter.push_and_update(self.pose.pitch) + self.pose.yaw_offseter.push_and_update(self.pose.yaw) - # don't check for param too often as it's a kernel call - ts = sec_since_boot() - if ts - self.ts_last_check > 3.: - self.monitor_param_on = params.get("IsDriverMonitoringEnabled") == "1" - self.ts_last_check = ts - - self.monitor_on = self.monitor_valid and self.monitor_param_on - if monitor_param_on_prev != self.monitor_param_on: - self._reset_filters() - self._set_timers(self.monitor_on and self.face_detected) + self.pose_calibrated = self.pose.pitch_offseter.filtered_stat.n > _POSE_OFFSET_MIN_COUNT and \ + self.pose.yaw_offseter.filtered_stat.n > _POSE_OFFSET_MIN_COUNT + self._set_timers(self.face_detected) def update(self, events, driver_engaged, ctrl_active, standstill): - if driver_engaged: + if (driver_engaged and self.awareness > 0) or not ctrl_active or not self.dragon_enable_driver_safety_check: + # reset only when on disengagement if red reached self.awareness = 1. + self.awareness_active = 1. + self.awareness_passive = 1. return events - # don't check for param too often as it's a kernel call - ts = sec_since_boot() - if ts - self.dp_last_check > 3.: - self.dragon_enable_driver_safety_check = False if params.get("DragonEnableDriverSafetyCheck") == "0" else True - self.dp_last_check = ts - - if not self.dragon_enable_driver_safety_check: - return events - - driver_engaged |= (self.driver_distraction_filter.x < 0.37 and self.monitor_on) + driver_attentive = self.driver_distraction_filter.x < 0.37 awareness_prev = self.awareness - if (driver_engaged and self.awareness > 0) or not ctrl_active: - # always reset if driver is in control (unless we are in red alert state) or op isn't active - self.awareness = min(self.awareness + (2.75*(1.-self.awareness)+1.25)*self.step_change, 1.) + if (driver_attentive and self.face_detected and self.awareness > 0): + # only restore awareness when paying attention and alert is not red + self.awareness = min(self.awareness + ((_RECOVERY_FACTOR_MAX-_RECOVERY_FACTOR_MIN)*(1.-self.awareness)+_RECOVERY_FACTOR_MIN)*self.step_change, 1.) + if self.awareness == 1.: + self.awareness_passive = min(self.awareness_passive + self.step_change, 1.) + # don't display alert banner when awareness is recovering and has cleared orange + if self.awareness > self.threshold_prompt: + return events # should always be counting if distracted unless at standstill and reaching orange - if ((not self.monitor_on or (self.monitor_on and not self.face_detected)) or (self.driver_distraction_filter.x > 0.63 and self.driver_distracted and self.face_detected)) and \ + if (not self.face_detected or (self.driver_distraction_filter.x > 0.63 and self.driver_distracted and self.face_detected)) and \ not (standstill and self.awareness - self.step_change <= self.threshold_prompt): self.awareness = max(self.awareness - self.step_change, -0.1) alert = None - if self.awareness < 0.: + if self.awareness <= 0.: # terminal red alert: disengagement required - alert = 'driverDistracted' if self.monitor_on else 'driverUnresponsive' - if awareness_prev >= 0.: + alert = 'driverDistracted' if self.active_monitoring_mode else 'driverUnresponsive' + if awareness_prev > 0.: self.terminal_alert_cnt += 1 elif self.awareness <= self.threshold_prompt: # prompt orange alert - alert = 'promptDriverDistracted' if self.monitor_on else 'promptDriverUnresponsive' + alert = 'promptDriverDistracted' if self.active_monitoring_mode else 'promptDriverUnresponsive' elif self.awareness <= self.threshold_pre: # pre green alert - alert = 'preDriverDistracted' if self.monitor_on else 'preDriverUnresponsive' + alert = 'preDriverDistracted' if self.active_monitoring_mode else 'preDriverUnresponsive' + if alert is not None: events.append(create_event(alert, [ET.WARNING])) return events - - -if __name__ == "__main__": - ds = DriverStatus(True) - ds.driver_distraction_filter.x = 0. - ds.driver_distracted = 1 - for i in range(10): - ds.update([], False, True, False) - print(ds.awareness, ds.driver_distracted, ds.driver_distraction_filter.x) - ds.update([], True, True, False) - print(ds.awareness, ds.driver_distracted, ds.driver_distraction_filter.x) diff --git a/selfdrive/controls/lib/fcw.py b/selfdrive/controls/lib/fcw.py index 8180fadeb..c080fecb4 100644 --- a/selfdrive/controls/lib/fcw.py +++ b/selfdrive/controls/lib/fcw.py @@ -45,7 +45,6 @@ class FCWChecker(object): def update(self, mpc_solution, cur_time, active, v_ego, a_ego, x_lead, v_lead, a_lead, y_lead, vlat_lead, fcw_lead, blinkers): mpc_solution_a = list(mpc_solution[0].a_ego) - a_target = mpc_solution_a[1] self.last_min_a = min(mpc_solution_a) self.v_lead_max = max(self.v_lead_max, v_lead) @@ -66,9 +65,8 @@ class FCWChecker(object): future_fcw_allowed = all(c >= 10 for c in self.counters.values()) future_fcw = (self.last_min_a < -3.0 or a_delta < a_thr) and future_fcw_allowed - current_fcw = a_target < -3.0 and active - if (future_fcw or current_fcw) and (self.last_fcw_time + 5.0 < cur_time): + if future_fcw and (self.last_fcw_time + 5.0 < cur_time): self.last_fcw_time = cur_time self.last_fcw_a = self.last_min_a return True diff --git a/selfdrive/controls/lib/gps_helpers.py b/selfdrive/controls/lib/gps_helpers.py new file mode 100755 index 000000000..6ac27202d --- /dev/null +++ b/selfdrive/controls/lib/gps_helpers.py @@ -0,0 +1,17 @@ +_RHD_REGION_MAP = [ ['AUS', -54.76, -9.23, 112.91, 159.11], \ + ['IN1', 6.75, 28.10, 68.17, 97.4], \ + ['IN2', 28.09, 35.99, 72.18, 80.87], \ + ['IRL', 51.42, 55.38, -10.58, -5.99], \ + ['JP1', 32.66, 45.52, 137.27, 146.02], \ + ['JP2', 32.79, 37.60, 131.41, 137.28], \ + ['JP3', 24.04, 34.78, 122.93, 131.42], \ + ['NZ', -52.61, -29.24, 166, 178.84], \ + ['SF', -35.14, -22.13, 16.07, 33.21], \ + ['UK', 49.9, 60.84, -8.62, 1.77] ] + +def is_rhd_region(latitude, longitude): + for region in _RHD_REGION_MAP: + if region[1] <= latitude <= region[2] and \ + region[3] <= longitude <= region[4]: + return True + return False diff --git a/selfdrive/controls/lib/lane_planner.py b/selfdrive/controls/lib/lane_planner.py index c61f7217f..c32d09e4a 100644 --- a/selfdrive/controls/lib/lane_planner.py +++ b/selfdrive/controls/lib/lane_planner.py @@ -1,12 +1,22 @@ from common.numpy_fast import interp import numpy as np -from selfdrive.controls.lib.latcontrol_helpers import model_polyfit, compute_path_pinv from common.realtime import sec_since_boot from common.params import Params params = Params() CAMERA_OFFSET = 0.06 # m from center car to camera +def compute_path_pinv(l=50): + deg = 3 + x = np.arange(l*1.0) + X = np.vstack(tuple(x**n for n in range(deg, -1, -1))).T + pinv = np.linalg.pinv(X) + return pinv + + +def model_polyfit(points, path_pinv): + return np.dot(path_pinv, [float(x) for x in points]) + def calc_d_poly(l_poly, r_poly, p_poly, l_prob, r_prob, lane_width): # This will improve behaviour when lanes suddenly widen @@ -19,7 +29,7 @@ def calc_d_poly(l_poly, r_poly, p_poly, l_prob, r_prob, lane_width): path_from_right_lane = r_poly.copy() path_from_right_lane[3] += lane_width / 2.0 - lr_prob = l_prob + r_prob - l_prob * r_prob + lr_prob = l_prob * r_prob d_poly_lane = (l_prob * path_from_left_lane + r_prob * path_from_right_lane) / (l_prob + r_prob + 0.0001) return lr_prob * d_poly_lane + (1.0 - lr_prob) * p_poly @@ -38,7 +48,6 @@ class LanePlanner(object): self.l_prob = 0. self.r_prob = 0. - self.lr_prob = 0. self._path_pinv = compute_path_pinv() self.x_points = np.arange(50) @@ -67,8 +76,6 @@ class LanePlanner(object): self.l_poly[3] += self.camera_offset self.r_poly[3] += self.camera_offset - self.lr_prob = self.l_prob + self.r_prob - self.l_prob * self.r_prob - # Find current lanewidth self.lane_width_certainty += 0.05 * (self.l_prob * self.r_prob - self.lane_width_certainty) current_lane_width = abs(self.l_poly[3] - self.r_poly[3]) diff --git a/selfdrive/controls/lib/latcontrol_helpers.py b/selfdrive/controls/lib/latcontrol_helpers.py deleted file mode 100644 index ff5fa478a..000000000 --- a/selfdrive/controls/lib/latcontrol_helpers.py +++ /dev/null @@ -1,62 +0,0 @@ -import numpy as np -import math -from common.numpy_fast import interp - -_K_CURV_V = [1., 0.6] -_K_CURV_BP = [0., 0.002] - -# lane width http://safety.fhwa.dot.gov/geometric/pubs/mitigationstrategies/chapter3/3_lanewidth.cfm -_LANE_WIDTH_V = [3., 3.8] - -# break points of speed -_LANE_WIDTH_BP = [0., 31.] - - -def calc_d_lookahead(v_ego, d_poly): - # this function computes how far too look for lateral control - # howfar we look ahead is function of speed and how much curvy is the path - offset_lookahead = 1. - k_lookahead = 7. - # integrate abs value of second derivative of poly to get a measure of path curvature - pts_len = 50. # m - if len(d_poly) > 0: - pts = np.polyval([6 * d_poly[0], 2 * d_poly[1]], np.arange(0, pts_len)) - else: - pts = 0. - curv = np.sum(np.abs(pts)) / pts_len - - k_curv = interp(curv, _K_CURV_BP, _K_CURV_V) - - # sqrt on speed is needed to keep, for a given curvature, the y_des - # proportional to speed. Indeed, y_des is prop to d_lookahead^2 - # 36m at 25m/s - d_lookahead = offset_lookahead + math.sqrt(max(v_ego, 0)) * k_lookahead * k_curv - return d_lookahead - - -def calc_lookahead_offset(v_ego, angle_steers, d_lookahead, VM, angle_offset): - # this function returns the lateral offset given the steering angle, speed and the lookahead distance - sa = math.radians(angle_steers - angle_offset) - curvature = VM.calc_curvature(sa, v_ego) - # clip is to avoid arcsin NaNs due to too sharp turns - y_actual = d_lookahead * np.tan(np.arcsin(np.clip(d_lookahead * curvature, -0.999, 0.999)) / 2.) - return y_actual, curvature - - -def calc_desired_steer_angle(v_ego, y_des, d_lookahead, VM, angle_offset): - # inverse of the above function - curvature = np.sin(np.arctan(y_des / d_lookahead) * 2.) / d_lookahead - steer_des = math.degrees(VM.get_steer_from_curvature(curvature, v_ego)) + angle_offset - return steer_des, curvature - - -def compute_path_pinv(l=50): - deg = 3 - x = np.arange(l*1.0) - X = np.vstack(tuple(x**n for n in range(deg, -1, -1))).T - pinv = np.linalg.pinv(X) - return pinv - - -def model_polyfit(points, path_pinv): - return np.dot(path_pinv, [float(x) for x in points]) diff --git a/selfdrive/controls/lib/latcontrol_lqr.py b/selfdrive/controls/lib/latcontrol_lqr.py index 8c0e3ec31..23d91cae4 100644 --- a/selfdrive/controls/lib/latcontrol_lqr.py +++ b/selfdrive/controls/lib/latcontrol_lqr.py @@ -22,6 +22,7 @@ class LatControlLQR(object): self.i_unwind_rate = 0.3 / rate self.i_rate = 1.0 / rate + self.reset() def reset(self): @@ -31,6 +32,7 @@ class LatControlLQR(object): def update(self, active, v_ego, angle_steers, angle_steers_rate, eps_torque, steer_override, CP, VM, path_plan): lqr_log = log.ControlsState.LateralLQRState.new_message() + steers_max = get_steer_max(CP, v_ego) torque_scale = (0.45 + v_ego / 60.0)**2 # Scale actuator model with speed # Subtract offset. Zero angle should correspond to zero torque @@ -44,29 +46,32 @@ class LatControlLQR(object): if v_ego < 0.3 or not active: lqr_log.active = False + lqr_output = 0. self.reset() else: lqr_log.active = True # LQR u_lqr = float(self.angle_steers_des / self.dc_gain - self.K.dot(self.x_hat)) + lqr_output = torque_scale * u_lqr / self.scale # Integrator if steer_override: self.i_lqr -= self.i_unwind_rate * float(np.sign(self.i_lqr)) else: - self.i_lqr += self.ki * self.i_rate * (self.angle_steers_des - angle_steers_k) + error = self.angle_steers_des - angle_steers_k + i = self.i_lqr + self.ki * self.i_rate * error + control = lqr_output + i - lqr_output = torque_scale * u_lqr / self.scale - self.i_lqr = clip(self.i_lqr, -1.0 - lqr_output, 1.0 - lqr_output) # (LQR + I) has to be between -1 and 1 + if ((error >= 0 and (control <= steers_max or i < 0.0)) or \ + (error <= 0 and (control >= -steers_max or i > 0.0))): + self.i_lqr = i self.output_steer = lqr_output + self.i_lqr - - # Clip output - steers_max = get_steer_max(CP, v_ego) self.output_steer = clip(self.output_steer, -steers_max, steers_max) lqr_log.steerAngle = angle_steers_k + path_plan.angleOffset lqr_log.i = self.i_lqr lqr_log.output = self.output_steer + lqr_log.lqrOutput = lqr_output return self.output_steer, float(self.angle_steers_des), lqr_log diff --git a/selfdrive/controls/lib/long_mpc.py b/selfdrive/controls/lib/long_mpc.py index 9d43e97f2..cb1ab94dc 100644 --- a/selfdrive/controls/lib/long_mpc.py +++ b/selfdrive/controls/lib/long_mpc.py @@ -12,8 +12,7 @@ LOG_MPC = os.environ.get('LOG_MPC', False) class LongitudinalMpc(object): - def __init__(self, mpc_id, live_longitudinal_mpc): - self.live_longitudinal_mpc = live_longitudinal_mpc + def __init__(self, mpc_id): self.mpc_id = mpc_id self.setup_mpc() @@ -27,7 +26,7 @@ class LongitudinalMpc(object): self.last_cloudlog_t = 0.0 - def send_mpc_solution(self, qp_iterations, calculation_time): + def send_mpc_solution(self, pm, qp_iterations, calculation_time): qp_iterations = max(0, qp_iterations) dat = messaging.new_message() dat.init('liveLongitudinalMpc') @@ -41,7 +40,7 @@ class LongitudinalMpc(object): dat.liveLongitudinalMpc.qpIterations = qp_iterations dat.liveLongitudinalMpc.mpcId = self.mpc_id dat.liveLongitudinalMpc.calculationTime = calculation_time - self.live_longitudinal_mpc.send(dat.to_bytes()) + pm.send('liveLongitudinalMpc', dat) def setup_mpc(self): ffi, self.libmpc = libmpc_py.get_libmpc(self.mpc_id) @@ -58,7 +57,7 @@ class LongitudinalMpc(object): self.cur_state[0].v_ego = v self.cur_state[0].a_ego = a - def update(self, CS, lead, v_cruise_setpoint): + def update(self, pm, CS, lead, v_cruise_setpoint): v_ego = CS.vEgo # Setup current mpc state @@ -97,7 +96,7 @@ class LongitudinalMpc(object): duration = int((sec_since_boot() - t) * 1e9) if LOG_MPC: - self.send_mpc_solution(n_its, duration) + self.send_mpc_solution(pm, n_its, duration) # Get solution. MPC timestep is 0.2 s, so interpolation to 0.05 s is needed self.v_mpc = self.mpc_solution[0].v_ego[1] diff --git a/selfdrive/controls/lib/pathplanner.py b/selfdrive/controls/lib/pathplanner.py index faa812ac6..b62d9f110 100644 --- a/selfdrive/controls/lib/pathplanner.py +++ b/selfdrive/controls/lib/pathplanner.py @@ -4,7 +4,6 @@ import numpy as np # from common.numpy_fast import clip from common.realtime import sec_since_boot -from selfdrive.services import service_list from selfdrive.swaglog import cloudlog from selfdrive.controls.lib.lateral_mpc import libmpc_py from selfdrive.controls.lib.drive_helpers import MPC_COST_LAT @@ -26,9 +25,6 @@ class PathPlanner(object): self.last_cloudlog_t = 0 - self.plan = messaging.pub_sock(service_list['pathPlan'].port) - self.livempc = messaging.pub_sock(service_list['liveMpc'].port) - self.setup_mpc(CP.steerRateCost) self.solution_invalid_cnt = 0 self.path_offset_i = 0.0 @@ -49,13 +45,12 @@ class PathPlanner(object): self.angle_steers_des_prev = 0.0 self.angle_steers_des_time = 0.0 - def update(self, sm, CP, VM): + def update(self, sm, pm, CP, VM): v_ego = sm['carState'].vEgo angle_steers = sm['carState'].steeringAngle active = sm['controlsState'].active - angle_offset_average = sm['liveParameters'].angleOffsetAverage - angle_offset_bias = sm['controlsState'].angleModelBias + angle_offset_average + angle_offset = sm['liveParameters'].angleOffset self.LP.update(v_ego, sm['model']) @@ -73,7 +68,7 @@ class PathPlanner(object): # self.path_offset_i = 0.0 # account for actuation delay - self.cur_state = calc_states_after_delay(self.cur_state, v_ego, angle_steers - angle_offset_average, curvature_factor, VM.sR, CP.steerActuatorDelay) + self.cur_state = calc_states_after_delay(self.cur_state, v_ego, angle_steers - angle_offset, curvature_factor, VM.sR, CP.steerActuatorDelay) v_ego_mpc = max(v_ego, 5.0) # avoid mpc roughness due to low speed self.libmpc.run_mpc(self.cur_state, self.mpc_solution, @@ -85,19 +80,19 @@ class PathPlanner(object): delta_desired = self.mpc_solution[0].delta[1] rate_desired = math.degrees(self.mpc_solution[0].rate[0] * VM.sR) else: - delta_desired = math.radians(angle_steers - angle_offset_bias) / VM.sR + delta_desired = math.radians(angle_steers - angle_offset) / VM.sR rate_desired = 0.0 self.cur_state[0].delta = delta_desired - self.angle_steers_des_mpc = float(math.degrees(delta_desired * VM.sR) + angle_offset_bias) + self.angle_steers_des_mpc = float(math.degrees(delta_desired * VM.sR) + angle_offset) # Check for infeasable MPC solution mpc_nans = np.any(np.isnan(list(self.mpc_solution[0].delta))) t = sec_since_boot() if mpc_nans: self.libmpc.init(MPC_COST_LAT.PATH, MPC_COST_LAT.LANE, MPC_COST_LAT.HEADING, CP.steerRateCost) - self.cur_state[0].delta = math.radians(angle_steers - angle_offset_bias) / VM.sR + self.cur_state[0].delta = math.radians(angle_steers - angle_offset) / VM.sR if t > self.last_cloudlog_t + 5.0: self.last_cloudlog_t = t @@ -121,13 +116,13 @@ class PathPlanner(object): plan_send.pathPlan.angleSteers = float(self.angle_steers_des_mpc) plan_send.pathPlan.rateSteers = float(rate_desired) - plan_send.pathPlan.angleOffset = float(self.path_offset_i) + plan_send.pathPlan.angleOffset = float(sm['liveParameters'].angleOffsetAverage) plan_send.pathPlan.mpcSolutionValid = bool(plan_solution_valid) plan_send.pathPlan.paramsValid = bool(sm['liveParameters'].valid) plan_send.pathPlan.sensorValid = bool(sm['liveParameters'].sensorValid) plan_send.pathPlan.posenetValid = bool(sm['liveParameters'].posenetValid) - self.plan.send(plan_send.to_bytes()) + pm.send('pathPlan', plan_send) if LOG_MPC: dat = messaging.new_message() @@ -137,4 +132,4 @@ class PathPlanner(object): dat.liveMpc.psi = list(self.mpc_solution[0].psi) dat.liveMpc.delta = list(self.mpc_solution[0].delta) dat.liveMpc.cost = self.mpc_solution[0].cost - self.livempc.send(dat.to_bytes()) + pm.send('liveMpc', dat) diff --git a/selfdrive/controls/lib/planner.py b/selfdrive/controls/lib/planner.py index 52712d15a..26230843a 100755 --- a/selfdrive/controls/lib/planner.py +++ b/selfdrive/controls/lib/planner.py @@ -9,7 +9,6 @@ from cereal import car from common.realtime import sec_since_boot, DT_PLAN from selfdrive.swaglog import cloudlog from selfdrive.config import Conversions as CV -from selfdrive.services import service_list from selfdrive.controls.lib.speed_smoother import speed_smoother from selfdrive.controls.lib.longcontrol import LongCtrlState, MIN_CAN_SPEED from selfdrive.controls.lib.fcw import FCWChecker @@ -71,14 +70,11 @@ def limit_accel_in_turns(v_ego, angle_steers, a_target, CP): class Planner(object): - def __init__(self, CP, fcw_enabled): + def __init__(self, CP): self.CP = CP - self.plan = messaging.pub_sock(service_list['plan'].port) - self.live_longitudinal_mpc = messaging.pub_sock(service_list['liveLongitudinalMpc'].port) - - self.mpc1 = LongitudinalMpc(1, self.live_longitudinal_mpc) - self.mpc2 = LongitudinalMpc(2, self.live_longitudinal_mpc) + self.mpc1 = LongitudinalMpc(1) + self.mpc2 = LongitudinalMpc(2) self.v_acc_start = 0.0 self.a_acc_start = 0.0 @@ -93,7 +89,6 @@ class Planner(object): self.longitudinalPlanSource = 'cruise' self.fcw_checker = FCWChecker() - self.fcw_enabled = fcw_enabled self.path_x = np.arange(192) self.params = Params() @@ -125,7 +120,7 @@ class Planner(object): self.v_acc_future = min([self.mpc1.v_mpc_future, self.mpc2.v_mpc_future, v_cruise_setpoint]) - def update(self, sm, CP, VM, PP): + def update(self, sm, pm, CP, VM, PP): """Gets called when new radarState is available""" cur_time = sec_since_boot() v_ego = sm['carState'].vEgo @@ -199,8 +194,8 @@ class Planner(object): self.mpc1.set_cur_state(self.v_acc_start, self.a_acc_start) self.mpc2.set_cur_state(self.v_acc_start, self.a_acc_start) - self.mpc1.update(sm['carState'], lead_1, v_cruise_setpoint) - self.mpc2.update(sm['carState'], lead_2, v_cruise_setpoint) + self.mpc1.update(pm, sm['carState'], lead_1, v_cruise_setpoint) + self.mpc2.update(pm, sm['carState'], lead_2, v_cruise_setpoint) self.choose_solution(v_cruise_setpoint, enabled) @@ -251,10 +246,9 @@ class Planner(object): plan_send.plan.processingDelay = (plan_send.logMonoTime / 1e9) - sm.rcv_time['radarState'] # Send out fcw - fcw = fcw and (self.fcw_enabled or long_control_state != LongCtrlState.off) plan_send.plan.fcw = fcw - self.plan.send(plan_send.to_bytes()) + pm.send('plan', plan_send) # Interpolate 0.05 seconds and save as starting point for next iteration a_acc_sol = self.a_acc_start + (DT_PLAN / LON_MPC_STEP) * (self.a_acc - self.a_acc_start) diff --git a/selfdrive/controls/lib/radar_helpers.py b/selfdrive/controls/lib/radar_helpers.py index 02a38ca2a..d246d5d8c 100644 --- a/selfdrive/controls/lib/radar_helpers.py +++ b/selfdrive/controls/lib/radar_helpers.py @@ -26,6 +26,7 @@ class Track(object): def __init__(self): self.ekf = None self.cnt = 0 + self.aLeadTau = _LEAD_ACCEL_TAU def update(self, d_rel, y_rel, v_rel, v_ego_t_aligned, measured): # relative values, copy @@ -123,7 +124,7 @@ class Cluster(object): @property def measured(self): - return any([t.measured for t in self.tracks]) + return any(t.measured for t in self.tracks) def get_RadarState(self, model_prob=0.0): return { diff --git a/selfdrive/controls/plannerd.py b/selfdrive/controls/plannerd.py index 9286ea058..7a5742b3e 100755 --- a/selfdrive/controls/plannerd.py +++ b/selfdrive/controls/plannerd.py @@ -11,27 +11,26 @@ from selfdrive.controls.lib.pathplanner import PathPlanner import selfdrive.messaging as messaging -def plannerd_thread(): +def plannerd_thread(sm=None, pm=None): gc.disable() # start the loop set_realtime_priority(2) - params = Params() - - # Get FCW toggle from settings - fcw_enabled = params.get("IsFcwEnabled") == "1" - cloudlog.info("plannerd is waiting for CarParams") CP = car.CarParams.from_bytes(Params().get("CarParams", block=True)) cloudlog.info("plannerd got CarParams: %s", CP.carName) - PL = Planner(CP, fcw_enabled) + PL = Planner(CP) PP = PathPlanner(CP) VM = VehicleModel(CP) - sm = messaging.SubMaster(['carState', 'controlsState', 'radarState', 'model', 'liveParameters']) + if sm is None: + sm = messaging.SubMaster(['carState', 'controlsState', 'radarState', 'model', 'liveParameters']) + + if pm is None: + pm = messaging.PubMaster(['plan', 'liveLongitudinalMpc', 'pathPlan', 'liveMpc']) sm['liveParameters'].valid = True sm['liveParameters'].sensorValid = True @@ -42,13 +41,13 @@ def plannerd_thread(): sm.update() if sm.updated['model']: - PP.update(sm, CP, VM) + PP.update(sm, pm, CP, VM) if sm.updated['radarState']: - PL.update(sm, CP, VM, PP) + PL.update(sm, pm, CP, VM, PP) -def main(gctx=None): - plannerd_thread() +def main(sm=None, pm=None): + plannerd_thread(sm, pm) if __name__ == "__main__": diff --git a/selfdrive/controls/radard.py b/selfdrive/controls/radard.py index 84410fa8e..d51631633 100755 --- a/selfdrive/controls/radard.py +++ b/selfdrive/controls/radard.py @@ -173,7 +173,7 @@ class RadarD(object): # fuses camera and radar data for best lead detection -def radard_thread(gctx=None): +def radard_thread(sm=None, pm=None, can_sock=None): set_realtime_priority(2) # wait for stats about the car to come in from controls @@ -186,14 +186,17 @@ def radard_thread(gctx=None): cloudlog.info("radard is importing %s", CP.carName) RadarInterface = importlib.import_module('selfdrive.car.%s.radar_interface' % CP.carName).RadarInterface - can_sock = messaging.sub_sock(service_list['can'].port) - sm = messaging.SubMaster(['model', 'controlsState', 'liveParameters']) + if can_sock is None: + can_sock = messaging.sub_sock(service_list['can'].port) - RI = RadarInterface(CP) + if sm is None: + sm = messaging.SubMaster(['model', 'controlsState', 'liveParameters']) # *** publish radarState and liveTracks - radarState = messaging.pub_sock(service_list['radarState'].port) - liveTracks = messaging.pub_sock(service_list['liveTracks'].port) + if pm is None: + pm = messaging.PubMaster(['radarState', 'liveTracks']) + + RI = RadarInterface(CP) rk = Ratekeeper(rate, print_delay_threshold=None) RD = RadarD(mocked) @@ -212,7 +215,7 @@ def radard_thread(gctx=None): dat = RD.update(rk.frame, RI.delay, sm, rr, has_radar) dat.radarState.cumLagMs = -rk.remaining*1000. - radarState.send(dat.to_bytes()) + pm.send('radarState', dat) # *** publish tracks for UI debugging (keep last) *** tracks = RD.tracks @@ -226,13 +229,13 @@ def radard_thread(gctx=None): "yRel": float(tracks[ids].yRel), "vRel": float(tracks[ids].vRel), } - liveTracks.send(dat.to_bytes()) + pm.send('liveTracks', dat) rk.monitor_time() -def main(gctx=None): - radard_thread(gctx) +def main(sm=None, pm=None, can_sock=None): + radard_thread(sm, pm, can_sock) if __name__ == "__main__": diff --git a/selfdrive/controls/tests/test_following_distance.py b/selfdrive/controls/tests/test_following_distance.py index 994ea7ea5..bcc67c42a 100644 --- a/selfdrive/controls/tests/test_following_distance.py +++ b/selfdrive/controls/tests/test_following_distance.py @@ -15,9 +15,9 @@ def RW(v_ego, v_l): return (v_ego * TR - (v_l - v_ego) * TR + v_ego * v_ego / (2 * G) - v_l * v_l / (2 * G)) -class FakeSocket(object): - def send(self, data): - assert data +class FakePubMaster(object): + def send(self, s, data): + assert data def run_following_distance_simulation(v_lead, t_end=200.0): @@ -32,7 +32,8 @@ def run_following_distance_simulation(v_lead, t_end=200.0): v_cruise_setpoint = v_lead + 10. - mpc = LongitudinalMpc(1, FakeSocket()) + pm = FakePubMaster() + mpc = LongitudinalMpc(1) first = True while t < t_end: @@ -61,8 +62,8 @@ def run_following_distance_simulation(v_lead, t_end=200.0): mpc.set_cur_state(v_ego, a_ego) if first: # Make sure MPC is converged on first timestep for _ in range(20): - mpc.update(CS.carState, lead, v_cruise_setpoint) - mpc.update(CS.carState, lead, v_cruise_setpoint) + mpc.update(pm, CS.carState, lead, v_cruise_setpoint) + mpc.update(pm, CS.carState, lead, v_cruise_setpoint) # Choose slowest of two solutions if v_cruise < mpc.v_mpc: diff --git a/selfdrive/controls/tests/test_monitoring.py b/selfdrive/controls/tests/test_monitoring.py new file mode 100644 index 000000000..d543dfc9a --- /dev/null +++ b/selfdrive/controls/tests/test_monitoring.py @@ -0,0 +1,200 @@ +import unittest +import numpy as np +from common.realtime import DT_CTRL, DT_DMON +from selfdrive.controls.lib.driver_monitor import DriverStatus, MAX_TERMINAL_ALERTS, \ + _AWARENESS_TIME, _AWARENESS_PRE_TIME_TILL_TERMINAL, \ + _AWARENESS_PROMPT_TIME_TILL_TERMINAL, _DISTRACTED_TIME, \ + _DISTRACTED_PRE_TIME_TILL_TERMINAL, _DISTRACTED_PROMPT_TIME_TILL_TERMINAL +from selfdrive.controls.lib.gps_helpers import is_rhd_region + +_TEST_TIMESPAN = 120 # seconds +_DISTRACTED_SECONDS_TO_ORANGE = _DISTRACTED_TIME - _DISTRACTED_PROMPT_TIME_TILL_TERMINAL + 1 +_DISTRACTED_SECONDS_TO_RED = _DISTRACTED_TIME + 1 +_INVISIBLE_SECONDS_TO_ORANGE = _AWARENESS_TIME - _AWARENESS_PROMPT_TIME_TILL_TERMINAL + 1 +_INVISIBLE_SECONDS_TO_RED = _AWARENESS_TIME + 1 + +class fake_DM_msg(): + def __init__(self, is_face_detected, is_distracted=False): + self.faceOrientation = [0.,0.,0.] + self.facePosition = [0.,0.] + self.faceProb = 1. * is_face_detected + self.leftEyeProb = 1. + self.rightEyeProb = 1. + self.leftBlinkProb = 1. * is_distracted + self.rightBlinkProb = 1. * is_distracted + + +# driver state from neural net, 10Hz +msg_NO_FACE_DETECTED = fake_DM_msg(is_face_detected=False) +msg_ATTENTIVE = fake_DM_msg(is_face_detected=True) +msg_DISTRACTED = fake_DM_msg(is_face_detected=True, is_distracted=True) + +# driver interaction with car +car_interaction_DETECTED = True +car_interaction_NOT_DETECTED = False + +# openpilot state +openpilot_ENGAGED = True +openpilot_NOT_ENGAGED = False + +# car standstill state +car_STANDSTILL = True +car_NOT_STANDSTILL = False + +# some common state vectors +always_no_face = [msg_NO_FACE_DETECTED] * int(_TEST_TIMESPAN/DT_DMON) +always_attentive = [msg_ATTENTIVE] * int(_TEST_TIMESPAN/DT_DMON) +always_distracted = [msg_DISTRACTED] * int(_TEST_TIMESPAN/DT_DMON) +always_true = [True] * int(_TEST_TIMESPAN/DT_DMON) +always_false = [False] * int(_TEST_TIMESPAN/DT_DMON) + +def run_DState_seq(driver_state_msgs, driver_car_interaction, openpilot_status, car_standstill_status): + # inputs are all 10Hz + DS = DriverStatus() + events_from_DM = [] + for idx in range(len(driver_state_msgs)): + DS.get_pose(driver_state_msgs[idx], [0,0,0], 0, openpilot_status[idx]) + # cal_rpy and car_speed don't matter here + + # to match frequency of controlsd (100Hz) + for _ in range(int(DT_DMON/DT_CTRL)): + event_per_state = DS.update([], driver_car_interaction[idx], openpilot_status[idx], car_standstill_status[idx]) + events_from_DM.append(event_per_state) # evaluate events at 10Hz for tests + + assert len(events_from_DM)==len(driver_state_msgs), 'somethings wrong' + return events_from_DM + +class TestMonitoring(unittest.TestCase): + # -1. rhd parser sanity check + def test_rhd_parser(self): + cities = [[32.7, -117.1, 0],\ + [51.5, 0.129, 1],\ + [35.7, 139.7, 1],\ + [-37.8, 144.9, 1],\ + [32.1, 41.74, 0],\ + [55.7, 12.69, 0]] + result = [] + for city in cities: + result.append(int(is_rhd_region(city[0],city[1]))) + self.assertEqual(result,[int(city[2]) for city in cities]) + + # 0. op engaged, driver is doing fine all the time + def test_fully_aware_driver(self): + events_output = run_DState_seq(always_attentive, always_false, always_true, always_false) + self.assertTrue(np.sum([len(event) for event in events_output])==0) + + # 1. op engaged, driver is distracted and does nothing + def test_fully_distracted_driver(self): + events_output = run_DState_seq(always_distracted, always_false, always_true, always_false) + self.assertTrue(len(events_output[int((_DISTRACTED_TIME-_DISTRACTED_PRE_TIME_TILL_TERMINAL)/2/DT_DMON)])==0) + self.assertEqual(events_output[int((_DISTRACTED_TIME-_DISTRACTED_PRE_TIME_TILL_TERMINAL+\ + ((_DISTRACTED_PRE_TIME_TILL_TERMINAL-_DISTRACTED_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)][0].name, 'preDriverDistracted') + self.assertEqual(events_output[int((_DISTRACTED_TIME-_DISTRACTED_PROMPT_TIME_TILL_TERMINAL+\ + ((_DISTRACTED_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)][0].name, 'promptDriverDistracted') + self.assertEqual(events_output[int((_DISTRACTED_TIME+\ + ((_TEST_TIMESPAN-10-_DISTRACTED_TIME)/2))/DT_DMON)][0].name, 'driverDistracted') + + # 2. op engaged, no face detected the whole time, no action + def test_fully_invisible_driver(self): + events_output = run_DState_seq(always_no_face, always_false, always_true, always_false) + self.assertTrue(len(events_output[int((_AWARENESS_TIME-_AWARENESS_PRE_TIME_TILL_TERMINAL)/2/DT_DMON)])==0) + self.assertEqual(events_output[int((_AWARENESS_TIME-_AWARENESS_PRE_TIME_TILL_TERMINAL+\ + ((_AWARENESS_PRE_TIME_TILL_TERMINAL-_AWARENESS_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)][0].name, 'preDriverUnresponsive') + self.assertEqual(events_output[int((_AWARENESS_TIME-_AWARENESS_PROMPT_TIME_TILL_TERMINAL+\ + ((_AWARENESS_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)][0].name, 'promptDriverUnresponsive') + self.assertEqual(events_output[int((_AWARENESS_TIME+\ + ((_TEST_TIMESPAN-10-_AWARENESS_TIME)/2))/DT_DMON)][0].name, 'driverUnresponsive') + + # 3. op engaged, down to orange, driver pays attention, back to normal; then down to orange, driver touches wheel + # - should have short orange recovery time and no green afterwards; should recover rightaway on wheel touch + def test_normal_driver(self): + ds_vector = [msg_DISTRACTED] * int(_DISTRACTED_SECONDS_TO_ORANGE/DT_DMON) + \ + [msg_ATTENTIVE] * int(_DISTRACTED_SECONDS_TO_ORANGE/DT_DMON) + \ + [msg_DISTRACTED] * (int(_TEST_TIMESPAN/DT_DMON)-int(_DISTRACTED_SECONDS_TO_ORANGE*2/DT_DMON)) + interaction_vector = [car_interaction_NOT_DETECTED] * int(_DISTRACTED_SECONDS_TO_ORANGE*3/DT_DMON) + \ + [car_interaction_DETECTED] * (int(_TEST_TIMESPAN/DT_DMON)-int(_DISTRACTED_SECONDS_TO_ORANGE*3/DT_DMON)) + events_output = run_DState_seq(ds_vector, interaction_vector, always_true, always_false) + self.assertTrue(len(events_output[int(_DISTRACTED_SECONDS_TO_ORANGE*0.5/DT_DMON)])==0) + self.assertEqual(events_output[int((_DISTRACTED_SECONDS_TO_ORANGE-0.1)/DT_DMON)][0].name, 'promptDriverDistracted') + self.assertTrue(len(events_output[int(_DISTRACTED_SECONDS_TO_ORANGE*1.5/DT_DMON)])==0) + self.assertEqual(events_output[int((_DISTRACTED_SECONDS_TO_ORANGE*3-0.1)/DT_DMON)][0].name, 'promptDriverDistracted') + self.assertTrue(len(events_output[int((_DISTRACTED_SECONDS_TO_ORANGE*3+0.1)/DT_DMON)])==0) + + # 4. op engaged, down to orange, driver dodges camera, then comes back still distracted, down to red, \ + # driver dodges, and then touches wheel to no avail, disengages and reengages + # - orange/red alert should remain after disappearance, and only disengaging clears red + def test_biggest_comma_fan(self): + _invisible_time = 2 # seconds + ds_vector = always_distracted[:] + interaction_vector = always_false[:] + op_vector = always_true[:] + ds_vector[int(_DISTRACTED_SECONDS_TO_ORANGE/DT_DMON):int((_DISTRACTED_SECONDS_TO_ORANGE+_invisible_time)/DT_DMON)] = [msg_NO_FACE_DETECTED] * int(_invisible_time/DT_DMON) + ds_vector[int((_DISTRACTED_SECONDS_TO_RED+_invisible_time)/DT_DMON):int((_DISTRACTED_SECONDS_TO_RED+2*_invisible_time)/DT_DMON)] = [msg_NO_FACE_DETECTED] * int(_invisible_time/DT_DMON) + interaction_vector[int((_DISTRACTED_SECONDS_TO_RED+2*_invisible_time+0.5)/DT_DMON):int((_DISTRACTED_SECONDS_TO_RED+2*_invisible_time+1.5)/DT_DMON)] = [True] * int(1/DT_DMON) + op_vector[int((_DISTRACTED_SECONDS_TO_RED+2*_invisible_time+2.5)/DT_DMON):int((_DISTRACTED_SECONDS_TO_RED+2*_invisible_time+3)/DT_DMON)] = [False] * int(0.5/DT_DMON) + events_output = run_DState_seq(ds_vector, interaction_vector, op_vector, always_false) + self.assertEqual(events_output[int((_DISTRACTED_SECONDS_TO_ORANGE+0.5*_invisible_time)/DT_DMON)][0].name, 'promptDriverDistracted') + self.assertEqual(events_output[int((_DISTRACTED_SECONDS_TO_RED+1.5*_invisible_time)/DT_DMON)][0].name, 'driverDistracted') + self.assertEqual(events_output[int((_DISTRACTED_SECONDS_TO_RED+2*_invisible_time+1.5)/DT_DMON)][0].name, 'driverDistracted') + self.assertTrue(len(events_output[int((_DISTRACTED_SECONDS_TO_RED+2*_invisible_time+3.5)/DT_DMON)])==0) + + # 5. op engaged, invisible driver, down to orange, driver touches wheel; then down to orange again, driver appears + # - both actions should clear the alert, but momentary appearence should not + def test_sometimes_transparent_commuter(self): + _visible_time = np.random.choice([1,10]) # seconds + # print _visible_time + ds_vector = always_no_face[:]*2 + interaction_vector = always_false[:]*2 + ds_vector[int((2*_INVISIBLE_SECONDS_TO_ORANGE+1)/DT_DMON):int((2*_INVISIBLE_SECONDS_TO_ORANGE+1+_visible_time)/DT_DMON)] = [msg_ATTENTIVE] * int(_visible_time/DT_DMON) + interaction_vector[int((_INVISIBLE_SECONDS_TO_ORANGE)/DT_DMON):int((_INVISIBLE_SECONDS_TO_ORANGE+1)/DT_DMON)] = [True] * int(1/DT_DMON) + events_output = run_DState_seq(ds_vector, interaction_vector, 2*always_true, 2*always_false) + self.assertTrue(len(events_output[int(_INVISIBLE_SECONDS_TO_ORANGE*0.5/DT_DMON)])==0) + self.assertEqual(events_output[int((_INVISIBLE_SECONDS_TO_ORANGE-0.1)/DT_DMON)][0].name, 'promptDriverUnresponsive') + self.assertTrue(len(events_output[int((_INVISIBLE_SECONDS_TO_ORANGE+0.1)/DT_DMON)])==0) + if _visible_time == 1: + self.assertEqual(events_output[int((_INVISIBLE_SECONDS_TO_ORANGE*2+1-0.1)/DT_DMON)][0].name, 'promptDriverUnresponsive') + self.assertEqual(events_output[int((_INVISIBLE_SECONDS_TO_ORANGE*2+1+0.1+_visible_time)/DT_DMON)][0].name, 'preDriverUnresponsive') + elif _visible_time == 10: + self.assertEqual(events_output[int((_INVISIBLE_SECONDS_TO_ORANGE*2+1-0.1)/DT_DMON)][0].name, 'promptDriverUnresponsive') + self.assertTrue(len(events_output[int((_INVISIBLE_SECONDS_TO_ORANGE*2+1+0.1+_visible_time)/DT_DMON)])==0) + else: + pass + + # 6. op engaged, invisible driver, down to red, driver appears and then touches wheel, then disengages/reengages + # - only disengage will clear the alert + def test_last_second_responder(self): + _visible_time = 2 # seconds + ds_vector = always_no_face[:] + interaction_vector = always_false[:] + op_vector = always_true[:] + ds_vector[int(_INVISIBLE_SECONDS_TO_RED/DT_DMON):int((_INVISIBLE_SECONDS_TO_RED+_visible_time)/DT_DMON)] = [msg_ATTENTIVE] * int(_visible_time/DT_DMON) + interaction_vector[int((_INVISIBLE_SECONDS_TO_RED+_visible_time)/DT_DMON):int((_INVISIBLE_SECONDS_TO_RED+_visible_time+1)/DT_DMON)] = [True] * int(1/DT_DMON) + op_vector[int((_INVISIBLE_SECONDS_TO_RED+_visible_time+1)/DT_DMON):int((_INVISIBLE_SECONDS_TO_RED+_visible_time+0.5)/DT_DMON)] = [False] * int(0.5/DT_DMON) + events_output = run_DState_seq(ds_vector, interaction_vector, op_vector, always_false) + self.assertTrue(len(events_output[int(_INVISIBLE_SECONDS_TO_ORANGE*0.5/DT_DMON)])==0) + self.assertEqual(events_output[int((_INVISIBLE_SECONDS_TO_ORANGE-0.1)/DT_DMON)][0].name, 'promptDriverUnresponsive') + self.assertEqual(events_output[int((_INVISIBLE_SECONDS_TO_RED-0.1)/DT_DMON)][0].name, 'driverUnresponsive') + self.assertEqual(events_output[int((_INVISIBLE_SECONDS_TO_RED+0.5*_visible_time)/DT_DMON)][0].name, 'driverUnresponsive') + self.assertEqual(events_output[int((_INVISIBLE_SECONDS_TO_RED+_visible_time+0.5)/DT_DMON)][0].name, 'driverUnresponsive') + self.assertTrue(len(events_output[int((_INVISIBLE_SECONDS_TO_RED+_visible_time+1+0.1)/DT_DMON)])==0) + + # 7. op not engaged, always distracted driver + # - dm should stay quiet when not engaged + def test_pure_dashcam_user(self): + events_output = run_DState_seq(always_distracted, always_false, always_false, always_false) + self.assertTrue(np.sum([len(event) for event in events_output])==0) + + # 8. op engaged, car stops at traffic light, down to orange, no action, then car starts moving + # - should only reach green when stopped, but continues counting down on launch + def test_long_traffic_light_victim(self): + _redlight_time = 60 # seconds + standstill_vector = always_true[:] + standstill_vector[int(_redlight_time/DT_DMON):] = [False] * int((_TEST_TIMESPAN-_redlight_time)/DT_DMON) + events_output = run_DState_seq(always_distracted, always_false, always_true, standstill_vector) + self.assertEqual(events_output[int((_DISTRACTED_TIME-_DISTRACTED_PRE_TIME_TILL_TERMINAL+1)/DT_DMON)][0].name, 'preDriverDistracted') + self.assertEqual(events_output[int((_redlight_time-0.1)/DT_DMON)][0].name, 'preDriverDistracted') + self.assertEqual(events_output[int((_redlight_time+0.5)/DT_DMON)][0].name, 'promptDriverDistracted') + +if __name__ == "__main__": + print 'MAX_TERMINAL_ALERTS', MAX_TERMINAL_ALERTS + unittest.main() diff --git a/selfdrive/dragonpilot/appd/appd.py b/selfdrive/dragonpilot/appd/appd.py index aeb36c8a4..c19690903 100644 --- a/selfdrive/dragonpilot/appd/appd.py +++ b/selfdrive/dragonpilot/appd/appd.py @@ -7,7 +7,7 @@ import subprocess import cereal ThermalStatus = cereal.log.ThermalData.ThermalStatus from selfdrive.swaglog import cloudlog -from common.params import Params +from common.params import Params, put_nonblocking params = Params() # v1.16.2 @@ -42,9 +42,9 @@ def main(gctx=None): stop_delay = None high_accuracy_mode_enabled = False - params.put('DragonRunTomTom', '0') - params.put('DragonRunAutonavi', '0') - params.put('DragonRunMixplorer', '0') + put_nonblocking('DragonRunTomTom', '0') + put_nonblocking('DragonRunAutonavi', '0') + put_nonblocking('DragonRunMixplorer', '0') # we want to disable all app when boot system("pm disable %s ; pm disable %s ; pm disable %s" % (tomtom, autonavi, mixplorer)) @@ -64,22 +64,22 @@ def main(gctx=None): if dragon_enable_tomtom: status = params.get('DragonRunTomTom') if not status == "0": - tomtom_is_running = execApp(status, tomtom, tomtom_main) - params.put('DragonRunTomTom', '0') + tomtom_is_running = exec_app(status, tomtom, tomtom_main) + put_nonblocking('DragonRunTomTom', '0') manual_tomtom = status != "0" if dragon_enable_autonavi: status = params.get('DragonRunAutonavi') if not status == "0": - autonavi_is_running = execApp(status, autonavi, autonavi_main) - params.put('DragonRunAutonavi', '0') + autonavi_is_running = exec_app(status, autonavi, autonavi_main) + put_nonblocking('DragonRunAutonavi', '0') manual_autonavi = status != "0" if dragon_enable_mixplorer: status = params.get('DragonRunMixplorer') if not status == "0": - mixplorer_is_running = execApp(status, mixplorer, mixplorer_main) - params.put('DragonRunMixplorer', '0') + mixplorer_is_running = exec_app(status, mixplorer, mixplorer_main) + put_nonblocking('DragonRunMixplorer', '0') # if manual control is set, we do not allow any of the auto actions auto_tomtom = not manual_tomtom and dragon_enable_tomtom and dragon_boot_tomtom @@ -105,20 +105,20 @@ def main(gctx=None): # only allow auto boot when thermal status is < red if thermal_status < ThermalStatus.red: if auto_tomtom and not tomtom_is_running and frame > start_delay: - tomtom_is_running = execApp('1', tomtom, tomtom_main) + tomtom_is_running = exec_app('1', tomtom, tomtom_main) if auto_autonavi and not autonavi_is_running and frame > start_delay: - autonavi_is_running = execApp('1', autonavi, autonavi_main) + autonavi_is_running = exec_app('1', autonavi, autonavi_main) else: if auto_tomtom and tomtom_is_running: - tomtom_is_running = execApp('-1', tomtom, tomtom_main) + tomtom_is_running = exec_app('-1', tomtom, tomtom_main) if auto_autonavi and autonavi_is_running: - autonavi_is_running = execApp('-1', autonavi, autonavi_main) + autonavi_is_running = exec_app('-1', autonavi, autonavi_main) # set allow_auto_boot to False once the thermal status is >= red allow_auto_boot = False # kill mixplorer when car started if mixplorer_is_running: - mixplorer_is_running = execApp('-1', mixplorer, mixplorer_main) + mixplorer_is_running = exec_app('-1', mixplorer, mixplorer_main) # car off else: @@ -126,9 +126,9 @@ def main(gctx=None): if stop_delay is None: stop_delay = frame + 30 if auto_tomtom and tomtom_is_running and frame > stop_delay: - tomtom_is_running = execApp('-1', tomtom, tomtom_main) + tomtom_is_running = exec_app('-1', tomtom, tomtom_main) if auto_autonavi and autonavi_is_running and frame > stop_delay: - autonavi_is_running = execApp('-1', autonavi, autonavi_main) + autonavi_is_running = exec_app('-1', autonavi, autonavi_main) # if car state changed, we remove manual control state if not last_started == started: @@ -140,7 +140,7 @@ def main(gctx=None): # every 3 seconds, we re-check status time.sleep(3) -def execApp(status, app, app_main): +def exec_app(status, app, app_main): if status == "1": system("pm enable %s && am start -n %s/%s" % (app, app, app_main)) return True diff --git a/selfdrive/dragonpilot/dragonconf/__init__.py b/selfdrive/dragonpilot/dragonconf/__init__.py index b6bd59ac5..7e442a7bc 100644 --- a/selfdrive/dragonpilot/dragonconf/__init__.py +++ b/selfdrive/dragonpilot/dragonconf/__init__.py @@ -1,5 +1,5 @@ #!/usr/bin/env python2.7 -from common.params import Params +from common.params import Params, put_nonblocking default_conf = { 'DragonEnableDashcam': '1', @@ -21,6 +21,7 @@ default_conf = { 'DragonBBUI': '0', # deprecated 'DragonToyotaStockDSU': '0', 'DragonLatCtrl': '1', + 'DragonUISpeed': '1', 'DragonUIEvent': '0', 'DragonUIMaxSpeed': '0', 'DragonUIFace': '0', @@ -39,6 +40,8 @@ default_conf = { 'DragonCameraOffset': '6', 'DragonUIVolumeBoost': '0', 'DragonGreyPandaMode': '0', + 'DragonDrivingUI': '1', + 'DragonDisplaySteeringLimitAlert': '1', } deprecated_conf = { @@ -67,13 +70,13 @@ def dragonpilot_set_params(params): # invert the value if true if old in deprecated_conf_invert and deprecated_conf_invert[old] is True: new_val = "1" if old_val == "0" else "0" - params.put(new, new_val) + put_nonblocking(new, new_val) params.delete(old) # set params for key, val in default_conf.items(): if params.get(key) is None and key not in deprecated_conf: - params.put(key, str(val)) + put_nonblocking(key, str(val)) if __name__ == "__main__": params = Params() diff --git a/selfdrive/dragonpilot/shutdownd/shutdownd.py b/selfdrive/dragonpilot/shutdownd/shutdownd.py index 40fd07720..552729534 100644 --- a/selfdrive/dragonpilot/shutdownd/shutdownd.py +++ b/selfdrive/dragonpilot/shutdownd/shutdownd.py @@ -10,6 +10,7 @@ def main(gctx=None): shutdown_count = 0 auto_shutdown_at = get_shutdown_val() frame = 0 + last_shutdown_val = get_shutdown_val() while 1: with open("/sys/class/power_supply/usb/present") as f: @@ -23,6 +24,10 @@ def main(gctx=None): else: shutdown_count = 0 + if not last_shutdown_val == auto_shutdown_at: + shutdown_count = 0 + last_shutdown_val = auto_shutdown_at + if auto_shutdown_at is None: auto_shutdown_at = get_shutdown_val() else: diff --git a/selfdrive/locationd/calibrationd.py b/selfdrive/locationd/calibrationd.py index 2890b0f61..db4b0c226 100755 --- a/selfdrive/locationd/calibrationd.py +++ b/selfdrive/locationd/calibrationd.py @@ -6,7 +6,6 @@ import numpy as np import selfdrive.messaging as messaging from selfdrive.locationd.calibration_helpers import Calibration from selfdrive.swaglog import cloudlog -from selfdrive.services import service_list from common.params import Params from common.transformations.model import model_height from common.transformations.camera import view_frame_from_device_frame, get_view_frame_from_road_frame, \ @@ -64,7 +63,7 @@ class Calibrator(object): self.just_calibrated = True def handle_cam_odom(self, log): - trans, rot = log.cameraOdometry.trans, log.cameraOdometry.rot + trans, rot = log.trans, log.rot if np.linalg.norm(trans) > MIN_SPEED_FILTER and abs(rot[2]) < MAX_YAW_RATE_FILTER: new_vp = eon_intrinsics.dot(view_frame_from_device_frame.dot(trans)) new_vp = new_vp[:2]/new_vp[2] @@ -81,7 +80,7 @@ class Calibrator(object): else: return None - def send_data(self, livecalibration): + def send_data(self, pm): calib = get_calib_from_vp(self.vp) extrinsic_matrix = get_view_frame_from_road_frame(0, calib[1], calib[2], model_height) @@ -92,27 +91,31 @@ class Calibrator(object): cal_send.liveCalibration.extrinsicMatrix = [float(x) for x in extrinsic_matrix.flatten()] cal_send.liveCalibration.rpyCalib = [float(x) for x in calib] - livecalibration.send(cal_send.to_bytes()) + pm.send('liveCalibration', cal_send) -def calibrationd_thread(gctx=None, addr="127.0.0.1"): - cameraodometry = messaging.sub_sock(service_list['cameraOdometry'].port, addr=addr, conflate=True) - livecalibration = messaging.pub_sock(service_list['liveCalibration'].port) +def calibrationd_thread(sm=None, pm=None): + if sm is None: + sm = messaging.SubMaster(['cameraOdometry']) + + if pm is None: + pm = messaging.PubMaster(['liveCalibration']) + calibrator = Calibrator(param_put=True) # buffer with all the messages that still need to be input into the kalman while 1: - co = messaging.recv_one(cameraodometry) + sm.update() - new_vp = calibrator.handle_cam_odom(co) + new_vp = calibrator.handle_cam_odom(sm['cameraOdometry']) if DEBUG and new_vp is not None: print 'got new vp', new_vp - calibrator.send_data(livecalibration) + calibrator.send_data(pm) -def main(gctx=None, addr="127.0.0.1"): - calibrationd_thread(gctx, addr) +def main(sm=None, pm=None): + calibrationd_thread(sm, pm) if __name__ == "__main__": diff --git a/selfdrive/locationd/locationd_yawrate.cc b/selfdrive/locationd/locationd_yawrate.cc index 93e706499..de6ff9ff4 100644 --- a/selfdrive/locationd/locationd_yawrate.cc +++ b/selfdrive/locationd/locationd_yawrate.cc @@ -10,7 +10,7 @@ #include "locationd_yawrate.h" -void Localizer::update_state(const Eigen::Matrix &C, const double R, double current_time, double meas) { +void Localizer::update_state(const Eigen::Matrix &C, const double R, double current_time, double meas) { double dt = current_time - prev_update_time; if (dt < 0) { @@ -19,36 +19,34 @@ void Localizer::update_state(const Eigen::Matrix &C, const double prev_update_time = current_time; } - // x = A * x; - // P = A * P * A.transpose() + dt * Q; - // Simplify because A is unity - P = P + dt * Q; + x = A * x; + P = A * P * A.transpose() + dt * Q; double y = meas - C * x; double S = R + C * P * C.transpose(); - Eigen::Vector2d K = P * C.transpose() * (1.0 / S); + Eigen::Vector4d K = P * C.transpose() * (1.0 / S); x = x + K * y; P = (I - K * C) * P; } void Localizer::handle_sensor_events(capnp::List::Reader sensor_events, double current_time) { for (cereal::SensorEventData::Reader sensor_event : sensor_events){ - if (sensor_event.getType() == 4) { + if (sensor_event.getSensor() == 5) { sensor_data_time = current_time; - - double meas = -sensor_event.getGyro().getV()[0]; + double meas = -sensor_event.getGyroUncalibrated().getV()[0]; update_state(C_gyro, R_gyro, current_time, meas); } } } void Localizer::handle_camera_odometry(cereal::CameraOdometry::Reader camera_odometry, double current_time) { - double R = 250.0 * pow(camera_odometry.getRotStd()[2], 2); + double R = 100.0 * pow(camera_odometry.getRotStd()[2], 2); double meas = camera_odometry.getRot()[2]; update_state(C_posenet, R, current_time, meas); auto trans = camera_odometry.getTrans(); posenet_speed = sqrt(trans[0]*trans[0] + trans[1]*trans[1] + trans[2]*trans[2]); + camera_odometry_time = current_time; } void Localizer::handle_controls_state(cereal::ControlsState::Reader controls_state, double current_time) { @@ -59,17 +57,34 @@ void Localizer::handle_controls_state(cereal::ControlsState::Reader controls_sta Localizer::Localizer() { - A << 1, 0, 0, 1; - I << 1, 0, 0, 1; + // States: [yaw rate, yaw rate diff, gyro bias, gyro bias diff] + A << + 1, 1, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 1, + 0, 0, 0, 1; + I << + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1; - Q << pow(0.1, 2.0), 0, 0, pow(0.005 / 100.0, 2.0); - P << pow(1.0, 2.0), 0, 0, pow(0.05, 2.0); + Q << + 0, 0, 0, 0, + 0, pow(0.1, 2.0), 0, 0, + 0, 0, 0, 0, + 0, 0, pow(0.0005 / 100.0, 2.0), 0; + P << + pow(100.0, 2.0), 0, 0, 0, + 0, pow(100.0, 2.0), 0, 0, + 0, 0, pow(100.0, 2.0), 0, + 0, 0, 0, pow(100.0, 2.0); - C_posenet << 1, 0; - C_gyro << 1, 1; - x << 0, 0; + C_posenet << 1, 0, 0, 0; + C_gyro << 1, 0, 1, 0; + x << 0, 0, 0, 0; - R_gyro = pow(0.05, 2.0); + R_gyro = pow(0.25, 2.0); } void Localizer::handle_log(cereal::Event::Reader event) { @@ -118,20 +133,31 @@ extern "C" { } double localizer_get_bias(void * localizer) { Localizer * loc = (Localizer*) localizer; - return loc->x[1]; + return loc->x[2]; } - void localizer_set_yaw(void * localizer, double yaw) { + double * localizer_get_state(void * localizer) { Localizer * loc = (Localizer*) localizer; - loc->x[0] = yaw; + return loc->x.data(); } - void localizer_set_bias(void * localizer, double bias) { + + void localizer_set_state(void * localizer, double * state) { Localizer * loc = (Localizer*) localizer; - loc->x[1] = bias; + memcpy(loc->x.data(), state, 4 * sizeof(double)); } double localizer_get_t(void * localizer) { Localizer * loc = (Localizer*) localizer; return loc->prev_update_time; } + + double * localizer_get_P(void * localizer) { + Localizer * loc = (Localizer*) localizer; + return loc->P.data(); + } + + void localizer_set_P(void * localizer, double * P) { + Localizer * loc = (Localizer*) localizer; + memcpy(loc->P.data(), P, 16 * sizeof(double)); + } } diff --git a/selfdrive/locationd/locationd_yawrate.h b/selfdrive/locationd/locationd_yawrate.h index d5db91e79..9c6885241 100644 --- a/selfdrive/locationd/locationd_yawrate.h +++ b/selfdrive/locationd/locationd_yawrate.h @@ -7,28 +7,29 @@ class Localizer { - Eigen::Matrix2d A; - Eigen::Matrix2d I; - Eigen::Matrix2d Q; - Eigen::Matrix2d P; - Eigen::Matrix C_posenet; - Eigen::Matrix C_gyro; + Eigen::Matrix4d A; + Eigen::Matrix4d I; + Eigen::Matrix4d Q; + Eigen::Matrix C_posenet; + Eigen::Matrix C_gyro; double R_gyro; - void update_state(const Eigen::Matrix &C, const double R, double current_time, double meas); + void update_state(const Eigen::Matrix &C, const double R, double current_time, double meas); void handle_sensor_events(capnp::List::Reader sensor_events, double current_time); void handle_camera_odometry(cereal::CameraOdometry::Reader camera_odometry, double current_time); void handle_controls_state(cereal::ControlsState::Reader controls_state, double current_time); public: - Eigen::Vector2d x; + Eigen::Vector4d x; + Eigen::Matrix4d P; double steering_angle = 0; double car_speed = 0; double posenet_speed = 0; double prev_update_time = -1; double controls_state_time = -1; double sensor_data_time = -1; + double camera_odometry_time = -1; Localizer(); void handle_log(cereal::Event::Reader event); diff --git a/selfdrive/locationd/params_learner.cc b/selfdrive/locationd/params_learner.cc index 912abde35..66f378a1d 100644 --- a/selfdrive/locationd/params_learner.cc +++ b/selfdrive/locationd/params_learner.cc @@ -45,7 +45,7 @@ ParamsLearner::ParamsLearner(cereal::CarParams::Reader car_params, } bool ParamsLearner::update(double psi, double u, double sa) { - if (u > 10.0 && fabs(sa) < (DEGREES_TO_RADIANS * 15.)) { + if (u > 10.0 && fabs(sa) < (DEGREES_TO_RADIANS * 90.)) { double ao_diff = 2.0*cF0*cR0*l*u*x*(1.0*cF0*cR0*l*u*x*(ao - sa) + psi*sR*(cF0*cR0*pow(l, 2)*x - m*pow(u, 2)*(aF*cF0 - aR*cR0)))/(pow(sR, 2)*pow(cF0*cR0*pow(l, 2)*x - m*pow(u, 2)*(aF*cF0 - aR*cR0), 2)); double new_ao = ao - alpha1 * ao_diff; diff --git a/selfdrive/locationd/paramsd.cc b/selfdrive/locationd/paramsd.cc index f3bc6a5d7..b9b4a9c1a 100644 --- a/selfdrive/locationd/paramsd.cc +++ b/selfdrive/locationd/paramsd.cc @@ -137,33 +137,32 @@ int main(int argc, char *argv[]) { // TODO: Fix in replay double sensor_data_age = localizer.controls_state_time - localizer.sensor_data_time; + double camera_odometry_age = localizer.controls_state_time - localizer.camera_odometry_time; double angle_offset_degrees = RADIANS_TO_DEGREES * learner.ao; double angle_offset_average_degrees = RADIANS_TO_DEGREES * learner.slow_ao; - // Send parameters at 10 Hz - if (save_counter % 10 == 0){ - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto live_params = event.initLiveParameters(); - live_params.setValid(valid); - live_params.setYawRate(localizer.x[0]); - live_params.setGyroBias(localizer.x[1]); - live_params.setSensorValid(sensor_data_age < 10.0); - live_params.setAngleOffset(angle_offset_degrees); - live_params.setAngleOffsetAverage(angle_offset_average_degrees); - live_params.setStiffnessFactor(learner.x); - live_params.setSteerRatio(learner.sR); - live_params.setPosenetSpeed(localizer.posenet_speed); - live_params.setPosenetValid(posenet_invalid_count < 8); + capnp::MallocMessageBuilder msg; + cereal::Event::Builder event = msg.initRoot(); + event.setLogMonoTime(nanos_since_boot()); + auto live_params = event.initLiveParameters(); + live_params.setValid(valid); + live_params.setYawRate(localizer.x[0]); + live_params.setGyroBias(localizer.x[2]); + live_params.setSensorValid(sensor_data_age < 5.0); + live_params.setAngleOffset(angle_offset_degrees); + live_params.setAngleOffsetAverage(angle_offset_average_degrees); + live_params.setStiffnessFactor(learner.x); + live_params.setSteerRatio(learner.sR); + live_params.setPosenetSpeed(localizer.posenet_speed); + live_params.setPosenetValid((posenet_invalid_count < 4) && (camera_odometry_age < 5.0)); - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(live_parameters_sock_raw, bytes.begin(), bytes.size(), ZMQ_DONTWAIT); - } + auto words = capnp::messageToFlatArray(msg); + auto bytes = words.asBytes(); + zmq_send(live_parameters_sock_raw, bytes.begin(), bytes.size(), ZMQ_DONTWAIT); // Save parameters every minute + // TODO: Save in seperate thread if (save_counter % 6000 == 0) { json11::Json json = json11::Json::object { {"carVin", vin}, diff --git a/selfdrive/loggerd/uploader.py b/selfdrive/loggerd/uploader.py index 59765d13e..38887f4ad 100644 --- a/selfdrive/loggerd/uploader.py +++ b/selfdrive/loggerd/uploader.py @@ -93,9 +93,9 @@ def is_on_hotspot(): return False class Uploader(object): - def __init__(self, dongle_id, private_key, root): + def __init__(self, dongle_id, root): self.dongle_id = dongle_id - self.api = Api(dongle_id, private_key) + self.api = Api(dongle_id) self.root = root self.upload_thread = None @@ -146,14 +146,11 @@ class Uploader(object): return (key, fn, 0) if with_raw: - # then upload log files + # then upload the full log files, rear and front camera files for name, key, fn in self.gen_upload_files(): if name == "rlog.bz2": return (key, fn, 1) - - # then upload rear and front camera files - for name, key, fn in self.gen_upload_files(): - if name == "fcamera.hevc": + elif name == "fcamera.hevc": return (key, fn, 2) elif name == "dcamera.hevc": return (key, fn, 3) @@ -241,13 +238,12 @@ def uploader_fn(exit_event): params = Params() dongle_id = params.get("DongleId") - private_key = open("/persist/comma/id_rsa").read() - if dongle_id is None or private_key is None: - cloudlog.info("uploader missing dongle_id or private_key") - raise Exception("uploader can't start without dongle id and private key") + if dongle_id is None: + cloudlog.info("uploader missing dongle_id") + raise Exception("uploader can't start without dongle id") - uploader = Uploader(dongle_id, private_key, ROOT) + uploader = Uploader(dongle_id, ROOT) backoff = 0.1 while True: diff --git a/selfdrive/manager.py b/selfdrive/manager.py index 77df540c4..52caab8dd 100755 --- a/selfdrive/manager.py +++ b/selfdrive/manager.py @@ -49,7 +49,7 @@ if __name__ == "__main__": if is_neos: version = int(open("/VERSION").read()) if os.path.isfile("/VERSION") else 0 revision = int(open("/REVISION").read()) if version >= 10 else 0 # Revision only present in NEOS 10 and up - neos_update_required = version < 10 or (version == 10 and revision != 4) + neos_update_required = version < 10 or (version == 10 and revision < 4) if neos_update_required: # update continue.sh before updating NEOS @@ -95,7 +95,6 @@ from selfdrive.version import version, dirty import selfdrive.crash as crash from selfdrive.loggerd.config import ROOT -from common.realtime import sec_since_boot # comment out anything you don't want to run managed_processes = { @@ -374,6 +373,7 @@ def manager_thread(): # start frame pm_apply_packages('enable') + system("LD_LIBRARY_PATH= appops set ai.comma.plus.offroad SU allow") system("am start -n ai.comma.plus.frame/.MainActivity") if os.getenv("NOBOARD") is None: @@ -507,6 +507,11 @@ def manager_update(): update_ssh() update_apks() + uninstall = [app for app in get_installed_apks().keys() if app in ("com.spotify.music", "com.waze")] + for app in uninstall: + cloudlog.info("uninstalling %s" % app) + os.system("pm uninstall % s" % app) + def manager_prepare(): # build cereal first subprocess.check_call(["make", "-j4"], cwd=os.path.join(BASEDIR, "cereal")) @@ -564,16 +569,12 @@ def main(): params.put("IsMetric", "0") if params.get("RecordFront") is None: params.put("RecordFront", "0") - if params.get("IsFcwEnabled") is None: - params.put("IsFcwEnabled", "1") if params.get("HasAcceptedTerms") is None: params.put("HasAcceptedTerms", "0") if params.get("IsUploadRawEnabled") is None: params.put("IsUploadRawEnabled", "1") if params.get("IsUploadVideoOverCellularEnabled") is None: params.put("IsUploadVideoOverCellularEnabled", "1") - if params.get("IsDriverMonitoringEnabled") is None: - params.put("IsDriverMonitoringEnabled", "1") if params.get("IsGeofenceEnabled") is None: params.put("IsGeofenceEnabled", "-1") if params.get("SpeedLimitOffset") is None: diff --git a/selfdrive/messaging.py b/selfdrive/messaging.py index cad7e2e8b..13fb41efe 100644 --- a/selfdrive/messaging.py +++ b/selfdrive/messaging.py @@ -84,8 +84,8 @@ def recv_one_or_none(sock): return None -class SubMaster(): - def __init__(self, services, addr="127.0.0.1"): +class SubMaster(object): + def __init__(self, services, ignore_alive=None, addr="127.0.0.1"): self.poller = zmq.Poller() self.frame = -1 self.updated = {s : False for s in services} @@ -97,6 +97,12 @@ class SubMaster(): self.data = {} self.logMonoTime = {} self.valid = {} + + if ignore_alive is not None: + self.ignore_alive = ignore_alive + else: + self.ignore_alive = [] + for s in services: # TODO: get address automatically from service_list if addr is not None: @@ -141,7 +147,7 @@ class SubMaster(): def all_alive(self, service_list=None): if service_list is None: # check all service_list = self.alive.keys() - return all(self.alive[s] for s in service_list) + return all(self.alive[s] for s in service_list if s not in self.ignore_alive) def all_valid(self, service_list=None): if service_list is None: # check all @@ -152,3 +158,16 @@ class SubMaster(): if service_list is None: # check all service_list = self.alive.keys() return self.all_alive(service_list=service_list) and self.all_valid(service_list=service_list) + + +class PubMaster(): + def __init__(self, services): + self.sock = {} + for s in services: + self.sock[s] = pub_sock(service_list[s].port) + + def send(self, s, dat): + # accept either bytes or capnp builder + if not isinstance(dat, str): + dat = dat.to_bytes() + self.sock[s].send(dat) diff --git a/selfdrive/service_list.yaml b/selfdrive/service_list.yaml index 0c82a3187..ec8b0b9d4 100644 --- a/selfdrive/service_list.yaml +++ b/selfdrive/service_list.yaml @@ -16,7 +16,7 @@ thermal: [8005, true, 2., 1] can: [8006, true, 100.] controlsState: [8007, true, 100., 100] #liveEvent: [8008, true, 0.] -model: [8009, true, 20.] +model: [8009, true, 20., 5] features: [8010, true, 0.] health: [8011, true, 2., 1] radarState: [8012, true, 20.] diff --git a/selfdrive/test/test_car_models_openpilot.py b/selfdrive/test/test_car_models.py similarity index 77% rename from selfdrive/test/test_car_models_openpilot.py rename to selfdrive/test/test_car_models.py index 53184653c..317f32591 100755 --- a/selfdrive/test/test_car_models_openpilot.py +++ b/selfdrive/test/test_car_models.py @@ -14,6 +14,7 @@ from selfdrive.services import service_list import selfdrive.messaging as messaging from common.params import Params from common.basedir import BASEDIR +from common.fingerprints import all_known_cars from selfdrive.car.honda.values import CAR as HONDA from selfdrive.car.toyota.values import CAR as TOYOTA from selfdrive.car.gm.values import CAR as GM @@ -54,6 +55,7 @@ def get_route_logs(route_name): with open(log_path, "w") as f: f.write(r.content) else: + print "failed to download test log %s" % route_name sys.exit(-1) routes = { @@ -140,6 +142,10 @@ routes = { 'carFingerprint': HONDA.CRV_HYBRID, 'enableCamera': True, }, + "99e3eaed7396619e|2019-08-13--15-07-03": { + 'carFingerprint': HONDA.FIT, + 'enableCamera': True, + }, "2ac95059f70d76eb|2018-02-05--15-03-29": { 'carFingerprint': HONDA.ACURA_ILX, 'enableCamera': True, @@ -351,6 +357,21 @@ routes = { 'enableCamera': False, 'enableDsu': False, }, + "2e07163a1ba9a780|2019-08-25--13-15-13": { + 'carFingerprint': TOYOTA.LEXUS_IS, + 'enableCamera': True, + 'enableDsu': False, + }, + "2e07163a1ba9a780|2019-08-29--09-35-42": { + 'carFingerprint': TOYOTA.LEXUS_IS, + 'enableCamera': False, + 'enableDsu': False, + }, + "1dd19ceed0ee2b48|2018-12-22--17-36-49": { + 'carFingerprint': TOYOTA.LEXUS_IS, # 300 hybrid + 'enableCamera': True, + 'enableDsu': False, + }, "791340bc01ed993d|2019-03-10--16-28-08": { 'carFingerprint': SUBARU.IMPREZA, 'enableCamera': True, @@ -370,33 +391,59 @@ passive_routes = [ #"bfa17080b080f3ec|2018-06-28--23-27-47", ] -public_routes = [ - "f1b4c567731f4a1b|2018-06-06--14-43-46", - "f1b4c567731f4a1b|2018-04-18--11-29-37", - "f1b4c567731f4a1b|2018-04-18--11-29-37", - "7ed9cdf8d0c5f43e|2018-05-17--09-31-36", - "38bfd238edecbcd7|2018-08-22--09-45-44", - "38bfd238edecbcd7|2018-08-29--22-02-15", - "b0f5a01cf604185c|2018-01-26--00-54-32", - "b0f5a01cf604185c|2018-01-26--10-54-38", - "b0f5a01cf604185c|2018-01-26--10-59-31", - "56fb1c86a9a86404|2017-11-10--10-18-43", - "b0f5a01cf604185c|2017-12-18--20-32-32", - "b0c9d2329ad1606b|2019-04-02--13-24-43", - "791340bc01ed993d|2019-03-10--16-28-08", +# TODO: replace all these with public routes +# TODO: add routes for untested cars: HONDA ACCORD 2018 HYBRID TOURING and CHRYSLER PACIFICA 2018 +non_public_routes = [ + "0607d2516fc2148f|2019-02-13--23-03-16", # CHRYSLER PACIFICA HYBRID 2019 + "3e9592a1c78a3d63|2018-02-08--20-28-24", # HONDA PILOT 2017 TOURING + "aa20e335f61ba898|2019-02-05--16-59-04", # BUICK REGAL ESSENCE 2018 + "1851183c395ef471|2018-05-31--18-07-21", # HONDA CR-V 2017 EX + "9d5fb4f0baa1b3e1|2019-01-14--17-45-59", # KIA SORENTO GT LINE 2018 + "b4c18bf13d5955da|2018-07-29--13-39-46", # TOYOTA C-HR HYBRID 2018 + "5a2cfe4bb362af9e|2018-02-02--23-41-07", # ACURA RDX 2018 ACURAWATCH PLUS + "362d23d4d5bea2fa|2018-08-10--13-31-40", # TOYOTA HIGHLANDER HYBRID 2018 + "aa20e335f61ba898|2018-12-17--21-10-37", # BUICK REGAL ESSENCE 2018 + "215cd70e9c349266|2018-11-25--22-22-12", # KIA STINGER GT2 2018 + "192a598e34926b1e|2019-04-04--13-27-39", # JEEP GRAND CHEROKEE 2019 + "34a84d2b765df688|2018-08-28--12-41-00", # HONDA PILOT 2019 ELITE + "b0c9d2329ad1606b|2019-01-06--10-11-23", # CHRYSLER PACIFICA HYBRID 2017 + "31390e3eb6f7c29a|2019-01-23--08-56-00", # KIA OPTIMA SX 2019 + "fd10b9a107bb2e49|2018-07-24--16-32-42", # TOYOTA C-HR 2018 + "9f7a7e50a51fb9db|2019-01-17--18-34-21", # JEEP GRAND CHEROKEE V6 2018 + "aadda448b49c99ad|2018-10-25--17-16-22", # CHEVROLET MALIBU PREMIER 2017 + "362d23d4d5bea2fa|2018-09-02--17-03-55", # TOYOTA HIGHLANDER HYBRID 2018 + "1582e1dc57175194|2018-08-15--07-46-07", # HONDA ACCORD 2018 LX 1.5T + "fd10b9a107bb2e49|2018-07-24--20-32-08", # TOYOTA C-HR 2018 + "265007255e794bce|2018-11-24--22-08-31", # CADILLAC ATS Premium Performance 2018 + "53ac3251e03f95d7|2019-01-10--13-43-32", # HYUNDAI ELANTRA LIMITED ULTIMATE 2017 + "21aa231dee2a68bd|2018-01-30--04-54-41", # HONDA ODYSSEY 2018 EX-L + "900ad17e536c3dc7|2018-04-12--22-02-36", # HONDA RIDGELINE 2017 BLACK EDITION + "975b26878285314d|2018-12-25--14-42-13", # CHRYSLER PACIFICA HYBRID 2018 + "8ae193ceb56a0efe|2018-06-18--20-07-32", # TOYOTA RAV4 HYBRID 2017 + "a893a80e5c5f72c8|2019-01-14--20-02-59", # HYUNDAI GENESIS 2018 + "49c73650e65ff465|2018-11-19--16-58-04", # HOLDEN ASTRA RS-V BK 2017 + "d2d8152227f7cb82|2018-07-25--13-40-56", # TOYOTA CAMRY 2018 + "07cb8a788c31f645|2018-06-17--18-50-29", # mock + "c9d60e5e02c04c5c|2018-01-08--16-01-49", # HONDA CR-V 2016 TOURING + "1632088eda5e6c4d|2018-06-07--08-03-18", # HONDA CIVIC HATCHBACK 2017 SEDAN/COUPE 2019 + "fbd011384db5e669|2018-07-26--20-51-48", # TOYOTA CAMRY HYBRID 2018 ] if __name__ == "__main__": + # TODO: add routes for untested cars and fail test if we have an untested car + tested_cars = [keys["carFingerprint"] for route, keys in routes.items()] + for car_model in all_known_cars(): + if car_model not in tested_cars: + print "***** WARNING: %s not tested *****" % car_model + results = {} for route, checks in routes.items(): - - if route not in public_routes: - print "route not public", route + if route not in non_public_routes: + get_route_logs(route) + elif "UNLOGGER_PATH" not in os.environ: continue - get_route_logs(route) - for _ in range(3): shutil.rmtree('/data/params') manager.gctx = {} @@ -420,7 +467,10 @@ if __name__ == "__main__": # Start unlogger print "Start unlogger" - unlogger_cmd = [os.path.join(BASEDIR, 'tools/replay/unlogger.py'), '%s' % route, '/tmp', '--disable', 'frame,plan,pathPlan,liveLongitudinalMpc,radarState,controlsState,liveTracks,liveMpc,sendcan,carState,carControl', '--no-interactive'] + if route in non_public_routes: + unlogger_cmd = [os.path.join(BASEDIR, os.environ['UNLOGGER_PATH']), '%s' % route, '--disable', 'frame,plan,pathPlan,liveLongitudinalMpc,radarState,controlsState,liveTracks,liveMpc,sendcan,carState,carControl', '--no-interactive'] + else: + unlogger_cmd = [os.path.join(BASEDIR, 'tools/replay/unlogger.py'), '%s' % route, '/tmp', '--disable', 'frame,plan,pathPlan,liveLongitudinalMpc,radarState,controlsState,liveTracks,liveMpc,sendcan,carState,carControl', '--no-interactive'] unlogger = subprocess.Popen(unlogger_cmd, preexec_fn=os.setsid) print "Check sockets" diff --git a/selfdrive/test/tests/plant/test_longitudinal.py b/selfdrive/test/tests/plant/test_longitudinal.py index 09e81b2a1..ca0592420 100755 --- a/selfdrive/test/tests/plant/test_longitudinal.py +++ b/selfdrive/test/tests/plant/test_longitudinal.py @@ -332,7 +332,6 @@ class LongitudinalControl(unittest.TestCase): shutil.rmtree('/data/params', ignore_errors=True) params = Params() params.put("Passive", "1" if os.getenv("PASSIVE") else "0") - params.put("IsFcwEnabled", "1") manager.gctx = {} manager.prepare_managed_process('radard') diff --git a/selfdrive/test/tests/process_replay/README.md b/selfdrive/test/tests/process_replay/README.md index 639ca9051..7e92717f9 100644 --- a/selfdrive/test/tests/process_replay/README.md +++ b/selfdrive/test/tests/process_replay/README.md @@ -13,3 +13,12 @@ Currently the following processes are tested: * plannerd * calibrationd +## Forks + +openpilot forks can use this test with their own reference logs + +To generate new logs: + +`./update-refs.py --no-upload` + +Then, check in the new logs using git-lfs. Make sure to also include the updated `ref_commit` file. diff --git a/selfdrive/test/tests/process_replay/compare_logs.py b/selfdrive/test/tests/process_replay/compare_logs.py index 260e06c77..5a1bd3fd7 100755 --- a/selfdrive/test/tests/process_replay/compare_logs.py +++ b/selfdrive/test/tests/process_replay/compare_logs.py @@ -11,7 +11,6 @@ else: from tools.lib.logreader import LogReader - def save_log(dest, log_msgs): dat = "" for msg in log_msgs: @@ -21,25 +20,42 @@ def save_log(dest, log_msgs): with open(dest, "w") as f: f.write(dat) +def remove_ignored_fields(msg, ignore): + msg = msg.as_builder() + for key, val in ignore: + attr = msg + keys = key.split(".") + if msg.which() not in key and len(keys) > 1: + continue + + for k in keys[:-1]: + try: + attr = getattr(msg, k) + except: + break + else: + setattr(attr, keys[-1], val) + return msg.as_reader() + def compare_logs(log1, log2, ignore=[]): assert len(log1) == len(log2), "logs are not same length" + ignore_fields = [k for k, v in ignore] diff = [] for msg1, msg2 in tqdm(zip(log1, log2)): assert msg1.which() == msg2.which(), "msgs not aligned between logs" - msg1_bytes = msg1.as_builder().to_bytes() - msg2_bytes = msg2.as_builder().to_bytes() + msg1_bytes = remove_ignored_fields(msg1, ignore).as_builder().to_bytes() + msg2_bytes = remove_ignored_fields(msg2, ignore).as_builder().to_bytes() if msg1_bytes != msg2_bytes: msg1_dict = msg1.to_dict(verbose=True) msg2_dict = msg2.to_dict(verbose=True) - dd = dictdiffer.diff(msg1_dict, msg2_dict, ignore=ignore, tolerance=0) + dd = dictdiffer.diff(msg1_dict, msg2_dict, ignore=ignore_fields, tolerance=0) diff.extend(dd) return diff if __name__ == "__main__": log1 = list(LogReader(sys.argv[1])) log2 = list(LogReader(sys.argv[2])) - compare_logs(log1, log2, sys.argv[3:]) diff --git a/selfdrive/test/tests/process_replay/process_replay.py b/selfdrive/test/tests/process_replay/process_replay.py index 66067b405..b360aed97 100755 --- a/selfdrive/test/tests/process_replay/process_replay.py +++ b/selfdrive/test/tests/process_replay/process_replay.py @@ -1,14 +1,15 @@ #!/usr/bin/env python2 -import gc import os -import time +import threading +import importlib +import zmq if "CI" in os.environ: tqdm = lambda x: x else: from tqdm import tqdm -from cereal import car +from cereal import car, log from selfdrive.car.car_helpers import get_car import selfdrive.manager as manager import selfdrive.messaging as messaging @@ -18,61 +19,154 @@ from collections import namedtuple ProcessConfig = namedtuple('ProcessConfig', ['proc_name', 'pub_sub', 'ignore', 'init_callback', 'should_recv_callback']) -def fingerprint(msgs, pub_socks, sub_socks): +class FakeSocket: + def __init__(self, wait=True): + self.data = [] + self.wait = wait + self.recv_called = threading.Event() + self.recv_ready = threading.Event() + + def recv(self, block=None): + if block == zmq.NOBLOCK: + raise zmq.error.Again + + if self.wait: + self.recv_called.set() + self.recv_ready.wait() + self.recv_ready.clear() + return self.data.pop() + + def send(self, data): + if self.wait: + self.recv_called.wait() + self.recv_called.clear() + + self.data.append(data) + + if self.wait: + self.recv_ready.set() + + def wait_for_recv(self): + self.recv_called.wait() + +class DumbSocket: + def __init__(self, s=None): + if s is not None: + dat = messaging.new_message() + dat.init(s) + self.data = dat.to_bytes() + + def recv(self, block=None): + return self.data + + def send(self, dat): + pass + +class FakeSubMaster(messaging.SubMaster): + def __init__(self, services): + super(FakeSubMaster, self).__init__(services, addr=None) + self.sock = {s: DumbSocket(s) for s in services} + self.update_called = threading.Event() + self.update_ready = threading.Event() + + self.wait_on_getitem = False + + def __getitem__(self, s): + # hack to know when fingerprinting is done + if self.wait_on_getitem: + self.update_called.set() + self.update_ready.wait() + self.update_ready.clear() + return self.data[s] + + def update(self, timeout=-1): + self.update_called.set() + self.update_ready.wait() + self.update_ready.clear() + + def update_msgs(self, cur_time, msgs): + self.update_called.wait() + self.update_called.clear() + super(FakeSubMaster, self).update_msgs(cur_time, msgs) + self.update_ready.set() + + def wait_for_update(self): + self.update_called.wait() + +class FakePubMaster(messaging.PubMaster): + def __init__(self, services): + self.data = {} + self.sock = {} + self.last_updated = None + for s in services: + data = messaging.new_message() + try: + data.init(s) + except: + data.init(s, 0) + self.data[s] = data.as_reader() + self.sock[s] = DumbSocket() + self.send_called = threading.Event() + self.get_called = threading.Event() + + def send(self, s, dat): + self.last_updated = s + if isinstance(dat, str): + self.data[s] = log.Event.from_bytes(dat) + else: + self.data[s] = dat.as_reader() + self.send_called.set() + self.get_called.wait() + self.get_called.clear() + + def wait_for_msg(self): + self.send_called.wait() + self.send_called.clear() + dat = self.data[self.last_updated] + self.get_called.set() + return dat + +def fingerprint(msgs, fsm, can_sock): print "start fingerprinting" - manager.prepare_managed_process("logmessaged") - manager.start_managed_process("logmessaged") - - can = pub_socks["can"] - logMessage = messaging.sub_sock(service_list["logMessage"].port) - - time.sleep(1) - messaging.drain_sock(logMessage) - - # controlsd waits for a health packet before fingerprinting - msg = messaging.new_message() - msg.init("health") - pub_socks["health"].send(msg.to_bytes()) + fsm.wait_on_getitem = True + # populate fake socket with data for fingerprinting canmsgs = filter(lambda msg: msg.which() == "can", msgs) - for msg in canmsgs[:200]: - can.send(msg.as_builder().to_bytes()) + can_sock.recv_called.wait() + can_sock.recv_called.clear() + can_sock.data = [msg.as_builder().to_bytes() for msg in canmsgs[:300]] + can_sock.recv_ready.set() + can_sock.wait = False - time.sleep(0.005) - log = messaging.recv_one_or_none(logMessage) - if log is not None and "fingerprinted" in log.logMessage: - break - manager.kill_managed_process("logmessaged") + # we know fingerprinting is done when controlsd sets sm['pathPlan'].sensorValid + fsm.update_called.wait() + fsm.update_called.clear() + + fsm.wait_on_getitem = False + can_sock.wait = True + can_sock.data = [] + + fsm.update_ready.set() print "finished fingerprinting" -def get_car_params(msgs, pub_socks, sub_socks): - sendcan = pub_socks.get("sendcan", None) - if sendcan is None: - sendcan = messaging.pub_sock(service_list["sendcan"].port) - logcan = sub_socks.get("can", None) - if logcan is None: - logcan = messaging.sub_sock(service_list["can"].port) - can = pub_socks.get("can", None) - if can is None: - can = messaging.pub_sock(service_list["can"].port) +def get_car_params(msgs, fsm, can_sock): + can = FakeSocket(wait=False) + sendcan = FakeSocket(wait=False) - time.sleep(0.5) - - canmsgs = filter(lambda msg: msg.which() == "can", msgs) - for m in canmsgs[:200]: + canmsgs = filter(lambda msg: msg.which() == 'can', msgs) + for m in canmsgs[:300]: can.send(m.as_builder().to_bytes()) - _, CP = get_car(logcan, sendcan) + _, CP = get_car(can, sendcan) Params().put("CarParams", CP.to_bytes()) - time.sleep(0.5) - messaging.drain_sock(logcan) def radar_rcv_callback(msg, CP): if msg.which() != "can": return [] + elif CP.radarOffCan: + return ["radarState", "liveTracks"] - # hyundai and subaru don't have radar - radar_msgs = {"honda": [0x445], "toyota": [0x19f, 0x22f], "gm": [0x475], - "hyundai": [], "chrysler": [0x2d4], "subaru": []}.get(CP.carName, None) + radar_msgs = {"honda": [0x445], "toyota": [0x19f, 0x22f], "gm": [0x474], + "chrysler": [0x2d4]}.get(CP.carName, None) if radar_msgs is None: raise NotImplementedError @@ -80,24 +174,16 @@ def radar_rcv_callback(msg, CP): for m in msg.can: if m.src == 1 and m.address in radar_msgs: return ["radarState", "liveTracks"] - return [] -def plannerd_rcv_callback(msg, CP): - if msg.which() in ["model", "radarState"]: - time.sleep(0.005) - else: - time.sleep(0.002) - return {"model": ["pathPlan"], "radarState": ["plan"]}.get(msg.which(), []) - CONFIGS = [ ProcessConfig( proc_name="controlsd", pub_sub={ - "can": ["controlsState", "carState", "carControl", "sendcan"], - "thermal": [], "health": [], "liveCalibration": [], "driverMonitoring": [], "plan": [], "pathPlan": [] + "can": ["controlsState", "carState", "carControl", "sendcan", "carEvents", "carParams"], + "thermal": [], "health": [], "liveCalibration": [], "driverMonitoring": [], "plan": [], "pathPlan": [], "gpsLocation": [], }, - ignore=["logMonoTime", "controlsState.startMonoTime", "controlsState.cumLagMs"], + ignore=[("logMonoTime", 0), ("valid", True), ("controlsState.startMonoTime", 0), ("controlsState.cumLagMs", 0)], init_callback=fingerprint, should_recv_callback=None, ), @@ -107,7 +193,7 @@ CONFIGS = [ "can": ["radarState", "liveTracks"], "liveParameters": [], "controlsState": [], "model": [], }, - ignore=["logMonoTime", "radarState.cumLagMs"], + ignore=[("logMonoTime", 0), ("valid", True), ("radarState.cumLagMs", 0)], init_callback=get_car_params, should_recv_callback=radar_rcv_callback, ), @@ -117,69 +203,82 @@ CONFIGS = [ "model": ["pathPlan"], "radarState": ["plan"], "carState": [], "controlsState": [], "liveParameters": [], }, - ignore=["logMonoTime", "valid", "plan.processingDelay"], + ignore=[("logMonoTime", 0), ("valid", True), ("plan.processingDelay", 0)], init_callback=get_car_params, - should_recv_callback=plannerd_rcv_callback, + should_recv_callback=None, ), ProcessConfig( proc_name="calibrationd", pub_sub={ "cameraOdometry": ["liveCalibration"] }, - ignore=["logMonoTime"], + ignore=[("logMonoTime", 0), ("valid", True)], init_callback=get_car_params, should_recv_callback=None, ), ] def replay_process(cfg, lr): - gc.disable() # gc can occasionally cause canparser to timeout + sub_sockets = [s for _, sub in cfg.pub_sub.items() for s in sub] + pub_sockets = [s for s in cfg.pub_sub.keys() if s != 'can'] - pub_socks, sub_socks = {}, {} - for pub, sub in cfg.pub_sub.iteritems(): - pub_socks[pub] = messaging.pub_sock(service_list[pub].port) - - for s in sub: - sub_socks[s] = messaging.sub_sock(service_list[s].port) + fsm = FakeSubMaster(pub_sockets) + fpm = FakePubMaster(sub_sockets) + args = (fsm, fpm) + if 'can' in cfg.pub_sub.keys(): + can_sock = FakeSocket() + args = (fsm, fpm, can_sock) all_msgs = sorted(lr, key=lambda msg: msg.logMonoTime) - pub_msgs = filter(lambda msg: msg.which() in pub_socks.keys(), all_msgs) + pub_msgs = filter(lambda msg: msg.which() in cfg.pub_sub.keys(), all_msgs) params = Params() params.manager_start() params.put("Passive", "0") - manager.gctx = {} + os.environ['NO_RADAR_SLEEP'] = "1" manager.prepare_managed_process(cfg.proc_name) - manager.start_managed_process(cfg.proc_name) - time.sleep(3) # Wait for started process to be ready + mod = importlib.import_module(manager.managed_processes[cfg.proc_name]) + thread = threading.Thread(target=mod.main, args=args) + thread.daemon = True + thread.start() if cfg.init_callback is not None: - cfg.init_callback(all_msgs, pub_socks, sub_socks) + if 'can' not in cfg.pub_sub.keys(): + can_sock = None + cfg.init_callback(all_msgs, fsm, can_sock) CP = car.CarParams.from_bytes(params.get("CarParams", block=True)) - log_msgs = [] + # wait for started process to be ready + if 'can' in cfg.pub_sub.keys(): + can_sock.wait_for_recv() + else: + fsm.wait_for_update() + + log_msgs, msg_queue = [], [] for msg in tqdm(pub_msgs): if cfg.should_recv_callback is not None: recv_socks = cfg.should_recv_callback(msg, CP) else: - recv_socks = cfg.pub_sub[msg.which()] + recv_socks = [s for s in cfg.pub_sub[msg.which()] if + (fsm.frame + 1) % int(service_list[msg.which()].frequency / service_list[s].frequency) == 0] - pub_socks[msg.which()].send(msg.as_builder().to_bytes()) + should_recv = bool(len(recv_socks)) - if len(recv_socks): - # TODO: add timeout - for sock in recv_socks: - m = messaging.recv_one(sub_socks[sock]) + if msg.which() == 'can': + can_sock.send(msg.as_builder().to_bytes()) + else: + msg_queue.append(msg.as_builder()) - # make these values fixed for faster comparison - m_builder = m.as_builder() - m_builder.logMonoTime = 0 - m_builder.valid = True - log_msgs.append(m_builder.as_reader()) + if should_recv: + fsm.update_msgs(0, msg_queue) + msg_queue = [] - gc.enable() - manager.kill_managed_process(cfg.proc_name) + recv_cnt = len(recv_socks) + while recv_cnt > 0: + m = fpm.wait_for_msg() + log_msgs.append(m) + + recv_cnt -= m.which() in recv_socks return log_msgs - diff --git a/selfdrive/test/tests/process_replay/ref_commit b/selfdrive/test/tests/process_replay/ref_commit index 30a1a2853..3744386a8 100644 --- a/selfdrive/test/tests/process_replay/ref_commit +++ b/selfdrive/test/tests/process_replay/ref_commit @@ -1 +1 @@ -e3388c62ffb80f4b3ca8721da56a581a93c44e79 \ No newline at end of file +8a11bcbc9833e154e10b59a8babb2b4545372f56 \ No newline at end of file diff --git a/selfdrive/ui/spinner/Makefile b/selfdrive/ui/spinner/Makefile new file mode 100644 index 000000000..93871bb00 --- /dev/null +++ b/selfdrive/ui/spinner/Makefile @@ -0,0 +1,74 @@ +CC = clang +CXX = clang++ + +PHONELIBS = ../../../phonelibs + +WARN_FLAGS = -Werror=implicit-function-declaration \ + -Werror=incompatible-pointer-types \ + -Werror=int-conversion \ + -Werror=return-type \ + -Werror=format-extra-args + +CFLAGS = -std=gnu11 -fPIC -O2 $(WARN_FLAGS) +CXXFLAGS = -std=c++11 -fPIC -O2 $(WARN_FLAGS) + +NANOVG_FLAGS = -I$(PHONELIBS)/nanovg + +OPENGL_LIBS = -lGLESv3 + +FRAMEBUFFER_LIBS = -lutils -lgui -lEGL + +OBJS = spinner.o \ + ../../common/framebuffer.o \ + $(PHONELIBS)/nanovg/nanovg.o \ + ../../common/spinner.o \ + opensans_semibold.o \ + img_spinner_track.o \ + img_spinner_comma.o + +DEPS := $(OBJS:.o=.d) + +.PHONY: all +all: spinner + +spinner: $(OBJS) + @echo "[ LINK ] $@" + $(CXX) -fPIC -o '$@' $^ \ + -s \ + $(FRAMEBUFFER_LIBS) \ + -L/system/vendor/lib64 \ + $(OPENGL_LIBS) \ + -lm -llog + +../../common/framebuffer.o: ../../common/framebuffer.cc + @echo "[ CXX ] $@" + $(CXX) $(CXXFLAGS) -MMD \ + -I$(PHONELIBS)/android_frameworks_native/include \ + -I$(PHONELIBS)/android_system_core/include \ + -I$(PHONELIBS)/android_hardware_libhardware/include \ + -c -o '$@' '$<' + +opensans_semibold.o: ../../assets/fonts/opensans_semibold.ttf + @echo "[ bin2o ] $@" + cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' + +img_spinner_track.o: ../../assets/img_spinner_track.png + @echo "[ bin2o ] $@" + cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' + +img_spinner_comma.o: ../../assets/img_spinner_comma.png + @echo "[ bin2o ] $@" + cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' + +%.o: %.c + @echo "[ CC ] $@" + $(CC) $(CFLAGS) -MMD \ + -I../.. \ + $(NANOVG_FLAGS) \ + -c -o '$@' '$<' + +.PHONY: clean +clean: + rm -f spinner $(OBJS) $(DEPS) + +-include $(DEPS) diff --git a/selfdrive/ui/spinner/spinner.c b/selfdrive/ui/spinner/spinner.c index 3ec36e740..14b452a49 100644 --- a/selfdrive/ui/spinner/spinner.c +++ b/selfdrive/ui/spinner/spinner.c @@ -9,92 +9,13 @@ #include #include -#include "nanovg.h" -#define NANOVG_GLES3_IMPLEMENTATION -#include "nanovg_gl.h" -#include "nanovg_gl_utils.h" - #include "common/framebuffer.h" +#include "common/spinner.h" int main(int argc, char** argv) { int err; - const char* spintext = NULL; - if (argc >= 2) { - spintext = argv[1]; - } - - // spinner - int fb_w, fb_h; - EGLDisplay display; - EGLSurface surface; - FramebufferState *fb = framebuffer_init("spinner", 0x00001000, false, - &display, &surface, &fb_w, &fb_h); - assert(fb); - - NVGcontext *vg = nvgCreateGLES3(NVG_ANTIALIAS | NVG_STENCIL_STROKES); - assert(vg); - - int font = nvgCreateFont(vg, "Bold", "../../assets/fonts/opensans_semibold.ttf"); - assert(font >= 0); - - int spinner_img = nvgCreateImage(vg, "../../assets/img_spinner_track.png", 0); - assert(spinner_img >= 0); - int spinner_img_s = 360; - int spinner_img_x = ((fb_w/2)-(spinner_img_s/2)); - int spinner_img_y = 260; - int spinner_img_xc = (fb_w/2); - int spinner_img_yc = (fb_h/2)-100; - int spinner_comma_img = nvgCreateImage(vg, "../../assets/img_spinner_comma.png", 0); - assert(spinner_comma_img >= 0); - - for (int cnt = 0; ; cnt++) { - glClearColor(0.1, 0.1, 0.1, 1.0); - glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - nvgBeginFrame(vg, fb_w, fb_h, 1.0f); - - // background - nvgBeginPath(vg); - NVGpaint bg = nvgLinearGradient(vg, fb_w, 0, fb_w, fb_h, - nvgRGBA(0, 0, 0, 175), nvgRGBA(0, 0, 0, 255)); - nvgFillPaint(vg, bg); - nvgRect(vg, 0, 0, fb_w, fb_h); - nvgFill(vg); - - // spin track - nvgSave(vg); - nvgTranslate(vg, spinner_img_xc, spinner_img_yc); - nvgRotate(vg, (3.75*M_PI * cnt/120.0)); - nvgTranslate(vg, -spinner_img_xc, -spinner_img_yc); - NVGpaint spinner_imgPaint = nvgImagePattern(vg, spinner_img_x, spinner_img_y, - spinner_img_s, spinner_img_s, 0, spinner_img, 0.6f); - nvgBeginPath(vg); - nvgFillPaint(vg, spinner_imgPaint); - nvgRect(vg, spinner_img_x, spinner_img_y, spinner_img_s, spinner_img_s); - nvgFill(vg); - nvgRestore(vg); - - // comma - NVGpaint comma_imgPaint = nvgImagePattern(vg, spinner_img_x, spinner_img_y, - spinner_img_s, spinner_img_s, 0, spinner_comma_img, 1.0f); - nvgBeginPath(vg); - nvgFillPaint(vg, comma_imgPaint); - nvgRect(vg, spinner_img_x, spinner_img_y, spinner_img_s, spinner_img_s); - nvgFill(vg); - - // message - if (spintext) { - nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_TOP); - nvgFontSize(vg, 96.0f); - nvgText(vg, fb_w/2, (fb_h*2/3)+24, spintext, NULL); - } - - nvgEndFrame(vg); - eglSwapBuffers(display, surface); - assert(glGetError() == GL_NO_ERROR); - } + spin(argc, argv); return 0; } diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c index 92935906f..e38007f6b 100644 --- a/selfdrive/ui/ui.c +++ b/selfdrive/ui/ui.c @@ -42,7 +42,6 @@ #define STATUS_ENGAGED 2 #define STATUS_WARNING 3 #define STATUS_ALERT 4 -#define STATUS_MAX 5 #define ALERTSIZE_NONE 0 #define ALERTSIZE_SMALL 1 @@ -124,7 +123,6 @@ typedef struct UIScene { float mpc_y[50]; bool world_objects_visible; - mat3 warp_matrix; // transformed box -> frame. mat4 extrinsic_matrix; // Last row is 0 so we can use mat4. float v_cruise; @@ -260,12 +258,15 @@ typedef struct UIState { int awake_timeout; int volume_timeout; + int controls_timeout; int alert_sound_timeout; int speed_lim_off_timeout; int is_metric_timeout; int longitudinal_control_timeout; int limit_set_speed_timeout; + bool controls_seen; + int status; bool is_metric; bool longitudinal_control; @@ -294,6 +295,7 @@ typedef struct UIState { track_vertices_data track_vertices[2]; // dragonpilot + int dragon_ui_speed_timeout; int dragon_ui_event_timeout; int dragon_ui_maxspeed_timeout; int dragon_ui_face_timeout; @@ -301,7 +303,9 @@ typedef struct UIState { int dragon_ui_dev_mini_timeout; int dragon_enable_dashcam_timeout; int dragon_ui_volume_boost_timeout; + int dragon_driving_ui_timeout; + bool dragon_ui_speed; bool dragon_ui_event; bool dragon_ui_maxspeed; bool dragon_ui_face; @@ -309,6 +313,7 @@ typedef struct UIState { bool dragon_ui_dev_mini; bool dragon_enable_dashcam; float dragon_ui_volume_boost; + bool dragon_driving_ui; } UIState; @@ -483,6 +488,25 @@ sound_file* get_sound_file(AudibleAlert alert) { return NULL; } +void play_alert_sound(AudibleAlert alert) { + sound_file* sound = get_sound_file(alert); + char* error = NULL; + + slplay_play(sound->uri, sound->loop, &error); + if(error) { + LOGW("error playing sound: %s", error); + } +} + +void stop_alert_sound(AudibleAlert alert) { + sound_file* sound = get_sound_file(alert); + char* error = NULL; + + slplay_stop_uri(sound->uri, &error); + if(error) { + LOGW("error stopping sound: %s", error); + } +} void ui_sound_init(char **error) { slplay_setup(error); @@ -676,6 +700,7 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs, read_param_bool(&s->longitudinal_control, "LongitudinalControl"); read_param_bool(&s->limit_set_speed, "LimitSetSpeed"); // dragonpilot + read_param_bool(&s->dragon_ui_speed, "DragonUISpeed"); read_param_bool(&s->dragon_ui_event, "DragonUIEvent"); read_param_bool(&s->dragon_ui_maxspeed, "DragonUIMaxSpeed"); read_param_bool(&s->dragon_ui_face, "DragonUIFace"); @@ -683,6 +708,7 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs, read_param_bool(&s->dragon_ui_dev_mini, "DragonUIDevMini"); read_param_bool(&s->dragon_enable_dashcam, "DragonEnableDashcam"); read_param_float(&s->dragon_ui_volume_boost, "DragonUIVolumeBoost"); + read_param_bool(&s->dragon_driving_ui, "DragonDrivingUI"); // Set offsets so params don't get read at the same time @@ -691,6 +717,7 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs, s->limit_set_speed_timeout = UI_FREQ; // dragonpilot, 1hz + s->dragon_ui_speed_timeout = 100; s->dragon_ui_event_timeout = 100; s->dragon_ui_maxspeed_timeout = 100; s->dragon_ui_face_timeout = 100; @@ -698,43 +725,7 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs, s->dragon_ui_dev_mini_timeout = 100; s->dragon_enable_dashcam_timeout = 100; s->dragon_ui_volume_boost_timeout = 100; -} - -static void ui_draw_transformed_box(UIState *s, uint32_t color) { - const UIScene *scene = &s->scene; - - const mat3 bbt = scene->warp_matrix; - - struct { - vec3 pos; - uint32_t color; - } verts[] = { - {matvecmul3(bbt, (vec3){{0.0, 0.0, 1.0,}}), color}, - {matvecmul3(bbt, (vec3){{scene->transformed_width, 0.0, 1.0,}}), color}, - {matvecmul3(bbt, (vec3){{scene->transformed_width, scene->transformed_height, 1.0,}}), color}, - {matvecmul3(bbt, (vec3){{0.0, scene->transformed_height, 1.0,}}), color}, - {matvecmul3(bbt, (vec3){{0.0, 0.0, 1.0,}}), color}, - }; - - for (int i=0; irgb_height - verts[i].pos.v[1] / verts[i].pos.v[2]; - } - - glUseProgram(s->line_program); - - mat4 out_mat = matmul(device_transform, - matmul(frame_transform, s->rgb_transform)); - glUniformMatrix4fv(s->line_transform_loc, 1, GL_TRUE, out_mat.v); - - glEnableVertexAttribArray(s->line_pos_loc); - glVertexAttribPointer(s->line_pos_loc, 2, GL_FLOAT, GL_FALSE, sizeof(verts[0]), &verts[0].pos.v[0]); - - glEnableVertexAttribArray(s->line_color_loc); - glVertexAttribPointer(s->line_color_loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(verts[0]), &verts[0].color); - - assert(glGetError() == GL_NO_ERROR); - glDrawArrays(GL_LINE_STRIP, 0, ARRAYSIZE(verts)); + s->dragon_driving_ui_timeout = 100; } // Projects a point in car to space to the corresponding point in full frame @@ -1428,16 +1419,16 @@ static void ui_draw_vision_header(UIState *s) { const UIScene *scene = &s->scene; int ui_viz_rx = scene->ui_viz_rx; int ui_viz_rw = scene->ui_viz_rw; - - nvgBeginPath(s->vg); - NVGpaint gradient = nvgLinearGradient(s->vg, ui_viz_rx, - (box_y+(header_h-(header_h/2.5))), - ui_viz_rx, box_y+header_h, - nvgRGBAf(0,0,0,0.45), nvgRGBAf(0,0,0,0)); - nvgFillPaint(s->vg, gradient); - nvgRect(s->vg, ui_viz_rx, box_y, ui_viz_rw, header_h); - nvgFill(s->vg); - + if (s->dragon_driving_ui) { + nvgBeginPath(s->vg); + NVGpaint gradient = nvgLinearGradient(s->vg, ui_viz_rx, + (box_y+(header_h-(header_h/2.5))), + ui_viz_rx, box_y+header_h, + nvgRGBAf(0,0,0,0.45), nvgRGBAf(0,0,0,0)); + nvgFillPaint(s->vg, gradient); + nvgRect(s->vg, ui_viz_rx, box_y, ui_viz_rw, header_h); + nvgFill(s->vg); + } if (s->dragon_ui_maxspeed) { ui_draw_vision_maxspeed(s); } @@ -1445,24 +1436,40 @@ static void ui_draw_vision_header(UIState *s) { #ifdef SHOW_SPEEDLIMIT ui_draw_vision_speedlimit(s); #endif - ui_draw_vision_speed(s); + if (s->dragon_ui_speed) { + ui_draw_vision_speed(s); + } if (s->dragon_ui_event) { ui_draw_vision_event(s); } } static void ui_draw_infobar(UIState *s) { - // timestamp from pjlao307 dashcam (https://github.com/pjlao307) - int rect_w = 1440; // 1920 * 0.75 - int rect_h = 50; - int rect_x = (1920-rect_w)/2; - int rect_y = (1080-rect_h-50); - int sidebar_offset = 0; + const UIScene *scene = &s->scene; + int ui_viz_rx = scene->ui_viz_rx; bool hasSidebar = !s->scene.uilayout_sidebarcollapsed; - if (hasSidebar) { - sidebar_offset = 100; + // rect_w = screen_width - sidebar width + int rect_w = vwp_w - (hasSidebar? sbr_w : 0); + if (s->dragon_driving_ui) { + // if driving ui is enabled, rect_w = rect_w - vision start x - small boarder + rect_w = rect_w - ui_viz_rx - bdr_s; } + int rect_h = 80; + // rect_x = 0 + sidebar width + int rect_x = 0; + if (s->dragon_driving_ui) { + // if driving ui is enabled, rect_x = rect_x + vision start x + rect_x = rect_x + (hasSidebar? sbr_w : 0) + ui_viz_rx; + } + // rect_y = screen height - board - background height + int rect_y = vwp_h - bdr_s - rect_h; +// int text_width; + int text_x = rect_w / 2; + if (s->dragon_driving_ui) { + text_x = text_x + (hasSidebar? sbr_w : 0) + ui_viz_rx; + } + int text_y = rect_y + 55; // Get local time to display char infobar[68]; @@ -1488,7 +1495,6 @@ static void ui_draw_infobar(UIState *s) { snprintf(lead_dist, sizeof(lead_dist), "%7s", "N/A"); } - snprintf( infobar, sizeof(infobar), @@ -1518,14 +1524,15 @@ static void ui_draw_infobar(UIState *s) { } nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, rect_x + sidebar_offset, rect_y, rect_w, rect_h, 15); + nvgRoundedRect(s->vg, rect_x, rect_y, rect_w, rect_h, 15); nvgFillColor(s->vg, nvgRGBA(0, 0, 0, 100)); nvgFill(s->vg); - nvgFontSize(s->vg, 40); + nvgFontSize(s->vg, hasSidebar? 40:50); nvgFontFace(s->vg, "courbd"); nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 175)); - nvgText(s->vg, rect_x + 720 + sidebar_offset, rect_y + 35, infobar, NULL); + nvgTextAlign(s->vg, NVG_ALIGN_CENTER); + nvgText(s->vg, text_x, text_y, infobar, NULL); } //BB START: functions added for the display of various items @@ -1823,7 +1830,9 @@ static void ui_draw_vision(UIState *s) { glScissor(ui_viz_rx, s->fb_h-(box_y+box_h), ui_viz_rw, box_h); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - draw_frame(s); + if (s->dragon_driving_ui) { + draw_frame(s); + } glViewport(0, 0, s->fb_w, s->fb_h); glDisable(GL_SCISSOR_TEST); @@ -1831,14 +1840,15 @@ static void ui_draw_vision(UIState *s) { nvgBeginFrame(s->vg, s->fb_w, s->fb_h, 1.0f); nvgSave(s->vg); - - // Draw augmented elements - const int inner_height = viz_w*9/16; - nvgScissor(s->vg, ui_viz_rx, box_y, ui_viz_rw, box_h); - nvgTranslate(s->vg, ui_viz_rx+ui_viz_ro, box_y + (box_h-inner_height)/2.0); - nvgScale(s->vg, (float)viz_w / s->fb_w, (float)inner_height / s->fb_h); - if (!scene->frontview && !scene->fullview) { - ui_draw_world(s); + if (s->dragon_driving_ui) { + // Draw augmented elements + const int inner_height = viz_w*9/16; + nvgScissor(s->vg, ui_viz_rx, box_y, ui_viz_rw, box_h); + nvgTranslate(s->vg, ui_viz_rx+ui_viz_ro, box_y + (box_h-inner_height)/2.0); + nvgScale(s->vg, (float)viz_w / s->fb_w, (float)inner_height / s->fb_h); + if (!scene->frontview && !scene->fullview) { + ui_draw_world(s); + } } nvgRestore(s->vg); @@ -1954,6 +1964,9 @@ void handle_message(UIState *s, void *which) { struct cereal_ControlsState datad; cereal_read_ControlsState(&datad, eventd.controlsState); + s->controls_timeout = 1 * UI_FREQ; + s->controls_seen = true; + if (datad.vCruise != s->scene.v_cruise) { s->scene.v_cruise_update_ts = eventd.logMonoTime; } @@ -1969,38 +1982,21 @@ void handle_message(UIState *s, void *which) { s->scene.decel_for_model = datad.decelForModel; - s->alert_sound_timeout = 1 * UI_FREQ; - + // dragonpilot s->scene.angleSteers = datad.angleSteers; s->scene.angleSteersDes = datad.angleSteersDes; if (datad.alertSound != cereal_CarControl_HUDControl_AudibleAlert_none && datad.alertSound != s->alert_sound) { - char* error = NULL; if (s->alert_sound != cereal_CarControl_HUDControl_AudibleAlert_none) { - sound_file* active_sound = get_sound_file(s->alert_sound); - slplay_stop_uri(active_sound->uri, &error); - if (error) { - LOGW("error stopping active sound %s", error); - } - } - - sound_file* sound = get_sound_file(datad.alertSound); - slplay_play(sound->uri, sound->loop, &error); - if(error) { - LOGW("error playing sound: %s", error); + stop_alert_sound(s->alert_sound); } + play_alert_sound(datad.alertSound); s->alert_sound = datad.alertSound; snprintf(s->alert_type, sizeof(s->alert_type), "%s", datad.alertType.str); - } else if ((!datad.alertSound || datad.alertSound == cereal_CarControl_HUDControl_AudibleAlert_none) && s->alert_sound != cereal_CarControl_HUDControl_AudibleAlert_none) { - sound_file* sound = get_sound_file(s->alert_sound); - - char* error = NULL; - - slplay_stop_uri(sound->uri, &error); - if(error) { - LOGW("error stopping sound: %s", error); - } + } else if ((!datad.alertSound || datad.alertSound == cereal_CarControl_HUDControl_AudibleAlert_none) + && s->alert_sound != cereal_CarControl_HUDControl_AudibleAlert_none) { + stop_alert_sound(s->alert_sound); s->alert_type[0] = '\0'; s->alert_sound = cereal_CarControl_HUDControl_AudibleAlert_none; } @@ -2072,13 +2068,6 @@ void handle_message(UIState *s, void *which) { struct cereal_LiveCalibrationData datad; cereal_read_LiveCalibrationData(&datad, eventd.liveCalibration); - // should we still even have this? - capn_list32 warpl = datad.warpMatrix2; - capn_resolve(&warpl.p); // is this a bug? - for (int i = 0; i < 3 * 3; i++) { - s->scene.warp_matrix.v[i] = capn_to_f32(capn_get32(warpl, i)); - } - capn_list32 extrinsicl = datad.extrinsicMatrix; capn_resolve(&extrinsicl.p); // is this a bug? for (int i = 0; i < 3 * 4; i++) { @@ -2654,18 +2643,31 @@ int main(int argc, char* argv[]) { set_volume(s, volume); } - // stop playing alert sounds if no controlsState msg for 1 second - if (s->alert_sound_timeout > 0) { - s->alert_sound_timeout--; - } else if (s->alert_sound != cereal_CarControl_HUDControl_AudibleAlert_none){ - sound_file* sound = get_sound_file(s->alert_sound); - char* error = NULL; - - slplay_stop_uri(sound->uri, &error); - if(error) { - LOGW("error stopping sound: %s", error); + if (s->controls_timeout > 0) { + s->controls_timeout--; + } else { + // stop playing alert sound + if ((!s->vision_connected || (s->vision_connected && s->alert_sound_timeout == 0)) && + s->alert_sound != cereal_CarControl_HUDControl_AudibleAlert_none) { + stop_alert_sound(s->alert_sound); + s->alert_sound = cereal_CarControl_HUDControl_AudibleAlert_none; } - s->alert_sound = cereal_CarControl_HUDControl_AudibleAlert_none; + + // if visiond is still running and controlsState times out, display an alert + if (s->controls_seen && s->vision_connected && strcmp(s->scene.alert_text2, "Controls Unresponsive") != 0) { + s->scene.alert_size = ALERTSIZE_FULL; + update_status(s, STATUS_ALERT); + snprintf(s->scene.alert_text1, sizeof(s->scene.alert_text1), "%s", "TAKE CONTROL IMMEDIATELY"); + snprintf(s->scene.alert_text2, sizeof(s->scene.alert_text2), "%s", "Controls Unresponsive"); + ui_draw_vision_alert(s, s->scene.alert_size, s->status, s->scene.alert_text1, s->scene.alert_text2); + + s->alert_sound_timeout = 2 * UI_FREQ; + + s->alert_sound = cereal_CarControl_HUDControl_AudibleAlert_chimeWarningRepeat; + play_alert_sound(s->alert_sound); + } + s->alert_sound_timeout--; + s->controls_seen = false; } read_param_bool_timeout(&s->is_metric, "IsMetric", &s->is_metric_timeout); @@ -2673,6 +2675,7 @@ int main(int argc, char* argv[]) { read_param_bool_timeout(&s->limit_set_speed, "LimitSetSpeed", &s->limit_set_speed_timeout); read_param_float_timeout(&s->speed_lim_off, "SpeedLimitOffset", &s->limit_set_speed_timeout); // dragonpilot + read_param_bool_timeout(&s->dragon_ui_speed, "DragonUISpeed", &s->dragon_ui_speed_timeout); read_param_bool_timeout(&s->dragon_ui_event, "DragonUIEvent", &s->dragon_ui_event_timeout); read_param_bool_timeout(&s->dragon_ui_maxspeed, "DragonUIMaxSpeed", &s->dragon_ui_maxspeed_timeout); read_param_bool_timeout(&s->dragon_ui_face, "DragonUIFace", &s->dragon_ui_face_timeout); @@ -2680,6 +2683,7 @@ int main(int argc, char* argv[]) { read_param_bool_timeout(&s->dragon_ui_dev_mini, "DragonUIDevMini", &s->dragon_ui_dev_mini_timeout); read_param_bool_timeout(&s->dragon_enable_dashcam, "DragonEnableDashcam", &s->dragon_enable_dashcam_timeout); read_param_float_timeout(&s->dragon_ui_volume_boost, "DragonUIVolumeBoost", &s->dragon_ui_volume_boost_timeout); + read_param_bool_timeout(&s->dragon_driving_ui, "DragonDrivingUI", &s->dragon_driving_ui_timeout); pthread_mutex_unlock(&s->lock); diff --git a/selfdrive/visiond/cameras/camera_frame_stream.cc b/selfdrive/visiond/cameras/camera_frame_stream.cc new file mode 100644 index 000000000..81b2bd400 --- /dev/null +++ b/selfdrive/visiond/cameras/camera_frame_stream.cc @@ -0,0 +1,172 @@ +#include "camera_frame_stream.h" + +#include +#include +#include +#include + +#include +#include +#include +#include "cereal/gen/cpp/log.capnp.h" + +#include "common/util.h" +#include "common/timing.h" +#include "common/swaglog.h" +#include "buffering.h" + +extern "C" { +#include +} + +extern volatile int do_exit; + +#define FRAME_WIDTH 1164 +#define FRAME_HEIGHT 874 + +namespace { +void camera_open(CameraState *s, VisionBuf *camera_bufs, bool rear) { + assert(camera_bufs); + s->camera_bufs = camera_bufs; +} + +void camera_close(CameraState *s) { + tbuffer_stop(&s->camera_tb); +} + +void camera_release_buffer(void *cookie, int buf_idx) { + CameraState *s = static_cast(cookie); +} + +void camera_init(CameraState *s, int camera_id, unsigned int fps) { + assert(camera_id < ARRAYSIZE(cameras_supported)); + s->ci = cameras_supported[camera_id]; + assert(s->ci.frame_width != 0); + + s->frame_size = s->ci.frame_height * s->ci.frame_stride; + s->fps = fps; + + tbuffer_init2(&s->camera_tb, FRAME_BUF_COUNT, "frame", camera_release_buffer, s); +} + +void run_frame_stream(DualCameraState *s) { + int err; + zsock_t *recorder_sock = zsock_new_sub(">tcp://127.0.0.1:8002", ""); + assert(recorder_sock); + void *recorder_sock_raw = zsock_resolve(recorder_sock); + + CameraState *const rear_camera = &s->rear; + auto *tb = &rear_camera->camera_tb; + + while (!do_exit) { + zmq_msg_t msg; + err = zmq_msg_init(&msg); + assert(err == 0); + + err = zmq_msg_recv(&msg, recorder_sock_raw, 0); + if(err == -1) + break; + + // make copy due to alignment issues, will be freed on out of scope + size_t len = zmq_msg_size(&msg); + auto amsg = kj::heapArray((len / sizeof(capnp::word)) + 1); + memcpy(amsg.begin(), (const uint8_t*)zmq_msg_data(&msg), len); + + capnp::FlatArrayMessageReader cmsg(amsg); + cereal::Event::Reader event = cmsg.getRoot(); + auto frame = event.getFrame(); + + const int buf_idx = tbuffer_select(tb); + rear_camera->camera_bufs_metadata[buf_idx] = { + .frame_id = frame.getFrameId(), + .timestamp_eof = frame.getTimestampEof(), + .frame_length = static_cast(frame.getFrameLength()), + .integ_lines = static_cast(frame.getIntegLines()), + .global_gain = static_cast(frame.getGlobalGain()), + }; + + cl_command_queue q = rear_camera->camera_bufs[buf_idx].copy_q; + cl_mem yuv_cl = rear_camera->camera_bufs[buf_idx].buf_cl; + cl_event map_event; + void *yuv_buf = (void *)clEnqueueMapBuffer(q, yuv_cl, CL_TRUE, + CL_MAP_WRITE, 0, frame.getImage().size(), + 0, NULL, &map_event, &err); + assert(err == 0); + clWaitForEvents(1, &map_event); + clReleaseEvent(map_event); + memcpy(yuv_buf, frame.getImage().begin(), frame.getImage().size()); + + clEnqueueUnmapMemObject(q, yuv_cl, yuv_buf, 0, NULL, &map_event); + clWaitForEvents(1, &map_event); + clReleaseEvent(map_event); + tbuffer_dispatch(tb, buf_idx); + + err = zmq_msg_close(&msg); + assert(err == 0); + } + zsock_destroy(&recorder_sock); +} + +} // namespace + +CameraInfo cameras_supported[CAMERA_ID_MAX] = { + [CAMERA_ID_IMX298] = { + .frame_width = FRAME_WIDTH, + .frame_height = FRAME_HEIGHT, + .frame_stride = FRAME_WIDTH*3, + .bayer = false, + .bayer_flip = false, + }, + [CAMERA_ID_OV8865] = { + .frame_width = 1632, + .frame_height = 1224, + .frame_stride = 2040, // seems right + .bayer = false, + .bayer_flip = 3, + .hdr = false + }, +}; + +void cameras_init(DualCameraState *s) { + memset(s, 0, sizeof(*s)); + + camera_init(&s->rear, CAMERA_ID_IMX298, 20); + s->rear.transform = (mat3){{ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0, + }}; + + camera_init(&s->front, CAMERA_ID_OV8865, 10); + s->front.transform = (mat3){{ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0, + }}; +} + +void camera_autoexposure(CameraState *s, float grey_frac) {} + +void cameras_open(DualCameraState *s, VisionBuf *camera_bufs_rear, + VisionBuf *camera_bufs_focus, VisionBuf *camera_bufs_stats, + VisionBuf *camera_bufs_front) { + assert(camera_bufs_rear); + assert(camera_bufs_front); + int err; + + // LOG("*** open front ***"); + camera_open(&s->front, camera_bufs_front, false); + + // LOG("*** open rear ***"); + camera_open(&s->rear, camera_bufs_rear, true); +} + +void cameras_close(DualCameraState *s) { + camera_close(&s->rear); +} + +void cameras_run(DualCameraState *s) { + set_thread_name("frame_streaming"); + run_frame_stream(s); + cameras_close(s); +} diff --git a/selfdrive/visiond/cameras/camera_frame_stream.h b/selfdrive/visiond/cameras/camera_frame_stream.h new file mode 100644 index 000000000..6351a183d --- /dev/null +++ b/selfdrive/visiond/cameras/camera_frame_stream.h @@ -0,0 +1,56 @@ +#ifndef CAMERA_FRAME_STREAM_H +#define CAMERA_FRAME_STREAM_H + +#include + +#ifdef __APPLE__ +#include +#else +#include +#endif + +#include "common/mat.h" + +#include "buffering.h" +#include "common/visionbuf.h" +#include "camera_common.h" + +#define FRAME_BUF_COUNT 16 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct CameraState { + int camera_id; + CameraInfo ci; + int frame_size; + + VisionBuf *camera_bufs; + FrameMetadata camera_bufs_metadata[FRAME_BUF_COUNT]; + TBuffer camera_tb; + + int fps; + float digital_gain; + + mat3 transform; +} CameraState; + + +typedef struct DualCameraState { + int ispif_fd; + + CameraState rear; + CameraState front; +} DualCameraState; + +void cameras_init(DualCameraState *s); +void cameras_open(DualCameraState *s, VisionBuf *camera_bufs_rear, VisionBuf *camera_bufs_focus, VisionBuf *camera_bufs_stats, VisionBuf *camera_bufs_front); +void cameras_run(DualCameraState *s); +void cameras_close(DualCameraState *s); +void camera_autoexposure(CameraState *s, float grey_frac); +#ifdef __cplusplus +} // extern "C" +#endif + +#endif diff --git a/selfdrive/visiond/models/commonmodel.c b/selfdrive/visiond/models/commonmodel.c index 33aabd1ce..0369d16d5 100644 --- a/selfdrive/visiond/models/commonmodel.c +++ b/selfdrive/visiond/models/commonmodel.c @@ -66,134 +66,3 @@ float sigmoid(float input) { float softplus(float input) { return log1p(expf(input)); } - -void softmax(const float* input, float* output, size_t len) { - float max_val = -FLT_MAX; - for(int i = 0; i < len; i++) { - const float v = input[i]; - if( v > max_val ) { - max_val = v; - } - } - - float denominator = 0; - for(int i = 0; i < len; i++) { - float const v = input[i]; - float const v_exp = expf(v - max_val); - denominator += v_exp; - output[i] = v_exp; - } - - const float inv_denominator = 1. / denominator; - for(int i = 0; i < len; i++) { - output[i] *= inv_denominator; - } - -} - - -static cereal_ModelData_PathData_ptr path_to_cereal(struct capn_segment *cs, const PathData data) { - capn_list32 poly_ptr = capn_new_list32(cs, POLYFIT_DEGREE); - for (int i=0; im->addRecurrent(&s->output[OUTPUT_SIZE], TEMPORAL_SIZE); #endif +#ifdef DESIRE + s->desire = (float*)malloc(DESIRE_SIZE * sizeof(float)); + for (int i = 0; i < DESIRE_SIZE; i++) s->desire[i] = 0.0; + s->m->addDesire(s->desire, DESIRE_SIZE); +#endif // Build Vandermonde matrix for(int i = 0; i < MODEL_PATH_DISTANCE; i++) { @@ -53,7 +58,7 @@ void model_init(ModelState* s, cl_device_id device_id, cl_context context, int t ModelData model_eval_frame(ModelState* s, cl_command_queue q, cl_mem yuv_cl, int width, int height, - mat3 transform, void* sock) { + mat3 transform, void* sock, float *desire_in) { struct { float *path; float *left_lane; @@ -62,6 +67,12 @@ ModelData model_eval_frame(ModelState* s, cl_command_queue q, float *speed; } net_outputs = {NULL}; +#ifdef DESIRE + if (desire_in != NULL) { + for (int i = 0; i < DESIRE_SIZE; i++) s->desire[i] = desire_in[i]; + } +#endif + //for (int i = 0; i < OUTPUT_SIZE + TEMPORAL_SIZE; i++) { printf("%f ", s->output[i]); } printf("\n"); float *net_input_buf = model_input_prepare(&s->in, q, yuv_cl, width, height, transform); @@ -201,3 +212,57 @@ void poly_fit(float *in_pts, float *in_stds, float *out) { // Apply scale to output p = p.transpose() * scale.asDiagonal(); } + + +void fill_path(cereal::ModelData::PathData::Builder path, const PathData path_data) { + kj::ArrayPtr poly(&path_data.poly[0], ARRAYSIZE(path_data.poly)); + path.setPoly(poly); + path.setProb(path_data.prob); + path.setStd(path_data.std); +} + +void fill_lead(cereal::ModelData::LeadData::Builder lead, const LeadData lead_data) { + lead.setDist(lead_data.dist); + lead.setProb(lead_data.prob); + lead.setStd(lead_data.std); + lead.setRelY(lead_data.rel_y); + lead.setRelYStd(lead_data.rel_y_std); + lead.setRelVel(lead_data.rel_v); + lead.setRelVelStd(lead_data.rel_v_std); + lead.setRelA(lead_data.rel_a); + lead.setRelAStd(lead_data.rel_a_std); +} + +void model_publish(void* sock, uint32_t frame_id, + const ModelData data, uint64_t timestamp_eof) { + // make msg + capnp::MallocMessageBuilder msg; + cereal::Event::Builder event = msg.initRoot(); + event.setLogMonoTime(nanos_since_boot()); + + auto framed = event.initModel(); + framed.setFrameId(frame_id); + framed.setTimestampEof(timestamp_eof); + + kj::ArrayPtr speed(&data.speed[0], ARRAYSIZE(data.speed)); + framed.setSpeed(speed); + + + auto lpath = framed.initPath(); + fill_path(lpath, data.path); + auto left_lane = framed.initLeftLane(); + fill_path(left_lane, data.left_lane); + auto right_lane = framed.initRightLane(); + fill_path(right_lane, data.right_lane); + + auto lead = framed.initLead(); + fill_lead(lead, data.lead); + auto lead_future = framed.initLeadFuture(); + fill_lead(lead_future, data.lead_future); + + + // send message + auto words = capnp::messageToFlatArray(msg); + auto bytes = words.asBytes(); + zmq_send(sock, bytes.begin(), bytes.size(), ZMQ_DONTWAIT); + } diff --git a/selfdrive/visiond/models/driving.h b/selfdrive/visiond/models/driving.h index 966cf6947..c384d6ef4 100644 --- a/selfdrive/visiond/models/driving.h +++ b/selfdrive/visiond/models/driving.h @@ -3,25 +3,41 @@ // gate this here #define TEMPORAL +#define DESIRE + +#ifdef DESIRE + #define DESIRE_SIZE 8 +#endif #include "common/mat.h" #include "common/modeldata.h" +#include "common/util.h" #include "commonmodel.h" #include "runners/run.h" +#include "cereal/gen/cpp/log.capnp.h" +#include +#include + + typedef struct ModelState { ModelInput in; float *output; RunModel *m; +#ifdef DESIRE + float *desire; +#endif } ModelState; void model_init(ModelState* s, cl_device_id device_id, cl_context context, int temporal); ModelData model_eval_frame(ModelState* s, cl_command_queue q, cl_mem yuv_cl, int width, int height, - mat3 transform, void* sock); + mat3 transform, void* sock, float *desire_in); void model_free(ModelState* s); void poly_fit(float *in_pts, float *in_stds, float *out); +void model_publish(void* sock, uint32_t frame_id, + const ModelData data, uint64_t timestamp_eof); #endif diff --git a/selfdrive/visiond/models/monitoring.cc b/selfdrive/visiond/models/monitoring.cc index f6e47880f..959902b98 100644 --- a/selfdrive/visiond/models/monitoring.cc +++ b/selfdrive/visiond/models/monitoring.cc @@ -1,6 +1,7 @@ #include #include "monitoring.h" #include "common/mat.h" +#include "common/timing.h" #define MODEL_WIDTH 320 #define MODEL_HEIGHT 160 @@ -47,9 +48,32 @@ MonitoringResult monitoring_eval_frame(MonitoringState* s, cl_command_queue q, return ret; } +void monitoring_publish(void* sock, uint32_t frame_id, const MonitoringResult res) { + // make msg + capnp::MallocMessageBuilder msg; + cereal::Event::Builder event = msg.initRoot(); + event.setLogMonoTime(nanos_since_boot()); + + auto framed = event.initDriverMonitoring(); + framed.setFrameId(frame_id); + + kj::ArrayPtr face_orientation(&res.face_orientation[0], ARRAYSIZE(res.face_orientation)); + kj::ArrayPtr face_position(&res.face_position[0], ARRAYSIZE(res.face_position)); + framed.setFaceOrientation(face_orientation); + framed.setFacePosition(face_position); + framed.setFaceProb(res.face_prob); + framed.setLeftEyeProb(res.left_eye_prob); + framed.setRightEyeProb(res.right_eye_prob); + framed.setLeftBlinkProb(res.left_blink_prob); + framed.setRightBlinkProb(res.right_blink_prob); + + // send message + auto words = capnp::messageToFlatArray(msg); + auto bytes = words.asBytes(); + zmq_send(sock, bytes.begin(), bytes.size(), ZMQ_DONTWAIT); + } void monitoring_free(MonitoringState* s) { model_input_free(&s->in); delete s->m; } - diff --git a/selfdrive/visiond/models/monitoring.h b/selfdrive/visiond/models/monitoring.h index 2be96825f..49b910ef5 100644 --- a/selfdrive/visiond/models/monitoring.h +++ b/selfdrive/visiond/models/monitoring.h @@ -1,9 +1,14 @@ #ifndef MONITORING_H #define MONITORING_H +#include "common/util.h" #include "commonmodel.h" #include "runners/run.h" +#include "cereal/gen/cpp/log.capnp.h" +#include +#include + #ifdef __cplusplus extern "C" { #endif @@ -32,6 +37,7 @@ typedef struct MonitoringState { void monitoring_init(MonitoringState* s, cl_device_id device_id, cl_context context); MonitoringResult monitoring_eval_frame(MonitoringState* s, cl_command_queue q, cl_mem yuv_cl, int width, int height); +void monitoring_publish(void* sock, uint32_t frame_id, const MonitoringResult res); void monitoring_free(MonitoringState* s); #ifdef __cplusplus diff --git a/selfdrive/visiond/runners/runmodel.h b/selfdrive/visiond/runners/runmodel.h index 245f4c8df..d1563a61a 100644 --- a/selfdrive/visiond/runners/runmodel.h +++ b/selfdrive/visiond/runners/runmodel.h @@ -4,6 +4,7 @@ class RunModel { public: virtual void addRecurrent(float *state, int state_size) {} + virtual void addDesire(float *state, int state_size) {} virtual void execute(float *net_input_buf) {} }; diff --git a/selfdrive/visiond/runners/snpemodel.cc b/selfdrive/visiond/runners/snpemodel.cc index 15b3bcc31..ae69f76d6 100644 --- a/selfdrive/visiond/runners/snpemodel.cc +++ b/selfdrive/visiond/runners/snpemodel.cc @@ -86,18 +86,27 @@ SNPEModel::SNPEModel(const char *path, float *output, size_t output_size) { } void SNPEModel::addRecurrent(float *state, int state_size) { + recurrentBuffer = this->addExtra(state, state_size, 2); +} + +void SNPEModel::addDesire(float *state, int state_size) { + desireBuffer = this->addExtra(state, state_size, 1); +} + +std::unique_ptr SNPEModel::addExtra(float *state, int state_size, int idx) { // get input and output names const auto &strListi_opt = snpe->getInputTensorNames(); if (!strListi_opt) throw std::runtime_error("Error obtaining Input tensor names"); const auto &strListi = *strListi_opt; - const char *input_tensor_name = strListi.at(1); - printf("adding recurrent: %s\n", input_tensor_name); + const char *input_tensor_name = strListi.at(idx); + printf("adding index %d: %s\n", idx, input_tensor_name); zdl::DlSystem::UserBufferEncodingFloat userBufferEncodingFloat; zdl::DlSystem::IUserBufferFactory& ubFactory = zdl::SNPE::SNPEFactory::getUserBufferFactory(); - std::vector recurrentStrides = {state_size * sizeof(float), sizeof(float)}; - recurrentBuffer = ubFactory.createUserBuffer(state, state_size * sizeof(float), recurrentStrides, &userBufferEncodingFloat); - inputMap.add(input_tensor_name, recurrentBuffer.get()); + std::vector retStrides = {state_size * sizeof(float), sizeof(float)}; + auto ret = ubFactory.createUserBuffer(state, state_size * sizeof(float), retStrides, &userBufferEncodingFloat); + inputMap.add(input_tensor_name, ret.get()); + return ret; } void SNPEModel::execute(float *net_input_buf) { diff --git a/selfdrive/visiond/runners/snpemodel.h b/selfdrive/visiond/runners/snpemodel.h index 0a6e030f4..cd47a3ade 100644 --- a/selfdrive/visiond/runners/snpemodel.h +++ b/selfdrive/visiond/runners/snpemodel.h @@ -20,6 +20,7 @@ public: if (model_data) free(model_data); } void addRecurrent(float *state, int state_size); + void addDesire(float *state, int state_size); void execute(float *net_input_buf); private: uint8_t *model_data = NULL; @@ -36,8 +37,10 @@ private: std::unique_ptr outputBuffer; float *output; - // recurrent + // recurrent and desire + std::unique_ptr addExtra(float *state, int state_size, int idx); std::unique_ptr recurrentBuffer; + std::unique_ptr desireBuffer; }; #endif diff --git a/selfdrive/visiond/visiond.cc b/selfdrive/visiond/visiond.cc index a0cce70ab..53d1f8277 100644 --- a/selfdrive/visiond/visiond.cc +++ b/selfdrive/visiond/visiond.cc @@ -155,6 +155,8 @@ struct VisionState { int rgb_front_width, rgb_front_height, rgb_front_stride; VisionBuf rgb_front_bufs[UI_BUF_COUNT]; cl_mem rgb_front_bufs_cl[UI_BUF_COUNT]; + int front_meteringbox_xmin, front_meteringbox_xmax; + int front_meteringbox_ymin, front_meteringbox_ymax; ModelState model; ModelData model_bufs[UI_BUF_COUNT]; @@ -725,40 +727,27 @@ void* monitoring_thread(void *arg) { double t2 = millis_since_boot(); - // send driver monitoring packet + // set front camera metering target + if (res.face_prob > 0.4) { - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - - auto framed = event.initDriverMonitoring(); - framed.setFrameId(frame_data.frame_id); - - // junk 0s from legacy model - //kj::ArrayPtr descriptor_DEPRECATED(&res.descriptor_DEPRECATED[0], ARRAYSIZE(res.descriptor_DEPRECATED)); - //framed.setDescriptor(descriptor_DEPRECATED); - //framed.setStd(res.std_DEPRECATED); - // why not use this junk space for reporting inference time instead - // framed.setStdDEPRECATED(static_cast(t2-t1)); - - kj::ArrayPtr face_orientation(&res.face_orientation[0], ARRAYSIZE(res.face_orientation)); - kj::ArrayPtr face_position(&res.face_position[0], ARRAYSIZE(res.face_position)); - framed.setFaceOrientation(face_orientation); - framed.setFacePosition(face_position); - framed.setFaceProb(res.face_prob); - framed.setLeftEyeProb(res.left_eye_prob); - framed.setRightEyeProb(res.right_eye_prob); - framed.setLeftBlinkProb(res.left_blink_prob); - framed.setRightBlinkProb(res.right_blink_prob); - - - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(s->monitoring_sock_raw, bytes.begin(), bytes.size(), ZMQ_DONTWAIT); + int x_offset = s->rgb_front_width - 0.5 * s->rgb_front_height; + s->front_meteringbox_xmin = x_offset + (res.face_position[0] + 0.5) * (0.5 * s->rgb_front_height) - 72; + s->front_meteringbox_xmax = x_offset + (res.face_position[0] + 0.5) * (0.5 * s->rgb_front_height) + 72; + s->front_meteringbox_ymin = (res.face_position[1] + 0.5) * (s->rgb_front_height) - 72; + s->front_meteringbox_ymax = (res.face_position[1] + 0.5) * (s->rgb_front_height) + 72; + } + else // use default setting if no face + { + s->front_meteringbox_ymin = s->rgb_front_height * 0; + s->front_meteringbox_ymax = s->rgb_front_height * 2 / 3; + s->front_meteringbox_xmin = s->rgb_front_width * 3 / 5; + s->front_meteringbox_xmax = s->rgb_front_width; } - t2 = millis_since_boot(); + // send dm packet + monitoring_publish(s->monitoring_sock_raw, frame_data.frame_id, res); + //t2 = millis_since_boot(); //LOGD("monitoring process: %.2fms, from last %.2fms", t2-t1, t1-last); last = t1; } @@ -816,11 +805,26 @@ void* frontview_thread(void *arg) { if (cnt % 3 == 0) #endif { - // for driver autoexposure, use bottom right corner - const int y_start = s->rgb_front_height / 3; - const int y_end = s->rgb_front_height; - const int x_start = s->rgb_front_width * 2 / 3; - const int x_end = s->rgb_front_width; + // use driver face crop for AE + int x_start; + int x_end; + int y_start; + int y_end; + + if (s->front_meteringbox_xmax > 0) + { + x_start = s->front_meteringbox_xmin<0 ? 0:s->front_meteringbox_xmin; + x_end = s->front_meteringbox_xmax>=s->rgb_front_width ? s->rgb_front_width-1:s->front_meteringbox_xmax; + y_start = s->front_meteringbox_ymin<0 ? 0:s->front_meteringbox_ymin; + y_end = s->front_meteringbox_ymax>=s->rgb_front_height ? s->rgb_front_height-1:s->front_meteringbox_ymax; + } + else + { + y_start = s->rgb_front_height * 0; + y_end = s->rgb_front_height * 2 / 3; + x_start = s->rgb_front_width * 3 / 5; + x_end = s->rgb_front_width; + } uint32_t lum_binning[256] = {0,}; for (int y = y_start; y < y_end; ++y) { @@ -1007,10 +1011,10 @@ void* processing_thread(void *arg) { mt1 = millis_since_boot(); s->model_bufs[ui_idx] = model_eval_frame(&s->model, q, yuv_cl, s->yuv_width, s->yuv_height, - model_transform, img_sock_raw); + model_transform, img_sock_raw, NULL); mt2 = millis_since_boot(); - model_publish(model_sock_raw, frame_id, model_transform, s->model_bufs[ui_idx]); + model_publish(model_sock_raw, frame_id, s->model_bufs[ui_idx], frame_data.timestamp_eof); } @@ -1073,6 +1077,8 @@ void* processing_thread(void *arg) { posenetd.setTransStd(trans_std_vs); kj::ArrayPtr rot_std_vs(&s->posenet.output[9], 3); posenetd.setRotStd(rot_std_vs); + posenetd.setTimestampEof(frame_data.timestamp_eof); + posenetd.setFrameId(frame_id); auto words = capnp::messageToFlatArray(msg); auto bytes = words.asBytes();