Toyota Enhanced BSM

This commit is contained in:
Rick Lan
2024-06-28 13:31:40 +08:00
parent a0a83dc040
commit b237bb0852
4 changed files with 16 additions and 0 deletions
+1
View File
@@ -233,6 +233,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"dp_toyota_pcm_compensation", PERSISTENT},
{"dp_device_is_clone", PERSISTENT},
{"dp_device_dm_unavailable", PERSISTENT},
{"dp_toyota_enhanced_bsm", PERSISTENT},
};
} // namespace
+7
View File
@@ -15,6 +15,9 @@ from openpilot.dp_ext.selfdrive.car.toyota.pcm_compensation_controller import PC
# for pcm compensation
LongCtrlState = car.CarControl.Actuators.LongControlState
# dp - for enhanced bsm
from openpilot.dp_ext.selfdrive.car.toyota.bsm.controller import BSMController
SteerControlType = car.CarParams.SteerControlType
VisualAlert = car.CarControl.HUDControl.VisualAlert
@@ -51,6 +54,7 @@ class CarController(CarControllerBase):
# dp
self.dlc = DoorLockController()
self.pcc = PCMCompensationController(CP, self.params, Params().get_bool("dp_toyota_pcm_compensation"))
self.bsmc = BSMController(self.CP)
def update(self, CC, CS, now_nanos):
actuators = CC.actuators
@@ -63,6 +67,9 @@ class CarController(CarControllerBase):
# *** control msgs ***
can_sends = []
# dp - for enhanced bsm
can_sends = self.bsmc.get_can_sends(self.frame, CS.out.vEgo, can_sends)
result = self.dlc.process(CS.out.gearShifter, CS.out.vEgo, CS.out.doorOpen)
if result:
can_sends.append(make_can_msg(result[0], result[1], result[2]))
+7
View File
@@ -12,6 +12,7 @@ from openpilot.selfdrive.car.toyota.values import ToyotaFlags, CAR, DBC, STEER_T
TSS2_CAR, RADAR_ACC_CAR, EPS_SCALE, UNSUPPORTED_DSU_CAR
from openpilot.dp_ext.selfdrive.car.toyota.zss_controller import ZSSController
from openpilot.dp_ext.selfdrive.car.toyota.bsm.state import BSMState
SteerControlType = car.CarParams.SteerControlType
@@ -55,6 +56,8 @@ class CarState(CarStateBase):
self.zssc = ZSSController()
# for pcm compensation
self.pcm_neutral_force = 0.
# enhanced bsm
self.bsm_state = BSMState()
def update(self, cp, cp_cam):
ret = car.CarState.new_message()
@@ -173,6 +176,10 @@ class CarState(CarStateBase):
ret.leftBlindspot = (cp.vl["BSM"]["L_ADJACENT"] == 1) or (cp.vl["BSM"]["L_APPROACHING"] == 1)
ret.rightBlindspot = (cp.vl["BSM"]["R_ADJACENT"] == 1) or (cp.vl["BSM"]["R_APPROACHING"] == 1)
# dp - enhanced bsm
self.bsm_state.update_states(ret.leftBlindspot, ret.rightBlindspot)
ret.leftBlindspot, ret.rightBlindspot = self.bsm_state.get_signals()
if self.CP.carFingerprint != CAR.TOYOTA_PRIUS_V:
self.lkas_hud = copy.copy(cp_cam.vl["LKAS_HUD"])
+1
View File
@@ -72,6 +72,7 @@ def manager_init() -> None:
("dp_toyota_pcm_compensation", "0"),
("dp_device_is_clone", "0"),
("dp_device_dm_unavailable", "0"),
("dp_toyota_enhanced_bsm", "0"),
]
if not PC:
default_params.append(("LastUpdateTime", datetime.datetime.now(datetime.UTC).replace(tzinfo=None).isoformat().encode('utf8')))