|
|
@ -6,7 +6,6 @@ from common.numpy_fast import clip, interp |
|
|
|
import cereal.messaging as messaging |
|
|
|
import cereal.messaging as messaging |
|
|
|
from common.conversions import Conversions as CV |
|
|
|
from common.conversions import Conversions as CV |
|
|
|
from common.filter_simple import FirstOrderFilter |
|
|
|
from common.filter_simple import FirstOrderFilter |
|
|
|
from common.params import Params |
|
|
|
|
|
|
|
from common.realtime import DT_MDL |
|
|
|
from common.realtime import DT_MDL |
|
|
|
from selfdrive.modeld.constants import T_IDXS |
|
|
|
from selfdrive.modeld.constants import T_IDXS |
|
|
|
from selfdrive.controls.lib.longcontrol import LongCtrlState |
|
|
|
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: |
|
|
|
class LongitudinalPlanner: |
|
|
|
def __init__(self, CP, init_v=0.0, init_a=0.0): |
|
|
|
def __init__(self, CP, init_v=0.0, init_a=0.0): |
|
|
|
self.CP = CP |
|
|
|
self.CP = CP |
|
|
|
self.params = Params() |
|
|
|
|
|
|
|
self.param_read_counter = 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.mpc = LongitudinalMpc() |
|
|
|
self.mpc = LongitudinalMpc() |
|
|
|
self.read_param() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.fcw = False |
|
|
|
self.fcw = False |
|
|
|
|
|
|
|
|
|
|
|
self.a_desired = init_a |
|
|
|
self.a_desired = init_a |
|
|
@ -65,10 +59,6 @@ class LongitudinalPlanner: |
|
|
|
self.j_desired_trajectory = np.zeros(CONTROL_N) |
|
|
|
self.j_desired_trajectory = np.zeros(CONTROL_N) |
|
|
|
self.solverExecutionTime = 0.0 |
|
|
|
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 |
|
|
|
@staticmethod |
|
|
|
def parse_model(model_msg, model_error): |
|
|
|
def parse_model(model_msg, model_error): |
|
|
|
if (len(model_msg.position.x) == 33 and |
|
|
|
if (len(model_msg.position.x) == 33 and |
|
|
@ -85,10 +75,8 @@ class LongitudinalPlanner: |
|
|
|
j = np.zeros(len(T_IDXS_MPC)) |
|
|
|
j = np.zeros(len(T_IDXS_MPC)) |
|
|
|
return x, v, a, j |
|
|
|
return x, v, a, j |
|
|
|
|
|
|
|
|
|
|
|
def update(self, sm, read=True): |
|
|
|
def update(self, sm): |
|
|
|
if self.param_read_counter % 50 == 0 and read: |
|
|
|
self.mpc.mode = 'blended' if sm['controlsState'].experimentalMode else 'acc' |
|
|
|
self.read_param() |
|
|
|
|
|
|
|
self.param_read_counter += 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
v_ego = sm['carState'].vEgo |
|
|
|
v_ego = sm['carState'].vEgo |
|
|
|
v_cruise_kph = sm['controlsState'].vCruise |
|
|
|
v_cruise_kph = sm['controlsState'].vCruise |
|
|
|