mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-21 09:13:46 +08:00
fix
This commit is contained in:
@@ -58,8 +58,8 @@ def get_cruise_accel(e2e, v_cruise, v_ego, a_cruise_prev, angle_steers, CP, dt,
|
||||
# An override only counts as "active" if it's the bound that actually determined target_accel here --
|
||||
# turn/coast derating can shrink max_accel back below max_accel_override, and either bound can simply
|
||||
# not be reached if v_cruise - v_ego already sits inside [min_accel, max_accel] on its own.
|
||||
accel_controller_active = ((max_accel_override is not None and max_accel == max_accel_override and target_accel == max_accel) or
|
||||
(min_accel_override is not None and min_accel == min_accel_override and target_accel == min_accel))
|
||||
accel_controller_active = bool((max_accel_override is not None and max_accel == max_accel_override and target_accel == max_accel) or
|
||||
(min_accel_override is not None and min_accel == min_accel_override and target_accel == min_accel))
|
||||
|
||||
j_cruise = np.interp(v_ego, A_CRUISE_MAX_BP, J_CRUISE_VALS)
|
||||
target_accel = float(np.clip(target_accel, a_cruise_prev - j_cruise * dt, a_cruise_prev + j_cruise * dt))
|
||||
|
||||
+4
@@ -19,6 +19,7 @@ import unittest
|
||||
|
||||
import numpy as np
|
||||
|
||||
from openpilot.cereal import messaging
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.common.realtime import DT_MDL
|
||||
from openpilot.common.test import OpenpilotTestCase
|
||||
@@ -202,6 +203,9 @@ class TestOffEqualsStock(OpenpilotTestCase):
|
||||
target, active = get_cruise_accel(True, **args, max_accel_override=0.4)
|
||||
self.assertAlmostEqual(target, 0.4, places=6)
|
||||
self.assertTrue(active)
|
||||
self.assertIsInstance(active, bool)
|
||||
plan = messaging.new_message('longitudinalPlanSP')
|
||||
plan.longitudinalPlanSP.accelController.active = active
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user