Lock doors when in drive for Toyota/Lexus
Added toggle to automatically lock the doors when in drive for Toyota/Lexus vehicles. Credit goes to AlexandreSato! https: //github.com/AlexandreSato/openpilot Co-Authored-By: Alexandre Nobuharu Sato <66435071+alexandresato@users.noreply.github.com>
This commit is contained in:
@@ -32,6 +32,12 @@ MAX_LTA_DRIVER_TORQUE_ALLOWANCE = 150 # slightly above steering pressed allows
|
||||
COMPENSATORY_CALCULATION_THRESHOLD_V = [-0.3, -0.25, 0.] # m/s^2
|
||||
COMPENSATORY_CALCULATION_THRESHOLD_BP = [0., 11., 23.] # m/s
|
||||
|
||||
# Lock / unlock door commands - Credit goes to AlexandreSato!
|
||||
LOCK_CMD = b'\x40\x05\x30\x11\x00\x80\x00\x00'
|
||||
UNLOCK_CMD = b'\x40\x05\x30\x11\x00\x40\x00\x00'
|
||||
PARK = car.CarState.GearShifter.park
|
||||
|
||||
|
||||
class CarController:
|
||||
def __init__(self, dbc_name, CP, VM):
|
||||
self.CP = CP
|
||||
@@ -55,6 +61,9 @@ class CarController:
|
||||
self.cydia_tune = params.get_bool("CydiaTune")
|
||||
self.frogs_go_moo_tune = params.get_bool("FrogsGoMooTune")
|
||||
|
||||
self.doors_locked = False
|
||||
self.doors_unlocked = True
|
||||
|
||||
def update(self, CC, CS, now_nanos, frogpilot_variables):
|
||||
actuators = CC.actuators
|
||||
hud_control = CC.hudControl
|
||||
@@ -234,5 +243,16 @@ class CarController:
|
||||
new_actuators.accel = self.accel
|
||||
new_actuators.gas = self.gas
|
||||
|
||||
# Lock doors when in drive / unlock doors when in park
|
||||
if frogpilot_variables.lock_doors:
|
||||
if self.doors_unlocked and CS.out.gearShifter != PARK:
|
||||
can_sends.append(make_can_msg(0x750, LOCK_CMD, 0))
|
||||
self.doors_locked = True
|
||||
self.doors_unlocked = False
|
||||
elif self.doors_locked and CS.out.gearShifter == PARK:
|
||||
can_sends.append(make_can_msg(0x750, UNLOCK_CMD, 0))
|
||||
self.doors_locked = False
|
||||
self.doors_unlocked = True
|
||||
|
||||
self.frame += 1
|
||||
return new_actuators, can_sends
|
||||
|
||||
Reference in New Issue
Block a user