mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-26 05:24:09 +08:00
planner: read experimental mode from controlsState (#26553)
read from controlsState
This commit is contained in:
@@ -6,7 +6,6 @@ from common.numpy_fast import clip, interp
|
||||
import cereal.messaging as messaging
|
||||
from common.conversions import Conversions as CV
|
||||
from common.filter_simple import FirstOrderFilter
|
||||
from common.params import Params
|
||||
from common.realtime import DT_MDL
|
||||
from selfdrive.modeld.constants import T_IDXS
|
||||
from selfdrive.controls.lib.longcontrol import LongCtrlState
|
||||
@@ -48,12 +47,7 @@ def limit_accel_in_turns(v_ego, angle_steers, a_target, CP):
|
||||
class LongitudinalPlanner:
|
||||
def __init__(self, CP, init_v=0.0, init_a=0.0):
|
||||
self.CP = CP
|
||||
self.params = Params()
|
||||
self.param_read_counter = 0
|
||||
|
||||
self.mpc = LongitudinalMpc()
|
||||
self.read_param()
|
||||
|
||||
self.fcw = False
|
||||
|
||||
self.a_desired = init_a
|
||||
@@ -65,10 +59,6 @@ class LongitudinalPlanner:
|
||||
self.j_desired_trajectory = np.zeros(CONTROL_N)
|
||||
self.solverExecutionTime = 0.0
|
||||
|
||||
def read_param(self):
|
||||
e2e = self.params.get_bool('ExperimentalMode') and self.CP.openpilotLongitudinalControl
|
||||
self.mpc.mode = 'blended' if e2e else 'acc'
|
||||
|
||||
@staticmethod
|
||||
def parse_model(model_msg, model_error):
|
||||
if (len(model_msg.position.x) == 33 and
|
||||
@@ -85,10 +75,8 @@ class LongitudinalPlanner:
|
||||
j = np.zeros(len(T_IDXS_MPC))
|
||||
return x, v, a, j
|
||||
|
||||
def update(self, sm, read=True):
|
||||
if self.param_read_counter % 50 == 0 and read:
|
||||
self.read_param()
|
||||
self.param_read_counter += 1
|
||||
def update(self, sm):
|
||||
self.mpc.mode = 'blended' if sm['controlsState'].experimentalMode else 'acc'
|
||||
|
||||
v_ego = sm['carState'].vEgo
|
||||
v_cruise_kph = sm['controlsState'].vCruise
|
||||
|
||||
Reference in New Issue
Block a user