Skip to content

Commit

Permalink
Bosch Gas Press (commaai#243)
Browse files Browse the repository at this point in the history
* Disabled gas press disengage for Bosch Honda

* Disable gasPressed for Bosch in interface.py

* Fix indent for interface.py gasPress Bosch disable

* allow gas disengagement for CR-V (commaai#237)

* allow disengagement for CR-V (commaai#238)

already tested
  • Loading branch information
kegman committed Dec 24, 2019
1 parent 38e9435 commit f7f899f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 5 additions & 3 deletions panda/board/safety/safety_honda.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ bool honda_moving = false;
bool honda_bosch_hardware = false;
bool honda_alt_brake_msg = false;
bool honda_fwd_brake = false;
bool bosch_ACC_allowed = false;

static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {

Expand Down Expand Up @@ -81,7 +82,7 @@ static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
if (!gas_interceptor_detected) {
if (addr == 0x17C) {
int gas = GET_BYTE(to_push, 0);
if (gas && !(honda_gas_prev) && long_controls_allowed) {
if (gas && !(honda_gas_prev) && long_controls_allowed && !(bosch_ACC_allowed)) {
controls_allowed = 0;
}
honda_gas_prev = gas;
Expand Down Expand Up @@ -146,7 +147,7 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {

// disallow actuator commands if gas or brake (with vehicle moving) are pressed
// and the the latching controls_allowed flag is True
int pedal_pressed = honda_gas_prev || (gas_interceptor_prev > HONDA_GAS_INTERCEPTOR_THRESHOLD) ||
int pedal_pressed = (!bosch_ACC_allowed && honda_gas_prev) || (gas_interceptor_prev > HONDA_GAS_INTERCEPTOR_THRESHOLD) ||
(honda_brake_pressed_prev && honda_moving);
bool current_controls_allowed = controls_allowed && !(pedal_pressed);

Expand All @@ -168,6 +169,7 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {

// STEER: safety check
if ((addr == 0xE4) || (addr == 0x194)) {
bosch_ACC_allowed = honda_bosch_hardware;
if (!current_controls_allowed) {
bool steer_applied = GET_BYTE(to_send, 0) | GET_BYTE(to_send, 1);
if (steer_applied) {
Expand All @@ -179,7 +181,7 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
// GAS: safety check
if (addr == 0x200) {
if (!current_controls_allowed || !long_controls_allowed) {
if (GET_BYTE(to_send, 0) || GET_BYTE(to_send, 1)) {
if (!bosch_ACC_allowed && (GET_BYTE(to_send, 0) || GET_BYTE(to_send, 1))) {
tx = 0;
}
}
Expand Down
9 changes: 7 additions & 2 deletions selfdrive/car/honda/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ def __init__(self, CP, CarController):
self.compute_gb = get_compute_gb_acura()
else:
self.compute_gb = compute_gb_honda

if self.CS.CP.carFingerprint in HONDA_BOSCH:
self.bosch_honda = True
else:
self.bosch_honda = False

@staticmethod
def calc_accel_override(a_ego, a_target, v_ego, v_target):
Expand Down Expand Up @@ -545,11 +550,11 @@ def update(self, c, can_strings):
events.append(create_event('speedTooLow', [ET.NO_ENTRY]))

# disable on pedals rising edge or when brake is pressed and speed isn't zero
if (ret.gasPressed and not self.gas_pressed_prev) or \
if (ret.gasPressed and not self.gas_pressed_prev and not self.bosch_honda) or \
(ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)):
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))

if ret.gasPressed:
if ret.gasPressed and not self.bosch_honda:
events.append(create_event('pedalPressed', [ET.PRE_ENABLE]))

# it can happen that car cruise disables while comma system is enabled: need to
Expand Down

0 comments on commit f7f899f

Please sign in to comment.