From 0f22e7c4959801b4072c1e28e3fdbd528ee00335 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Mon, 20 Apr 2026 00:24:04 -0500 Subject: [PATCH] update migration --- selfdrive/test/process_replay/migration.py | 5 ++-- .../test/process_replay/test_migration.py | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 selfdrive/test/process_replay/test_migration.py diff --git a/selfdrive/test/process_replay/migration.py b/selfdrive/test/process_replay/migration.py index c9b4e8841..171c84323 100644 --- a/selfdrive/test/process_replay/migration.py +++ b/selfdrive/test/process_replay/migration.py @@ -97,9 +97,10 @@ def migration(inputs: list[str], product: str|None=None): @migration(inputs=["longitudinalPlan", "carParams"]) def migrate_longitudinalPlan(msgs): - from openpilot.selfdrive.controls.lib.longitudinal_planner import CONTROL_N_T_IDX, get_accel_from_plan + from openpilot.selfdrive.controls.lib.drive_helpers import CONTROL_N, get_accel_from_plan ops = [] + control_n_t_idx = ModelConstants.T_IDXS[:CONTROL_N] needs_migration = all(msg.longitudinalPlan.aTarget == 0.0 for _, msg in msgs if msg.which() == 'longitudinalPlan') CP = next((m.carParams for _, m in msgs if m.which() == 'carParams'), None) @@ -110,7 +111,7 @@ def migrate_longitudinalPlan(msgs): if msg.which() != 'longitudinalPlan': continue new_msg = msg.as_builder() - a_target, should_stop = get_accel_from_plan(msg.longitudinalPlan.speeds, msg.longitudinalPlan.accels, CONTROL_N_T_IDX) + a_target, should_stop = get_accel_from_plan(msg.longitudinalPlan.speeds, msg.longitudinalPlan.accels, control_n_t_idx) new_msg.longitudinalPlan.aTarget, new_msg.longitudinalPlan.shouldStop = float(a_target), bool(should_stop) ops.append((index, new_msg.as_reader())) return ops, [], [] diff --git a/selfdrive/test/process_replay/test_migration.py b/selfdrive/test/process_replay/test_migration.py new file mode 100644 index 000000000..7a70e33b7 --- /dev/null +++ b/selfdrive/test/process_replay/test_migration.py @@ -0,0 +1,24 @@ +import cereal.messaging as messaging + +from openpilot.selfdrive.controls.lib.drive_helpers import CONTROL_N +from openpilot.selfdrive.test.process_replay.migration import migrate_longitudinalPlan + + +def test_migrate_longitudinal_plan_uses_legacy_helper_signature(): + long_plan = messaging.new_message('longitudinalPlan') + long_plan.longitudinalPlan.speeds = [float(i) for i in range(CONTROL_N)] + long_plan.longitudinalPlan.accels = [0.1] * CONTROL_N + + car_params = messaging.new_message('carParams') + + ops, add_ops, del_ops = migrate_longitudinalPlan([ + (0, long_plan.as_reader()), + (1, car_params.as_reader()), + ]) + + assert len(ops) == 1 + assert add_ops == [] + assert del_ops == [] + + _, migrated = ops[0] + assert migrated.longitudinalPlan.aTarget != 0.0