mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-07-26 20:32:04 +08:00
Vehicles - Toyota - 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:
@@ -51,6 +51,7 @@ const int TOYOTA_GAS_INTERCEPTOR_THRSLD = 805;
|
||||
// Stock longitudinal
|
||||
#define TOYOTA_COMMON_TX_MSGS \
|
||||
{0x2E4, 0, 5}, {0x191, 0, 8}, {0x412, 0, 8}, {0x343, 0, 8}, {0x1D2, 0, 8}, /* LKAS + LTA + ACC & PCM cancel cmds */ \
|
||||
{0x750, 0, 8}, /* white list 0x750 for Enhanced Diagnostic Request */ \
|
||||
|
||||
#define TOYOTA_COMMON_LONG_TX_MSGS \
|
||||
TOYOTA_COMMON_TX_MSGS \
|
||||
@@ -362,7 +363,9 @@ static bool toyota_tx_hook(const CANPacket_t *to_send) {
|
||||
if (addr == 0x750) {
|
||||
// this address is sub-addressed. only allow tester present to radar (0xF)
|
||||
bool invalid_uds_msg = (GET_BYTES(to_send, 0, 4) != 0x003E020FU) || (GET_BYTES(to_send, 4, 4) != 0x0U);
|
||||
if (invalid_uds_msg) {
|
||||
// AleSato added some more hack'sss
|
||||
bool valid_uds_msgs = (GET_BYTES(to_send, 0, 4) == 0x11300540U); // automatic door locking and unlocking
|
||||
if (invalid_uds_msg && !valid_uds_msgs) {
|
||||
tx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,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(CarControllerBase):
|
||||
def __init__(self, dbc_name, CP, VM):
|
||||
@@ -46,6 +51,8 @@ class CarController(CarControllerBase):
|
||||
# FrogPilot variables
|
||||
params = Params()
|
||||
|
||||
self.doors_locked = False
|
||||
|
||||
def update(self, CC, CS, now_nanos, frogpilot_toggles):
|
||||
actuators = CC.actuators
|
||||
hud_control = CC.hudControl
|
||||
@@ -205,5 +212,15 @@ class CarController(CarControllerBase):
|
||||
new_actuators.accel = self.accel
|
||||
new_actuators.gas = self.gas
|
||||
|
||||
# Lock doors when in drive / unlock doors when in park
|
||||
if not self.doors_locked and CS.out.gearShifter != PARK:
|
||||
if frogpilot_toggles.lock_doors:
|
||||
can_sends.append(make_can_msg(0x750, LOCK_CMD, 0))
|
||||
self.doors_locked = True
|
||||
elif self.doors_locked and CS.out.gearShifter == PARK:
|
||||
if frogpilot_toggles.unlock_doors:
|
||||
can_sends.append(make_can_msg(0x750, UNLOCK_CMD, 0))
|
||||
self.doors_locked = False
|
||||
|
||||
self.frame += 1
|
||||
return new_actuators, can_sends
|
||||
|
||||
Reference in New Issue
Block a user