From 084d7427f6e7d47d42ca33410bde5108d70863e4 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 22 Dec 2021 12:53:00 -0700 Subject: [PATCH 01/16] bump opendbc --- opendbc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opendbc b/opendbc index 2bab99fd861786..75c8dd4d0df665 160000 --- a/opendbc +++ b/opendbc @@ -1 +1 @@ -Subproject commit 2bab99fd861786312bde676823e21d80eeeb01fa +Subproject commit 75c8dd4d0df66546c568682bf54b90083add6138 From c5cd553b04eddfed15b0a5c25c96b072470ddfff Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 21 Dec 2021 03:19:04 -0700 Subject: [PATCH 02/16] add groundwork for accel response profiles --- selfdrive/car/toyota/interface.py | 1 + selfdrive/car/toyota/values.py | 2 +- selfdrive/controls/lib/longitudinal_planner.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 8be6073003ec06..7c30e24ea6e884 100755 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -16,6 +16,7 @@ class CarInterface(CarInterfaceBase): @staticmethod def get_pid_accel_limits(CP, current_speed, cruise_speed): + # as well as here (pid output is clipped to this) return CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX @staticmethod diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index 9361b10f74f420..5188b86a25beee 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -10,7 +10,7 @@ class CarControllerParams: - ACCEL_MAX = 1.6 # m/s2, lower than allowed 2.0 m/s2 for tuning reasons + ACCEL_MAX = 1.8 # m/s2, lower than allowed 2.0 m/s2 for tuning reasons ACCEL_MIN = -3.5 # m/s2 STEER_MAX = 1500 diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index 4af37a2307f199..6a5d770a25cbf5 100755 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -25,6 +25,7 @@ def get_max_accel(v_ego): + # change A_CRUISE_MAX_VALS live return interp(v_ego, A_CRUISE_MAX_BP, A_CRUISE_MAX_VALS) From 59072463271bae24206a38453f6fd7568b5cd23e Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 22 Dec 2021 13:28:06 -0700 Subject: [PATCH 03/16] add signals --- cereal | 2 +- selfdrive/car/toyota/carstate.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cereal b/cereal index ecb9c5eb8554fa..03bc465ba1d739 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit ecb9c5eb8554fae8f40698df80eeadf3fc1131e7 +Subproject commit 03bc465ba1d7394838830e7818a2b295366e23fb diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index 743546c5debd08..cf646e34140aea 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -87,6 +87,8 @@ def update(self, cp, cp_cam): can_gear = int(cp.vl["GEAR_PACKET"]["GEAR"]) ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear, None)) + ret.sportOn = bool(cp.vl["GEAR_PACKET"]["SPORT_ON"]) + ret.econOn = bool(cp.vl["GEAR_PACKET"]["ECON_ON"]) ret.leftBlinker = cp.vl["STEERING_LEVERS"]["TURN_SIGNALS"] == 1 ret.rightBlinker = cp.vl["STEERING_LEVERS"]["TURN_SIGNALS"] == 2 @@ -157,6 +159,8 @@ def get_can_parser(CP): # sig_name, sig_address, default ("STEER_ANGLE", "STEER_ANGLE_SENSOR", 0), ("GEAR", "GEAR_PACKET", 0), + ("SPORT_ON", "GEAR_PACKET", 0), + ("ECON_ON", "GEAR_PACKET", 0), ("BRAKE_PRESSED", "BRAKE_MODULE", 0), ("GAS_PEDAL", "GAS_PEDAL", 0), ("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0), From 227960d8bb892df86143fe52f29ae760aaa538b9 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 22 Dec 2021 14:40:08 -0700 Subject: [PATCH 04/16] only cars with sport eco --- selfdrive/car/toyota/carstate.py | 15 ++++++++++----- selfdrive/car/toyota/values.py | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index cf646e34140aea..49e24d226f160f 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -8,7 +8,7 @@ from selfdrive.car.interfaces import CarStateBase from opendbc.can.parser import CANParser from selfdrive.config import Conversions as CV -from selfdrive.car.toyota.values import CAR, DBC, STEER_THRESHOLD, NO_STOP_TIMER_CAR, TSS2_CAR +from selfdrive.car.toyota.values import CAR, DBC, STEER_THRESHOLD, NO_STOP_TIMER_CAR, TSS2_CAR, SPORT_ECO_CAR class CarState(CarStateBase): @@ -87,8 +87,9 @@ def update(self, cp, cp_cam): can_gear = int(cp.vl["GEAR_PACKET"]["GEAR"]) ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear, None)) - ret.sportOn = bool(cp.vl["GEAR_PACKET"]["SPORT_ON"]) - ret.econOn = bool(cp.vl["GEAR_PACKET"]["ECON_ON"]) + if self.CP.carFingerprint in SPORT_ECO_CAR: + ret.sportOn = bool(cp.vl["GEAR_PACKET"]["SPORT_ON"]) + ret.econOn = bool(cp.vl["GEAR_PACKET"]["ECON_ON"]) ret.leftBlinker = cp.vl["STEERING_LEVERS"]["TURN_SIGNALS"] == 1 ret.rightBlinker = cp.vl["STEERING_LEVERS"]["TURN_SIGNALS"] == 2 @@ -159,8 +160,6 @@ def get_can_parser(CP): # sig_name, sig_address, default ("STEER_ANGLE", "STEER_ANGLE_SENSOR", 0), ("GEAR", "GEAR_PACKET", 0), - ("SPORT_ON", "GEAR_PACKET", 0), - ("ECON_ON", "GEAR_PACKET", 0), ("BRAKE_PRESSED", "BRAKE_MODULE", 0), ("GAS_PEDAL", "GAS_PEDAL", 0), ("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0), @@ -239,6 +238,12 @@ def get_can_parser(CP): signals.append(("FD_BUTTON", "SDSU", 0)) checks.append(("SDSU", 33)) + if CP.carFingerprint in SPORT_ECO_CAR: + signals += [ + ("SPORT_ON", "GEAR_PACKET", 0), + ("ECON_ON", "GEAR_PACKET", 0), + ] + return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0) @staticmethod diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index 5188b86a25beee..ca4190ad5e4079 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -1644,6 +1644,7 @@ class CAR: CAR.MIRAI, CAR.LEXUS_NX_TSS2, CAR.ALPHARD_TSS2} NO_DSU_CAR = TSS2_CAR | {CAR.CHR, CAR.CHRH, CAR.CAMRY, CAR.CAMRYH} +SPORT_ECO_CAR = TSS2_CAR | {CAR.CHR, CAR.CHRH, CAR.CAMRY} # CamryH for some reason has special dbc # no resume button press required NO_STOP_TIMER_CAR = TSS2_CAR | {CAR.RAV4H, CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.SIENNA, CAR.LEXUS_ESH} From bb0390323cb03dbf6dc58275a8a144147beaf7bb Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 22 Dec 2021 14:42:30 -0700 Subject: [PATCH 05/16] change accel limit in mpc --- selfdrive/controls/lib/longitudinal_planner.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index 6a5d770a25cbf5..2808eb85e9dc77 100755 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -17,6 +17,8 @@ AWARENESS_DECEL = -0.2 # car smoothly decel at .2m/s^2 when user is distracted A_CRUISE_MIN = -1.2 A_CRUISE_MAX_VALS = [1.5, 1.2, 0.8, 0.6] +A_CRUISE_MAX_VALS_SPORT = [1.7, 1.3, 1.0, 0.8] # 1.7 gives us 0.1 m/s/s head room for controls +A_CRUISE_MAX_VALS_ECON = [1.2, 1.0, 0.6, 0.4] A_CRUISE_MAX_BP = [0., 15., 25., 40.] # Lookup table for turns @@ -24,9 +26,14 @@ _A_TOTAL_MAX_BP = [15., 40.] -def get_max_accel(v_ego): +def get_max_accel(v_ego, CS): # change A_CRUISE_MAX_VALS live - return interp(v_ego, A_CRUISE_MAX_BP, A_CRUISE_MAX_VALS) + if CS.sportOn: + return interp(v_ego, A_CRUISE_MAX_BP, A_CRUISE_MAX_VALS_SPORT) + elif CS.econOn: + return interp(v_ego, A_CRUISE_MAX_BP, A_CRUISE_MAX_VALS_ECON) + else: + return interp(v_ego, A_CRUISE_MAX_BP, A_CRUISE_MAX_VALS) def limit_accel_in_turns(v_ego, angle_steers, a_target, CP): @@ -79,7 +86,7 @@ def update(self, sm): self.v_desired = self.alpha * self.v_desired + (1 - self.alpha) * v_ego self.v_desired = max(0.0, self.v_desired) - accel_limits = [A_CRUISE_MIN, get_max_accel(v_ego)] + accel_limits = [A_CRUISE_MIN, get_max_accel(v_ego, sm['carState'])] accel_limits_turns = limit_accel_in_turns(v_ego, sm['carState'].steeringAngleDeg, accel_limits, self.CP) if force_slow_decel: # if required so, force a smooth deceleration From 12fb9c9857dc61e91e23bedaf7025f3860e5ff5d Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 22 Dec 2021 15:15:33 -0700 Subject: [PATCH 06/16] apply limits in longcontrol --- selfdrive/controls/lib/longcontrol.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index b8eb4af3ce6f9c..c8ddf68068f0fc 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -79,7 +79,12 @@ def update(self, active, CS, CP, long_plan, accel_limits, extras): a_target = clip(a_target, ACCEL_MIN_ISO, ACCEL_MAX_ISO) self.pid.neg_limit = accel_limits[0] - self.pid.pos_limit = accel_limits[1] + if CS.sportOn: + self.pid.pos_limit = accel_limits[1] # maximum accel + elif CS.econOn: + self.pid.pos_limit = 1.2 + else: + self.pid.pos_limit = 1.5 # Update state machine output_accel = self.last_output_accel From f3fd259db6c97be0d9b6bb7a38c6bc3a5cb2f8d0 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Dec 2021 02:24:59 -0700 Subject: [PATCH 07/16] correctly clip --- selfdrive/controls/lib/longcontrol.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index c8ddf68068f0fc..2c48a443886052 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -77,14 +77,14 @@ def update(self, active, CS, CP, long_plan, accel_limits, extras): # TODO: This check is not complete and needs to be enforced by MPC a_target = clip(a_target, ACCEL_MIN_ISO, ACCEL_MAX_ISO) - self.pid.neg_limit = accel_limits[0] if CS.sportOn: - self.pid.pos_limit = accel_limits[1] # maximum accel + pass # already max accel from CarControllerParams elif CS.econOn: - self.pid.pos_limit = 1.2 + accel_limits[1] = 1.2 else: - self.pid.pos_limit = 1.5 + accel_limits[1] = 1.5 + self.pid.pos_limit = accel_limits[1] # Update state machine output_accel = self.last_output_accel From 7de3de484f7f28062352854aa276c64898921625 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Dec 2021 02:34:02 -0700 Subject: [PATCH 08/16] tune profiles --- selfdrive/car/toyota/values.py | 2 +- selfdrive/controls/lib/longcontrol.py | 5 +++-- selfdrive/controls/lib/longitudinal_planner.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index ca4190ad5e4079..8758025aff5a81 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -10,7 +10,7 @@ class CarControllerParams: - ACCEL_MAX = 1.8 # m/s2, lower than allowed 2.0 m/s2 for tuning reasons + ACCEL_MAX = 1.9 # m/s2, lower than allowed 2.0 m/s2 for tuning reasons ACCEL_MIN = -3.5 # m/s2 STEER_MAX = 1500 diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index 2c48a443886052..74f96d471c51fa 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -77,13 +77,14 @@ def update(self, active, CS, CP, long_plan, accel_limits, extras): # TODO: This check is not complete and needs to be enforced by MPC a_target = clip(a_target, ACCEL_MIN_ISO, ACCEL_MAX_ISO) + self.pid.neg_limit = accel_limits[0] if CS.sportOn: pass # already max accel from CarControllerParams elif CS.econOn: - accel_limits[1] = 1.2 + accel_limits[1] = 1.3 else: - accel_limits[1] = 1.5 + accel_limits[1] = 1.6 self.pid.pos_limit = accel_limits[1] # Update state machine diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index 2808eb85e9dc77..632a41d2ad24aa 100755 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -17,7 +17,7 @@ AWARENESS_DECEL = -0.2 # car smoothly decel at .2m/s^2 when user is distracted A_CRUISE_MIN = -1.2 A_CRUISE_MAX_VALS = [1.5, 1.2, 0.8, 0.6] -A_CRUISE_MAX_VALS_SPORT = [1.7, 1.3, 1.0, 0.8] # 1.7 gives us 0.1 m/s/s head room for controls +A_CRUISE_MAX_VALS_SPORT = [1.8, 1.4, 1.2, 1.0] A_CRUISE_MAX_VALS_ECON = [1.2, 1.0, 0.6, 0.4] A_CRUISE_MAX_BP = [0., 15., 25., 40.] From 867ec3d0ab54cba328ba837018cd5809eb95b4ec Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Dec 2021 02:48:07 -0700 Subject: [PATCH 09/16] make list --- selfdrive/controls/controlsd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 1233baddacef5a..bbd2d551498a03 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -585,7 +585,7 @@ def state_control(self, CS): 'live_tracks': self.sm_smiskol['liveTracks'], 'has_lead': long_plan.hasLead} # accel PID loop - pid_accel_limits = self.CI.get_pid_accel_limits(self.CP, CS.vEgo, self.v_cruise_kph * CV.KPH_TO_MS) + pid_accel_limits = list(self.CI.get_pid_accel_limits(self.CP, CS.vEgo, self.v_cruise_kph * CV.KPH_TO_MS)) actuators.accel = self.LoC.update(self.active, CS, self.CP, long_plan, pid_accel_limits, extras_loc) # interpolate lat plan to 100hz From be6805e66671366905bdd372b37779d6b4b2d79e Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Dec 2021 02:52:17 -0700 Subject: [PATCH 10/16] Revert "Remove dynamic gas references" This reverts commit 0dab7a2b7af7ee7db2ca2b982fca49bcb938017f. --- README.md | 2 +- selfdrive/controls/lib/longcontrol.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dd54d2c308f378..352530269faf5f 100755 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Want to request a feature or create a bug report? [Open an issue here!](https:// * **Lane Speed** * [**Lane Speed Alerts**](#Lane-Speed-alerts) - alerts for when an adjacent lane is faster * [**~~Dynamic camera offsetting~~ (removed temporarily)**](#Dynamic-camera-offset-based-on-oncoming-traffic) - moves you over if adjacent lane has oncoming traffic -* [**~~Dynamic gas~~** (no longer needed)](#dynamic-gas) - smoother gas control +* [**~~Dynamic gas~~**](#dynamic-gas) - smoother gas control * [**~~Adding derivative to PI for better control~~**](#pi---pid-controller-for-long-and-lat) - lat: smoother control in turns; long: fix for comma pedal overshoot ### General Features diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index 74f96d471c51fa..4168f63c470131 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -4,6 +4,7 @@ from selfdrive.controls.lib.pid import PIDController from selfdrive.controls.lib.drive_helpers import CONTROL_N from selfdrive.modeld.constants import T_IDXS +from selfdrive.controls.lib.dynamic_gas import DynamicGas from common.op_params import opParams LongCtrlState = car.CarControl.Actuators.LongControlState @@ -53,6 +54,9 @@ def __init__(self, CP): self.v_pid = 0.0 self.last_output_accel = 0.0 + # self.op_params = opParams() + # self.dynamic_gas = DynamicGas(CP, candidate) + def reset(self, v_pid): """Reset PID controller and change setpoint""" self.pid.reset() @@ -87,6 +91,9 @@ def update(self, active, CS, CP, long_plan, accel_limits, extras): accel_limits[1] = 1.6 self.pid.pos_limit = accel_limits[1] + # if self.op_params.get('dynamic_gas'): + # gas_max = self.dynamic_gas.update(CS, extras) + # Update state machine output_accel = self.last_output_accel self.long_control_state = long_control_state_trans(CP, active, self.long_control_state, CS.vEgo, From 99bbb41c5a048005a7216f62db1a66c2088bcbef Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Dec 2021 03:19:38 -0700 Subject: [PATCH 11/16] tune profiles. most people want similar accelerations at low speeds --- selfdrive/car/toyota/values.py | 2 +- selfdrive/controls/lib/longcontrol.py | 2 +- selfdrive/controls/lib/longitudinal_planner.py | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index 8758025aff5a81..ca4190ad5e4079 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -10,7 +10,7 @@ class CarControllerParams: - ACCEL_MAX = 1.9 # m/s2, lower than allowed 2.0 m/s2 for tuning reasons + ACCEL_MAX = 1.8 # m/s2, lower than allowed 2.0 m/s2 for tuning reasons ACCEL_MIN = -3.5 # m/s2 STEER_MAX = 1500 diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index 4168f63c470131..ceaf2331ef806c 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -88,7 +88,7 @@ def update(self, active, CS, CP, long_plan, accel_limits, extras): elif CS.econOn: accel_limits[1] = 1.3 else: - accel_limits[1] = 1.6 + accel_limits[1] = 1.5 self.pid.pos_limit = accel_limits[1] # if self.op_params.get('dynamic_gas'): diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index 632a41d2ad24aa..f8b9b7013367b2 100755 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -16,10 +16,11 @@ LON_MPC_STEP = 0.2 # first step is 0.2s AWARENESS_DECEL = -0.2 # car smoothly decel at .2m/s^2 when user is distracted A_CRUISE_MIN = -1.2 -A_CRUISE_MAX_VALS = [1.5, 1.2, 0.8, 0.6] -A_CRUISE_MAX_VALS_SPORT = [1.8, 1.4, 1.2, 1.0] -A_CRUISE_MAX_VALS_ECON = [1.2, 1.0, 0.6, 0.4] -A_CRUISE_MAX_BP = [0., 15., 25., 40.] +# TODO: tune from DATA! +A_CRUISE_MAX_VALS = [1.6, 1.5, 0.7, 0.5] +A_CRUISE_MAX_VALS_SPORT = [1.9, 1.8, 1.0, 0.8] +A_CRUISE_MAX_VALS_ECON = [1.4, 1.2, 0.3, 0.3] +A_CRUISE_MAX_BP = [0., 6.4, 22.5, 40.] # 0., 14., 50.3, 90 mph # Lookup table for turns _A_TOTAL_MAX_V = [2.5, 3.8] From 8ce0cf994b71c4439e9ed62fe6ba9a6f0f0cf3b8 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sat, 25 Dec 2021 20:15:40 -0700 Subject: [PATCH 12/16] tune profiles --- selfdrive/controls/lib/longitudinal_planner.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index f8b9b7013367b2..8b37da2a978387 100755 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -17,9 +17,9 @@ AWARENESS_DECEL = -0.2 # car smoothly decel at .2m/s^2 when user is distracted A_CRUISE_MIN = -1.2 # TODO: tune from DATA! -A_CRUISE_MAX_VALS = [1.6, 1.5, 0.7, 0.5] -A_CRUISE_MAX_VALS_SPORT = [1.9, 1.8, 1.0, 0.8] -A_CRUISE_MAX_VALS_ECON = [1.4, 1.2, 0.3, 0.3] +A_CRUISE_MAX_VALS = [1.6, 1.5, 0.6, 0.4] +A_CRUISE_MAX_VALS_SPORT = [1.9, 1.6, 1.0, 0.8] +A_CRUISE_MAX_VALS_ECON = [1.4, 0.8, 0.4, 0.3] A_CRUISE_MAX_BP = [0., 6.4, 22.5, 40.] # 0., 14., 50.3, 90 mph # Lookup table for turns From 41901787641d4e854fdb3957b6ed2a066c7d84e6 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sun, 26 Dec 2021 03:00:12 -0700 Subject: [PATCH 13/16] econ values from stock system (draft) --- selfdrive/controls/lib/longitudinal_planner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index 8b37da2a978387..a87abb6eb5ddad 100755 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -19,7 +19,7 @@ # TODO: tune from DATA! A_CRUISE_MAX_VALS = [1.6, 1.5, 0.6, 0.4] A_CRUISE_MAX_VALS_SPORT = [1.9, 1.6, 1.0, 0.8] -A_CRUISE_MAX_VALS_ECON = [1.4, 0.8, 0.4, 0.3] +A_CRUISE_MAX_VALS_ECON = [1.4, 0.92, 0.5, 0.186] A_CRUISE_MAX_BP = [0., 6.4, 22.5, 40.] # 0., 14., 50.3, 90 mph # Lookup table for turns From 7f83e59de72d6b6ee55954f078307cdda6237aa0 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sun, 26 Dec 2021 04:34:47 -0700 Subject: [PATCH 14/16] tune profiles from data --- selfdrive/controls/lib/longitudinal_planner.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index a87abb6eb5ddad..29058e11cb754c 100755 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -18,10 +18,14 @@ A_CRUISE_MIN = -1.2 # TODO: tune from DATA! A_CRUISE_MAX_VALS = [1.6, 1.5, 0.6, 0.4] -A_CRUISE_MAX_VALS_SPORT = [1.9, 1.6, 1.0, 0.8] -A_CRUISE_MAX_VALS_ECON = [1.4, 0.92, 0.5, 0.186] A_CRUISE_MAX_BP = [0., 6.4, 22.5, 40.] # 0., 14., 50.3, 90 mph +A_CRUISE_MAX_VALS_SPORT = [1.0, 0.656] +A_CRUISE_MAX_BP_SPORT = [11.3876, 29.238] + +A_CRUISE_MAX_VALS_ECON = [1.0, 0.64, 0.5, 0.36] +A_CRUISE_MAX_BP_ECON = [3., 16.6332, 22.4933, 30.2597] + # Lookup table for turns _A_TOTAL_MAX_V = [2.5, 3.8] _A_TOTAL_MAX_BP = [15., 40.] @@ -30,9 +34,9 @@ def get_max_accel(v_ego, CS): # change A_CRUISE_MAX_VALS live if CS.sportOn: - return interp(v_ego, A_CRUISE_MAX_BP, A_CRUISE_MAX_VALS_SPORT) + return interp(v_ego, A_CRUISE_MAX_BP_SPORT, A_CRUISE_MAX_VALS_SPORT) elif CS.econOn: - return interp(v_ego, A_CRUISE_MAX_BP, A_CRUISE_MAX_VALS_ECON) + return interp(v_ego, A_CRUISE_MAX_BP_ECON, A_CRUISE_MAX_VALS_ECON) else: return interp(v_ego, A_CRUISE_MAX_BP, A_CRUISE_MAX_VALS) From fe36ff9f2abd355feb4e3a072f173694b5d42fd2 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sun, 26 Dec 2021 04:36:15 -0700 Subject: [PATCH 15/16] clip max requested accel to 1.0, with PID up to 1.5 --- selfdrive/car/toyota/values.py | 2 +- selfdrive/controls/lib/longcontrol.py | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index ca4190ad5e4079..b519d4f3346dcc 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -10,7 +10,7 @@ class CarControllerParams: - ACCEL_MAX = 1.8 # m/s2, lower than allowed 2.0 m/s2 for tuning reasons + ACCEL_MAX = 1.0 # m/s2, lower than allowed 2.0 m/s2 for tuning reasons ACCEL_MIN = -3.5 # m/s2 STEER_MAX = 1500 diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index ceaf2331ef806c..712ed50c17d765 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -83,12 +83,13 @@ def update(self, active, CS, CP, long_plan, accel_limits, extras): a_target = clip(a_target, ACCEL_MIN_ISO, ACCEL_MAX_ISO) self.pid.neg_limit = accel_limits[0] - if CS.sportOn: - pass # already max accel from CarControllerParams - elif CS.econOn: - accel_limits[1] = 1.3 - else: - accel_limits[1] = 1.5 + # if CS.sportOn: + # pass # already max accel from CarControllerParams + # elif CS.econOn: + # accel_limits[1] = 1.3 + # else: + # accel_limits[1] = 1.5 + accel_limits[1] = 1.5 self.pid.pos_limit = accel_limits[1] # if self.op_params.get('dynamic_gas'): From 385b49bce5aa58b85df17b656db542b5b82d2251 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sat, 8 Jan 2022 01:27:10 -0700 Subject: [PATCH 16/16] revert --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 352530269faf5f..dd54d2c308f378 100755 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Want to request a feature or create a bug report? [Open an issue here!](https:// * **Lane Speed** * [**Lane Speed Alerts**](#Lane-Speed-alerts) - alerts for when an adjacent lane is faster * [**~~Dynamic camera offsetting~~ (removed temporarily)**](#Dynamic-camera-offset-based-on-oncoming-traffic) - moves you over if adjacent lane has oncoming traffic -* [**~~Dynamic gas~~**](#dynamic-gas) - smoother gas control +* [**~~Dynamic gas~~** (no longer needed)](#dynamic-gas) - smoother gas control * [**~~Adding derivative to PI for better control~~**](#pi---pid-controller-for-long-and-lat) - lat: smoother control in turns; long: fix for comma pedal overshoot ### General Features