diff --git a/README.md b/README.md index bdd695bd3c2a3b..f05c7886eb5d25 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ FrogPilot is a fully open-sourced fork of openpilot, featuring clear and concise ------ FrogPilot was last updated on: -**November 10th, 2024** +**November 23rd, 2024** Features ------ diff --git a/cereal/car.capnp b/cereal/car.capnp index cd3f35a621113c..62559a402b7817 100644 --- a/cereal/car.capnp +++ b/cereal/car.capnp @@ -84,6 +84,7 @@ struct CarEvent @0x9b1657f34caf3ad3 { startup @75; startupNoCar @76; startupNoControl @77; + startupNoSecOcKey @149; startupMaster @78; startupNoFw @104; fcw @79; @@ -548,6 +549,9 @@ struct CarParams { wheelSpeedFactor @63 :Float32; # Multiplier on wheels speeds to computer actual speeds + secOcRequired @74 :Bool; # Car requires SecOC message authentication to operate + secOcKeyAvailable @75 :Bool; # Stored SecOC key loaded from params + struct SafetyConfig { safetyModel @0 :SafetyModel; safetyParam @3 :UInt16; diff --git a/cereal/custom.capnp b/cereal/custom.capnp index 0fa098743f01b7..172b802f3b7bed 100644 --- a/cereal/custom.capnp +++ b/cereal/custom.capnp @@ -51,7 +51,7 @@ struct FrogPilotPlan @0x80ae746ee2596b11 { accelerationJerkStock @1 :Float32; adjustedCruise @2 :Float32; dangerJerk @3 :Float32; - desiredFollowDistance @4 :Float32; + desiredFollowDistance @4 :Int64; experimentalMode @5 :Bool; forcingStop @6 :Bool; forcingStopLength @7 :Float32; diff --git a/common/params.cc b/common/params.cc index bb50721f5a9d7a..eba32fab4fceb2 100644 --- a/common/params.cc +++ b/common/params.cc @@ -189,6 +189,7 @@ std::unordered_map keys = { {"RecordFrontLock", PERSISTENT}, // for the internal fleet {"ReplayControlsState", CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION}, {"RouteCount", PERSISTENT}, + {"SecOCKey", PERSISTENT | DONT_LOG}, {"SnoozeUpdate", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION}, {"SshEnabled", PERSISTENT}, {"TermsVersion", PERSISTENT}, @@ -253,9 +254,7 @@ std::unordered_map keys = { {"CENavigationIntersections", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"CENavigationLead", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"CENavigationTurns", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, - {"CertifiedHerbalistCalibrationParams", PERSISTENT}, {"CertifiedHerbalistDrives", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, - {"CertifiedHerbalistLiveTorqueParameters", PERSISTENT}, {"CertifiedHerbalistScore", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"CESignalSpeed", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"CESignalLaneDetection", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, @@ -294,9 +293,7 @@ std::unordered_map keys = { {"DisableCurveSpeedSmoothing", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"DisableOnroadUploads", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"DisableOpenpilotLongitudinal", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VEHICLES}, - {"DissolvedOxygenCalibrationParams", PERSISTENT}, {"DissolvedOxygenDrives", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, - {"DissolvedOxygenLiveTorqueParameters", PERSISTENT}, {"DissolvedOxygenScore", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"DistanceIconToDownload", PERSISTENT}, {"DisengageVolume", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, @@ -308,11 +305,10 @@ std::unordered_map keys = { {"DownloadableSounds", PERSISTENT}, {"DownloadableWheels", PERSISTENT}, {"DownloadAllModels", PERSISTENT}, - {"DriveRated", CLEAR_ON_ONROAD_TRANSITION}, + {"DragonRiderDrives", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, + {"DragonRiderScore", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"DriverCamera", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, - {"DuckAmigoCalibrationParams", PERSISTENT}, {"DuckAmigoDrives", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, - {"DuckAmigoLiveTorqueParameters", PERSISTENT}, {"DuckAmigoScore", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"DynamicPathWidth", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"DynamicPedalsOnUI", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, @@ -352,6 +348,7 @@ std::unordered_map keys = { {"HideMapIcon", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"HideMaxSpeed", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"HideSpeed", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, + {"HideSpeedLimit", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"HolidayThemes", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"HumanAcceleration", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"HumanFollowing", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, @@ -373,9 +370,7 @@ std::unordered_map keys = { {"LongitudinalMetrics", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"LongitudinalTune", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"LongPitch", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VEHICLES}, - {"LosAngelesCalibrationParams", PERSISTENT}, {"LosAngelesDrives", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, - {"LosAngelesLiveTorqueParameters", PERSISTENT}, {"LosAngelesScore", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"LoudBlindspotAlert", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"LowVoltageShutdown", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, @@ -385,7 +380,7 @@ std::unordered_map keys = { {"MapboxSecretKey", PERSISTENT}, {"MapDeceleration", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"MapGears", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, - {"MapsSelected", PERSISTENT | FROGPILOT_OTHER}, + {"MapsSelected", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_OTHER}, {"MapSpeedLimit", PERSISTENT}, {"MapStyle", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"MapTargetVelocities", PERSISTENT}, @@ -406,18 +401,13 @@ std::unordered_map keys = { {"NextMapSpeedLimit", PERSISTENT}, {"NewLongAPI", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VEHICLES}, {"NewLongAPIGM", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VEHICLES}, - {"NewToyotaTune", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VEHICLES}, {"NNFF", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"NNFFLite", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"NNFFModelName", CLEAR_ON_OFFROAD_TRANSITION}, {"NoLogging", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, - {"NorthDakotaCalibrationParams", PERSISTENT}, {"NorthDakotaDrives", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, - {"NorthDakotaLiveTorqueParameters", PERSISTENT}, {"NorthDakotaScore", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, - {"NotreDameCalibrationParams", PERSISTENT}, {"NotreDameDrives", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, - {"NotreDameLiveTorqueParameters", PERSISTENT}, {"NotreDameScore", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"NoUploads", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"NudgelessLaneChange", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, @@ -449,14 +439,10 @@ std::unordered_map keys = { {"QOLLongitudinal", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"QOLVisuals", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"RadarlessModels", PERSISTENT}, - {"RadicalTurtleCalibrationParams", PERSISTENT}, {"RadicalTurtleDrives", PERSISTENT | FROGPILOT_CONTROLS}, - {"RadicalTurtleLiveTorqueParameters", PERSISTENT}, {"RadicalTurtleScore", PERSISTENT | FROGPILOT_CONTROLS}, {"RandomEvents", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, - {"RecertifiedHerbalistCalibrationParams", PERSISTENT}, {"RecertifiedHerbalistDrives", PERSISTENT | FROGPILOT_CONTROLS}, - {"RecertifiedHerbalistLiveTorqueParameters", PERSISTENT}, {"RecertifiedHerbalistScore", PERSISTENT | FROGPILOT_CONTROLS}, {"RefuseVolume", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"RelaxedFollow", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, @@ -479,9 +465,7 @@ std::unordered_map keys = { {"ScreenTimeout", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"ScreenTimeoutOnroad", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"SearchInput", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_OTHER}, - {"SecretGoodOpenpilotCalibrationParams", PERSISTENT}, {"SecretGoodOpenpilotDrives", PERSISTENT | FROGPILOT_CONTROLS}, - {"SecretGoodOpenpilotLiveTorqueParameters", PERSISTENT}, {"SecretGoodOpenpilotScore", PERSISTENT | FROGPILOT_CONTROLS}, {"SetSpeedLimit", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"SetSpeedOffset", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, @@ -536,9 +520,9 @@ std::unordered_map keys = { {"SteerRatioStock", PERSISTENT}, {"StoppedTimer", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"TacoTune", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, + {"TestingSound", PERSISTENT}, {"TetheringEnabled", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_OTHER}, {"ThemeDownloadProgress", PERSISTENT}, - {"ThemeUpdated", PERSISTENT}, {"ToyotaDoors", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VEHICLES}, {"TrafficFollow", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"TrafficJerkAcceleration", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, @@ -562,9 +546,7 @@ std::unordered_map keys = { {"VoltSNG", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VEHICLES}, {"WarningImmediateVolume", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"WarningSoftVolume", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, - {"WD40CalibrationParams", PERSISTENT}, {"WD40Drives", PERSISTENT | FROGPILOT_CONTROLS}, - {"WD40LiveTorqueParameters", PERSISTENT}, {"WD40Score", PERSISTENT | FROGPILOT_CONTROLS}, {"WheelIcon", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"WheelSpeed", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, diff --git a/opendbc/toyota_new_mc_pt_generated.dbc b/opendbc/toyota_new_mc_pt_generated.dbc index 1a9a2a9a26c204..2b74b4651cbe87 100644 --- a/opendbc/toyota_new_mc_pt_generated.dbc +++ b/opendbc/toyota_new_mc_pt_generated.dbc @@ -197,7 +197,11 @@ BO_ 643 PRE_COLLISION: 7 DSU 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 + SG_ ETQLVSC : 15|16@0- (0.03125,0) [0|0] "Nm" XXX + SG_ ETQREAL : 31|16@0- (0.03125,0) [0|0] "Nm" SCS + SG_ ETQISC : 47|8@0+ (1,-192) [0|0] "Nm" XXX + SG_ GAS_PEDAL : 55|8@0+ (0.5,0) [0|0] "%" DS1,FCM + SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" DS1,FCM BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX diff --git a/opendbc/toyota_nodsu_pt_generated.dbc b/opendbc/toyota_nodsu_pt_generated.dbc index 5f106bfc1797ce..ef60ba9319682e 100644 --- a/opendbc/toyota_nodsu_pt_generated.dbc +++ b/opendbc/toyota_nodsu_pt_generated.dbc @@ -197,7 +197,11 @@ BO_ 643 PRE_COLLISION: 7 DSU 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 + SG_ ETQLVSC : 15|16@0- (0.03125,0) [0|0] "Nm" XXX + SG_ ETQREAL : 31|16@0- (0.03125,0) [0|0] "Nm" SCS + SG_ ETQISC : 47|8@0+ (1,-192) [0|0] "Nm" XXX + SG_ GAS_PEDAL : 55|8@0+ (0.5,0) [0|0] "%" DS1,FCM + SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" DS1,FCM BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX diff --git a/opendbc/toyota_rav4_prime_generated.dbc b/opendbc/toyota_rav4_prime_generated.dbc new file mode 100644 index 00000000000000..c2477c15182ddf --- /dev/null +++ b/opendbc/toyota_rav4_prime_generated.dbc @@ -0,0 +1,526 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +CM_ "Imported file _community.dbc starts here"; +BO_ 359 STEERING_IPAS_COMMA: 8 IPAS + SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX + SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX + SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX + SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX + SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX + SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; + +BO_ 512 GAS_COMMAND: 6 EON + SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR + SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [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+ (1,0) [0|1] "" EON + SG_ INTERCEPTOR_GAS2 : 23|16@0+ (1,0) [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" ; + +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + SG_ STATE : 23|4@0+ (1,0) [0|15] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS-P Toyotas. Learn more: https://github.com/RetroPilot/ocelot/tree/main/firmware/smart_dsu"; +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +VAL_ 767 STATE 7 "STATE_AEB_CTRL" 6 "FAULT_INVALID" 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; + + +CM_ "toyota_rav4_prime.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_: XXX DSU HCU EPS IPAS CGW BGM + +BO_ 15 SECOC_SYNCHRONIZATION: 8 XXX + SG_ TRIP_CNT : 7|16@0+ (1,0) [0|65535] "" XXX + SG_ RESET_CNT : 23|20@0+ (1,0) [0|65535] "" XXX + SG_ AUTHENTICATOR : 35|28@0+ (1,0) [0|268435455] "" XXX + +BO_ 37 STEER_ANGLE_SENSOR: 8 XXX + SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX + SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX + SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX + +BO_ 170 WHEEL_SPEEDS: 8 XXX + SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "km/h" XXX + SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "km/h" XXX + SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "km/h" XXX + SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "km/h" XXX + +BO_ 257 BRAKE_MODULE: 8 XXX + SG_ BRAKE_PRESSED : 3|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_PRESSURE_1 : 31|8@0+ (1,0) [0|15] "" XXX + SG_ BRAKE_PRESSURE_2 : 61|6@0+ (1,0) [0|63] "" XXX + +BO_ 278 GAS_PEDAL: 8 XXX + SG_ GAS_PEDAL_ACC : 7|8@0+ (0.005,0) [0|255] "" XXX + SG_ GAS_PEDAL_USER : 15|8@0+ (0.005,0) [0|255] "" XXX + SG_ AUTHENTICATOR : 35|28@0+ (1,0) [0|268435455] "" XXX + SG_ RESET_FLAG : 37|2@0+ (1,0) [0|3] "" XXX + SG_ MSG_CNT_LOWER : 39|2@0+ (1,0) [0|3] "" XXX + +BO_ 295 GEAR_PACKET_HYBRID: 8 XXX + SG_ CAR_MOVEMENT : 25|10@0- (1,0) [0|255] "" XXX + SG_ GEAR : 47|4@0+ (1,0) [0|15] "" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 305 STEERING_LTA_2: 8 XXX + SG_ STEER_REQUEST_2 : 0|1@0+ (1,0) [0|1] "" XXX + SG_ STEER_REQUEST : 3|1@0+ (1,0) [0|1] "" XXX + SG_ COUNTER : 13|6@0+ (1,0) [0|63] "" XXX + SG_ STEER_ANGLE_CMD : 23|16@0- (0.0573,0) [0|65535] "" XXX + SG_ AUTHENTICATOR : 35|28@0+ (1,0) [0|268435455] "" XXX + SG_ RESET_FLAG : 37|2@0+ (1,0) [0|3] "" XXX + SG_ MSG_CNT_LOWER : 39|2@0+ (1,0) [0|3] "" XXX + +BO_ 353 DSU_SPEED: 7 XXX + SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "km/h" XXX + +BO_ 374 PCM_CRUISE: 8 XXX + SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX + SG_ CRUISE_STATE : 31|4@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 375 PCM_CRUISE_3: 8 XXX + SG_ NEW_SIGNAL_1 : 7|16@0- (1,0) [0|65535] "" XXX + SG_ NEW_SIGNAL_4 : 16|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_6 : 19|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_7 : 21|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_5 : 22|1@0+ (1,0) [0|1] "" XXX + SG_ GAS_RELEASED : 30|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_2 : 31|1@0+ (1,0) [0|1] "" XXX + SG_ AUTHENTICATOR : 35|28@0+ (1,0) [0|268435455] "" XXX + SG_ RESET_FLAG : 37|2@0+ (1,0) [0|3] "" XXX + SG_ MSG_CNT_LOWER : 39|2@0+ (1,0) [0|3] "" XXX + +BO_ 387 ACC_CONTROL_2: 8 XXX + SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s^2" HCU + SG_ AUTHENTICATOR : 35|28@0+ (1,0) [0|268435455] "" XXX + SG_ RESET_FLAG : 37|2@0+ (1,0) [0|3] "" XXX + SG_ MSG_CNT_LOWER : 39|2@0+ (1,0) [0|3] "" XXX + +BO_ 401 STEERING_LTA: 8 XXX + SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX + SG_ COUNTER : 6|6@0+ (1,0) [0|255] "" XXX + SG_ SETME_X1 : 7|1@0+ (1,0) [0|1] "" XXX + SG_ STEER_ANGLE_CMD : 15|16@0- (0.0573,0) [-540|540] "" XXX + SG_ STEER_REQUEST_2 : 25|1@0+ (1,0) [0|1] "" XXX + SG_ LKA_ACTIVE : 26|1@0+ (1,0) [0|1] "" XXX + SG_ SETME_X3 : 29|2@0+ (1,0) [0|3] "" XXX + SG_ CLEAR_HOLD_STEERING_ALERT : 30|1@0+ (1,0) [0|1] "" XXX + SG_ PERCENTAGE : 39|8@0+ (1,0) [0|255] "" XXX + SG_ TORQUE_WIND_DOWN : 47|8@0+ (1,0) [0|255] "" XXX + SG_ ANGLE : 55|8@0- (0.5,0) [0|255] "" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 418 CRUISE_RELATED: 8 XXX + SG_ CRUISE_ACTIVE : 7|1@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 467 PCM_CRUISE_2: 8 XXX + SG_ BRAKE_PRESSED : 3|1@0+ (1,0) [0|1] "" XXX + SG_ PCM_FOLLOW_DISTANCE : 12|2@0+ (1,0) [0|3] "" XXX + SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "" XXX + SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX + SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "km/h" XXX + SG_ ACC_FAULTED : 47|1@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 608 STEER_TORQUE_SENSOR: 8 XXX + SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX + SG_ STEER_ANGLE_INITIALIZING : 3|1@0+ (1,0) [0|1] "" XXX + SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX + SG_ STEER_TORQUE_EPS : 47|16@0- (1,0) [-32768|32767] "" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 610 EPS_STATUS: 8 EPS + SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX + SG_ LTA_STATE : 15|5@0+ (1,0) [0|31] "" XXX + SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX + SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 643 PRE_COLLISION: 8 DSU + SG_ AUTHENTICATOR : 35|28@0+ (1,0) [0|268435455] "" XXX + SG_ RESET_FLAG : 37|2@0+ (1,0) [0|3] "" XXX + SG_ MSG_CNT_LOWER : 39|2@0+ (1,0) [0|3] "" XXX + +BO_ 740 STEERING_LKA: 8 XXX + SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX + SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX + SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX + SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX + SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX + SG_ AUTHENTICATOR : 35|28@0+ (1,0) [0|268435455] "" XXX + SG_ RESET_FLAG : 37|2@0+ (1,0) [0|3] "" XXX + SG_ MSG_CNT_LOWER : 39|2@0+ (1,0) [0|3] "" XXX + +BO_ 742 LEAD_INFO: 8 DSU + SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU + SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU + +BO_ 835 ACC_CONTROL: 8 DSU + SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s^2" HCU + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" XXX + SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX + SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX + SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU + SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU + SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU + SG_ ITS_CONNECT_LEAD : 39|8@0+ (1,0) [0|1] "" Vector__XXX + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 836 PRE_COLLISION_2: 8 DSU + SG_ AUTHENTICATOR : 35|28@0+ (1,0) [0|268435455] "" XXX + SG_ RESET_FLAG : 37|2@0+ (1,0) [0|3] "" XXX + SG_ MSG_CNT_LOWER : 39|2@0+ (1,0) [0|3] "" XXX + +BO_ 881 LTA_RELATED: 8 FCM + SG_ GAS_PEDAL : 15|8@0+ (0.005,0) [0|1] "" XXX + SG_ STEER_ANGLE : 23|16@0- (0.0573,0) [-500|500] "" XXX + SG_ TURN_SIGNALS : 35|2@0+ (1,0) [0|3] "" XXX + SG_ UNKNOWN_2 : 58|1@0+ (1,0) [0|1] "" XXX + SG_ LDA_SA_TOGGLE : 59|1@0+ (1,0) [0|1] "" XXX + SG_ LTA_STEER_REQUEST : 60|1@0+ (1,0) [0|1] "" XXX + SG_ UNKNOWN : 61|1@0+ (1,0) [0|1] "" XXX + SG_ STEERING_PRESSED : 63|1@0+ (1,0) [0|1] "" XXX + +BO_ 921 PCM_CRUISE_SM: 8 XXX + SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX + SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX + SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX + SG_ TEMP_ACC_FAULTED : 15|1@0+ (1,0) [0|1] "" XXX + SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX + +BO_ 951 ESP_CONTROL: 8 ESP + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX + SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1014 BSM: 8 XXX + SG_ L_ADJACENT : 0|1@0+ (1,0) [0|1] "" XXX + SG_ R_ADJACENT : 1|1@0+ (1,0) [0|1] "" XXX + SG_ ADJACENT_ENABLED : 7|1@0+ (1,0) [0|1] "" XXX + SG_ L_APPROACHING : 8|1@0+ (1,0) [0|1] "" XXX + SG_ R_APPROACHING : 10|1@0+ (1,0) [0|1] "" XXX + SG_ APPROACHING_ENABLED : 15|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX + +BO_ 1041 PCS_HUD: 8 DSU + SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX + SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX + SG_ PCS_DUST : 34|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_TEMP : 35|1@0+ (1,0) [0|0] "" XXX + SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX + SG_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_DUST2 : 41|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_TEMP2 : 42|1@0+ (1,0) [0|0] "" XXX + SG_ FRD_ADJ : 53|3@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 55|8@0+ (1,0) [0|1] "" XXX + +BO_ 1042 LKAS_HUD: 8 DSU + SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX + SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX + SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX + SG_ LKAS_STATUS : 7|2@0+ (1,0) [0|3] "" XXX + SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX + SG_ LDW_EXIST : 10|1@0+ (1,0) [0|1] "" XXX + SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX + SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LDA_UNAVAILABLE_QUIET : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX + SG_ LDA_UNAVAILABLE : 16|1@0+ (1,0) [0|1] "" XXX + SG_ LDA_SENSITIVITY : 18|2@0+ (1,0) [0|3] "" XXX + SG_ LDA_SA_TOGGLE : 20|2@0+ (1,0) [0|3] "" XXX + SG_ LDA_MESSAGES : 23|3@0+ (1,0) [0|1] "" XXX + SG_ LDA_ON_MESSAGE : 31|2@0+ (1,0) [0|3] "" XXX + SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX + SG_ SET_ME_X01 : 42|1@0+ (1,0) [0|1] "" XXX + SG_ LANE_SWAY_TOGGLE : 43|1@0+ (1,0) [0|1] "" XXX + SG_ LANE_SWAY_SENSITIVITY : 45|2@0+ (1,0) [0|3] "" XXX + SG_ TAKE_CONTROL : 46|1@0+ (1,0) [0|1] "" XXX + SG_ LDA_FRONT_CAMERA_BLOCKED : 47|1@0+ (1,0) [0|1] "" XXX + SG_ LANE_SWAY_BUZZER : 50|2@0+ (1,0) [0|0] "" XXX + SG_ LANE_SWAY_FLD : 53|3@0+ (1,0) [0|7] "" XXX + SG_ LANE_SWAY_WARNING : 55|2@0+ (1,0) [0|3] "" XXX + SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX + +BO_ 1044 AUTO_HIGH_BEAM: 8 FCM + SG_ AHB_DUTY : 47|8@0+ (0.5,0) [0|0] "%" Vector__XXX + SG_ C_AHB : 51|4@0+ (1,0) [0|0] "" Vector__XXX + SG_ F_AHB : 55|4@0+ (1,0) [0|0] "" Vector__XXX + +BO_ 1161 RSA1: 8 FCM + SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX + SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX + SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX + SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "km/h" XXX + SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX + SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX + SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX + SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX + SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX + SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX + SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX + SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX + SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX + +BO_ 1162 RSA2: 8 FCM + SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX + SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX + SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX + SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX + SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX + SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX + SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX + SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX + SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX + SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX + SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX + SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX + SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX + SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX + +BO_ 1163 RSA3: 8 FCM + SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX + SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX + SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX + SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX + SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX + SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX + SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX + SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX + SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX + +BO_ 1552 BODY_CONTROL_STATE_2: 8 XXX + SG_ UI_SPEED : 23|8@0+ (1,0) [0|255] "" XXX + SG_ METER_SLIDER_BRIGHTNESS_PCT : 30|7@0+ (1,0) [12|100] "%" XXX + SG_ METER_SLIDER_LOW_BRIGHTNESS : 37|1@0+ (1,0) [0|1] "" XXX + SG_ METER_SLIDER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ UNITS : 63|3@0+ (1,0) [1|4] "" XXX + +BO_ 1553 UI_SETTING: 8 XXX + SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX + SG_ ODOMETER : 39|32@0+ (1,0) [0|1048575] "" XXX + +BO_ 1556 BLINKERS_STATE: 8 XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX + SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + +BO_ 1568 BODY_CONTROL_STATE: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX + SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX + +BO_ 1570 LIGHT_STALK: 8 SCM + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX + SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX + +BO_ 1571 CERTIFICATION_ECU: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX + +BO_ 1592 DOOR_LOCKS: 8 XXX + SG_ LOCK_STATUS_CHANGED : 15|1@0+ (1,0) [0|1] "" XXX + SG_ LOCK_STATUS : 20|1@0+ (1,0) [0|1] "" XXX + SG_ LOCKED_VIA_KEYFOB : 23|1@0+ (1,0) [0|1] "" XXX + +CM_ SG_ 37 STEER_RATE "factor is tbd"; +CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; +CM_ SG_ 305 STEER_ANGLE_CMD "Used in place of STEERING_LTA.STEER_ANGLE_CMD on SecOC cars"; +CM_ SG_ 387 ACCEL_CMD "Used in place of ACC_CONTROL.ACCEL_CMD on SecOC cars"; +CM_ SG_ 401 STEER_REQUEST "enable bit for steering, 1 to steer, 0 to not"; +CM_ SG_ 401 SETME_X1 "usually 1, seen at 0 on some South American Corollas indicating lack of stock Lane Tracing Assist"; +CM_ SG_ 401 STEER_ANGLE_CMD "desired angle, OEM steers up to 95 degrees, no angle limit but torque will bottom out"; +CM_ SG_ 401 STEER_REQUEST_2 "enable bit for steering, 1 to steer, 0 to not"; +CM_ SG_ 401 LKA_ACTIVE "1 when using LTA for LKA"; +CM_ SG_ 401 SETME_X3 "almost completely correlates with Toyota Safety Sense version, but may instead describe max torque when using LTA. if TSS 2.5 or 2022 RAV4, this is always 1. if TSS 2.0 this is always 3 (or 0 on Alphard, Highlander, NX)"; +CM_ SG_ 401 CLEAR_HOLD_STEERING_ALERT "set to 1 when user clears LKAS_HUD->LDA_ALERT ('Hold Steering') by applying torque to steering wheel"; +CM_ SG_ 401 PERCENTAGE "driver override percentage (0-100), very close to steeringPressed in OP"; +CM_ SG_ 401 TORQUE_WIND_DOWN "used to wind down torque on user override"; +CM_ SG_ 401 ANGLE "angle of car relative to lane center on LTA camera"; +CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; +CM_ SG_ 467 SET_SPEED "43 km/h are shown as 28 mph, so conversion isn't perfect"; +CM_ SG_ 467 ACC_FAULTED "1 when ACC is faulted and the PCM disallows engagement"; +CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; +CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; +CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 DISTANCE "Cycle through ACC following distance from long, mid, short when set to 1"; +CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ITS_CONNECT_LEAD "Displayed when lead car is capable of ITS Connect"; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; +CM_ SG_ 881 GAS_PEDAL "not set on all cars, only seen on TSS 2.5 Camry Hybrid so far"; +CM_ SG_ 881 STEER_ANGLE "matches STEER_TORQUE_SENSOR->STEER_ANGLE"; +CM_ SG_ 881 TURN_SIGNALS "flipped on some cars"; +CM_ SG_ 881 LDA_SA_TOGGLE "not applicable for all cars"; +CM_ SG_ 881 LTA_STEER_REQUEST "only applicable for TSS 2.5: matches STEERING_LTA->STEER_REQUEST"; +CM_ SG_ 881 UNKNOWN "related to steering wheel angle"; +CM_ SG_ 881 STEERING_PRESSED "only applicable for TSS 2.5: low sensitivity steering wheel pressed by driver signal"; +CM_ SG_ 921 TEMP_ACC_FAULTED "1 when the UI is displaying or playing fault-related alerts or sounds. Also 1 when pressing main on."; +CM_ SG_ 921 UI_SET_SPEED "set speed shown in the vehicle's UI with the vehicle's unit"; +CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; +CM_ SG_ 1014 L_ADJACENT "vehicle adjacent left side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; +CM_ SG_ 1014 R_ADJACENT "vehicle adjacent right side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; +CM_ SG_ 1014 ADJACENT_ENABLED "when BSM is enabled in settings, this is on along with APPROACHING_ENABLED. this controls bsm alert visibility"; +CM_ SG_ 1014 L_APPROACHING "vehicle approaching from left side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; +CM_ SG_ 1014 R_APPROACHING "vehicle approaching from right side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; +CM_ SG_ 1014 APPROACHING_ENABLED "when BSM is enabled in settings, this is on along with ADJACENT_ENABLED. this controls bsm alert visibility"; +CM_ SG_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_DUST "alert: Front Camera Low Visibility Unavailable See Owner's Manual"; +CM_ SG_ 1041 PCS_TEMP "alert: Front Camera Out of Temperature Range Unavailable Wait until Normal Temperature"; +CM_ SG_ 1041 PCS_DUST2 "alert: Pre-Collision System Radar Sensor Blocked Unavailable Clean Radar Sensor"; +CM_ SG_ 1041 PCS_TEMP2 "alert: Pre-Collision System Out of Temperature Range Unavailable See Owner's Manual"; +CM_ SG_ 1041 FRD_ADJ "alert: ERROR ADJUSTING FRONT RADAR BEAM"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; +CM_ SG_ 1042 LDW_EXIST "Unclear what this is, it's usually set to 0"; +CM_ SG_ 1042 LDA_UNAVAILABLE_QUIET "LDA toggles and sensitivity settings are greyed out if set to 1"; +CM_ SG_ 1042 LDA_SENSITIVITY "LDA Sensitivity"; +CM_ SG_ 1042 LDA_SA_TOGGLE "LDA Steering Assist Toggle"; +CM_ SG_ 1042 LDA_MESSAGES "Various LDA Messages"; +CM_ SG_ 1042 LDA_ON_MESSAGE "Display LDA Turned ON message"; +CM_ SG_ 1042 REPEATED_BEEPS "LDA audible warning"; +CM_ SG_ 1042 SET_ME_X01 "empty bit on leaked dbc, always set to 1 during normal operations"; +CM_ SG_ 1042 LANE_SWAY_TOGGLE "Lane Sway Warning System SWS Switch"; +CM_ SG_ 1042 TAKE_CONTROL "Please Control Steering Wheel warning"; +CM_ SG_ 1042 LDA_FRONT_CAMERA_BLOCKED "originally LDAFCVB, LDA related settings are greyed out if set to 1"; +CM_ SG_ 1042 LANE_SWAY_BUZZER "Similar to TWO_BEEPS"; +CM_ SG_ 1042 LANE_SWAY_FLD "Unknown signal for Lane Sway Warning System, set to 7 on stock system when SWS is enabled, 0 when SWS is disabled"; +CM_ SG_ 1042 LANE_SWAY_WARNING "Lane Sway Warning System Triggered"; +CM_ SG_ 1042 SET_ME_X02 "empty bit on leaked dbc, always set to 2 during normal operations"; +CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; +CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; +CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; +CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; +CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; +CM_ SG_ 1163 OVSPNTM "always 3"; +CM_ SG_ 1163 NTLVLSPD "always 3"; +CM_ SG_ 1163 OTSGNNTM "always 3"; +CM_ SG_ 1163 TSRMSW "always 1"; +CM_ SG_ 1163 TSREQPD "always 1"; +CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; +CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; +CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; +CM_ SG_ 1163 TSRSPU "always 1"; +CM_ SG_ 1552 UI_SPEED "Does not appear to match dash"; +CM_ SG_ 1552 METER_SLIDER_BRIGHTNESS_PCT "Combination display brightness setting, scales from 12 per cent to 100 per cent, reflects combination meter settings only, not linked with headlight state"; +CM_ SG_ 1552 METER_SLIDER_LOW_BRIGHTNESS "Combination display low brightness mode, also controls footwell lighting"; +CM_ SG_ 1552 METER_SLIDER_DIMMED "Combination display slider not at max, reflects combination meter settings only, not linked with headlight state"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; +CM_ SG_ 1592 LOCK_STATUS_CHANGED "1 on rising edge of lock/unlocking"; +CM_ SG_ 1592 LOCK_STATUS "The next 3 bits always seem to follow this signal."; +CM_ SG_ 1592 LOCKED_VIA_KEYFOB "1 for as long as car is locked with key fob or door handle touch"; +VAL_ 295 GEAR 0 "P" 1 "R" 2 "N" 3 "D" 4 "B"; +VAL_ 401 SETME_X3 3 "TSS 2.0" 1 "TSS 2.5 or 2022 RAV4" 0 "TSS 2.0 on Alphard, Highlander, NX"; +VAL_ 467 PCM_FOLLOW_DISTANCE 1 "far" 2 "medium" 3 "close"; +VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; +VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; +VAL_ 610 LTA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 3 "lta_missing_unavailable" 1 "standby"; +VAL_ 610 LKA_STATE 25 "temporary_fault" 17 "permanent_fault" 11 "lka_missing_unavailable2" 9 "temporary_fault2" 5 "active" 3 "lka_missing_unavailable" 1 "standby"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; +VAL_ 1042 BARRIERS 3 "left" 2 "right" 1 "both" 0 "none"; +VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; +VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; +VAL_ 1042 LKAS_STATUS 1 "on" 0 "off"; +VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; +VAL_ 1042 LDA_SENSITIVITY 2 "standard" 1 "high" 0 "undefined"; +VAL_ 1042 LDA_SA_TOGGLE 2 "steering assist off" 1 "steering assist on"; +VAL_ 1042 LDA_MESSAGES 4 "lda unavailable at this speed" 1 "lda unavailable below approx 50km/h" 0 "ok"; +VAL_ 1042 LDA_ON_MESSAGE 2 "Lane Departure Alert Turned ON, Steering Assist Inactive" 1 "Lane Departure Alert Turned ON, Steering Assist Active" 0 "clear"; +VAL_ 1042 TAKE_CONTROL 1 "take control" 0 "ok"; +VAL_ 1042 LDA_FRONT_CAMERA_BLOCKED 1 "lda unavailable" 0 "ok"; +VAL_ 1042 LANE_SWAY_BUZZER 3 "ok" 2 "beep twice" 1 "beep twice" 0 "ok"; +VAL_ 1042 LANE_SWAY_WARNING 3 "ok" 2 "orange please take a break" 1 "prompt would you like to take a break" 0 "ok"; +VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; +VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; +VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; +VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; +VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; +VAL_ 1552 METER_SLIDER_LOW_BRIGHTNESS 1 "Low brightness mode, footwell lights off" 0 "Normal mode, footwell lights on"; +VAL_ 1552 METER_SLIDER_DIMMED 1 "Dimmed" 0 "Not Dimmed"; +VAL_ 1552 UNITS 1 "km (km/L)" 2 "km (L/100km)" 3 "miles (MPG US)" 4 "miles (MPG Imperial)"; +VAL_ 1553 UNITS 1 "km" 2 "miles"; +VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; +VAL_ 1592 LOCK_STATUS 0 "locked" 1 "unlocked"; diff --git a/opendbc/toyota_tnga_k_pt_generated.dbc b/opendbc/toyota_tnga_k_pt_generated.dbc index 14c1d7f40f9d7e..7f99d387326126 100644 --- a/opendbc/toyota_tnga_k_pt_generated.dbc +++ b/opendbc/toyota_tnga_k_pt_generated.dbc @@ -197,7 +197,11 @@ BO_ 643 PRE_COLLISION: 7 DSU 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 + SG_ ETQLVSC : 15|16@0- (0.03125,0) [0|0] "Nm" XXX + SG_ ETQREAL : 31|16@0- (0.03125,0) [0|0] "Nm" SCS + SG_ ETQISC : 47|8@0+ (1,-192) [0|0] "Nm" XXX + SG_ GAS_PEDAL : 55|8@0+ (0.5,0) [0|0] "%" DS1,FCM + SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" DS1,FCM BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX diff --git a/selfdrive/car/body/interface.py b/selfdrive/car/body/interface.py index 30acfd4a1c0a36..c5e265496d36df 100644 --- a/selfdrive/car/body/interface.py +++ b/selfdrive/car/body/interface.py @@ -7,7 +7,7 @@ class CarInterface(CarInterfaceBase): @staticmethod - def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params): + def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs): ret.notCar = True ret.carName = "body" ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.body)] diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py index 08013593fd4d42..c9f30f6e3de616 100644 --- a/selfdrive/car/car_helpers.py +++ b/selfdrive/car/car_helpers.py @@ -14,7 +14,6 @@ import cereal.messaging as messaging import openpilot.system.sentry as sentry from openpilot.selfdrive.car import gen_empty_fingerprint -from openpilot.system.version import get_build_metadata FRAME_FINGERPRINT = 100 # 1s @@ -188,7 +187,7 @@ def get_car_interface(CP): return CarInterface(CP, CarController, CarState) -def get_car(logcan, sendcan, disable_openpilot_long, experimental_long_allowed, params, num_pandas=1): +def get_car(logcan, sendcan, disable_openpilot_long, experimental_long_allowed, params, num_pandas=1, frogpilot_toggles=None): car_model = params.get("CarModel", encoding='utf-8') force_fingerprint = params.get_bool("ForceFingerprint") @@ -204,7 +203,7 @@ def get_car(logcan, sendcan, disable_openpilot_long, experimental_long_allowed, params.put_nonblocking("CarMake", candidate.split('_')[0].title()) params.put_nonblocking("CarModel", candidate) - if get_build_metadata().channel == "FrogPilot-Development" and params.get("DongleId", encoding='utf-8') != "FrogsGoMoo": + if frogpilot_toggles.block_user: candidate = "MOCK" threading.Thread(target=sentry.capture_fingerprint, args=(candidate, params, True,)).start() elif not params.get_bool("FingerprintLogged"): diff --git a/selfdrive/car/card.py b/selfdrive/car/card.py index d66165474a1514..6e38b918ff59b7 100755 --- a/selfdrive/car/card.py +++ b/selfdrive/car/card.py @@ -10,14 +10,14 @@ from openpilot.common.params import Params from openpilot.common.realtime import config_realtime_process, Priority, Ratekeeper, DT_CTRL +from openpilot.common.swaglog import cloudlog from openpilot.selfdrive.pandad import can_list_to_can_capnp from openpilot.selfdrive.car.car_helpers import get_car, get_one_can from openpilot.selfdrive.car.interfaces import CarInterfaceBase from openpilot.selfdrive.controls.lib.events import Events -from openpilot.selfdrive.frogpilot.frogpilot_utilities import update_frogpilot_toggles -from openpilot.selfdrive.frogpilot.frogpilot_variables import get_frogpilot_toggles +from openpilot.selfdrive.frogpilot.frogpilot_variables import get_frogpilot_toggles, update_frogpilot_toggles REPLAY = "REPLAY" in os.environ @@ -50,7 +50,7 @@ def __init__(self, CI=None): num_pandas = len(messaging.recv_one_retry(self.sm.sock['pandaStates']).pandaStates) disable_openpilot_long = self.params.get_bool("DisableOpenpilotLongitudinal") experimental_long_allowed = self.params.get_bool("ExperimentalLongitudinalEnabled") - self.CI, self.CP = get_car(self.can_sock, self.pm.sock['sendcan'], disable_openpilot_long, experimental_long_allowed, self.params, num_pandas) + self.CI, self.CP = get_car(self.can_sock, self.pm.sock['sendcan'], disable_openpilot_long, experimental_long_allowed, self.params, num_pandas, get_frogpilot_toggles()) else: self.CI, self.CP = CI, CI.CP @@ -70,6 +70,18 @@ def __init__(self, CI=None): safety_config.safetyModel = car.CarParams.SafetyModel.noOutput self.CP.safetyConfigs = [safety_config] + if self.CP.secOcRequired and not self.params.get_bool("IsReleaseBranch"): + secoc_key = self.params.get("SecOCKey", encoding='utf8') + if secoc_key is not None: + saved_secoc_key = bytes.fromhex(secoc_key.strip()) + if len(saved_secoc_key) == 16: + self.CP.secOcKeyAvailable = True + self.CI.CS.secoc_key = saved_secoc_key + if controller_available: + self.CI.CC.secoc_key = saved_secoc_key + else: + cloudlog.warning("Saved SecOC key is invalid") + # Write previous route's CarParams prev_cp = self.params.get("CarParamsPersistent") if prev_cp is not None: @@ -81,9 +93,9 @@ def __init__(self, CI=None): self.rk = Ratekeeper(100, print_delay_threshold=None) # FrogPilot variables - self.frogpilot_toggles = get_frogpilot_toggles(True) + self.frogpilot_toggles = get_frogpilot_toggles() - if self.params.get_bool("AlwaysOnLateral"): + if self.frogpilot_toggles.always_on_lateral: self.CP.alternativeExperience |= ALTERNATIVE_EXPERIENCE.ALWAYS_ON_LATERAL self.CP.alternativeExperience |= ALTERNATIVE_EXPERIENCE.DISABLE_DISENGAGE_ON_GAS diff --git a/selfdrive/car/chrysler/interface.py b/selfdrive/car/chrysler/interface.py index 27e6bf801c0b08..e3e76433aa7013 100755 --- a/selfdrive/car/chrysler/interface.py +++ b/selfdrive/car/chrysler/interface.py @@ -11,7 +11,7 @@ class CarInterface(CarInterfaceBase): @staticmethod - def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params): + def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs): ret.carName = "chrysler" # radar parsing needs some work, see https://github.com/commaai/openpilot/issues/26842 diff --git a/selfdrive/car/ford/interface.py b/selfdrive/car/ford/interface.py index 4a4e1782514900..15ecb4bbf0b0bf 100644 --- a/selfdrive/car/ford/interface.py +++ b/selfdrive/car/ford/interface.py @@ -14,7 +14,7 @@ class CarInterface(CarInterfaceBase): @staticmethod - def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params): + def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs): ret.carName = "ford" ret.dashcamOnly = False diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index d7c2696986c6f7..337f268523c71c 100644 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -12,6 +12,8 @@ from openpilot.selfdrive.car.interfaces import CarInterfaceBase, TorqueFromLateralAccelCallbackType, FRICTION_THRESHOLD, LatControlInputs, NanoFFModel from openpilot.selfdrive.controls.lib.drive_helpers import get_friction +from openpilot.selfdrive.frogpilot.frogpilot_variables import params + ButtonType = car.CarState.ButtonEvent.Type FrogPilotButtonType = custom.FrogPilotCarState.ButtonEvent.Type EventName = car.CarEvent.EventName @@ -94,7 +96,7 @@ def torque_from_lateral_accel(self) -> TorqueFromLateralAccelCallbackType: return self.torque_from_lateral_accel_linear @staticmethod - def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params): + def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs): use_new_api = params.get_bool("NewLongAPIGM") ret.carName = "gm" diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index f5d4f8a6e3e61f..253e44dc259d07 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -35,7 +35,7 @@ def get_pid_accel_limits(CP, current_speed, cruise_speed): return CarControllerParams.NIDEC_ACCEL_MIN, interp(current_speed, ACCEL_MAX_BP, ACCEL_MAX_VALS) @staticmethod - def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params): + def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs): ret.carName = "honda" CAN = CanBus(ret, fingerprint) diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 0de21000304a72..94f5950fff97d6 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -64,11 +64,9 @@ def calculate_speed_limit(self, cp, cp_cam): speed_limit_bus = cp if self.CP.flags & HyundaiFlags.CANFD_HDA2 else cp_cam return speed_limit_bus.vl["CLUSTER_SPEED_LIMIT"]["SPEED_LIMIT_1"] else: - if self.CP.flags & HyundaiFlags.LKAS12: - speed_limit = cp_cam.vl["LKAS12"]["CF_Lkas_TsrSpeed_Display_Clu"] - else: - speed_limit = cp.vl["Navi_HU"]["SpeedLim_Nav_Clu"] - return speed_limit if speed_limit not in (0, 255) else 0 + speed_limit_nav = cp.vl["Navi_HU"]["SpeedLim_Nav_Clu"] if self.CP.flags & HyundaiFlags.NAV_MSG else 0 + speed_limit_cam = cp_cam.vl["LKAS12"]["CF_Lkas_TsrSpeed_Display_Clu"] if self.CP.flags & HyundaiFlags.LKAS12 else 0 + return speed_limit_cam if speed_limit_cam not in (0, 255) else speed_limit_nav def update(self, cp, cp_cam, frogpilot_toggles): if self.CP.carFingerprint in CANFD_CAR: diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index ebd8ce39981137..7ae1679bfd0e34 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -9,6 +9,8 @@ from openpilot.selfdrive.car.interfaces import CarInterfaceBase from openpilot.selfdrive.car.disable_ecu import disable_ecu +from openpilot.selfdrive.frogpilot.frogpilot_variables import params + Ecu = car.CarParams.Ecu ButtonType = car.CarState.ButtonEvent.Type FrogPilotButtonType = custom.FrogPilotCarState.ButtonEvent.Type @@ -21,7 +23,7 @@ class CarInterface(CarInterfaceBase): @staticmethod - def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params): + def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs): use_new_api = params.get_bool("NewLongAPI") ret.carName = "hyundai" @@ -163,6 +165,10 @@ def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, exp ret.centerToFront = ret.wheelbase * 0.4 + # Detect smartMDPS + if 0x2AA in fingerprint[0]: + ret.minSteerSpeed = 0. + return ret @staticmethod diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index 51145d30f22329..8ab60d786ecbed 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -14,7 +14,6 @@ from openpilot.common.conversions import Conversions as CV from openpilot.common.simple_kalman import KF1D, get_kalman_gain from openpilot.common.numpy_fast import clip -from openpilot.common.params import Params from openpilot.common.realtime import DT_CTRL from openpilot.selfdrive.car import apply_hysteresis, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness, STD_CARGO_KG from openpilot.selfdrive.car.values import PLATFORMS @@ -22,7 +21,7 @@ from openpilot.selfdrive.controls.lib.events import Events from openpilot.selfdrive.controls.lib.vehicle_model import VehicleModel -from openpilot.selfdrive.frogpilot.frogpilot_variables import get_frogpilot_toggles +from openpilot.selfdrive.frogpilot.frogpilot_variables import get_frogpilot_toggles, params, params_memory ButtonType = car.CarState.ButtonEvent.Type FrogPilotButtonType = custom.FrogPilotCarState.ButtonEvent.Type @@ -225,10 +224,7 @@ def __init__(self, CP, CarController, CarState): self.CC: CarControllerBase = CarController(dbc_name, CP, self.VM) # FrogPilot variables - self.frogpilot_toggles = get_frogpilot_toggles(True) - - self.params = Params() - self.params_memory = Params("/dev/shm/params") + self.frogpilot_toggles = get_frogpilot_toggles() eps_firmware = str(next((fw.fwVersion for fw in CP.carFw if fw.ecu == "eps"), "")) @@ -278,7 +274,7 @@ def get_non_essential_params(cls, candidate: str): return cls.get_params(candidate, gen_empty_fingerprint(), list(), False, False, False) @classmethod - def get_params(cls, candidate: str, fingerprint: dict[int, dict[int, int]], car_fw: list[car.CarParams.CarFw], disable_openpilot_long: bool, experimental_long: bool, params: Params, docs: bool): + def get_params(cls, candidate: str, fingerprint: dict[int, dict[int, int]], car_fw: list[car.CarParams.CarFw], disable_openpilot_long: bool, experimental_long: bool, params: params, docs: bool): ret = CarInterfaceBase.get_std_params(candidate) platform = PLATFORMS[candidate] @@ -291,7 +287,7 @@ def get_params(cls, candidate: str, fingerprint: dict[int, dict[int, int]], car_ ret.tireStiffnessFactor = platform.config.specs.tireStiffnessFactor ret.flags |= int(platform.config.flags) - ret = cls._get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params) + ret = cls._get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs) # Enable torque controller for all cars that do not use angle based steering if ret.steerControlType != car.CarParams.SteerControlType.angle and params.get_bool("LateralTune") and params.get_bool("NNFF"): @@ -513,7 +509,7 @@ def create_common_events(self, cs_out, extra_gears=None, pcm_enable=True, allow_ return events def frogpilot_distance_functions(self, frogpilot_toggles): - distance_button = self.CS.distance_button or self.params_memory.get_bool("OnroadDistanceButtonPressed") + distance_button = self.CS.distance_button or params_memory.get_bool("OnroadDistanceButtonPressed") if distance_button: self.gap_counter += 1 @@ -522,12 +518,12 @@ def frogpilot_distance_functions(self, frogpilot_toggles): if self.gap_counter == CRUISE_LONG_PRESS * (1.5 if self.is_gm else 1) and frogpilot_toggles.experimental_mode_via_distance or self.traffic_mode_changed: if frogpilot_toggles.conditional_experimental_mode: - conditional_status = self.params_memory.get_int("CEStatus") + conditional_status = params_memory.get_int("CEStatus") override_value = 0 if conditional_status in {1, 2, 3, 4, 5, 6} else 1 if conditional_status >= 7 else 2 - self.params_memory.put_int("CEStatus", override_value) + params_memory.put_int("CEStatus", override_value) else: - experimental_mode = self.params.get_bool("ExperimentalMode") - self.params.put_bool("ExperimentalMode", not experimental_mode) + experimental_mode = params.get_bool("ExperimentalMode") + params.put_bool("ExperimentalMode", not experimental_mode) self.traffic_mode_changed = False if self.gap_counter == CRUISE_LONG_PRESS * 5: diff --git a/selfdrive/car/mazda/interface.py b/selfdrive/car/mazda/interface.py index 2a27229948af69..9f46274b74d83d 100755 --- a/selfdrive/car/mazda/interface.py +++ b/selfdrive/car/mazda/interface.py @@ -12,7 +12,7 @@ class CarInterface(CarInterfaceBase): @staticmethod - def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params): + def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs): ret.carName = "mazda" ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.mazda)] ret.radarUnavailable = True diff --git a/selfdrive/car/mock/interface.py b/selfdrive/car/mock/interface.py index bb602374248435..414bcd4553921d 100755 --- a/selfdrive/car/mock/interface.py +++ b/selfdrive/car/mock/interface.py @@ -12,7 +12,7 @@ def __init__(self, CP, CarController, CarState): self.sm = messaging.SubMaster(['gpsLocation', 'gpsLocationExternal']) @staticmethod - def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params): + def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs): ret.carName = "mock" ret.mass = 1700. ret.wheelbase = 2.70 diff --git a/selfdrive/car/nissan/interface.py b/selfdrive/car/nissan/interface.py index 39af7cfbab81f3..e1addf0e22a04c 100644 --- a/selfdrive/car/nissan/interface.py +++ b/selfdrive/car/nissan/interface.py @@ -11,7 +11,7 @@ class CarInterface(CarInterfaceBase): @staticmethod - def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params): + def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs): ret.carName = "nissan" ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.nissan)] ret.autoResumeSng = False diff --git a/selfdrive/car/secoc.py b/selfdrive/car/secoc.py new file mode 100644 index 00000000000000..971ea36a192a90 --- /dev/null +++ b/selfdrive/car/secoc.py @@ -0,0 +1,47 @@ +import struct + +from Crypto.Hash import CMAC +from Crypto.Cipher import AES + +def add_mac(key, trip_cnt, reset_cnt, msg_cnt, msg): + # TODO: clean up conversion to and from hex + + addr, payload, bus = msg + reset_flag = reset_cnt & 0b11 + msg_cnt_flag = msg_cnt & 0b11 + payload = payload[:4] + + # Step 1: Build Freshness Value (48 bits) + # [Trip Counter (16 bit)][[Reset Counter (20 bit)][Message Counter (8 bit)][Reset Flag (2 bit)][Padding (2 bit)] + freshness_value = struct.pack('>HI', trip_cnt, (reset_cnt << 12) | ((msg_cnt & 0xff) << 4) | (reset_flag << 2)) + + # Step 2: Build data to authenticate (96 bits) + # [Message ID (16 bits)][Payload (32 bits)][Freshness Value (48 bits)] + to_auth = struct.pack('>H', addr) + payload + freshness_value + + # Step 3: Calculate CMAC (28 bit) + cmac = CMAC.new(key, ciphermod=AES) + cmac.update(to_auth) + mac = cmac.digest().hex()[:7] # truncated MAC + + # Step 4: Build message + # [Payload (32 bit)][Message Counter Flag (2 bit)][Reset Flag (2 bit)][Authenticator (28 bit)] + msg_cnt_rst_flag = struct.pack('>B', (msg_cnt_flag << 2) | reset_flag).hex()[1] + msg = payload.hex() + msg_cnt_rst_flag + mac + payload = bytes.fromhex(msg) + + return (addr, payload, bus) + +def build_sync_mac(key, trip_cnt, reset_cnt, id_=0xf): + id_ = struct.pack('>H', id_) # 16 + trip_cnt = struct.pack('>H', trip_cnt) # 16 + reset_cnt = struct.pack('>I', reset_cnt << 12)[:-1] # 20 + 4 padding + + to_auth = id_ + trip_cnt + reset_cnt # SecOC 11.4.1.1 page 138 + + cmac = CMAC.new(key, ciphermod=AES) + cmac.update(to_auth) + + msg = "0" + cmac.digest().hex()[:7] + msg = bytes.fromhex(msg) + return struct.unpack('>I', msg)[0] diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index ede2980fcaf9a2..f14f10e0e68463 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -3,17 +3,14 @@ from openpilot.selfdrive.car import create_button_events, get_safety_config from openpilot.selfdrive.car.disable_ecu import disable_ecu from openpilot.selfdrive.car.interfaces import CarInterfaceBase -from openpilot.selfdrive.car.subaru.values import CAR, GLOBAL_ES_ADDR, SubaruFlags +from openpilot.selfdrive.car.subaru.values import CAR, GLOBAL_ES_ADDR, SubaruFlags, FrogPilotSubaruFlags FrogPilotButtonType = custom.FrogPilotCarState.ButtonEvent.Type class CarInterface(CarInterfaceBase): @staticmethod - def _get_params(ret, candidate: CAR, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params): - # FrogPilot variables - crosstrek_torque_increase = params.get_bool("CrosstrekTorque") - + def _get_params(ret, candidate: CAR, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs): ret.carName = "subaru" ret.radarUnavailable = True # for HYBRID CARS to be upstreamed, we need: @@ -54,9 +51,9 @@ def _get_params(ret, candidate: CAR, fingerprint, car_fw, disable_openpilot_long elif candidate == CAR.SUBARU_IMPREZA: ret.steerActuatorDelay = 0.4 # end-to-end angle controller ret.lateralTuning.init('pid') - ret.lateralTuning.pid.kf = 0.00003333 if crosstrek_torque_increase else 0.00005 + ret.lateralTuning.pid.kf = 0.00003333 if ret.flags & FrogPilotSubaruFlags.CROSSTREK_TORQUE_INCREASE else 0.00005 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 20.], [0., 20.]] - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.133, 0.2], [0.0133, 0.02]] if crosstrek_torque_increase else [[0.2, 0.3], [0.02, 0.03]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.133, 0.2], [0.0133, 0.02]] if ret.flags & FrogPilotSubaruFlags.CROSSTREK_TORQUE_INCREASE else [[0.2, 0.3], [0.02, 0.03]] elif candidate == CAR.SUBARU_IMPREZA_2020: ret.lateralTuning.init('pid') diff --git a/selfdrive/car/subaru/values.py b/selfdrive/car/subaru/values.py index f2d0544a46519f..9ec19388932a5f 100644 --- a/selfdrive/car/subaru/values.py +++ b/selfdrive/car/subaru/values.py @@ -3,11 +3,12 @@ from cereal import car from panda.python import uds -from openpilot.common.params import Params from openpilot.selfdrive.car import CarSpecs, DbcDict, PlatformConfig, Platforms, dbc_dict from openpilot.selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarDocs, CarParts, Tool, Column from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries, p16 +from openpilot.selfdrive.frogpilot.frogpilot_variables import get_frogpilot_toggles + Ecu = car.CarParams.Ecu @@ -26,7 +27,7 @@ def __init__(self, CP): self.STEER_DELTA_DOWN = 40 elif CP.carFingerprint == CAR.SUBARU_IMPREZA_2020: self.STEER_MAX = 1439 - elif CP.carFingerprint == CAR.SUBARU_IMPREZA and Params().get_bool("CrosstrekTorque"): + elif CP.carFingerprint == CAR.SUBARU_IMPREZA and CP.flags & FrogPilotSubaruFlags.CROSSTREK_TORQUE_INCREASE: self.STEER_MAX = 3071 else: self.STEER_MAX = 2047 @@ -70,6 +71,8 @@ class SubaruFlags(IntFlag): HYBRID = 32 LKAS_ANGLE = 64 +class FrogPilotSubaruFlags(IntFlag): + CROSSTREK_TORQUE_INCREASE = 1 GLOBAL_ES_ADDR = 0x787 GEN2_ES_BUTTONS_DID = b'\x11\x30' @@ -142,6 +145,7 @@ class CAR(Platforms): SubaruCarDocs("Subaru XV 2018-19", video_link="https://youtu.be/Agww7oE1k-s?t=26"), ], CarSpecs(mass=1568, wheelbase=2.67, steerRatio=15), + flags=(FrogPilotSubaruFlags.CROSSTREK_TORQUE_INCREASE if get_frogpilot_toggles().crosstrek_torque else 0), ) SUBARU_IMPREZA_2020 = SubaruPlatformConfig( [ diff --git a/selfdrive/car/tesla/interface.py b/selfdrive/car/tesla/interface.py index 04c36b7f4df4fa..0c8a1d69c81082 100755 --- a/selfdrive/car/tesla/interface.py +++ b/selfdrive/car/tesla/interface.py @@ -8,7 +8,7 @@ class CarInterface(CarInterfaceBase): @staticmethod - def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params): + def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs): ret.carName = "tesla" # There is no safe way to do steer blending with user torque, diff --git a/selfdrive/car/torque_data/substitute.toml b/selfdrive/car/torque_data/substitute.toml index 08c5783f98c726..1525bf11411fd6 100644 --- a/selfdrive/car/torque_data/substitute.toml +++ b/selfdrive/car/torque_data/substitute.toml @@ -9,6 +9,8 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"] "TOYOTA_ALPHARD_TSS2" = "TOYOTA_SIENNA" "TOYOTA_PRIUS_V" = "TOYOTA_PRIUS" +"TOYOTA_RAV4_PRIME" = "TOYOTA_RAV4_TSS2" +"TOYOTA_SIENNA_4TH_GEN" = "TOYOTA_RAV4_TSS2" "LEXUS_IS" = "LEXUS_NX" "LEXUS_CTH" = "LEXUS_NX" "LEXUS_ES" = "TOYOTA_CAMRY" diff --git a/selfdrive/car/toyota/fingerprints.py b/selfdrive/car/toyota/fingerprints.py index e3a918dac8eda0..b8942cd59d3df9 100644 --- a/selfdrive/car/toyota/fingerprints.py +++ b/selfdrive/car/toyota/fingerprints.py @@ -394,6 +394,7 @@ (Ecu.fwdCamera, 0x750, 0x6d): [ b'\x028646FF410200\x00\x00\x00\x008646GF408200\x00\x00\x00\x00', b'\x028646FF411100\x00\x00\x00\x008646GF409000\x00\x00\x00\x00', + b'\x028646FF413000\x00\x00\x00\x008646GF411000\x00\x00\x00\x00', b'\x028646FF413100\x00\x00\x00\x008646GF411100\x00\x00\x00\x00', ], }, @@ -723,11 +724,13 @@ b'\x01896630EE7000\x00\x00\x00\x00', b'\x01896630EF8000\x00\x00\x00\x00', b'\x01896630EG3000\x00\x00\x00\x00', + b'\x01896630EG3100\x00\x00\x00\x00', b'\x01896630EG5000\x00\x00\x00\x00', b'\x02896630E66000\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', b'\x02896630E66100\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', b'\x02896630EB3000\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', b'\x02896630EB3100\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', + b'\x02896630EB3200\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'\x018821F3301400\x00\x00\x00\x00', @@ -1221,6 +1224,7 @@ (Ecu.fwdCamera, 0x750, 0x6d): [ b'\x028646F0R05100\x00\x00\x00\x008646G0R02100\x00\x00\x00\x00', b'\x028646F0R05200\x00\x00\x00\x008646G0R02200\x00\x00\x00\x00', + b'\x028646F0R05300\x00\x00\x00\x008646G0R02300\x00\x00\x00\x00', b'\x028646F0R11000\x00\x00\x00\x008646G0R04000\x00\x00\x00\x00', ], }, @@ -1285,18 +1289,21 @@ CAR.LEXUS_CTH: { (Ecu.dsu, 0x791, None): [ b'881517601100\x00\x00\x00\x00', + b'881517602000\x00\x00\x00\x00', ], (Ecu.abs, 0x7b0, None): [ b'F152676144\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [ b'\x0237635000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0237641000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F7601100\x00\x00\x00\x00', + b'8646F7601200\x00\x00\x00\x00', ], }, CAR.LEXUS_ES_TSS2: { @@ -1308,6 +1315,7 @@ b'\x01896633T07000\x00\x00\x00\x00', b'\x01896633T38000\x00\x00\x00\x00', b'\x01896633T58000\x00\x00\x00\x00', + b'\x01896633T63000\x00\x00\x00\x00', b'\x028966333S8000\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', b'\x028966333S8000\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', b'\x028966333T0100\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', @@ -1331,6 +1339,7 @@ b'8965B33252\x00\x00\x00\x00\x00\x00', b'8965B33590\x00\x00\x00\x00\x00\x00', b'8965B33690\x00\x00\x00\x00\x00\x00', + b'8965B33702\x00\x00\x00\x00\x00\x00', b'8965B33721\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ @@ -1352,6 +1361,7 @@ b'\x028646F3304300\x00\x00\x00\x008646G2601500\x00\x00\x00\x00', b'\x028646F3309100\x00\x00\x00\x008646G3304000\x00\x00\x00\x00', b'\x028646F3309100\x00\x00\x00\x008646G5301200\x00\x00\x00\x00', + b'\x028646F3309400\x00\x00\x00\x008646G3304000\x00\x00\x00\x00', ], }, CAR.LEXUS_ES: { diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 792b25ba24911f..03393d3e731888 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -12,6 +12,7 @@ EventName = car.CarEvent.EventName SteerControlType = car.CarParams.SteerControlType +from openpilot.selfdrive.frogpilot.frogpilot_variables import params class CarInterface(CarInterfaceBase): @staticmethod @@ -19,7 +20,7 @@ def get_pid_accel_limits(CP, current_speed, cruise_speed): return CarControllerParams(CP).ACCEL_MIN, CarControllerParams(CP).ACCEL_MAX @staticmethod - def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params): + def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs): ret.carName = "toyota" ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.toyota)] ret.safetyConfigs[0].safetyParam = EPS_SCALE[candidate] diff --git a/selfdrive/car/volkswagen/interface.py b/selfdrive/car/volkswagen/interface.py index fd41a402e85bb8..ce35ac84078485 100644 --- a/selfdrive/car/volkswagen/interface.py +++ b/selfdrive/car/volkswagen/interface.py @@ -20,7 +20,7 @@ def __init__(self, CP, CarController, CarState): self.cp_ext = self.cp_cam @staticmethod - def _get_params(ret, candidate: CAR, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params): + def _get_params(ret, candidate: CAR, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs): ret.carName = "volkswagen" ret.radarUnavailable = True diff --git a/selfdrive/classic_modeld/classic_modeld.py b/selfdrive/classic_modeld/classic_modeld.py index c285acd636d20e..07e05dcffee49b 100755 --- a/selfdrive/classic_modeld/classic_modeld.py +++ b/selfdrive/classic_modeld/classic_modeld.py @@ -25,9 +25,7 @@ from openpilot.selfdrive.classic_modeld.constants import ModelConstants from openpilot.selfdrive.classic_modeld.models.commonmodel_pyx import ModelFrame, CLContext -from openpilot.selfdrive.frogpilot.assets.model_manager import DEFAULT_MODEL -from openpilot.selfdrive.frogpilot.frogpilot_functions import MODELS_PATH -from openpilot.selfdrive.frogpilot.frogpilot_variables import get_frogpilot_toggles +from openpilot.selfdrive.frogpilot.frogpilot_variables import DEFAULT_CLASSIC_MODEL, MODELS_PATH, get_frogpilot_toggles PROCESS_NAME = "selfdrive.classic_modeld.modeld" SEND_RAW_PRED = os.getenv('SEND_RAW_PRED') @@ -61,7 +59,7 @@ def __init__(self, context: CLContext, frogpilot_toggles: SimpleNamespace): self.radarless = frogpilot_toggles.radarless_model model_path = Path(__file__).parent / f'{MODELS_PATH}/{frogpilot_toggles.model}.thneed' - if frogpilot_toggles.model != DEFAULT_MODEL and model_path.exists(): + if frogpilot_toggles.model != DEFAULT_CLASSIC_MODEL and model_path.exists(): MODEL_PATHS[ModelRunner.THNEED] = model_path self.frame = ModelFrame(context) @@ -136,7 +134,7 @@ def run(self, buf: VisionBuf, wbuf: VisionBuf, transform: np.ndarray, transform_ def main(demo=False): # FrogPilot variables - frogpilot_toggles = get_frogpilot_toggles(True) + frogpilot_toggles = get_frogpilot_toggles() enable_navigation = not frogpilot_toggles.navigationless_model radarless = frogpilot_toggles.radarless_model diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 4b803b6bdeaa9f..e46a7bb828b37d 100644 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -32,7 +32,7 @@ from openpilot.system.hardware import HARDWARE from openpilot.selfdrive.frogpilot.controls.lib.frogpilot_acceleration import get_max_allowed_accel -from openpilot.selfdrive.frogpilot.frogpilot_variables import NON_DRIVING_GEARS, get_frogpilot_toggles +from openpilot.selfdrive.frogpilot.frogpilot_variables import NON_DRIVING_GEARS, get_frogpilot_toggles, params_memory SOFT_DISABLE_TIME = 3 # seconds LDW_MIN_SPEED = 31 * CV.MPH_TO_MS @@ -98,7 +98,7 @@ def __init__(self, CI=None): if REPLAY: # no vipc in replay will make them ignored anyways ignore += ['roadCameraState', 'wideRoadCameraState'] - if get_frogpilot_toggles(True).radarless_model: + if get_frogpilot_toggles().radarless_model: ignore += ['radarState'] self.sm = messaging.SubMaster(['deviceState', 'pandaStates', 'peripheralState', 'modelV2', 'liveCalibration', 'carOutput', 'driverMonitoringState', 'longitudinalPlan', 'liveLocationKalman', @@ -163,7 +163,10 @@ def __init__(self, CI=None): self.can_log_mono_time = 0 - self.startup_event = get_startup_event(car_recognized, not self.CP.passive, len(self.CP.carFw) > 0) + if car_recognized and not self.CP.passive and self.CP.secOcRequired and not self.CP.secOcKeyAvailable: + self.startup_event = EventName.startupNoSecOcKey + else: + self.startup_event = get_startup_event(car_recognized, not self.CP.passive, len(self.CP.carFw) > 0) if not sounds_available: self.events.add(EventName.soundsUnavailable, static=True) @@ -180,9 +183,7 @@ def __init__(self, CI=None): self.rk = Ratekeeper(100, print_delay_threshold=None) # FrogPilot variables - self.frogpilot_toggles = get_frogpilot_toggles(True) - - self.params_memory = Params("/dev/shm/params") + self.frogpilot_toggles = get_frogpilot_toggles() self.always_on_lateral_active = False self.always_on_lateral_active_previously = False @@ -193,7 +194,6 @@ def __init__(self, CI=None): self.resume_previously_pressed = False self.steer_saturated_event_triggered = False - self.block_user = self.branch == "FrogPilot-Development" and self.params.get("DongleId", encoding='utf-8') != "FrogsGoMoo" self.radarless_model = self.frogpilot_toggles.radarless_model self.use_old_long = self.frogpilot_toggles.old_long_api @@ -399,7 +399,8 @@ def update_events(self, CS): planner_fcw = self.sm['longitudinalPlan'].fcw and self.enabled if (planner_fcw or model_fcw) and not (self.CP.notCar and self.joystick_mode): self.events.add(EventName.fcw) - self.fcw_event_triggered = True + if self.frogpilot_toggles.random_events: + self.fcw_event_triggered = True for m in messaging.drain_sock(self.log_sock, wait_for_one=False): try: @@ -427,7 +428,7 @@ def update_events(self, CS): # Add FrogPilot events self.events.add_from_msg(self.sm['frogpilotPlan'].frogpilotEvents) - if self.block_user: + if self.frogpilot_toggles.block_user: self.events.add(EventName.blockUser, static=True) def data_sample(self): @@ -545,7 +546,8 @@ def state_transition(self, CS): if self.events.contains(ET.ENABLE): if self.events.contains(ET.NO_ENTRY): self.current_alert_types.append(ET.NO_ENTRY) - self.no_entry_alert_triggered = True + if self.frogpilot_toggles.random_events: + self.no_entry_alert_triggered = True else: if self.events.contains(ET.PRE_ENABLE): @@ -624,7 +626,7 @@ def state_control(self, CS): t_since_plan = (self.sm.frame - self.sm.recv_frame['longitudinalPlan']) * DT_CTRL actuators.accel = self.LoC.update_old_long(CC.longActive, CS, long_plan, pid_accel_limits, t_since_plan) else: - actuators.accel = self.LoC.update(CC.longActive, CS, long_plan.aTarget, long_plan.shouldStop or self.sm['frogpilotPlan'].forcingStopLength == 0, pid_accel_limits) + actuators.accel = self.LoC.update(CC.longActive, CS, long_plan.aTarget, long_plan.shouldStop or self.sm['frogpilotPlan'].forcingStopLength < 1, pid_accel_limits) if len(long_plan.speeds): actuators.speed = long_plan.speeds[-1] @@ -672,7 +674,8 @@ def state_control(self, CS): max_torque = abs(self.sm['carOutput'].actuatorsOutput.steer) > 0.99 if undershooting and turning and good_speed and max_torque: lac_log.active and self.events.add(EventName.goatSteerSaturated if self.frogpilot_toggles.goat_scream_alert else EventName.steerSaturated) - self.steer_saturated_event_triggered = True + if self.frogpilot_toggles.random_events: + self.steer_saturated_event_triggered = True else: self.steer_saturated_event_triggered = False elif lac_log.saturated: @@ -706,11 +709,11 @@ def state_control(self, CS): if self.CP.openpilotLongitudinalControl: if any(not be.pressed and be.type == ButtonType.gapAdjustCruise for be in CS.buttonEvents) or self.onroad_distance_pressed: menu_open = self.display_timer > 0 or not self.sm['frogpilotCarState'].hasMenu - if not (self.sm['frogpilotCarState'].distanceLongPressed or self.params_memory.get_bool("OnroadDistanceButtonPressed")) and menu_open: + if not (self.sm['frogpilotCarState'].distanceLongPressed or params_memory.get_bool("OnroadDistanceButtonPressed")) and menu_open: self.personality = (self.personality - 1) % 3 self.params.put_nonblocking('LongitudinalPersonality', str(self.personality)) self.display_timer = 350 - self.onroad_distance_pressed = self.params_memory.get_bool("OnroadDistanceButtonPressed") + self.onroad_distance_pressed = params_memory.get_bool("OnroadDistanceButtonPressed") self.display_timer -= 1 @@ -720,7 +723,7 @@ def state_control(self, CS): def update_frogpilot_variables(self, CS): self.always_on_lateral_active |= self.frogpilot_toggles.always_on_lateral_main or CS.cruiseState.enabled - self.always_on_lateral_active &= self.frogpilot_toggles.always_on_lateral and CS.cruiseState.available + self.always_on_lateral_active &= self.frogpilot_toggles.always_on_lateral_set and CS.cruiseState.available self.always_on_lateral_active &= CS.gearShifter not in NON_DRIVING_GEARS self.always_on_lateral_active &= self.sm['frogpilotPlan'].lateralCheck self.always_on_lateral_active &= self.sm['liveCalibration'].calPerc >= 1 @@ -734,9 +737,9 @@ def update_frogpilot_variables(self, CS): if any(be.pressed and be.type == FrogPilotButtonType.lkas for be in CS.buttonEvents): if self.frogpilot_toggles.experimental_mode_via_lkas and self.enabled: if self.frogpilot_toggles.conditional_experimental_mode: - conditional_status = self.params_memory.get_int("CEStatus") + conditional_status = params_memory.get_int("CEStatus") override_value = 0 if conditional_status in {1, 2, 3, 4, 5, 6} else 3 if conditional_status >= 7 else 4 - self.params_memory.put_int("CEStatus", override_value) + params_memory.put_int("CEStatus", override_value) else: self.experimental_mode = not self.experimental_mode self.params.put_bool_nonblocking("ExperimentalMode", self.experimental_mode) diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index 4cc7572a007d12..1b7523d7c17f1c 100755 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -10,10 +10,11 @@ import cereal.messaging as messaging from openpilot.common.conversions import Conversions as CV from openpilot.common.git import get_short_branch -from openpilot.common.params import Params from openpilot.common.realtime import DT_CTRL from openpilot.selfdrive.locationd.calibrationd import MIN_SPEED_FILTER +from openpilot.selfdrive.frogpilot.frogpilot_variables import params + AlertSize = log.ControlsState.AlertSize AlertStatus = log.ControlsState.AlertStatus VisualAlert = car.CarControl.HUDControl.VisualAlert @@ -381,7 +382,7 @@ def no_lane_available_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.S def torque_nn_load_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, metric: bool, soft_disable_time: int, frogpilot_toggles: SimpleNamespace) -> Alert: - model_name = Params().get("NNFFModelName", encoding='utf-8') + model_name = params.get("NNFFModelName", encoding='utf-8') if model_name == "": return Alert( "NNFF Torque Controller not available", @@ -438,6 +439,12 @@ def torque_nn_load_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubM alert_status=AlertStatus.userPrompt), }, + EventName.startupNoSecOcKey: { + ET.PERMANENT: NormalPermanentAlert("Dashcam Mode", + "Security Key Not Available", + priority=Priority.HIGH), + }, + EventName.dashcamMode: { ET.PERMANENT: NormalPermanentAlert("Dashcam Mode", priority=Priority.LOWEST), diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index 0280f3e936bde8..c710cb79ffc56a 100644 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -162,8 +162,8 @@ def __init__(self, CP, init_v=0.0, init_a=0.0, dt=DT_MDL): @staticmethod def parse_model(model_msg, model_error, v_ego, taco_tune): if (len(model_msg.position.x) == ModelConstants.IDX_N and - len(model_msg.velocity.x) == ModelConstants.IDX_N and - len(model_msg.acceleration.x) == ModelConstants.IDX_N): + len(model_msg.velocity.x) == ModelConstants.IDX_N and + len(model_msg.acceleration.x) == ModelConstants.IDX_N): x = np.interp(T_IDXS_MPC, ModelConstants.T_IDXS, model_msg.position.x) - model_error * T_IDXS_MPC v = np.interp(T_IDXS_MPC, ModelConstants.T_IDXS, model_msg.velocity.x) - model_error a = np.interp(T_IDXS_MPC, ModelConstants.T_IDXS, model_msg.acceleration.x) diff --git a/selfdrive/controls/plannerd.py b/selfdrive/controls/plannerd.py index 4d306d4762b85f..c151c816076908 100644 --- a/selfdrive/controls/plannerd.py +++ b/selfdrive/controls/plannerd.py @@ -35,7 +35,7 @@ def plannerd_thread(): poll='modelV2', ignore_avg_freq=['radarState']) # FrogPilot variables - frogpilot_toggles = get_frogpilot_toggles(True) + frogpilot_toggles = get_frogpilot_toggles() classic_model = frogpilot_toggles.classic_model radarless_model = frogpilot_toggles.radarless_model diff --git a/selfdrive/controls/radard.py b/selfdrive/controls/radard.py index 4288a4ebe061a5..bdb986428abfa8 100644 --- a/selfdrive/controls/radard.py +++ b/selfdrive/controls/radard.py @@ -378,7 +378,7 @@ def main(): rk = Ratekeeper(1.0 / CP.radarTimeStep, print_delay_threshold=None) # FrogPilot variables - frogpilot_toggles = get_frogpilot_toggles(True) + frogpilot_toggles = get_frogpilot_toggles() RD = RadarD(frogpilot_toggles, CP.radarTimeStep, RI.delay) diff --git a/selfdrive/frogpilot/assets/download_functions.py b/selfdrive/frogpilot/assets/download_functions.py index 2228345cdd8181..7ae574fc1d1870 100644 --- a/selfdrive/frogpilot/assets/download_functions.py +++ b/selfdrive/frogpilot/assets/download_functions.py @@ -18,7 +18,7 @@ def download_file(cancel_param, destination, temp_destination, progress_param, u response.raise_for_status() for chunk in response.iter_content(chunk_size=8192): if params_memory.get_bool(cancel_param): - handle_error(temp_destination, "Download cancelled.", "Download cancelled.", download_param, progress_param, params_memory) + handle_error(temp_destination, "Download cancelled", "Download cancelled", download_param, progress_param, params_memory) return if chunk: @@ -46,13 +46,13 @@ def handle_error(destination, error_message, error, download_param, progress_par def handle_request_error(error, destination, download_param, progress_param, params_memory): error_map = { - requests.ConnectionError: "Connection dropped.", - requests.HTTPError: lambda e: f"Server error ({e.response.status_code})" if e.response else "Server error.", - requests.RequestException: "Network request error. Check connection.", - requests.Timeout: "Download timed out." + requests.ConnectionError: "Connection dropped", + requests.HTTPError: lambda e: f"Server error ({e.response.status_code})" if e.response else "Server error", + requests.RequestException: "Network request error. Check connection", + requests.Timeout: "Download timed out" } - error_message = error_map.get(type(error), "Unexpected error.") + error_message = error_map.get(type(error), "Unexpected error") handle_error(destination, f"Failed: {error_message}", error, download_param, progress_param, params_memory) def get_remote_file_size(url): diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/colors/colors.json b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/colors/colors.json new file mode 100644 index 00000000000000..6a91eb709410e1 --- /dev/null +++ b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/colors/colors.json @@ -0,0 +1,44 @@ +{ + "LaneLines": { + "red": 237, + "green": 116, + "blue": 46, + "alpha": 255 + }, + "LeadMarker": { + "red": 237, + "green": 116, + "blue": 46, + "alpha": 255 + }, + "Path": { + "red": 248, + "green": 177, + "blue": 44, + "alpha": 255 + }, + "PathEdge": { + "red": 198, + "green": 142, + "blue": 35, + "alpha": 255 + }, + "Sidebar1": { + "red": 153, + "green": 99, + "blue": 54, + "alpha": 255 + }, + "Sidebar2": { + "red": 248, + "green": 177, + "blue": 44, + "alpha": 255 + }, + "Sidebar3": { + "red": 237, + "green": 116, + "blue": 46, + "alpha": 255 + } +} diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_flag.gif b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_flag.gif new file mode 100644 index 00000000000000..8ba4c7704c167f Binary files /dev/null and b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_flag.gif differ diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_flag.png b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_flag.png deleted file mode 100644 index 627af8aff329cd..00000000000000 Binary files a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_flag.png and /dev/null differ diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_home.gif b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_home.gif new file mode 100644 index 00000000000000..8ba4c7704c167f Binary files /dev/null and b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_home.gif differ diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_home.png b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_home.png deleted file mode 100644 index 627af8aff329cd..00000000000000 Binary files a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_home.png and /dev/null differ diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_settings.png b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_settings.png index 55927599758a9b..125c4e54436dce 100644 Binary files a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_settings.png and b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/icons/button_settings.png differ diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/signals/traditional_25 b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/signals/traditional_25 new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/signals/turn_signal.gif b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/signals/turn_signal.gif new file mode 100644 index 00000000000000..1561be8373ca8d Binary files /dev/null and b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/signals/turn_signal.gif differ diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/disengage.wav b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/disengage.wav index ba583c41f362d3..050f4f7eaacec0 100644 Binary files a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/disengage.wav and b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/disengage.wav differ diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/engage.wav b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/engage.wav index 41e9b2d588d4aa..d3154356a3cdf6 100644 Binary files a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/engage.wav and b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/engage.wav differ diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/prompt.wav b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/prompt.wav deleted file mode 100644 index 1ae77051eb5722..00000000000000 Binary files a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/prompt.wav and /dev/null differ diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/prompt_distracted.wav b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/prompt_distracted.wav deleted file mode 100644 index c3d4475caa70ce..00000000000000 Binary files a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/prompt_distracted.wav and /dev/null differ diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/refuse.wav b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/refuse.wav deleted file mode 100644 index 0e80f7d127dcd4..00000000000000 Binary files a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/refuse.wav and /dev/null differ diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/warning_immediate.wav b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/warning_immediate.wav deleted file mode 100644 index b1815a95867b9e..00000000000000 Binary files a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/warning_immediate.wav and /dev/null differ diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/warning_soft.wav b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/warning_soft.wav deleted file mode 100644 index 261c7e1376c672..00000000000000 Binary files a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/sounds/warning_soft.wav and /dev/null differ diff --git a/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/steering_wheel/wheel.gif b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/steering_wheel/wheel.gif new file mode 100644 index 00000000000000..f1d730ddb2fa17 Binary files /dev/null and b/selfdrive/frogpilot/assets/holiday_themes/thanksgiving_week/steering_wheel/wheel.gif differ diff --git a/selfdrive/frogpilot/assets/model_manager.py b/selfdrive/frogpilot/assets/model_manager.py index d85b1fa3373363..62a96ee860d8f1 100644 --- a/selfdrive/frogpilot/assets/model_manager.py +++ b/selfdrive/frogpilot/assets/model_manager.py @@ -11,21 +11,11 @@ from openpilot.common.params import Params from openpilot.selfdrive.frogpilot.assets.download_functions import GITHUB_URL, GITLAB_URL, download_file, get_repository_url, handle_error, handle_request_error, verify_download -from openpilot.selfdrive.frogpilot.frogpilot_functions import MODELS_PATH from openpilot.selfdrive.frogpilot.frogpilot_utilities import delete_file +from openpilot.selfdrive.frogpilot.frogpilot_variables import DEFAULT_MODEL, DEFAULT_MODEL_NAME, DEFAULT_CLASSIC_MODEL, DEFAULT_CLASSIC_MODEL_NAME, MODELS_PATH VERSION = "v10" -DEFAULT_MODEL = "north-dakota" -DEFAULT_MODEL_NAME = "North Dakota (Default)" - - -def process_model_name(model_name): - cleaned_name = re.sub(r'[🗺️👀📡]', '', model_name) - cleaned_name = re.sub(r'[^a-zA-Z0-9()-]', '', cleaned_name) - return cleaned_name.replace(' ', '').replace('(Default)', '').replace('-', '') - - class ModelManager: def __init__(self): self.params = Params() @@ -73,19 +63,19 @@ def fetch_all_model_sizes(repo_url): else: return {file['name'].replace('.thneed', ''): file['size'] for file in thneed_files if 'size' in file} except Exception as e: - raise ConnectionError(f"Failed to fetch model sizes from {'GitHub' if 'github' in repo_url else 'GitLab'}: {e}") + handle_request_error(f"Failed to fetch model sizes from {'GitHub' if 'github' in repo_url else 'GitLab'}: {e}", None, None, None, None) return {} @staticmethod def copy_default_model(): - classic_default_model_path = os.path.join(MODELS_PATH, f"{DEFAULT_MODEL}.thneed") + classic_default_model_path = os.path.join(MODELS_PATH, f"{DEFAULT_CLASSIC_MODEL}.thneed") source_path = os.path.join(BASEDIR, "selfdrive", "classic_modeld", "models", "supercombo.thneed") if os.path.isfile(source_path): shutil.copyfile(source_path, classic_default_model_path) print(f"Copied the classic default model from {source_path} to {classic_default_model_path}") - default_model_path = os.path.join(MODELS_PATH, "secret-good-openpilot.thneed") + default_model_path = os.path.join(MODELS_PATH, f"{DEFAULT_MODEL}.thneed") source_path = os.path.join(BASEDIR, "selfdrive", "modeld", "models", "supercombo.thneed") if os.path.isfile(source_path): @@ -101,7 +91,7 @@ def handle_verification_failure(self, model, model_path, temp_model_path): download_file(self.cancel_download_param, model_path, temp_model_path, self.download_progress_param, model_url, self.download_param, self.params_memory) if verify_download(model_path, temp_model_path, model_url): - print(f"Model {model} redownloaded and verified successfully from GitLab.") + print(f"Model {model} redownloaded and verified successfully from GitLab") else: handle_error(model_path, "GitLab verification failed", "Verification failed", self.download_param, self.download_progress_param, self.params_memory) @@ -147,13 +137,15 @@ def update_model_params(self, model_info, repo_url): self.params.put_nonblocking("ExperimentalModels", ','.join([model['id'] for model in model_info if model.get("experimental", False)])) self.params.put_nonblocking("NavigationModels", ','.join([model['id'] for model in model_info if "🗺️" in model['name']])) self.params.put_nonblocking("RadarlessModels", ','.join([model['id'] for model in model_info if "📡" not in model['name']])) - print("Models list updated successfully.") + print("Models list updated successfully") if available_models: models_downloaded = self.are_all_models_downloaded(available_models, repo_url) self.params.put_bool_nonblocking("ModelsDownloaded", models_downloaded) def are_all_models_downloaded(self, available_models, repo_url): + available_models = set(available_models) - {DEFAULT_MODEL, DEFAULT_CLASSIC_MODEL} + automatically_update_models = self.params.get_bool("AutomaticallyUpdateModels") all_models_downloaded = True @@ -190,7 +182,7 @@ def validate_models(self): current_model = self.params.get("Model", encoding='utf-8') current_model_name = self.params.get("ModelName", encoding='utf-8') - if "(Default)" in current_model_name and current_model_name != DEFAULT_MODEL_NAME: + if "(Default)" in current_model_name and current_model_name != DEFAULT_CLASSIC_MODEL_NAME: self.params.put_nonblocking("ModelName", current_model_name.replace(" (Default)", "")) available_models = self.params.get("AvailableModels", encoding='utf-8') @@ -206,8 +198,8 @@ def validate_models(self): model_name = model_file.replace(".thneed", "") if model_name not in available_models.split(','): if model_name == current_model: - self.params.put_nonblocking("Model", DEFAULT_MODEL) - self.params.put_nonblocking("ModelName", DEFAULT_MODEL_NAME) + self.params.put_nonblocking("Model", DEFAULT_CLASSIC_MODEL) + self.params.put_nonblocking("ModelName", DEFAULT_CLASSIC_MODEL_NAME) delete_file(os.path.join(MODELS_PATH, model_file)) print(f"Deleted model file: {model_file} - Reason: Model is not in the list of available models") diff --git a/selfdrive/frogpilot/assets/other_images/original_bg.jpg b/selfdrive/frogpilot/assets/other_images/original_bg.jpg new file mode 100644 index 00000000000000..13c36a7e240359 Binary files /dev/null and b/selfdrive/frogpilot/assets/other_images/original_bg.jpg differ diff --git a/selfdrive/frogpilot/assets/theme_manager.py b/selfdrive/frogpilot/assets/theme_manager.py index c7676ce3cfff82..c5b9a874e97a99 100644 --- a/selfdrive/frogpilot/assets/theme_manager.py +++ b/selfdrive/frogpilot/assets/theme_manager.py @@ -10,17 +10,15 @@ from dateutil import easter from openpilot.common.basedir import BASEDIR -from openpilot.common.params import Params from openpilot.selfdrive.frogpilot.assets.download_functions import GITHUB_URL, GITLAB_URL, download_file, get_repository_url, handle_error, handle_request_error, verify_download -from openpilot.selfdrive.frogpilot.frogpilot_functions import ACTIVE_THEME_PATH, THEME_SAVE_PATH -from openpilot.selfdrive.frogpilot.frogpilot_utilities import update_frogpilot_toggles +from openpilot.selfdrive.frogpilot.frogpilot_variables import ACTIVE_THEME_PATH, THEME_SAVE_PATH, params, params_memory, update_frogpilot_toggles CANCEL_DOWNLOAD_PARAM = "CancelThemeDownload" DOWNLOAD_PROGRESS_PARAM = "ThemeDownloadProgress" -def update_theme_asset(asset_type, theme, holiday_theme, params): +def update_theme_asset(asset_type, theme, holiday_theme): save_location = os.path.join(ACTIVE_THEME_PATH, asset_type) if holiday_theme: @@ -81,16 +79,15 @@ def update_wheel_image(image, holiday_theme=None, random_event=True): class ThemeManager: def __init__(self): - self.params = Params() - self.params_memory = Params("/dev/shm/params") - self.previous_assets = {} @staticmethod def calculate_thanksgiving(year): november_first = date(year, 11, 1) - day_of_week = november_first.weekday() - return november_first + timedelta(days=(3 - day_of_week + 21) % 7 + 21) + days_to_thursday = (3 - november_first.weekday()) % 7 + first_thursday = november_first + timedelta(days=days_to_thursday) + thanksgiving_date = first_thursday + timedelta(days=21) + return thanksgiving_date @staticmethod def is_within_week_of(target_date, now): @@ -195,30 +192,30 @@ def update_holiday(self): for holiday, holiday_date in holidays.items(): if (holiday.endswith("_week") and self.is_within_week_of(holiday_date, now)) or (now == holiday_date): if holiday != self.previous_assets.get("holiday_theme"): - self.params.put("CurrentHolidayTheme", holiday) - self.params_memory.put_bool("UpdateTheme", True) + params.put("CurrentHolidayTheme", holiday) + params_memory.put_bool("UpdateTheme", True) return if "holiday_theme" in self.previous_assets: - self.params.remove("CurrentHolidayTheme") - self.params_memory.put_bool("UpdateTheme", True) + params.remove("CurrentHolidayTheme") + params_memory.put_bool("UpdateTheme", True) self.previous_assets.pop("holiday_theme") def update_active_theme(self): if not os.path.exists(THEME_SAVE_PATH): return - holiday_themes = self.params.get_bool("HolidayThemes") - current_holiday_theme = self.params.get("CurrentHolidayTheme", encoding='utf-8') if holiday_themes else None + holiday_themes = params.get_bool("HolidayThemes") + current_holiday_theme = params.get("CurrentHolidayTheme", encoding='utf-8') if holiday_themes else None - if not current_holiday_theme and self.params.get_bool("PersonalizeOpenpilot"): + if not current_holiday_theme and params.get_bool("PersonalizeOpenpilot"): asset_mappings = { - "color_scheme": ("colors", self.params.get("CustomColors", encoding='utf-8')), - "distance_icons": ("distance_icons", self.params.get("CustomDistanceIcons", encoding='utf-8')), - "icon_pack": ("icons", self.params.get("CustomIcons", encoding='utf-8')), - "sound_pack": ("sounds", self.params.get("CustomSounds", encoding='utf-8')), - "turn_signal_pack": ("signals", self.params.get("CustomSignals", encoding='utf-8')), - "wheel_image": ("wheel_image", self.params.get("WheelIcon", encoding='utf-8')) + "color_scheme": ("colors", params.get("CustomColors", encoding='utf-8')), + "distance_icons": ("distance_icons", params.get("CustomDistanceIcons", encoding='utf-8')), + "icon_pack": ("icons", params.get("CustomIcons", encoding='utf-8')), + "sound_pack": ("sounds", params.get("CustomSounds", encoding='utf-8')), + "turn_signal_pack": ("signals", params.get("CustomSignals", encoding='utf-8')), + "wheel_image": ("wheel_image", params.get("WheelIcon", encoding='utf-8')) } else: asset_mappings = { @@ -238,7 +235,7 @@ def update_active_theme(self): if asset_type == "wheel_image": update_wheel_image(current_value, current_holiday_theme, random_event=False) else: - update_theme_asset(asset_type, current_value, current_holiday_theme, self.params) + update_theme_asset(asset_type, current_value, current_holiday_theme) self.previous_assets[asset] = current_value theme_changed = True @@ -246,7 +243,6 @@ def update_active_theme(self): if theme_changed: if current_holiday_theme: self.previous_assets["holiday_theme"] = current_holiday_theme - self.params_memory.put_bool("ThemeUpdated", True) update_frogpilot_toggles() def extract_zip(self, zip_file, extract_path): @@ -254,12 +250,12 @@ def extract_zip(self, zip_file, extract_path): with zipfile.ZipFile(zip_file, 'r') as zip_ref: zip_ref.extractall(extract_path) os.remove(zip_file) - print(f"Extraction completed and zip file deleted.") + print(f"Extraction completed and zip file deleted") def handle_existing_theme(self, theme_name, theme_param): print(f"Theme {theme_name} already exists, skipping download...") - self.params_memory.put(DOWNLOAD_PROGRESS_PARAM, "Theme already exists...") - self.params_memory.remove(theme_param) + params_memory.put(DOWNLOAD_PROGRESS_PARAM, "Theme already exists...") + params_memory.remove(theme_param) def handle_verification_failure(self, extensions, theme_component, theme_name, theme_param, download_path): if theme_component == "distance_icons": @@ -274,24 +270,24 @@ def handle_verification_failure(self, extensions, theme_component, theme_name, t temp_theme_path = f"{os.path.splitext(theme_path)[0]}_temp{ext}" theme_url = download_link + ext print(f"Downloading theme from GitLab: {theme_name}") - download_file(CANCEL_DOWNLOAD_PARAM, theme_path, temp_theme_path, DOWNLOAD_PROGRESS_PARAM, theme_url, theme_param, self.params_memory) + download_file(CANCEL_DOWNLOAD_PARAM, theme_path, temp_theme_path, DOWNLOAD_PROGRESS_PARAM, theme_url, theme_param, params_memory) if verify_download(theme_path, temp_theme_path, theme_url): print(f"Theme {theme_name} downloaded and verified successfully from GitLab!") if ext == ".zip": - self.params_memory.put(DOWNLOAD_PROGRESS_PARAM, "Unpacking theme...") + params_memory.put(DOWNLOAD_PROGRESS_PARAM, "Unpacking theme...") self.extract_zip(theme_path, os.path.join(THEME_SAVE_PATH, theme_name)) - self.params_memory.put(DOWNLOAD_PROGRESS_PARAM, "Downloaded!") - self.params_memory.remove(theme_param) + params_memory.put(DOWNLOAD_PROGRESS_PARAM, "Downloaded!") + params_memory.remove(theme_param) return True - handle_error(download_path, "GitLab verification failed", "Verification failed", theme_param, DOWNLOAD_PROGRESS_PARAM, self.params_memory) + handle_error(download_path, "GitLab verification failed", "Verification failed", theme_param, DOWNLOAD_PROGRESS_PARAM, params_memory) return False def download_theme(self, theme_component, theme_name, theme_param): repo_url = get_repository_url() if not repo_url: - handle_error(None, "GitHub and GitLab are offline...", "Repository unavailable", theme_param, DOWNLOAD_PROGRESS_PARAM, self.params_memory) + handle_error(None, "GitHub and GitLab are offline...", "Repository unavailable", theme_param, DOWNLOAD_PROGRESS_PARAM, params_memory) return if theme_component == "distance_icons": @@ -312,20 +308,20 @@ def download_theme(self, theme_component, theme_name, theme_param): temp_theme_path = f"{os.path.splitext(theme_path)[0]}_temp{ext}" if os.path.isfile(theme_path): - handle_error(theme_path, "Theme already exists...", "Theme already exists...", theme_param, DOWNLOAD_PROGRESS_PARAM, self.params_memory) + handle_error(theme_path, "Theme already exists...", "Theme already exists...", theme_param, DOWNLOAD_PROGRESS_PARAM, params_memory) return theme_url = download_link + ext print(f"Downloading theme from GitHub: {theme_name}") - download_file(CANCEL_DOWNLOAD_PARAM, theme_path, temp_theme_path, DOWNLOAD_PROGRESS_PARAM, theme_url, theme_param, self.params_memory) + download_file(CANCEL_DOWNLOAD_PARAM, theme_path, temp_theme_path, DOWNLOAD_PROGRESS_PARAM, theme_url, theme_param, params_memory) if verify_download(theme_path, temp_theme_path, theme_url): print(f"Theme {theme_name} downloaded and verified successfully from GitHub!") if ext == ".zip": - self.params_memory.put(DOWNLOAD_PROGRESS_PARAM, "Unpacking theme...") + params_memory.put(DOWNLOAD_PROGRESS_PARAM, "Unpacking theme...") self.extract_zip(theme_path, download_path) - self.params_memory.put(DOWNLOAD_PROGRESS_PARAM, "Downloaded!") - self.params_memory.remove(theme_param) + params_memory.put(DOWNLOAD_PROGRESS_PARAM, "Downloaded!") + params_memory.remove(theme_param) return self.handle_verification_failure(extensions, theme_component, theme_name, theme_param, download_path) @@ -339,27 +335,27 @@ def filter_existing_assets(assets, subfolder): } return sorted(set(assets) - existing_themes) - self.params.put("DownloadableColors", ','.join(filter_existing_assets(downloadable_colors, "colors"))) - print("Colors list updated successfully.") + params.put("DownloadableColors", ','.join(filter_existing_assets(downloadable_colors, "colors"))) + print("Colors list updated successfully") distance_icons_directory = os.path.join(THEME_SAVE_PATH, "distance_icons") - self.params.put("DownloadableDistanceIcons", ','.join(sorted(set(downloadable_distance_icons) - { + params.put("DownloadableDistanceIcons", ','.join(sorted(set(downloadable_distance_icons) - { distance_icons.replace('_', ' ').split('.')[0].title() for distance_icons in os.listdir(distance_icons_directory) })) ) - self.params.put("DownloadableIcons", ','.join(filter_existing_assets(downloadable_icons, "icons"))) - print("Icons list updated successfully.") + params.put("DownloadableIcons", ','.join(filter_existing_assets(downloadable_icons, "icons"))) + print("Icons list updated successfully") - self.params.put("DownloadableSignals", ','.join(filter_existing_assets(downloadable_signals, "signals"))) - print("Signals list updated successfully.") + params.put("DownloadableSignals", ','.join(filter_existing_assets(downloadable_signals, "signals"))) + print("Signals list updated successfully") - self.params.put("DownloadableSounds", ','.join(filter_existing_assets(downloadable_sounds, "sounds"))) - print("Sounds list updated successfully.") + params.put("DownloadableSounds", ','.join(filter_existing_assets(downloadable_sounds, "sounds"))) + print("Sounds list updated successfully") wheel_directory = os.path.join(THEME_SAVE_PATH, "steering_wheels") - self.params.put("DownloadableWheels", ','.join(sorted(set(downloadable_wheels) - { + params.put("DownloadableWheels", ','.join(sorted(set(downloadable_wheels) - { wheel.replace('_', ' ').split('.')[0].title() for wheel in os.listdir(wheel_directory) if wheel != "img_chffr_wheel.png" })) @@ -376,7 +372,7 @@ def validate_themes(self): } for theme_param, theme_component in asset_mappings.items(): - theme_name = self.params.get(theme_param, encoding='utf-8') + theme_name = params.get(theme_param, encoding='utf-8') if not theme_name or theme_name == "stock": continue diff --git a/selfdrive/frogpilot/controls/frogpilot_planner.py b/selfdrive/frogpilot/controls/frogpilot_planner.py index 948b9c83a22836..313b3bf6fbbccd 100644 --- a/selfdrive/frogpilot/controls/frogpilot_planner.py +++ b/selfdrive/frogpilot/controls/frogpilot_planner.py @@ -1,7 +1,6 @@ import cereal.messaging as messaging from openpilot.common.conversions import Conversions as CV -from openpilot.common.params import Params from openpilot.selfdrive.controls.lib.drive_helpers import V_CRUISE_UNSET from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import A_CHANGE_COST, DANGER_ZONE_COST, J_EGO_COST, STOP_DISTANCE @@ -17,8 +16,6 @@ class FrogPilotPlanner: def __init__(self): - self.params_memory = Params("/dev/shm/params") - self.cem = ConditionalExperimentalMode(self) self.frogpilot_acceleration = FrogPilotAcceleration(self) self.frogpilot_events = FrogPilotEvents(self) diff --git a/selfdrive/frogpilot/controls/lib/conditional_experimental_mode.py b/selfdrive/frogpilot/controls/lib/conditional_experimental_mode.py index cf070263a8c559..2a1e292bde444d 100644 --- a/selfdrive/frogpilot/controls/lib/conditional_experimental_mode.py +++ b/selfdrive/frogpilot/controls/lib/conditional_experimental_mode.py @@ -1,15 +1,12 @@ -from openpilot.common.params import Params - from openpilot.selfdrive.frogpilot.frogpilot_utilities import MovingAverageCalculator -from openpilot.selfdrive.frogpilot.frogpilot_variables import CITY_SPEED_LIMIT, CRUISING_SPEED, THRESHOLD +from openpilot.selfdrive.frogpilot.frogpilot_variables import CITY_SPEED_LIMIT, CRUISING_SPEED, THRESHOLD, params_memory class ConditionalExperimentalMode: def __init__(self, FrogPilotPlanner): self.frogpilot_planner = FrogPilotPlanner - self.params_memory = Params("/dev/shm/params") - self.curvature_mac = MovingAverageCalculator() + self.slow_lead_mac = MovingAverageCalculator() self.stop_light_mac = MovingAverageCalculator() self.curve_detected = False @@ -18,14 +15,14 @@ def __init__(self, FrogPilotPlanner): def update(self, carState, frogpilotCarState, frogpilotNavigation, modelData, v_ego, v_lead, frogpilot_toggles): if frogpilot_toggles.experimental_mode_via_press: - self.status_value = self.params_memory.get_int("CEStatus") + self.status_value = params_memory.get_int("CEStatus") else: self.status_value = 0 if self.status_value not in {1, 2, 3, 4, 5, 6} and not carState.standstill: self.update_conditions(frogpilotCarState, self.frogpilot_planner.tracking_lead, v_ego, v_lead, frogpilot_toggles) self.experimental_mode = self.check_conditions(carState, frogpilotNavigation, modelData, self.frogpilot_planner.frogpilot_following.following_lead, v_ego, v_lead, frogpilot_toggles) - self.params_memory.put_int("CEStatus", self.status_value if self.experimental_mode else 0) + params_memory.put_int("CEStatus", self.status_value if self.experimental_mode else 0) else: self.experimental_mode = self.status_value in {2, 4, 6} or carState.standstill and self.experimental_mode self.stop_light_detected &= self.status_value not in {1, 2, 3, 4, 5, 6} @@ -63,7 +60,6 @@ def check_conditions(self, carState, frogpilotNavigation, modelData, following_l if self.frogpilot_planner.frogpilot_vcruise.slc.experimental_mode: self.status_value = 17 return True - return False def update_conditions(self, frogpilotCarState, tracking_lead, v_ego, v_lead, frogpilot_toggles): @@ -72,19 +68,25 @@ def update_conditions(self, frogpilotCarState, tracking_lead, v_ego, v_lead, fro self.stop_sign_and_light(frogpilotCarState, tracking_lead, v_ego, frogpilot_toggles) def curve_detection(self, tracking_lead, v_ego, frogpilot_toggles): - curve_detected = (1 / self.frogpilot_planner.road_curvature)**0.5 < v_ego - curve_active = (0.9 / self.frogpilot_planner.road_curvature)**0.5 < v_ego and self.curve_detected + if v_ego > CRUISING_SPEED: + curve_detected = (1 / self.frogpilot_planner.road_curvature)**0.5 < v_ego + curve_active = (0.9 / self.frogpilot_planner.road_curvature)**0.5 < v_ego and self.curve_detected - self.curvature_mac.add_data(curve_detected or curve_active) - self.curve_detected = self.curvature_mac.get_moving_average() >= THRESHOLD + self.curvature_mac.add_data(curve_detected or curve_active) + self.curve_detected = self.curvature_mac.get_moving_average() >= THRESHOLD + else: + self.curvature_mac.reset_data() + self.curve_detected = False def slow_lead(self, tracking_lead, v_lead, frogpilot_toggles): if tracking_lead: - slower_lead = self.frogpilot_planner.frogpilot_following.slower_lead and frogpilot_toggles.conditional_slower_lead + slower_lead = frogpilot_toggles.conditional_slower_lead and self.frogpilot_planner.frogpilot_following.slower_lead stopped_lead = frogpilot_toggles.conditional_stopped_lead and v_lead < 1 - self.slow_lead_detected = slower_lead or stopped_lead + self.slow_lead_mac.add_data(slower_lead or stopped_lead) + self.slow_lead_detected = self.slow_lead_mac.get_moving_average() >= THRESHOLD else: + self.slow_lead_mac.reset_data() self.slow_lead_detected = False def stop_sign_and_light(self, frogpilotCarState, tracking_lead, v_ego, frogpilot_toggles): diff --git a/selfdrive/frogpilot/controls/lib/frogpilot_acceleration.py b/selfdrive/frogpilot/controls/lib/frogpilot_acceleration.py index a239b11eee77eb..6e8d9a7bd4ef1f 100644 --- a/selfdrive/frogpilot/controls/lib/frogpilot_acceleration.py +++ b/selfdrive/frogpilot/controls/lib/frogpilot_acceleration.py @@ -22,7 +22,7 @@ def get_max_accel_sport_plus(v_ego): return interp(v_ego, A_CRUISE_MAX_BP_CUSTOM, A_CRUISE_MAX_VALS_SPORT_PLUS) def get_max_accel_ramp_off(max_accel, v_cruise, v_ego): - return interp(v_cruise - v_ego, [0., 1., 5., 10.], [0., 0.25, 0.75, max_accel]) + return interp(v_cruise - v_ego, [0., 1., 5., 10.], [0., 0.5, 1.0, max_accel]) def get_max_allowed_accel(v_ego): return interp(v_ego, [0., 5., 20.], [4.0, 4.0, 2.0]) # ISO 15622:2018 diff --git a/selfdrive/frogpilot/controls/lib/frogpilot_events.py b/selfdrive/frogpilot/controls/lib/frogpilot_events.py index 147a54fd32ef3b..d20c3d3db74299 100644 --- a/selfdrive/frogpilot/controls/lib/frogpilot_events.py +++ b/selfdrive/frogpilot/controls/lib/frogpilot_events.py @@ -4,19 +4,15 @@ import openpilot.system.sentry as sentry from openpilot.common.conversions import Conversions as CV -from openpilot.common.params import Params from openpilot.common.realtime import DT_MDL from openpilot.selfdrive.controls.controlsd import Desire from openpilot.selfdrive.controls.lib.events import EventName, Events from openpilot.selfdrive.frogpilot.assets.theme_manager import update_wheel_image -from openpilot.selfdrive.frogpilot.frogpilot_variables import CRUISING_SPEED +from openpilot.selfdrive.frogpilot.frogpilot_variables import CRUISING_SPEED, params, params_memory class FrogPilotEvents: def __init__(self, FrogPilotPlanner): - self.params = Params() - self.params_memory = Params("/dev/shm/params") - self.events = Events() self.frogpilot_planner = FrogPilotPlanner @@ -50,7 +46,7 @@ def update(self, carState, controlsState, frogpilotCarControl, frogpilotCarState self.random_event_timer += DT_MDL if self.random_event_timer >= 4: update_wheel_image(frogpilot_toggles.wheel_image, frogpilot_toggles.current_holiday_theme, False) - self.params_memory.put_bool("UpdateWheelImage", True) + params_memory.put_bool("UpdateWheelImage", True) self.random_event_played = False self.random_event_timer = 0 @@ -98,7 +94,7 @@ def update(self, carState, controlsState, frogpilotCarControl, frogpilotCarState if not self.accel30_played and 3.5 > self.max_acceleration >= 3.0 and acceleration < 1.5: self.events.add(EventName.accel30) update_wheel_image("weeb_wheel") - self.params_memory.put_bool("UpdateWheelImage", True) + params_memory.put_bool("UpdateWheelImage", True) self.accel30_played = True self.random_event_played = True self.max_acceleration = 0 @@ -106,7 +102,7 @@ def update(self, carState, controlsState, frogpilotCarControl, frogpilotCarState elif not self.accel35_played and 4.0 > self.max_acceleration >= 3.5 and acceleration < 1.5: self.events.add(EventName.accel35) update_wheel_image("tree_fiddy") - self.params_memory.put_bool("UpdateWheelImage", True) + params_memory.put_bool("UpdateWheelImage", True) self.accel35_played = True self.random_event_played = True self.max_acceleration = 0 @@ -114,7 +110,7 @@ def update(self, carState, controlsState, frogpilotCarControl, frogpilotCarState elif not self.accel40_played and self.max_acceleration >= 4.0 and acceleration < 1.5: self.events.add(EventName.accel40) update_wheel_image("great_scott") - self.params_memory.put_bool("UpdateWheelImage", True) + params_memory.put_bool("UpdateWheelImage", True) self.accel40_played = True self.random_event_played = True self.max_acceleration = 0 @@ -144,17 +140,17 @@ def update(self, carState, controlsState, frogpilotCarControl, frogpilotCarState if event_choice == "firefoxSteerSaturated": self.events.add(EventName.firefoxSteerSaturated) update_wheel_image("firefox") - self.params_memory.put_bool("UpdateWheelImage", True) + params_memory.put_bool("UpdateWheelImage", True) self.firefox_played = True elif event_choice == "goatSteerSaturated": self.events.add(EventName.goatSteerSaturated) update_wheel_image("goat") - self.params_memory.put_bool("UpdateWheelImage", True) + params_memory.put_bool("UpdateWheelImage", True) self.goat_played = True elif event_choice == "thisIsFineSteerSaturated": self.events.add(EventName.thisIsFineSteerSaturated) update_wheel_image("this_is_fine") - self.params_memory.put_bool("UpdateWheelImage", True) + params_memory.put_bool("UpdateWheelImage", True) self.this_is_fine_played = True self.random_event_played = True @@ -178,7 +174,7 @@ def update(self, carState, controlsState, frogpilotCarControl, frogpilotCarState if frogpilot_toggles.speed_limit_changed_alert and self.frogpilot_planner.frogpilot_vcruise.speed_limit_changed: self.events.add(EventName.speedLimitChanged) - if self.frame == 4 and self.params.get("NNFFModelName", encoding='utf-8') is not None: + if self.frame == 4 and params.get("NNFFModelName", encoding='utf-8') is not None: self.events.add(EventName.torqueNNLoad) if frogpilotCarState.trafficModeActive != self.previous_traffic_mode: diff --git a/selfdrive/frogpilot/controls/lib/frogpilot_vcruise.py b/selfdrive/frogpilot/controls/lib/frogpilot_vcruise.py index 09a9bab4b64ed4..49a386038c82a4 100644 --- a/selfdrive/frogpilot/controls/lib/frogpilot_vcruise.py +++ b/selfdrive/frogpilot/controls/lib/frogpilot_vcruise.py @@ -7,7 +7,7 @@ from openpilot.selfdrive.frogpilot.controls.lib.map_turn_speed_controller import MapTurnSpeedController from openpilot.selfdrive.frogpilot.controls.lib.speed_limit_controller import SpeedLimitController -from openpilot.selfdrive.frogpilot.frogpilot_variables import CRUISING_SPEED, PLANNER_TIME +from openpilot.selfdrive.frogpilot.frogpilot_variables import CRUISING_SPEED, PLANNER_TIME, params_memory TARGET_LAT_A = 1.9 @@ -15,8 +15,6 @@ class FrogPilotVCruise: def __init__(self, FrogPilotPlanner): self.frogpilot_planner = FrogPilotPlanner - self.params_memory = self.frogpilot_planner.params_memory - self.mtsc = MapTurnSpeedController() self.slc = SpeedLimitController() @@ -37,7 +35,7 @@ def __init__(self, FrogPilotPlanner): def update(self, carState, controlsState, frogpilotCarControl, frogpilotCarState, frogpilotNavigation, modelData, v_cruise, v_ego, frogpilot_toggles): force_stop = frogpilot_toggles.force_stops and self.frogpilot_planner.cem.stop_light_detected and controlsState.enabled - force_stop &= self.frogpilot_planner.model_length < 150 + force_stop &= self.frogpilot_planner.model_length < 100 force_stop &= self.override_force_stop_timer <= 0 self.force_stop_timer = self.force_stop_timer + DT_MDL if force_stop else 0 @@ -81,22 +79,22 @@ def update(self, carState, controlsState, frogpilotCarControl, frogpilotCarState self.slc.update(frogpilotCarState.dashboardSpeedLimit, controlsState.enabled, frogpilotNavigation.navigationSpeedLimit, v_cruise, v_ego, frogpilot_toggles) unconfirmed_slc_target = self.slc.desired_speed_limit - if (frogpilot_toggles.speed_limit_changed_alert or frogpilot_toggles.speed_limit_confirmation_lower or frogpilot_toggles.speed_limit_confirmation_higher) and self.slc_target != 0: + if (frogpilot_toggles.speed_limit_changed_alert or frogpilot_toggles.speed_limit_confirmation) and self.slc_target != 0: self.speed_limit_changed = unconfirmed_slc_target != self.previous_speed_limit and abs(self.slc_target - unconfirmed_slc_target) > 1 and unconfirmed_slc_target > 1 speed_limit_decreased = self.speed_limit_changed and self.slc_target > unconfirmed_slc_target speed_limit_increased = self.speed_limit_changed and self.slc_target < unconfirmed_slc_target - accepted_via_ui = self.params_memory.get_bool("SLCConfirmedPressed") and self.params_memory.get_bool("SLCConfirmed") - denied_via_ui = self.params_memory.get_bool("SLCConfirmedPressed") and not self.params_memory.get_bool("SLCConfirmed") + accepted_via_ui = params_memory.get_bool("SLCConfirmedPressed") and params_memory.get_bool("SLCConfirmed") + denied_via_ui = params_memory.get_bool("SLCConfirmedPressed") and not params_memory.get_bool("SLCConfirmed") - speed_limit_accepted = frogpilotCarControl.resumePressed or accepted_via_ui - speed_limit_denied = any(be.type == ButtonType.decelCruise for be in carState.buttonEvents) or denied_via_ui or self.speed_limit_timer >= 10 + speed_limit_accepted = frogpilotCarControl.resumePressed and controlsState.enabled or accepted_via_ui + speed_limit_denied = any(be.type == ButtonType.decelCruise for be in carState.buttonEvents) and controlsState.enabled or denied_via_ui or self.speed_limit_timer >= 10 if speed_limit_accepted or speed_limit_denied: self.previous_speed_limit = unconfirmed_slc_target - self.params_memory.put_bool("SLCConfirmed", False) - self.params_memory.put_bool("SLCConfirmedPressed", False) + params_memory.put_bool("SLCConfirmed", False) + params_memory.put_bool("SLCConfirmedPressed", False) if speed_limit_decreased: speed_limit_confirmed = not frogpilot_toggles.speed_limit_confirmation_lower or speed_limit_accepted @@ -145,7 +143,7 @@ def update(self, carState, controlsState, frogpilotCarControl, frogpilotCarState v_cruise = -1 elif force_stop_enabled and not self.override_force_stop: - self.forcing_stop = True + self.forcing_stop |= not carState.standstill self.tracked_model_length = max(self.tracked_model_length - v_ego * DT_MDL, 0) v_cruise = min((self.tracked_model_length // PLANNER_TIME), v_cruise) diff --git a/selfdrive/frogpilot/controls/lib/map_turn_speed_controller.py b/selfdrive/frogpilot/controls/lib/map_turn_speed_controller.py index f72e374ebf5f0c..38623843fdfa17 100644 --- a/selfdrive/frogpilot/controls/lib/map_turn_speed_controller.py +++ b/selfdrive/frogpilot/controls/lib/map_turn_speed_controller.py @@ -3,12 +3,9 @@ import math from openpilot.common.numpy_fast import interp -from openpilot.common.params import Params from openpilot.selfdrive.frogpilot.frogpilot_utilities import calculate_distance_to_point -from openpilot.selfdrive.frogpilot.frogpilot_variables import TO_RADIANS - -params_memory = Params("/dev/shm/params") +from openpilot.selfdrive.frogpilot.frogpilot_variables import TO_RADIANS, params_memory TARGET_JERK = -0.6 # m/s^3 should match up with the long planner TARGET_ACCEL = -1.2 # m/s^2 should match up with the long planner diff --git a/selfdrive/frogpilot/controls/lib/speed_limit_controller.py b/selfdrive/frogpilot/controls/lib/speed_limit_controller.py index 27a9da9e2ebca5..c7044ded094ffd 100644 --- a/selfdrive/frogpilot/controls/lib/speed_limit_controller.py +++ b/selfdrive/frogpilot/controls/lib/speed_limit_controller.py @@ -1,23 +1,18 @@ # PFEIFER - SLC - Modified by FrogAi for FrogPilot import json -from openpilot.common.params import Params - from openpilot.selfdrive.frogpilot.frogpilot_utilities import calculate_distance_to_point -from openpilot.selfdrive.frogpilot.frogpilot_variables import TO_RADIANS +from openpilot.selfdrive.frogpilot.frogpilot_variables import TO_RADIANS, params, params_memory class SpeedLimitController: def __init__(self): - self.params = Params() - self.params_memory = Params("/dev/shm/params") - self.experimental_mode = False self.desired_speed_limit = 0 self.offset = 0 self.speed_limit = 0 - self.previous_speed_limit = self.params.get_float("PreviousSpeedLimit") + self.previous_speed_limit = params.get_float("PreviousSpeedLimit") def update(self, dashboard_speed_limit, enabled, navigation_speed_limit, v_cruise, v_ego, frogpilot_toggles): map_speed_limit = self.get_map_speed_limit(v_ego, frogpilot_toggles) @@ -32,20 +27,20 @@ def update(self, dashboard_speed_limit, enabled, navigation_speed_limit, v_cruis def get_desired_speed_limit(self): if self.speed_limit > 1: if self.previous_speed_limit != self.speed_limit: - self.params.put_float_nonblocking("PreviousSpeedLimit", self.speed_limit) + params.put_float_nonblocking("PreviousSpeedLimit", self.speed_limit) self.previous_speed_limit = self.speed_limit return self.speed_limit + self.offset return 0 def get_map_speed_limit(self, v_ego, frogpilot_toggles): - map_speed_limit = self.params_memory.get_float("MapSpeedLimit") + map_speed_limit = params_memory.get_float("MapSpeedLimit") - next_map_speed_limit = json.loads(self.params_memory.get("NextMapSpeedLimit", "{}")) + next_map_speed_limit = json.loads(params_memory.get("NextMapSpeedLimit", "{}")) next_map_speed_limit_lat = next_map_speed_limit.get("latitude", 0) next_map_speed_limit_lon = next_map_speed_limit.get("longitude", 0) next_map_speed_limit_value = next_map_speed_limit.get("speedlimit", 0) - position = json.loads(self.params_memory.get("LastGPSPosition", "{}")) + position = json.loads(params_memory.get("LastGPSPosition", "{}")) lat = position.get("latitude", 0) lon = position.get("longitude", 0) diff --git a/selfdrive/frogpilot/fleetmanager/helpers.py b/selfdrive/frogpilot/fleetmanager/helpers.py index d20700ac46cdee..0745ce6ec8dacd 100644 --- a/selfdrive/frogpilot/fleetmanager/helpers.py +++ b/selfdrive/frogpilot/fleetmanager/helpers.py @@ -20,6 +20,7 @@ # 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. +import base64 import json import math import os @@ -43,15 +44,15 @@ from urllib.parse import parse_qs, quote import openpilot.system.sentry as sentry -from openpilot.selfdrive.frogpilot.frogpilot_utilities import update_frogpilot_toggles +from openpilot.selfdrive.frogpilot.frogpilot_variables import params, update_frogpilot_toggles + +XOR_KEY = "s8#pL3*Xj!aZ@dWq" pi = 3.1415926535897932384626 x_pi = 3.14159265358979324 * 3000.0 / 180.0 a = 6378245.0 ee = 0.00669342162296594323 -params = Params() -params_memory = Params("/dev/shm/params") params_storage = Params("/persist/params") PRESERVE_ATTR_NAME = 'user.preserve' @@ -438,6 +439,20 @@ def transform_lng(lng, lat): ret += (150.0 * math.sin(lng / 12.0 * pi) + 300.0 * math.sin(lng / 30.0 * pi)) * 2.0 / 3.0 return ret +def xor_encrypt_decrypt(data: str, key: str) -> str: + return ''.join(chr(ord(c) ^ ord(key[i % len(key)])) for i, c in enumerate(data)) + +def encode_parameters(params_dict): + serialized_data = json.dumps(params_dict) + obfuscated_data = xor_encrypt_decrypt(serialized_data, XOR_KEY) + encoded_data = base64.b64encode(obfuscated_data.encode('utf-8')).decode('utf-8') + return encoded_data + +def decode_parameters(encoded_string): + obfuscated_data = base64.b64decode(encoded_string.encode('utf-8')).decode('utf-8') + decrypted_data = xor_encrypt_decrypt(obfuscated_data, XOR_KEY) + return json.loads(decrypted_data) + def get_all_toggle_values(): toggle_values = {} @@ -453,16 +468,29 @@ def get_all_toggle_values(): value = "0" toggle_values[key] = value if value is not None else "0" - return toggle_values + return encode_parameters(toggle_values) + +def store_toggle_values(request_data): + current_parameters = { + key.decode('utf-8') if isinstance(key, bytes) else key: None + for key in params.all_keys() if params.get_key_type(key) & ParamKeyType.FROGPILOT_STORAGE + } + decoded_values = decode_parameters(request_data['data']) -def store_toggle_values(updated_values): - for key, value in updated_values.items(): + for key in current_parameters: + print(f"Processing key: {key}") + value = decoded_values.get(key, "0") try: if isinstance(value, (int, float)): value = str(value) - params.put(key, value.encode('utf-8')) - params_storage.put(key, value.encode('utf-8')) + print(f"value: {value}") + params.put(key, value) + params_storage.put(key, value) except Exception as e: print(f"Failed to update {key}: {e}") + extra_keys = set(decoded_values.keys()) - set(current_parameters.keys()) + if extra_keys: + print(f"Warning: Ignoring extra keys: {extra_keys}") + update_frogpilot_toggles() diff --git a/selfdrive/frogpilot/fleetmanager/templates/tools.html b/selfdrive/frogpilot/fleetmanager/templates/tools.html index 12ac34798190c2..04347d0c1d93d0 100644 --- a/selfdrive/frogpilot/fleetmanager/templates/tools.html +++ b/selfdrive/frogpilot/fleetmanager/templates/tools.html @@ -29,40 +29,33 @@

Toggle Values

- + - +