Vehicles - Automatically Lock/Unlock Doors
Automatically lock the doors when in drive and unlock when in park. 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:
parent
e521ce1da6
commit
a1c4130165
@ -26,6 +26,11 @@ MAX_USER_TORQUE = 500
|
|||||||
MAX_LTA_ANGLE = 94.9461 # deg
|
MAX_LTA_ANGLE = 94.9461 # deg
|
||||||
MAX_LTA_DRIVER_TORQUE_ALLOWANCE = 150 # slightly above steering pressed allows some resistance when changing lanes
|
MAX_LTA_DRIVER_TORQUE_ALLOWANCE = 150 # slightly above steering pressed allows some resistance when changing lanes
|
||||||
|
|
||||||
|
# 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(CarControllerBase):
|
class CarController(CarControllerBase):
|
||||||
def __init__(self, dbc_name, CP, VM):
|
def __init__(self, dbc_name, CP, VM):
|
||||||
@ -47,6 +52,9 @@ class CarController(CarControllerBase):
|
|||||||
# FrogPilot variables
|
# FrogPilot variables
|
||||||
params = Params()
|
params = Params()
|
||||||
|
|
||||||
|
self.doors_locked = False
|
||||||
|
self.doors_unlocked = True
|
||||||
|
|
||||||
def update(self, CC, CS, now_nanos, frogpilot_variables):
|
def update(self, CC, CS, now_nanos, frogpilot_variables):
|
||||||
actuators = CC.actuators
|
actuators = CC.actuators
|
||||||
hud_control = CC.hudControl
|
hud_control = CC.hudControl
|
||||||
@ -219,5 +227,18 @@ class CarController(CarControllerBase):
|
|||||||
new_actuators.accel = self.accel
|
new_actuators.accel = self.accel
|
||||||
new_actuators.gas = self.gas
|
new_actuators.gas = self.gas
|
||||||
|
|
||||||
|
# Lock doors when in drive / unlock doors when in park
|
||||||
|
if self.doors_unlocked and CS.out.gearShifter != PARK:
|
||||||
|
if frogpilot_variables.lock_doors:
|
||||||
|
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:
|
||||||
|
if frogpilot_variables.unlock_doors:
|
||||||
|
can_sends.append(make_can_msg(0x750, UNLOCK_CMD, 0))
|
||||||
|
self.doors_locked = False
|
||||||
|
self.doors_unlocked = True
|
||||||
|
|
||||||
self.frame += 1
|
self.frame += 1
|
||||||
return new_actuators, can_sends
|
return new_actuators, can_sends
|
||||||
|
Loading…
x
Reference in New Issue
Block a user