|
|
|
@ -3,7 +3,7 @@ import math |
|
|
|
|
import numpy as np |
|
|
|
|
from openpilot.common.numpy_fast import clip, interp |
|
|
|
|
from openpilot.common.params import Params |
|
|
|
|
from cereal import log |
|
|
|
|
from cereal import car, log |
|
|
|
|
|
|
|
|
|
import cereal.messaging as messaging |
|
|
|
|
from openpilot.common.conversions import Conversions as CV |
|
|
|
@ -17,6 +17,8 @@ from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import T_IDX |
|
|
|
|
from openpilot.selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, CONTROL_N, get_speed_error |
|
|
|
|
from openpilot.common.swaglog import cloudlog |
|
|
|
|
|
|
|
|
|
ButtonType = car.CarState.ButtonEvent.Type |
|
|
|
|
|
|
|
|
|
LON_MPC_STEP = 0.2 # first step is 0.2s |
|
|
|
|
A_CRUISE_MIN = -1.2 |
|
|
|
|
A_CRUISE_MAX_VALS = [1.6, 1.2, 0.8, 0.6] |
|
|
|
@ -89,8 +91,12 @@ class LongitudinalPlanner: |
|
|
|
|
return x, v, a, j |
|
|
|
|
|
|
|
|
|
def update(self, sm): |
|
|
|
|
if self.param_read_counter % 50 == 0: |
|
|
|
|
self.read_param() |
|
|
|
|
# if self.param_read_counter % 50 == 0: |
|
|
|
|
# self.read_param() |
|
|
|
|
# decrement personality on button press (Toyota can only decrement) |
|
|
|
|
if any(not be.pressed and be.type == ButtonType.gapAdjustCruise for be in sm['carState'].buttonEvents): |
|
|
|
|
self.personality = (self.personality - 1) % 3 |
|
|
|
|
|
|
|
|
|
self.param_read_counter += 1 |
|
|
|
|
self.mpc.mode = 'blended' if sm['controlsState'].experimentalMode else 'acc' |
|
|
|
|
|
|
|
|
|