|
|
|
@ -6,18 +6,17 @@ from math import fabs, exp |
|
|
|
|
from panda import Panda |
|
|
|
|
|
|
|
|
|
from openpilot.common.basedir import BASEDIR |
|
|
|
|
from openpilot.selfdrive.car import create_button_events, get_safety_config, get_friction |
|
|
|
|
from openpilot.selfdrive.car import create_button_events, get_safety_config, get_friction, structs |
|
|
|
|
from openpilot.selfdrive.car.conversions import Conversions as CV |
|
|
|
|
from openpilot.selfdrive.car.structs import CarParams |
|
|
|
|
from openpilot.selfdrive.car.gm.radar_interface import RADAR_HEADER_MSG |
|
|
|
|
from openpilot.selfdrive.car.gm.values import CAR, CruiseButtons, CarControllerParams, EV_CAR, CAMERA_ACC_CAR, CanBus |
|
|
|
|
from openpilot.selfdrive.car.interfaces import CarInterfaceBase, TorqueFromLateralAccelCallbackType, FRICTION_THRESHOLD, LatControlInputs, NanoFFModel |
|
|
|
|
|
|
|
|
|
ButtonType = car.CarState.ButtonEvent.Type |
|
|
|
|
ButtonType = structs.CarState.ButtonEvent.Type |
|
|
|
|
EventName = car.CarEvent.EventName |
|
|
|
|
GearShifter = car.CarState.GearShifter |
|
|
|
|
TransmissionType = CarParams.TransmissionType |
|
|
|
|
NetworkLocation = CarParams.NetworkLocation |
|
|
|
|
GearShifter = structs.CarState.GearShifter |
|
|
|
|
TransmissionType = structs.CarParams.TransmissionType |
|
|
|
|
NetworkLocation = structs.CarParams.NetworkLocation |
|
|
|
|
BUTTONS_DICT = {CruiseButtons.RES_ACCEL: ButtonType.accelCruise, CruiseButtons.DECEL_SET: ButtonType.decelCruise, |
|
|
|
|
CruiseButtons.MAIN: ButtonType.altButton3, CruiseButtons.CANCEL: ButtonType.cancel} |
|
|
|
|
|
|
|
|
@ -49,7 +48,7 @@ class CarInterface(CarInterfaceBase): |
|
|
|
|
else: |
|
|
|
|
return CarInterfaceBase.get_steer_feedforward_default |
|
|
|
|
|
|
|
|
|
def torque_from_lateral_accel_siglin(self, latcontrol_inputs: LatControlInputs, torque_params: CarParams.LateralTorqueTuning, lateral_accel_error: float, |
|
|
|
|
def torque_from_lateral_accel_siglin(self, latcontrol_inputs: LatControlInputs, torque_params: structs.CarParams.LateralTorqueTuning, lateral_accel_error: float, |
|
|
|
|
lateral_accel_deadzone: float, friction_compensation: bool, gravity_adjusted: bool) -> float: |
|
|
|
|
friction = get_friction(lateral_accel_error, lateral_accel_deadzone, FRICTION_THRESHOLD, torque_params, friction_compensation) |
|
|
|
|
|
|
|
|
@ -71,7 +70,7 @@ class CarInterface(CarInterfaceBase): |
|
|
|
|
steer_torque = (sig(latcontrol_inputs.lateral_acceleration * a) * b) + (latcontrol_inputs.lateral_acceleration * c) |
|
|
|
|
return float(steer_torque) + friction |
|
|
|
|
|
|
|
|
|
def torque_from_lateral_accel_neural(self, latcontrol_inputs: LatControlInputs, torque_params: CarParams.LateralTorqueTuning, lateral_accel_error: float, |
|
|
|
|
def torque_from_lateral_accel_neural(self, latcontrol_inputs: LatControlInputs, torque_params: structs.CarParams.LateralTorqueTuning, lateral_accel_error: float, |
|
|
|
|
lateral_accel_deadzone: float, friction_compensation: bool, gravity_adjusted: bool) -> float: |
|
|
|
|
friction = get_friction(lateral_accel_error, lateral_accel_deadzone, FRICTION_THRESHOLD, torque_params, friction_compensation) |
|
|
|
|
inputs = list(latcontrol_inputs) |
|
|
|
@ -89,9 +88,9 @@ class CarInterface(CarInterfaceBase): |
|
|
|
|
return self.torque_from_lateral_accel_linear |
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
def _get_params(ret: CarParams, candidate, fingerprint, car_fw, experimental_long, docs): |
|
|
|
|
def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experimental_long, docs): |
|
|
|
|
ret.carName = "gm" |
|
|
|
|
ret.safetyConfigs = [get_safety_config(CarParams.SafetyModel.gm)] |
|
|
|
|
ret.safetyConfigs = [get_safety_config(structs.CarParams.SafetyModel.gm)] |
|
|
|
|
ret.autoResumeSng = False |
|
|
|
|
ret.enableBsm = 0x142 in fingerprint[CanBus.POWERTRAIN] |
|
|
|
|
|
|
|
|
|