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:
@@ -24,6 +24,11 @@ MAX_USER_TORQUE = 500
|
||||
MAX_LTA_ANGLE = 94.9461 # deg
|
||||
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:
|
||||
def __init__(self, dbc_name, CP, VM):
|
||||
@@ -42,9 +47,14 @@ class CarController:
|
||||
self.accel = 0
|
||||
|
||||
# FrogPilot variables
|
||||
self.lock_doors = False
|
||||
self.reverse_cruise_increase = False
|
||||
|
||||
self.doors_locked = False
|
||||
self.doors_unlocked = True
|
||||
|
||||
def update_frogpilot_variables(self, params):
|
||||
self.lock_doors = params.get_bool("LockDoors")
|
||||
self.reverse_cruise_increase = params.get_bool("ReverseCruise")
|
||||
|
||||
def update(self, CC, CS, now_nanos, sport_plus):
|
||||
@@ -200,5 +210,16 @@ class CarController:
|
||||
new_actuators.accel = self.accel
|
||||
new_actuators.gas = self.gas
|
||||
|
||||
# Lock doors when in drive / unlock doors when in park
|
||||
if self.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
|
||||
|
||||
@@ -101,6 +101,8 @@ FrogPilotVehiclesPanel::FrogPilotVehiclesPanel(SettingsWindow *parent) : FrogPil
|
||||
std::vector<std::tuple<QString, QString, QString, QString>> vehicleToggles {
|
||||
{"GasRegenCmd", "Gas Regen Cmd", "", ""},
|
||||
{"LongPitch", "Long Pitch Compensation", "Reduce speed and acceleration error for greater passenger comfort and improved vehicle efficiency.", ""},
|
||||
|
||||
{"LockDoors", "Lock Doors In Drive", "Automatically lock the doors when in drive and unlock when in park.", ""},
|
||||
};
|
||||
|
||||
for (auto &[param, title, desc, icon] : vehicleToggles) {
|
||||
|
||||
Reference in New Issue
Block a user