Skip to content

Commit

Permalink
Honda fwd fixes (commaai#5)
Browse files Browse the repository at this point in the history
- fix chime forwarding
- forward radar hud msg from stock
- no EON chime during stock fcw
  • Loading branch information
rbiasini committed Dec 26, 2019
1 parent 8f78b61 commit a2ae18d
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion panda/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.6.9
v1.7.0
Binary file modified panda/board/obj/panda.bin.signed
Binary file not shown.
5 changes: 2 additions & 3 deletions panda/board/safety/safety_honda.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// accel rising edge
// brake rising edge
// brake > 0mph
const AddrBus HONDA_N_TX_MSGS[] = {{0xE4, 0}, {0x194, 0}, {0x1FA, 0}, {0x200, 0}, {0x30C, 0}, {0x33D, 0}, {0x39F, 0}};
const AddrBus HONDA_N_TX_MSGS[] = {{0xE4, 0}, {0x194, 0}, {0x1FA, 0}, {0x200, 0}, {0x30C, 0}, {0x33D, 0}};
const AddrBus HONDA_BH_TX_MSGS[] = {{0xE4, 0}, {0x296, 1}, {0x33D, 0}}; // Bosch Harness
const AddrBus HONDA_BG_TX_MSGS[] = {{0xE4, 2}, {0x296, 0}, {0x33D, 2}}; // Bosch Giraffe
const int HONDA_GAS_INTERCEPTOR_THRESHOLD = 328; // ratio between offset and gain from dbc file
Expand Down Expand Up @@ -216,7 +216,6 @@ static int honda_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
// fwd from car to camera. also fwd certain msgs from camera to car
// 0xE4 is steering on all cars except CRV and RDX, 0x194 for CRV and RDX,
// 0x1FA is brake control, 0x30C is acc hud, 0x33D is lkas hud,
// 0x39f is radar hud
int bus_fwd = -1;

if (!relay_malfunction) {
Expand All @@ -227,7 +226,7 @@ static int honda_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
// block stock lkas messages and stock acc messages (if OP is doing ACC)
int addr = GET_ADDR(to_fwd);
bool is_lkas_msg = (addr == 0xE4) || (addr == 0x194) || (addr == 0x33D);
bool is_acc_hud_msg = (addr == 0x30C) || (addr == 0x39F);
bool is_acc_hud_msg = addr == 0x30C;
bool is_brake_msg = addr == 0x1FA;
bool block_fwd = is_lkas_msg ||
(is_acc_hud_msg && long_controls_allowed) ||
Expand Down
4 changes: 2 additions & 2 deletions panda/tests/safety/test_honda.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
MAX_BRAKE = 255

INTERCEPTOR_THRESHOLD = 328
TX_MSGS = [[0xE4, 0], [0x194, 0], [0x1FA, 0], [0x200, 0], [0x30C, 0], [0x33D, 0], [0x39F, 0]]
TX_MSGS = [[0xE4, 0], [0x194, 0], [0x1FA, 0], [0x200, 0], [0x30C, 0], [0x33D, 0]]

class TestHondaSafety(unittest.TestCase):
@classmethod
Expand Down Expand Up @@ -253,7 +253,7 @@ def test_fwd_hook(self):
self.safety.set_long_controls_allowed(l)
blocked_msgs = [0xE4, 0x194, 0x33D]
if l:
blocked_msgs += [0x30C, 0x39F]
blocked_msgs += [0x30C]
if not f:
blocked_msgs += [0x1FA]
for b in buss:
Expand Down
2 changes: 1 addition & 1 deletion panda/tests/safety_replay/test_safety_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# (route, safety mode, param)
logs = [
("b0c9d2329ad1606b|2019-05-30--20-23-57.bz2", Panda.SAFETY_HONDA, 0), # HONDA.CIVIC
("2425568437959f9d|2019-12-22--16-24-37.bz2", Panda.SAFETY_HONDA_NIDEC, 0), # HONDA.CIVIC (fcw presents: 0x1FA blocked as expected)
("38bfd238edecbcd7|2019-06-07--10-15-25.bz2", Panda.SAFETY_TOYOTA, 66), # TOYOTA.PRIUS
("f89c604cf653e2bf|2018-09-29--13-46-50.bz2", Panda.SAFETY_GM, 0), # GM.VOLT
("0375fdf7b1ce594d|2019-05-21--20-10-33.bz2", Panda.SAFETY_HONDA_BOSCH, 1), # HONDA.ACCORD
Expand Down
12 changes: 2 additions & 10 deletions selfdrive/car/honda/hondacan.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from selfdrive.config import Conversions as CV
from selfdrive.car.honda.values import CAR, HONDA_BOSCH
from selfdrive.car.honda.values import HONDA_BOSCH


def get_pt_bus(car_fingerprint, has_relay):
Expand All @@ -25,7 +25,7 @@ def create_brake_command(packer, apply_brake, pump_on, pcm_override, pcm_cancel_
"COMPUTER_BRAKE_REQUEST": brake_rq,
"SET_ME_1": 1,
"BRAKE_LIGHTS": brakelights,
"CHIME": stock_brake["CHIME"], # chime issued when disabling FCM
"CHIME": stock_brake["CHIME"] if fcw else 0, # send the chime for stock fcw
"FCW": fcw << 1, # TODO: Why are there two bits for fcw?
"AEB_REQ_1": 0,
"AEB_REQ_2": 0,
Expand Down Expand Up @@ -76,14 +76,6 @@ def create_ui_commands(packer, pcm_speed, hud, car_fingerprint, is_metric, idx,
}
commands.append(packer.make_can_msg('LKAS_HUD', bus_lkas, lkas_hud_values, idx))

if car_fingerprint in (CAR.CIVIC, CAR.ODYSSEY):
radar_hud_values = {
'ACC_ALERTS': hud.acc_alert,
'LEAD_SPEED': 0x1fe, # What are these magic values
'LEAD_STATE': 0x7,
'LEAD_DISTANCE': 0x1e,
}
commands.append(packer.make_can_msg('RADAR_HUD', bus_pt, radar_hud_values, idx))
return commands


Expand Down
8 changes: 6 additions & 2 deletions selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,14 @@ def state_control(frame, rcv_frame, plan, path_plan, CS, CP, state, events, v_cr
# add eventual driver distracted events
events = driver_status.update(events, driver_engaged, isActive(state), CS.standstill)

# send FCW alert if triggered by planner
if plan.fcw or CS.stockFcw:
if plan.fcw:
# send FCW alert if triggered by planner
AM.add(frame, "fcw", enabled)

elif CS.stockFcw:
# send a silent alert when stock fcw triggers, since the car is already beeping
AM.add(frame, "fcwStock", enabled)

# State specific actions

if state in [State.preEnabled, State.disabled]:
Expand Down
7 changes: 7 additions & 0 deletions selfdrive/controls/lib/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ def __gt__(self, alert2):
AlertStatus.critical, AlertSize.full,
Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.chimeWarningRepeat, 1., 2., 2.),

Alert(
"fcwStock",
"BRAKE!",
"Risk of Collision",
AlertStatus.critical, AlertSize.full,
Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.none, 1., 2., 2.), # no EON chime for stock FCW

Alert(
"steerSaturated",
"TAKE CONTROL",
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/test/process_replay/ref_commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b2364d6239bca0a8caaf11f0433bf766c66e15a4
89304bdcab73fa43a8dd39cab93bc4ea4c9cbbdb

0 comments on commit a2ae18d

Please sign in to comment.