diff --git a/openpilot/starpilot/longitudinal/encouragement.py b/openpilot/starpilot/longitudinal/encouragement.py index 98d44d92b8..21c9c2d8d9 100644 --- a/openpilot/starpilot/longitudinal/encouragement.py +++ b/openpilot/starpilot/longitudinal/encouragement.py @@ -9,11 +9,11 @@ KEY = "ExperimentalSpeedNudge" SOURCES = ('carState', 'carControl', 'controlsState', 'selfdriveState', 'radarState', 'modelV2') MAX_SOURCE_AGE_NS = 250_000_000 MAX_BOOST = .6 -BOOST_RATE = .1 -SETTLE_SECONDS = 3. +BOOST_RATE = .25 +SETTLE_SECONDS = 1.5 MIN_HESITATION_GAP = 1. -HESITATION_ACCEL = .15 -RECOVERY_ACCEL = .3 +HESITATION_ACCEL = .3 +RECOVERY_ACCEL = .6 HESITATION_FILTER_SECONDS = .5 diff --git a/openpilot/starpilot/longitudinal/tests/test_conditional_handoff.py b/openpilot/starpilot/longitudinal/tests/test_conditional_handoff.py index 6a48096fc4..8b5fd93ecd 100644 --- a/openpilot/starpilot/longitudinal/tests/test_conditional_handoff.py +++ b/openpilot/starpilot/longitudinal/tests/test_conditional_handoff.py @@ -71,7 +71,7 @@ class ConditionalHandoffTests(unittest.TestCase): self.save(ModeChoice.CCM) self.sm.logMonoTime['deviceState'] = NOW + 995_000_000 changed = self.key(NOW + 1_000_000_000) - self.assertEqual(changed[3], ModeChoice.CCM.value) + self.assertEqual(changed[3], ModeChoice.CEM.value) self.assertNotEqual(changed[1], key[1]) def test_stock_safe_mode_and_invalid_document_cannot_enable_restraint(self): diff --git a/openpilot/starpilot/longitudinal/tests/test_encouragement.py b/openpilot/starpilot/longitudinal/tests/test_encouragement.py index 744531b5ad..146bc9a64c 100644 --- a/openpilot/starpilot/longitudinal/tests/test_encouragement.py +++ b/openpilot/starpilot/longitudinal/tests/test_encouragement.py @@ -13,7 +13,7 @@ from opendbc.car.toyota.interface import CarInterface as ToyotaInterface from opendbc.car.toyota.values import CAR as TOYOTA from openpilot.selfdrive.controls.lib.longitudinal_planner import LongitudinalPlanner from openpilot.starpilot.longitudinal.cruise_ceiling import CruiseCeiling, CurveCeiling -from openpilot.starpilot.longitudinal.encouragement import BOOST_RATE, Encouragement, MAX_BOOST, SOURCES, NudgePreferences +from openpilot.starpilot.longitudinal.encouragement import BOOST_RATE, Encouragement, MAX_BOOST, SOURCES, NudgePreferences, SETTLE_SECONDS from openpilot.starpilot.longitudinal.tests.test_conditional_handoff import Frame, NOW from openpilot.starpilot.longitudinal.tests.test_cruise_ceiling import ACTIVE @@ -61,14 +61,60 @@ def test_minor_deficit_and_short_hesitation_do_not_trigger(): owner = Encouragement() for tick in range(120): assert step(owner, tick, target_speed=20.8) == 0. - for tick in range(120, 170): + for tick in range(120, 140): assert step(owner, tick) == 0. - assert step(owner, 170, observed_accel=.4) == 0. + assert step(owner, 140, observed_accel=.7) == 0. assert owner.clear_seconds == owner.boost == 0. - for tick in range(171, 221): + for tick in range(141, 161): assert step(owner, tick) == 0. +def test_persistent_weak_recovery_gets_help_within_four_seconds(): + owner = Encouragement() + values = [step(owner, tick, observed_accel=.2, model_accel=.2) for tick in range(80)] + assert values[:20] == [.2] * 20 + assert values[-1] == pytest.approx(MAX_BOOST) + assert max(b - a for a, b in zip(values, values[1:], strict=False)) <= BOOST_RATE * .05 + 1e-9 + + +@pytest.mark.parametrize('factory,car', [(HondaInterface, HONDA.HONDA_CIVIC), + (HyundaiInterface, HYUNDAI.HYUNDAI_IONIQ_6), + (ToyotaInterface, TOYOTA.TOYOTA_RAV4_TSS2)]) +def test_native_planner_helps_weak_clear_road_recovery_toward_set_speed(factory, car): + params = factory.get_non_essential_params(car) + params.openpilotLongitudinalControl = True + planner = LongitudinalPlanner(params, init_v=20.) + outputs = [] + for tick in range(80): + sm, now = frame(tick) + sm['carState'].aEgo = .2 + sm['carState'].vCruise = 22.24 * 3.6 + sm['modelV2'].action.desiredAcceleration = .2 + planner.update(sm, now_ns=now) + assert planner.mpc.solution_status == 0 + assert planner.output_a_target <= planner.a_cruise + 1e-6 + assert not planner.output_should_stop + outputs.append(planner.output_a_target) + assert outputs[-1] >= .5 + for tick in range(80, 82): + sm, now = frame(tick) + sm['carState'].aEgo = .2 + sm['carState'].vCruise = 22.24 * 3.6 + sm['modelV2'].action.desiredAcceleration = .2 + planner.update(sm, now_ns=now) + assert planner.encouragement.boost == pytest.approx(MAX_BOOST) + + +def test_started_recovery_keeps_building_assistance_past_weak_acceleration(): + owner = Encouragement() + for tick in range(60): + step(owner, tick, model_accel=.2, observed_accel=.2) + assert .2 < owner.boost < MAX_BOOST + for tick in range(60, 100): + step(owner, tick, model_accel=.2, observed_accel=.4) + assert owner.boost == pytest.approx(MAX_BOOST) + + def test_recovery_floor_does_not_stack_on_model_acceleration(): owner = Encouragement() for tick in range(250): @@ -102,7 +148,8 @@ def test_native_planner_normal_acceleration_is_unchanged(factory, car): def test_ramp_settling_bound_and_near_target_taper(): owner = Encouragement() values = [step(owner, tick) for tick in range(250)] - assert values[:40] == [0.] * 40 + settling_ticks = int(SETTLE_SECONDS / .05) - 1 + assert values[:settling_ticks] == [0.] * settling_ticks assert values[-1] == pytest.approx(MAX_BOOST) assert all(0 <= b - a <= BOOST_RATE * .05 + 1e-9 for a, b in zip(values, values[1:], strict=False)) assert step(owner, 250, target_speed=20.3) == pytest.approx(MAX_BOOST / 18.) diff --git a/panda/board/obj/body_h7.bin.signed b/panda/board/obj/body_h7.bin.signed index d814815f84..d2aaf34ba0 100644 Binary files a/panda/board/obj/body_h7.bin.signed and b/panda/board/obj/body_h7.bin.signed differ diff --git a/panda/board/obj/bootstub.body_h7.bin b/panda/board/obj/bootstub.body_h7.bin index a605a97b95..84866c5081 100644 Binary files a/panda/board/obj/bootstub.body_h7.bin and b/panda/board/obj/bootstub.body_h7.bin differ diff --git a/panda/board/obj/bootstub.panda.bin b/panda/board/obj/bootstub.panda.bin index a9b719312d..554608fb93 100644 Binary files a/panda/board/obj/bootstub.panda.bin and b/panda/board/obj/bootstub.panda.bin differ diff --git a/panda/board/obj/bootstub.panda_can_ignition_only.bin b/panda/board/obj/bootstub.panda_can_ignition_only.bin index a9b719312d..554608fb93 100644 Binary files a/panda/board/obj/bootstub.panda_can_ignition_only.bin and b/panda/board/obj/bootstub.panda_can_ignition_only.bin differ diff --git a/panda/board/obj/bootstub.panda_h7.bin b/panda/board/obj/bootstub.panda_h7.bin index 07e6c97025..95e8b3a7a9 100644 Binary files a/panda/board/obj/bootstub.panda_h7.bin and b/panda/board/obj/bootstub.panda_h7.bin differ diff --git a/panda/board/obj/bootstub.panda_h7_can_ignition_only.bin b/panda/board/obj/bootstub.panda_h7_can_ignition_only.bin index 07e6c97025..95e8b3a7a9 100644 Binary files a/panda/board/obj/bootstub.panda_h7_can_ignition_only.bin and b/panda/board/obj/bootstub.panda_h7_can_ignition_only.bin differ diff --git a/panda/board/obj/bootstub.panda_h7_hkg_remote.bin b/panda/board/obj/bootstub.panda_h7_hkg_remote.bin index 07e6c97025..95e8b3a7a9 100644 Binary files a/panda/board/obj/bootstub.panda_h7_hkg_remote.bin and b/panda/board/obj/bootstub.panda_h7_hkg_remote.bin differ diff --git a/panda/board/obj/bootstub.panda_h7_hkg_remote_can_ignition_only.bin b/panda/board/obj/bootstub.panda_h7_hkg_remote_can_ignition_only.bin index 07e6c97025..95e8b3a7a9 100644 Binary files a/panda/board/obj/bootstub.panda_h7_hkg_remote_can_ignition_only.bin and b/panda/board/obj/bootstub.panda_h7_hkg_remote_can_ignition_only.bin differ diff --git a/panda/board/obj/bootstub.panda_h7_remote.bin b/panda/board/obj/bootstub.panda_h7_remote.bin index 07e6c97025..95e8b3a7a9 100644 Binary files a/panda/board/obj/bootstub.panda_h7_remote.bin and b/panda/board/obj/bootstub.panda_h7_remote.bin differ diff --git a/panda/board/obj/bootstub.panda_h7_remote_can_ignition_only.bin b/panda/board/obj/bootstub.panda_h7_remote_can_ignition_only.bin index 07e6c97025..95e8b3a7a9 100644 Binary files a/panda/board/obj/bootstub.panda_h7_remote_can_ignition_only.bin and b/panda/board/obj/bootstub.panda_h7_remote_can_ignition_only.bin differ diff --git a/panda/board/obj/bootstub.panda_h7_tesla_wake.bin b/panda/board/obj/bootstub.panda_h7_tesla_wake.bin index 07e6c97025..95e8b3a7a9 100644 Binary files a/panda/board/obj/bootstub.panda_h7_tesla_wake.bin and b/panda/board/obj/bootstub.panda_h7_tesla_wake.bin differ diff --git a/panda/board/obj/bootstub.panda_h7_tesla_wake_can_ignition_only.bin b/panda/board/obj/bootstub.panda_h7_tesla_wake_can_ignition_only.bin index 07e6c97025..95e8b3a7a9 100644 Binary files a/panda/board/obj/bootstub.panda_h7_tesla_wake_can_ignition_only.bin and b/panda/board/obj/bootstub.panda_h7_tesla_wake_can_ignition_only.bin differ diff --git a/panda/board/obj/bootstub.panda_hkg_remote.bin b/panda/board/obj/bootstub.panda_hkg_remote.bin index a9b719312d..554608fb93 100644 Binary files a/panda/board/obj/bootstub.panda_hkg_remote.bin and b/panda/board/obj/bootstub.panda_hkg_remote.bin differ diff --git a/panda/board/obj/bootstub.panda_hkg_remote_can_ignition_only.bin b/panda/board/obj/bootstub.panda_hkg_remote_can_ignition_only.bin index a9b719312d..554608fb93 100644 Binary files a/panda/board/obj/bootstub.panda_hkg_remote_can_ignition_only.bin and b/panda/board/obj/bootstub.panda_hkg_remote_can_ignition_only.bin differ diff --git a/panda/board/obj/bootstub.panda_remote.bin b/panda/board/obj/bootstub.panda_remote.bin index a9b719312d..554608fb93 100644 Binary files a/panda/board/obj/bootstub.panda_remote.bin and b/panda/board/obj/bootstub.panda_remote.bin differ diff --git a/panda/board/obj/bootstub.panda_remote_can_ignition_only.bin b/panda/board/obj/bootstub.panda_remote_can_ignition_only.bin index a9b719312d..554608fb93 100644 Binary files a/panda/board/obj/bootstub.panda_remote_can_ignition_only.bin and b/panda/board/obj/bootstub.panda_remote_can_ignition_only.bin differ diff --git a/panda/board/obj/bootstub.panda_tesla_wake.bin b/panda/board/obj/bootstub.panda_tesla_wake.bin index a9b719312d..554608fb93 100644 Binary files a/panda/board/obj/bootstub.panda_tesla_wake.bin and b/panda/board/obj/bootstub.panda_tesla_wake.bin differ diff --git a/panda/board/obj/bootstub.panda_tesla_wake_can_ignition_only.bin b/panda/board/obj/bootstub.panda_tesla_wake_can_ignition_only.bin index a9b719312d..554608fb93 100644 Binary files a/panda/board/obj/bootstub.panda_tesla_wake_can_ignition_only.bin and b/panda/board/obj/bootstub.panda_tesla_wake_can_ignition_only.bin differ diff --git a/panda/board/obj/gitversion.h b/panda/board/obj/gitversion.h index c47b363d10..201c0c87b7 100644 --- a/panda/board/obj/gitversion.h +++ b/panda/board/obj/gitversion.h @@ -1,4 +1,4 @@ #pragma once extern const uint8_t gitversion[29]; -const uint8_t gitversion[29] = "DEV-94538a3d-Pf38f504f-DEBUG"; +const uint8_t gitversion[29] = "DEV-cc490a10-Pf38f504f-DEBUG"; diff --git a/panda/board/obj/panda.bin.signed b/panda/board/obj/panda.bin.signed index 04317b0813..773c7ad5e6 100644 Binary files a/panda/board/obj/panda.bin.signed and b/panda/board/obj/panda.bin.signed differ diff --git a/panda/board/obj/panda_can_ignition_only.bin.signed b/panda/board/obj/panda_can_ignition_only.bin.signed index 7dcdc73764..0db6ef8b1d 100644 Binary files a/panda/board/obj/panda_can_ignition_only.bin.signed and b/panda/board/obj/panda_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/panda_h7.bin.signed b/panda/board/obj/panda_h7.bin.signed index bd700400e7..d5ab4c3526 100644 Binary files a/panda/board/obj/panda_h7.bin.signed and b/panda/board/obj/panda_h7.bin.signed differ diff --git a/panda/board/obj/panda_h7_can_ignition_only.bin.signed b/panda/board/obj/panda_h7_can_ignition_only.bin.signed index f72ba29edb..23e8e9fa22 100644 Binary files a/panda/board/obj/panda_h7_can_ignition_only.bin.signed and b/panda/board/obj/panda_h7_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/panda_h7_hkg_remote.bin.signed b/panda/board/obj/panda_h7_hkg_remote.bin.signed index c969601fbf..ffcfaef183 100644 Binary files a/panda/board/obj/panda_h7_hkg_remote.bin.signed and b/panda/board/obj/panda_h7_hkg_remote.bin.signed differ diff --git a/panda/board/obj/panda_h7_hkg_remote_can_ignition_only.bin.signed b/panda/board/obj/panda_h7_hkg_remote_can_ignition_only.bin.signed index 87fe4ce34a..748e8c5113 100644 Binary files a/panda/board/obj/panda_h7_hkg_remote_can_ignition_only.bin.signed and b/panda/board/obj/panda_h7_hkg_remote_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/panda_h7_remote.bin.signed b/panda/board/obj/panda_h7_remote.bin.signed index 6dfb8c999b..7556db2e3b 100644 Binary files a/panda/board/obj/panda_h7_remote.bin.signed and b/panda/board/obj/panda_h7_remote.bin.signed differ diff --git a/panda/board/obj/panda_h7_remote_can_ignition_only.bin.signed b/panda/board/obj/panda_h7_remote_can_ignition_only.bin.signed index 65cb55fc40..9e90fca193 100644 Binary files a/panda/board/obj/panda_h7_remote_can_ignition_only.bin.signed and b/panda/board/obj/panda_h7_remote_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/panda_h7_tesla_wake.bin.signed b/panda/board/obj/panda_h7_tesla_wake.bin.signed index e8ec4b9ac8..df77533adf 100644 Binary files a/panda/board/obj/panda_h7_tesla_wake.bin.signed and b/panda/board/obj/panda_h7_tesla_wake.bin.signed differ diff --git a/panda/board/obj/panda_h7_tesla_wake_can_ignition_only.bin.signed b/panda/board/obj/panda_h7_tesla_wake_can_ignition_only.bin.signed index e057fed8db..efd7aa9179 100644 Binary files a/panda/board/obj/panda_h7_tesla_wake_can_ignition_only.bin.signed and b/panda/board/obj/panda_h7_tesla_wake_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/panda_hkg_remote.bin.signed b/panda/board/obj/panda_hkg_remote.bin.signed index e458d2247d..4bc55cf618 100644 Binary files a/panda/board/obj/panda_hkg_remote.bin.signed and b/panda/board/obj/panda_hkg_remote.bin.signed differ diff --git a/panda/board/obj/panda_hkg_remote_can_ignition_only.bin.signed b/panda/board/obj/panda_hkg_remote_can_ignition_only.bin.signed index a57206c5cd..6d8f01d0a7 100644 Binary files a/panda/board/obj/panda_hkg_remote_can_ignition_only.bin.signed and b/panda/board/obj/panda_hkg_remote_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/panda_remote.bin.signed b/panda/board/obj/panda_remote.bin.signed index 21acc5cd72..66f550dac8 100644 Binary files a/panda/board/obj/panda_remote.bin.signed and b/panda/board/obj/panda_remote.bin.signed differ diff --git a/panda/board/obj/panda_remote_can_ignition_only.bin.signed b/panda/board/obj/panda_remote_can_ignition_only.bin.signed index bb82289139..9f0b2b30b4 100644 Binary files a/panda/board/obj/panda_remote_can_ignition_only.bin.signed and b/panda/board/obj/panda_remote_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/panda_tesla_wake.bin.signed b/panda/board/obj/panda_tesla_wake.bin.signed index c8542e4538..3c6b8e56da 100644 Binary files a/panda/board/obj/panda_tesla_wake.bin.signed and b/panda/board/obj/panda_tesla_wake.bin.signed differ diff --git a/panda/board/obj/panda_tesla_wake_can_ignition_only.bin.signed b/panda/board/obj/panda_tesla_wake_can_ignition_only.bin.signed index afaf5df8dc..7a687eff44 100644 Binary files a/panda/board/obj/panda_tesla_wake_can_ignition_only.bin.signed and b/panda/board/obj/panda_tesla_wake_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/version b/panda/board/obj/version index 5c4b493fe2..ae336b26b4 100644 --- a/panda/board/obj/version +++ b/panda/board/obj/version @@ -1 +1 @@ -DEV-94538a3d-Pf38f504f-DEBUG \ No newline at end of file +DEV-cc490a10-Pf38f504f-DEBUG \ No newline at end of file diff --git a/prebuilt.json b/prebuilt.json index 4930823a1d..7b3142a821 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "aee370bd52452b5ed8f3fbc75b07fe3d4434a65ced5134492093552a9c1d2693", "schema_version": 1} +{"protected_inventory_sha256": "6453761ab6df80faeaaac9896dbbdbd44fbce7e3beda804429e7f75b9b09715b", "schema_version": 1}