diff --git a/selfdrive/controls/lib/latcontrol_torque.py b/selfdrive/controls/lib/latcontrol_torque.py index e25c182d9..788d587fa 100644 --- a/selfdrive/controls/lib/latcontrol_torque.py +++ b/selfdrive/controls/lib/latcontrol_torque.py @@ -4,6 +4,7 @@ from collections import deque from cereal import log from opendbc.car.gm.values import CAR as GM_CAR +from opendbc.car.hyundai.values import CAR as HYUNDAI_CAR from opendbc.car.lateral import get_friction from openpilot.common.constants import ACCELERATION_DUE_TO_GRAVITY, CV from openpilot.common.filter_simple import FirstOrderFilter @@ -57,6 +58,15 @@ BOLT_2017_CARS = ( GM_CAR.CHEVROLET_BOLT_CC_2017, ) BOLT_CARS = BOLT_2022_2023_CARS + BOLT_2018_2021_CARS + BOLT_2017_CARS +VOLT_STANDARD_CARS = ( + GM_CAR.CHEVROLET_VOLT, + GM_CAR.CHEVROLET_VOLT_ASCM, + GM_CAR.CHEVROLET_VOLT_CAMERA, + GM_CAR.CHEVROLET_VOLT_CC, +) +GENESIS_G90_CARS = ( + HYUNDAI_CAR.GENESIS_G90, +) BOLT_2017_LATERAL_TESTING_GROUND_ID = testing_ground.id_3 BOLT_2017_STEER_RATIO_TEST_SCALE = 1.045 @@ -130,6 +140,56 @@ BOLT_2022_2023_TURN_IN_FRICTION_BOOST_RIGHT = 0.04 BOLT_2022_2023_UNWIND_FRICTION_REDUCTION_LEFT = 0.21 BOLT_2022_2023_UNWIND_FRICTION_REDUCTION_RIGHT = 0.17 +VOLT_STANDARD_LATERAL_TESTING_GROUND_ID = testing_ground.id_3 +VOLT_STANDARD_FF_GAIN_LEFT = 0.07 +VOLT_STANDARD_FF_GAIN_RIGHT = 0.10 +VOLT_STANDARD_FF_ONSET = 0.10 +VOLT_STANDARD_FF_ONSET_WIDTH = 0.05 +VOLT_STANDARD_FF_CUTOFF = 1.30 +VOLT_STANDARD_FF_CUTOFF_WIDTH = 0.24 +VOLT_STANDARD_TRANSITION_SPEED = 10.0 +VOLT_STANDARD_PHASE_SCALE = 0.10 +VOLT_STANDARD_TURN_IN_BOOST_LEFT = -0.08 +VOLT_STANDARD_TURN_IN_BOOST_RIGHT = 0.20 +VOLT_STANDARD_UNWIND_TAPER_LEFT = 0.03 +VOLT_STANDARD_UNWIND_TAPER_RIGHT = 0.02 +VOLT_STANDARD_FRICTION_MULT = 1.04 +VOLT_STANDARD_FRICTION_LAT_RISE = 0.20 +VOLT_STANDARD_FRICTION_JERK_RISE = 0.24 +VOLT_STANDARD_TURN_IN_THRESHOLD_REDUCTION_LEFT = -0.08 +VOLT_STANDARD_TURN_IN_THRESHOLD_REDUCTION_RIGHT = 0.12 +VOLT_STANDARD_UNWIND_THRESHOLD_INCREASE_LEFT = -0.06 +VOLT_STANDARD_UNWIND_THRESHOLD_INCREASE_RIGHT = -0.08 +VOLT_STANDARD_TURN_IN_FRICTION_BOOST_LEFT = -0.03 +VOLT_STANDARD_TURN_IN_FRICTION_BOOST_RIGHT = 0.06 +VOLT_STANDARD_UNWIND_FRICTION_REDUCTION_LEFT = -0.04 +VOLT_STANDARD_UNWIND_FRICTION_REDUCTION_RIGHT = -0.06 + +GENESIS_G90_LATERAL_TESTING_GROUND_ID = testing_ground.id_4 +GENESIS_G90_FF_GAIN_LEFT = 0.09 +GENESIS_G90_FF_GAIN_RIGHT = 0.06 +GENESIS_G90_FF_ONSET = 0.12 +GENESIS_G90_FF_ONSET_WIDTH = 0.05 +GENESIS_G90_FF_CUTOFF = 1.35 +GENESIS_G90_FF_CUTOFF_WIDTH = 0.25 +GENESIS_G90_TRANSITION_SPEED = 8.5 +GENESIS_G90_PHASE_SCALE = 0.12 +GENESIS_G90_TURN_IN_BOOST_LEFT = 0.06 +GENESIS_G90_TURN_IN_BOOST_RIGHT = 0.14 +GENESIS_G90_UNWIND_TAPER_LEFT = 0.08 +GENESIS_G90_UNWIND_TAPER_RIGHT = 0.12 +GENESIS_G90_FRICTION_MULT = 1.01 +GENESIS_G90_FRICTION_LAT_RISE = 0.22 +GENESIS_G90_FRICTION_JERK_RISE = 0.24 +GENESIS_G90_TURN_IN_THRESHOLD_REDUCTION_LEFT = 0.06 +GENESIS_G90_TURN_IN_THRESHOLD_REDUCTION_RIGHT = 0.10 +GENESIS_G90_UNWIND_THRESHOLD_INCREASE_LEFT = 0.06 +GENESIS_G90_UNWIND_THRESHOLD_INCREASE_RIGHT = 0.10 +GENESIS_G90_TURN_IN_FRICTION_BOOST_LEFT = 0.03 +GENESIS_G90_TURN_IN_FRICTION_BOOST_RIGHT = 0.05 +GENESIS_G90_UNWIND_FRICTION_REDUCTION_LEFT = 0.06 +GENESIS_G90_UNWIND_FRICTION_REDUCTION_RIGHT = 0.08 + VOLT_PLEXY_LATERAL_TESTING_GROUND_ID = testing_ground.id_7 VOLT_PLEXY_FF_GAIN_LEFT = 0.12 VOLT_PLEXY_FF_GAIN_RIGHT = 0.07 @@ -384,6 +444,150 @@ def get_bolt_2022_2023_friction_scale(v_ego: float, desired_lateral_accel: float return min(max(friction_scale, 0.92), 1.22) +def volt_standard_lateral_testing_ground_active() -> bool: + return testing_ground.use(VOLT_STANDARD_LATERAL_TESTING_GROUND_ID) + + +def _volt_standard_sigmoid(x: float) -> float: + return _sigmoid(x) + + +def _volt_standard_low_speed_factor(v_ego: float) -> float: + return 1.0 / (1.0 + (max(v_ego, 0.0) / VOLT_STANDARD_TRANSITION_SPEED) ** 2) + + +def _volt_standard_transition_phase(desired_lateral_accel: float, desired_lateral_jerk: float) -> float: + return math.tanh((desired_lateral_accel * desired_lateral_jerk) / VOLT_STANDARD_PHASE_SCALE) + + +def _volt_standard_side_value(desired_lateral_accel: float, left_value: float, right_value: float) -> float: + return left_value if desired_lateral_accel >= 0.0 else right_value + + +def _volt_standard_transition_envelope(v_ego: float, desired_lateral_accel: float, desired_lateral_jerk: float) -> float: + lat_factor = 1.0 - math.exp(-abs(desired_lateral_accel) / VOLT_STANDARD_FRICTION_LAT_RISE) + jerk_factor = 1.0 - math.exp(-abs(desired_lateral_jerk) / VOLT_STANDARD_FRICTION_JERK_RISE) + return _volt_standard_low_speed_factor(v_ego) * lat_factor * jerk_factor + + +def get_volt_standard_ff_scale(desired_lateral_accel: float, desired_lateral_jerk: float, v_ego: float) -> float: + if desired_lateral_accel == 0.0: + return 1.0 + + gain = _volt_standard_side_value(desired_lateral_accel, VOLT_STANDARD_FF_GAIN_LEFT, VOLT_STANDARD_FF_GAIN_RIGHT) + abs_lateral_accel = abs(desired_lateral_accel) + onset = _volt_standard_sigmoid((abs_lateral_accel - VOLT_STANDARD_FF_ONSET) / VOLT_STANDARD_FF_ONSET_WIDTH) + cutoff = _volt_standard_sigmoid((VOLT_STANDARD_FF_CUTOFF - abs_lateral_accel) / VOLT_STANDARD_FF_CUTOFF_WIDTH) + extra_scale = gain * onset * cutoff + phase = _volt_standard_transition_phase(desired_lateral_accel, desired_lateral_jerk) + turn_in_weight = max(phase, 0.0) + unwind_weight = max(-phase, 0.0) + low_speed_factor = _volt_standard_low_speed_factor(v_ego) + turn_in_boost = 1.0 + (_volt_standard_side_value(desired_lateral_accel, VOLT_STANDARD_TURN_IN_BOOST_LEFT, VOLT_STANDARD_TURN_IN_BOOST_RIGHT) * + turn_in_weight * low_speed_factor) + unwind_taper = 1.0 - (_volt_standard_side_value(desired_lateral_accel, VOLT_STANDARD_UNWIND_TAPER_LEFT, VOLT_STANDARD_UNWIND_TAPER_RIGHT) * + unwind_weight * (0.30 + 0.70 * low_speed_factor)) + return 1.0 + (extra_scale * turn_in_boost * max(unwind_taper, 0.0)) + + +def get_volt_standard_friction_threshold(v_ego: float, desired_lateral_accel: float = 0.0, desired_lateral_jerk: float = 0.0) -> float: + base_threshold = get_friction_threshold(v_ego) + transition_envelope = _volt_standard_transition_envelope(v_ego, desired_lateral_accel, desired_lateral_jerk) + phase = _volt_standard_transition_phase(desired_lateral_accel, desired_lateral_jerk) + turn_in_weight = max(phase, 0.0) + unwind_weight = max(-phase, 0.0) + threshold_scale = 1.0 - (_volt_standard_side_value(desired_lateral_accel, VOLT_STANDARD_TURN_IN_THRESHOLD_REDUCTION_LEFT, VOLT_STANDARD_TURN_IN_THRESHOLD_REDUCTION_RIGHT) * + transition_envelope * turn_in_weight) + threshold_scale += (_volt_standard_side_value(desired_lateral_accel, VOLT_STANDARD_UNWIND_THRESHOLD_INCREASE_LEFT, VOLT_STANDARD_UNWIND_THRESHOLD_INCREASE_RIGHT) * + transition_envelope * unwind_weight) + return base_threshold * min(max(threshold_scale, 0.84), 1.12) + + +def get_volt_standard_friction_scale(v_ego: float, desired_lateral_accel: float, desired_lateral_jerk: float) -> float: + transition_envelope = _volt_standard_transition_envelope(v_ego, desired_lateral_accel, desired_lateral_jerk) + phase = _volt_standard_transition_phase(desired_lateral_accel, desired_lateral_jerk) + turn_in_weight = max(phase, 0.0) + unwind_weight = max(-phase, 0.0) + friction_scale = VOLT_STANDARD_FRICTION_MULT + friction_scale += (_volt_standard_side_value(desired_lateral_accel, VOLT_STANDARD_TURN_IN_FRICTION_BOOST_LEFT, VOLT_STANDARD_TURN_IN_FRICTION_BOOST_RIGHT) * + transition_envelope * turn_in_weight) + friction_scale -= (_volt_standard_side_value(desired_lateral_accel, VOLT_STANDARD_UNWIND_FRICTION_REDUCTION_LEFT, VOLT_STANDARD_UNWIND_FRICTION_REDUCTION_RIGHT) * + transition_envelope * unwind_weight) + return min(max(friction_scale, 0.90), 1.14) + + +def genesis_g90_lateral_testing_ground_active() -> bool: + return testing_ground.use(GENESIS_G90_LATERAL_TESTING_GROUND_ID) + + +def _genesis_g90_sigmoid(x: float) -> float: + return _sigmoid(x) + + +def _genesis_g90_low_speed_factor(v_ego: float) -> float: + return 1.0 / (1.0 + (max(v_ego, 0.0) / GENESIS_G90_TRANSITION_SPEED) ** 2) + + +def _genesis_g90_transition_phase(desired_lateral_accel: float, desired_lateral_jerk: float) -> float: + return math.tanh((desired_lateral_accel * desired_lateral_jerk) / GENESIS_G90_PHASE_SCALE) + + +def _genesis_g90_side_value(desired_lateral_accel: float, left_value: float, right_value: float) -> float: + return left_value if desired_lateral_accel >= 0.0 else right_value + + +def _genesis_g90_transition_envelope(v_ego: float, desired_lateral_accel: float, desired_lateral_jerk: float) -> float: + lat_factor = 1.0 - math.exp(-abs(desired_lateral_accel) / GENESIS_G90_FRICTION_LAT_RISE) + jerk_factor = 1.0 - math.exp(-abs(desired_lateral_jerk) / GENESIS_G90_FRICTION_JERK_RISE) + return _genesis_g90_low_speed_factor(v_ego) * lat_factor * jerk_factor + + +def get_genesis_g90_ff_scale(desired_lateral_accel: float, desired_lateral_jerk: float, v_ego: float) -> float: + if desired_lateral_accel == 0.0: + return 1.0 + + gain = _genesis_g90_side_value(desired_lateral_accel, GENESIS_G90_FF_GAIN_LEFT, GENESIS_G90_FF_GAIN_RIGHT) + abs_lateral_accel = abs(desired_lateral_accel) + onset = _genesis_g90_sigmoid((abs_lateral_accel - GENESIS_G90_FF_ONSET) / GENESIS_G90_FF_ONSET_WIDTH) + cutoff = _genesis_g90_sigmoid((GENESIS_G90_FF_CUTOFF - abs_lateral_accel) / GENESIS_G90_FF_CUTOFF_WIDTH) + extra_scale = gain * onset * cutoff + phase = _genesis_g90_transition_phase(desired_lateral_accel, desired_lateral_jerk) + turn_in_weight = max(phase, 0.0) + unwind_weight = max(-phase, 0.0) + low_speed_factor = _genesis_g90_low_speed_factor(v_ego) + turn_in_boost = 1.0 + (_genesis_g90_side_value(desired_lateral_accel, GENESIS_G90_TURN_IN_BOOST_LEFT, GENESIS_G90_TURN_IN_BOOST_RIGHT) * + turn_in_weight * (0.35 + 0.65 * low_speed_factor)) + unwind_taper = 1.0 - (_genesis_g90_side_value(desired_lateral_accel, GENESIS_G90_UNWIND_TAPER_LEFT, GENESIS_G90_UNWIND_TAPER_RIGHT) * + unwind_weight * (0.30 + 0.70 * low_speed_factor)) + return 1.0 + (extra_scale * turn_in_boost * max(unwind_taper, 0.0)) + + +def get_genesis_g90_friction_threshold(v_ego: float, desired_lateral_accel: float = 0.0, desired_lateral_jerk: float = 0.0) -> float: + base_threshold = get_friction_threshold(v_ego) + transition_envelope = _genesis_g90_transition_envelope(v_ego, desired_lateral_accel, desired_lateral_jerk) + phase = _genesis_g90_transition_phase(desired_lateral_accel, desired_lateral_jerk) + turn_in_weight = max(phase, 0.0) + unwind_weight = max(-phase, 0.0) + threshold_scale = 1.0 - (_genesis_g90_side_value(desired_lateral_accel, GENESIS_G90_TURN_IN_THRESHOLD_REDUCTION_LEFT, GENESIS_G90_TURN_IN_THRESHOLD_REDUCTION_RIGHT) * + transition_envelope * turn_in_weight) + threshold_scale += (_genesis_g90_side_value(desired_lateral_accel, GENESIS_G90_UNWIND_THRESHOLD_INCREASE_LEFT, GENESIS_G90_UNWIND_THRESHOLD_INCREASE_RIGHT) * + transition_envelope * unwind_weight) + return base_threshold * min(max(threshold_scale, 0.86), 1.12) + + +def get_genesis_g90_friction_scale(v_ego: float, desired_lateral_accel: float, desired_lateral_jerk: float) -> float: + transition_envelope = _genesis_g90_transition_envelope(v_ego, desired_lateral_accel, desired_lateral_jerk) + phase = _genesis_g90_transition_phase(desired_lateral_accel, desired_lateral_jerk) + turn_in_weight = max(phase, 0.0) + unwind_weight = max(-phase, 0.0) + friction_scale = GENESIS_G90_FRICTION_MULT + friction_scale += (_genesis_g90_side_value(desired_lateral_accel, GENESIS_G90_TURN_IN_FRICTION_BOOST_LEFT, GENESIS_G90_TURN_IN_FRICTION_BOOST_RIGHT) * + transition_envelope * turn_in_weight) + friction_scale -= (_genesis_g90_side_value(desired_lateral_accel, GENESIS_G90_UNWIND_FRICTION_REDUCTION_LEFT, GENESIS_G90_UNWIND_FRICTION_REDUCTION_RIGHT) * + transition_envelope * unwind_weight) + return min(max(friction_scale, 0.92), 1.12) + + def volt_plexy_lateral_testing_ground_active() -> bool: return testing_ground.use(VOLT_PLEXY_LATERAL_TESTING_GROUND_ID) @@ -481,6 +685,8 @@ class LatControlTorque(LatControl): self.is_bolt_2022_2023 = CP.carFingerprint in BOLT_2022_2023_CARS self.is_bolt_2018_2021 = CP.carFingerprint in BOLT_2018_2021_CARS self.is_bolt_2017 = CP.carFingerprint in BOLT_2017_CARS + self.is_volt_standard = CP.carFingerprint in VOLT_STANDARD_CARS + self.is_genesis_g90 = CP.carFingerprint in GENESIS_G90_CARS self.is_volt_cc = CP.carFingerprint == GM_CAR.CHEVROLET_VOLT_CC self.is_silverado = CP.carFingerprint == GM_CAR.CHEVROLET_SILVERADO self.use_bolt_ff_scaling = self.is_bolt_2022_2023 or self.is_bolt_2018_2021 or self.is_bolt_2017 @@ -562,9 +768,11 @@ class LatControlTorque(LatControl): if self.use_bolt_ff_scaling: ff_scale = np.interp(ff, [-FF_SCALE_BLEND_LAT_ACCEL, 0.0, FF_SCALE_BLEND_LAT_ACCEL], [self.torque_ff_scale_neg, 1.0, self.torque_ff_scale_pos]) - ff *= ff_scale + ff *= ff_scale bolt_2022_2023_tuned_path_active = self.is_bolt_2022_2023 bolt_2018_2021_tuned_path_active = self.is_bolt_2018_2021 + volt_standard_test_active = self.is_volt_standard and volt_standard_lateral_testing_ground_active() + genesis_g90_test_active = self.is_genesis_g90 and genesis_g90_lateral_testing_ground_active() volt_plexy_test_active = self.is_volt_cc and volt_plexy_lateral_testing_ground_active() friction_threshold = get_friction_threshold(CS.vEgo) friction_scale = 1.0 @@ -575,6 +783,14 @@ class LatControlTorque(LatControl): elif bolt_2018_2021_tuned_path_active: friction_threshold = get_bolt_2018_2021_friction_threshold(CS.vEgo, setpoint, desired_lateral_jerk) friction_scale = get_bolt_2018_2021_friction_scale(CS.vEgo, setpoint, desired_lateral_jerk) + elif volt_standard_test_active: + ff *= get_volt_standard_ff_scale(setpoint, desired_lateral_jerk, CS.vEgo) + friction_threshold = get_volt_standard_friction_threshold(CS.vEgo, setpoint, desired_lateral_jerk) + friction_scale = get_volt_standard_friction_scale(CS.vEgo, setpoint, desired_lateral_jerk) + elif genesis_g90_test_active: + ff *= get_genesis_g90_ff_scale(setpoint, desired_lateral_jerk, CS.vEgo) + friction_threshold = get_genesis_g90_friction_threshold(CS.vEgo, setpoint, desired_lateral_jerk) + friction_scale = get_genesis_g90_friction_scale(CS.vEgo, setpoint, desired_lateral_jerk) elif volt_plexy_test_active: ff *= get_volt_plexy_ff_scale(setpoint, desired_lateral_jerk, CS.vEgo) friction_threshold = get_volt_plexy_friction_threshold(CS.vEgo, setpoint, desired_lateral_jerk) diff --git a/selfdrive/controls/tests/test_latcontrol.py b/selfdrive/controls/tests/test_latcontrol.py index 506378af8..c16513bf7 100644 --- a/selfdrive/controls/tests/test_latcontrol.py +++ b/selfdrive/controls/tests/test_latcontrol.py @@ -8,6 +8,7 @@ from opendbc.car.honda.values import CAR as HONDA from opendbc.car.toyota.values import CAR as TOYOTA from opendbc.car.nissan.values import CAR as NISSAN from opendbc.car.gm.values import CAR as GM +from opendbc.car.hyundai.values import CAR as HYUNDAI from opendbc.car.vehicle_model import VehicleModel from openpilot.common.realtime import DT_CTRL from openpilot.selfdrive.controls.lib.latcontrol_angle import LatControlAngle @@ -26,6 +27,12 @@ from openpilot.selfdrive.controls.lib.latcontrol_torque import ( get_bolt_2018_2021_friction_scale, get_bolt_2018_2021_friction_threshold, get_bolt_2018_2021_torque_scale, + get_genesis_g90_ff_scale, + get_genesis_g90_friction_scale, + get_genesis_g90_friction_threshold, + get_volt_standard_ff_scale, + get_volt_standard_friction_scale, + get_volt_standard_friction_threshold, get_volt_plexy_ff_scale, get_volt_plexy_friction_scale, get_volt_plexy_friction_threshold, @@ -134,6 +141,58 @@ class TestLatControl: assert get_volt_plexy_ff_scale(-0.6, -0.7, 8.0) > get_volt_plexy_ff_scale(-0.6, 0.0, 8.0) > get_volt_plexy_ff_scale(-0.6, 0.7, 8.0) assert get_volt_plexy_ff_scale(2.0, 0.0, 20.0) < get_volt_plexy_ff_scale(0.8, 0.0, 20.0) + def test_volt_standard_ff_scale_curve(self): + assert get_volt_standard_ff_scale(0.0, 0.0, 20.0) == 1.0 + assert get_volt_standard_ff_scale(-0.5, 0.0, 20.0) > get_volt_standard_ff_scale(0.5, 0.0, 20.0) + assert get_volt_standard_ff_scale(0.6, 0.7, 8.0) < get_volt_standard_ff_scale(0.6, 0.0, 8.0) + assert get_volt_standard_ff_scale(-0.6, -0.7, 8.0) > get_volt_standard_ff_scale(-0.6, 0.0, 8.0) + assert get_volt_standard_ff_scale(2.0, 0.0, 20.0) < get_volt_standard_ff_scale(0.8, 0.0, 20.0) + + def test_volt_standard_friction_threshold_curve(self): + base = get_friction_threshold(6.0) + left_turn_in = get_volt_standard_friction_threshold(6.0, 0.7, 0.8) + right_turn_in = get_volt_standard_friction_threshold(6.0, -0.7, -0.8) + left_unwind = get_volt_standard_friction_threshold(6.0, 0.7, -0.8) + right_unwind = get_volt_standard_friction_threshold(6.0, -0.7, 0.8) + assert left_turn_in > base > right_turn_in + assert left_unwind < base and right_unwind < base + + def test_volt_standard_friction_scale_curve(self): + base = get_volt_standard_friction_scale(25.0, 0.7, 0.8) + left_turn_in = get_volt_standard_friction_scale(6.0, 0.7, 0.8) + right_turn_in = get_volt_standard_friction_scale(6.0, -0.7, -0.8) + left_unwind = get_volt_standard_friction_scale(6.0, 0.7, -0.8) + right_unwind = get_volt_standard_friction_scale(6.0, -0.7, 0.8) + assert left_turn_in < base < right_turn_in + assert left_unwind > base and right_unwind > base + + def test_genesis_g90_ff_scale_curve(self): + assert get_genesis_g90_ff_scale(0.0, 0.0, 20.0) == 1.0 + assert get_genesis_g90_ff_scale(0.5, 0.0, 20.0) > get_genesis_g90_ff_scale(-0.5, 0.0, 20.0) + assert get_genesis_g90_ff_scale(0.6, 0.7, 8.0) > get_genesis_g90_ff_scale(0.6, 0.0, 8.0) > get_genesis_g90_ff_scale(0.6, -0.7, 8.0) + assert get_genesis_g90_ff_scale(-0.6, -0.7, 8.0) > get_genesis_g90_ff_scale(-0.6, 0.0, 8.0) > get_genesis_g90_ff_scale(-0.6, 0.7, 8.0) + assert get_genesis_g90_ff_scale(2.0, 0.0, 20.0) < get_genesis_g90_ff_scale(0.8, 0.0, 20.0) + + def test_genesis_g90_friction_threshold_curve(self): + base = get_friction_threshold(6.0) + left_turn_in = get_genesis_g90_friction_threshold(6.0, 0.7, 0.8) + right_turn_in = get_genesis_g90_friction_threshold(6.0, -0.7, -0.8) + left_unwind = get_genesis_g90_friction_threshold(6.0, 0.7, -0.8) + right_unwind = get_genesis_g90_friction_threshold(6.0, -0.7, 0.8) + assert left_turn_in < base + assert right_turn_in < left_turn_in + assert left_unwind > base + assert right_unwind > left_unwind + + def test_genesis_g90_friction_scale_curve(self): + base = get_genesis_g90_friction_scale(25.0, 0.7, 0.8) + left_turn_in = get_genesis_g90_friction_scale(6.0, 0.7, 0.8) + right_turn_in = get_genesis_g90_friction_scale(6.0, -0.7, -0.8) + left_unwind = get_genesis_g90_friction_scale(6.0, 0.7, -0.8) + right_unwind = get_genesis_g90_friction_scale(6.0, -0.7, 0.8) + assert right_turn_in > left_turn_in > base + assert base > left_unwind > right_unwind + def test_volt_plexy_friction_threshold_curve(self): base = get_friction_threshold(6.0) left_turn_in = get_volt_plexy_friction_threshold(6.0, 0.7, 0.8) @@ -172,6 +231,22 @@ class TestLatControl: assert lac_log.active + def test_volt_standard_testing_ground_update_path(self, monkeypatch): + controller, VM, CS, params, starpilot_toggles = self._build_torque_controller(GM.CHEVROLET_VOLT_ASCM) + monkeypatch.setattr(latcontrol_torque, "volt_standard_lateral_testing_ground_active", lambda: True) + + _, _, lac_log = controller.update(True, CS, VM, params, False, 0.0025, False, 0.2, None, None, starpilot_toggles) + + assert lac_log.active + + def test_genesis_g90_testing_ground_update_path(self, monkeypatch): + controller, VM, CS, params, starpilot_toggles = self._build_torque_controller(HYUNDAI.GENESIS_G90) + monkeypatch.setattr(latcontrol_torque, "genesis_g90_lateral_testing_ground_active", lambda: True) + + _, _, lac_log = controller.update(True, CS, VM, params, False, 0.0025, False, 0.2, None, None, starpilot_toggles) + + assert lac_log.active + def test_volt_plexy_testing_ground_update_path(self, monkeypatch): controller, VM, CS, params, starpilot_toggles = self._build_torque_controller(GM.CHEVROLET_VOLT_CC) monkeypatch.setattr(latcontrol_torque, "volt_plexy_lateral_testing_ground_active", lambda: True) diff --git a/starpilot/common/testing_grounds.py b/starpilot/common/testing_grounds.py index 12da6db95..ddde0e603 100644 --- a/starpilot/common/testing_grounds.py +++ b/starpilot/common/testing_grounds.py @@ -33,29 +33,31 @@ TESTING_GROUNDS_STATE_PATH = Path("/tmp/the_pond_testing_grounds_slots.json") if TESTING_GROUNDS_SLOT_DEFINITIONS = ( { "id": TESTING_GROUND_1, - "name": "GM Long Tune", + "name": "ACC Bolt Long Tune", "description": "BoltLongTune A/B sandbox for GM ACC longitudinal testing.", "aLabel": "A - Installed tune", - "bLabel": "B - BoltLongTune test", + "bLabel": "B - Firestar Tune", }, { "id": TESTING_GROUND_2, - "name": "volt test tune", + "name": "Volt Long Tune", "description": "Volt longitudinal tuning sandbox.", "aLabel": "A - Installed tune", - "bLabel": "B - Test Tune", + "bLabel": "B - Firestar Tune", }, { "id": TESTING_GROUND_3, - "name": "Unused", - "description": "", - "aLabel": "A", + "name": "Volt Lateral", + "description": "Standard-tire Volt lateral A/B sandbox, separate from Plexy's custom tire-size tune.", + "aLabel": "A - Installed tune", + "bLabel": "B - Firestar Tune", }, { "id": TESTING_GROUND_4, - "name": "Unused", - "description": "", - "aLabel": "A", + "name": "Genesis G90 Lateral", + "description": "Genesis G90 2017 lateral A/B sandbox.", + "aLabel": "A - Installed tune", + "bLabel": "B - Firestar Tune", }, { "id": TESTING_GROUND_5, @@ -74,7 +76,7 @@ TESTING_GROUNDS_SLOT_DEFINITIONS = ( "name": "Plexy's Car", "description": "Volt lateral A/B sandbox for Plexy's baseline torque tuning.", "aLabel": "A - Installed tune", - "bLabel": "B - Plexy baseline", + "bLabel": "B - Firestar Tune", }, ) diff --git a/starpilot/common/tests/test_testing_grounds.py b/starpilot/common/tests/test_testing_grounds.py index 23f165721..5e09fcbd2 100644 --- a/starpilot/common/tests/test_testing_grounds.py +++ b/starpilot/common/tests/test_testing_grounds.py @@ -5,7 +5,7 @@ import pytest from openpilot.starpilot.common import testing_grounds as tg -@pytest.mark.parametrize("hidden_slot_id", [tg.TESTING_GROUND_3, tg.TESTING_GROUND_6]) +@pytest.mark.parametrize("hidden_slot_id", [tg.TESTING_GROUND_5, tg.TESTING_GROUND_6]) def test_hidden_testing_ground_selection_is_migrated(tmp_path, monkeypatch, hidden_slot_id): state_path = tmp_path / "slots.json" state_path.write_text(json.dumps({