Always on Lateral
Added toggle for Always On Lateral / No disengage lateral on gas and brake. Lots of credit goes to "pfeiferj"! Couldn't of done it without him! https: //github.com/pfeiferj/openpilot Co-Authored-By: Jacob Pfeifer <jacob@pfeifer.dev>
This commit is contained in:
@@ -185,6 +185,7 @@ static void chrysler_rx_hook(CANPacket_t *to_push) {
|
||||
// enter controls on rising edge of ACC, exit controls on ACC off
|
||||
const int das_3_bus = (chrysler_platform == CHRYSLER_PACIFICA) ? 0 : 2;
|
||||
if ((bus == das_3_bus) && (addr == chrysler_addrs->DAS_3)) {
|
||||
acc_main_on = GET_BIT(to_push, 20U) == 1U;
|
||||
bool cruise_engaged = GET_BIT(to_push, 21U) == 1U;
|
||||
pcm_cruise_check(cruise_engaged);
|
||||
}
|
||||
|
||||
@@ -250,6 +250,7 @@ static void ford_rx_hook(CANPacket_t *to_push) {
|
||||
|
||||
// Signal: CcStat_D_Actl
|
||||
unsigned int cruise_state = GET_BYTE(to_push, 1) & 0x07U;
|
||||
acc_main_on = (cruise_state == 3U) ||(cruise_state == 4U) || (cruise_state == 5U);
|
||||
bool cruise_engaged = (cruise_state == 4U) || (cruise_state == 5U);
|
||||
pcm_cruise_check(cruise_engaged);
|
||||
}
|
||||
|
||||
@@ -127,6 +127,10 @@ static void gm_rx_hook(CANPacket_t *to_push) {
|
||||
brake_pressed = GET_BIT(to_push, 40U) != 0U;
|
||||
}
|
||||
|
||||
if (addr == 0xC9) {
|
||||
acc_main_on = GET_BIT(to_push, 29U) != 0U;
|
||||
}
|
||||
|
||||
if (addr == 0x1C4) {
|
||||
gas_pressed = GET_BYTE(to_push, 5) != 0U;
|
||||
|
||||
|
||||
@@ -331,7 +331,8 @@ static bool honda_tx_hook(CANPacket_t *to_send) {
|
||||
|
||||
// STEER: safety check
|
||||
if ((addr == 0xE4) || (addr == 0x194)) {
|
||||
if (!controls_allowed) {
|
||||
bool aol_allowed = acc_main_on && (alternative_experience & ALT_EXP_DISABLE_DISENGAGE_ON_GAS);
|
||||
if (!(controls_allowed || aol_allowed)) {
|
||||
bool steer_applied = GET_BYTE(to_send, 0) | GET_BYTE(to_send, 1);
|
||||
if (steer_applied) {
|
||||
tx = false;
|
||||
|
||||
@@ -63,6 +63,10 @@ void hyundai_common_cruise_state_check(const int cruise_engaged) {
|
||||
}
|
||||
|
||||
void hyundai_common_cruise_buttons_check(const int cruise_button, const int main_button) {
|
||||
if (main_button != 0 && main_button != cruise_main_prev) {
|
||||
acc_main_on = !acc_main_on;
|
||||
}
|
||||
cruise_main_prev = main_button;
|
||||
if ((cruise_button == HYUNDAI_BTN_RESUME) || (cruise_button == HYUNDAI_BTN_SET) || (cruise_button == HYUNDAI_BTN_CANCEL) ||
|
||||
(main_button != 0)) {
|
||||
hyundai_last_button_interaction = 0U;
|
||||
|
||||
@@ -52,6 +52,7 @@ static void mazda_rx_hook(CANPacket_t *to_push) {
|
||||
|
||||
// enter controls on rising edge of ACC, exit controls on ACC off
|
||||
if (addr == MAZDA_CRZ_CTRL) {
|
||||
acc_main_on = GET_BIT(to_push, 17U);
|
||||
bool cruise_engaged = GET_BYTE(to_push, 0) & 0x8U;
|
||||
pcm_cruise_check(cruise_engaged);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ const CanMsg NISSAN_TX_MSGS[] = {
|
||||
|
||||
// Signals duplicated below due to the fact that these messages can come in on either CAN bus, depending on car model.
|
||||
RxCheck nissan_rx_checks[] = {
|
||||
{.msg = {{0x1b6, 0, 8, .frequency = 100U},
|
||||
{0x1b6, 1, 8, .frequency = 100U}, { 0 }}}, // PRO_PILOT (100HZ)
|
||||
{.msg = {{0x2, 0, 5, .frequency = 100U},
|
||||
{0x2, 1, 5, .frequency = 100U}, { 0 }}}, // STEER_ANGLE_SENSOR
|
||||
{.msg = {{0x285, 0, 8, .frequency = 50U},
|
||||
@@ -64,11 +66,16 @@ static void nissan_rx_hook(CANPacket_t *to_push) {
|
||||
UPDATE_VEHICLE_SPEED((right_rear + left_rear) / 2.0 * 0.005 / 3.6);
|
||||
}
|
||||
|
||||
if (addr == 0x1b6) {
|
||||
acc_main_on = GET_BIT(to_push, 36U);
|
||||
}
|
||||
|
||||
// X-Trail 0x15c, Leaf 0x239
|
||||
if ((addr == 0x15c) || (addr == 0x239)) {
|
||||
if (addr == 0x15c){
|
||||
gas_pressed = ((GET_BYTE(to_push, 5) << 2) | ((GET_BYTE(to_push, 6) >> 6) & 0x3U)) > 3U;
|
||||
} else {
|
||||
acc_main_on = GET_BIT(to_push, 17U);
|
||||
gas_pressed = GET_BYTE(to_push, 0) > 3U;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +152,7 @@ static void subaru_rx_hook(CANPacket_t *to_push) {
|
||||
|
||||
// enter controls on rising edge of ACC, exit controls on ACC off
|
||||
if ((addr == MSG_SUBARU_CruiseControl) && (bus == alt_main_bus)) {
|
||||
acc_main_on = GET_BIT(to_push, 40U) != 0U;
|
||||
bool cruise_engaged = GET_BIT(to_push, 41U) != 0U;
|
||||
pcm_cruise_check(cruise_engaged);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ static void subaru_preglobal_rx_hook(CANPacket_t *to_push) {
|
||||
|
||||
// enter controls on rising edge of ACC, exit controls on ACC off
|
||||
if (addr == MSG_SUBARU_PG_CruiseControl) {
|
||||
acc_main_on = GET_BIT(to_push, 48U) != 0U;
|
||||
bool cruise_engaged = GET_BIT(to_push, 49U) != 0U;
|
||||
pcm_cruise_check(cruise_engaged);
|
||||
}
|
||||
|
||||
@@ -88,6 +88,14 @@ static void tesla_rx_hook(CANPacket_t *to_push) {
|
||||
if(addr == (tesla_powertrain ? 0x256 : 0x368)) {
|
||||
// Cruise state
|
||||
int cruise_state = (GET_BYTE(to_push, 1) >> 4);
|
||||
|
||||
acc_main_on = (cruise_state == 1) || // STANDBY
|
||||
(cruise_state == 2) || // ENABLED
|
||||
(cruise_state == 3) || // STANDSTILL
|
||||
(cruise_state == 4) || // OVERRIDE
|
||||
(cruise_state == 6) || // PRE_FAULT
|
||||
(cruise_state == 7); // PRE_CANCEL
|
||||
|
||||
bool cruise_engaged = (cruise_state == 2) || // ENABLED
|
||||
(cruise_state == 3) || // STANDSTILL
|
||||
(cruise_state == 4) || // OVERRIDE
|
||||
|
||||
@@ -47,6 +47,7 @@ const int TOYOTA_GAS_INTERCEPTOR_THRSLD = 805;
|
||||
{0x283, 0, 7}, {0x2E6, 0, 8}, {0x2E7, 0, 8}, {0x33E, 0, 7}, {0x344, 0, 8}, {0x365, 0, 7}, {0x366, 0, 7}, {0x4CB, 0, 8}, /* DSU bus 0 */ \
|
||||
{0x128, 1, 6}, {0x141, 1, 4}, {0x160, 1, 8}, {0x161, 1, 7}, {0x470, 1, 4}, /* DSU bus 1 */ \
|
||||
{0x2E4, 0, 5}, {0x191, 0, 8}, {0x411, 0, 8}, {0x412, 0, 8}, {0x343, 0, 8}, {0x1D2, 0, 8}, /* LKAS + ACC */ \
|
||||
{0x1D3, 0, 8}, \
|
||||
|
||||
const CanMsg TOYOTA_TX_MSGS[] = {
|
||||
TOYOTA_COMMON_TX_MSGS
|
||||
@@ -61,6 +62,7 @@ const CanMsg TOYOTA_INTERCEPTOR_TX_MSGS[] = {
|
||||
{.msg = {{ 0xaa, 0, 8, .check_checksum = false, .frequency = 83U}, { 0 }, { 0 }}}, \
|
||||
{.msg = {{0x260, 0, 8, .check_checksum = true, .quality_flag = (lta), .frequency = 50U}, { 0 }, { 0 }}}, \
|
||||
{.msg = {{0x1D2, 0, 8, .check_checksum = true, .frequency = 33U}, { 0 }, { 0 }}}, \
|
||||
{.msg = {{0x1D3, 0, 8, .check_checksum = true, .frequency = 33U}, { 0 }, { 0 }}}, \
|
||||
{.msg = {{0x224, 0, 8, .check_checksum = false, .frequency = 40U}, \
|
||||
{0x226, 0, 8, .check_checksum = false, .frequency = 40U}, { 0 }}}, \
|
||||
|
||||
@@ -166,6 +168,9 @@ static void toyota_rx_hook(CANPacket_t *to_push) {
|
||||
update_sample(&angle_meas, angle_meas_new);
|
||||
}
|
||||
}
|
||||
if (addr == 0x1D3) {
|
||||
acc_main_on = GET_BIT(to_push, 15U);
|
||||
}
|
||||
|
||||
// enter controls on rising edge of ACC, exit controls on ACC off
|
||||
// exit controls on rising edge of gas press
|
||||
|
||||
Reference in New Issue
Block a user