Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tuning with devel #2

Merged
merged 27 commits into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
faea9a4
GM: go passive if detected ASCM or LKA camera (#350)
vntarasov Sep 6, 2018
6eb1247
GM: update readme, ACC is a required package (#354)
vntarasov Sep 7, 2018
50d9c44
Tried native Stop and Go on Highlander ICE with no comma pedal: Works…
zeeexsixare Sep 7, 2018
d2b8c4f
fixed sign in after Google change (#357)
rbiasini Sep 8, 2018
b3654cb
Kia Sorento and future Multi-Car Support (#346)
emmertex Sep 9, 2018
0913968
Merge pull request #1 from commaai/devel
zeeexsixare Sep 12, 2018
a260581
1.5 to 1.0 m/s2
zeeexsixare Sep 12, 2018
70381ea
Stopping beeping on commanded disengage
zeeexsixare Sep 12, 2018
fe10156
Accel max to 1.5 to test other tuning
zeeexsixare Sep 13, 2018
7d46171
updated steerKiV for tuning v1
zeeexsixare Sep 13, 2018
a21c6a0
Increased ret.steerKiV another two steps
zeeexsixare Sep 13, 2018
8feb4da
Rename ui.c to ui_original.c
zeeexsixare Sep 13, 2018
63f7e94
Trying expanded ui.c again
zeeexsixare Sep 13, 2018
9c213aa
Trying to fix lane lines not showing
zeeexsixare Sep 13, 2018
807a2da
Fixing Lane Lines attempt #2
zeeexsixare Sep 13, 2018
5117f3d
Fix lane lines attempt #3
zeeexsixare Sep 13, 2018
3725753
Fix lane lines attempt #4
zeeexsixare Sep 13, 2018
ccb3375
Fix lane lines attempt #4
zeeexsixare Sep 13, 2018
abcd977
Attempt #5
zeeexsixare Sep 13, 2018
64e02cc
Attempt #6
zeeexsixare Sep 13, 2018
18e501a
Rollback some of the lines commented out
zeeexsixare Sep 14, 2018
4074fbe
Merge branch 'tuning' into devel
zeeexsixare Sep 17, 2018
9f59882
Clean up for PR with upstream
zeeexsixare Sep 17, 2018
51bc909
Merged pre/post driver monitoring engineering ui.c
zeeexsixare Sep 17, 2018
1da86bd
Delete ui_original.c
zeeexsixare Sep 17, 2018
17f7e7c
Fix whitespace
zeeexsixare Sep 17, 2018
6b99ea6
Fix whitespace #2
zeeexsixare Sep 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Supported Cars
| Acura | ILX 2016 | AcuraWatch Plus | Yes | Yes | 25mph<sup>1</sup>| 25mph |
| Acura | ILX 2017 | AcuraWatch Plus | Yes | Yes | 25mph<sup>1</sup>| 25mph |
| Acura | RDX 2018 | AcuraWatch Plus | Yes | Yes | 25mph<sup>1</sup>| 12mph |
| GM<sup>3</sup> | Volt 2017 | Driver Confidence II | Yes | Yes | 0mph | 7mph |
| GM<sup>3</sup> | Volt 2018 | Driver Confidence II | Yes | Yes | 0mph | 7mph |
| GM<sup>3</sup> | Volt 2017 | Adaptive Cruise | Yes | Yes | 0mph | 7mph |
| GM<sup>3</sup> | Volt 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph |
| Honda | Accord 2018 | All | Yes | Stock | 0mph | 3mph |
| Honda | Civic 2016 | Honda Sensing | Yes | Yes | 0mph | 12mph |
| Honda | Civic 2017 | Honda Sensing | Yes | Yes | 0mph | 12mph |
Expand All @@ -67,6 +67,10 @@ Supported Cars
| Honda | Ridgeline 2017 | Honda Sensing | Yes | Yes | 25mph<sup>1</sup>| 12mph |
| Honda | Ridgeline 2018 | Honda Sensing | Yes | Yes | 25mph<sup>1</sup>| 12mph |
| Hyundai<sup>6</sup>| Santa Fe 2019 | All | Yes | Stock | 0mph | 0mph |
| Hyundai<sup>6</sup>| Elantra 2017 | SCC + LKAS | Yes | Stock | 19mph | 34mph |
| Hyundai<sup>6</sup>| Genesis 2018 | All | Yes | Stock | 19mph | 34mph |
| Kia<sup>6</sup> | Sorento 2018 | All | Yes | Stock | 0mph | 0mph |
| Kia<sup>6</sup> | Stinger 2018 | SCC + LKAS | Yes | Stock | 0mph | 0mph |
| Lexus | RX Hybrid 2017 | All | Yes | Yes<sup>2</sup>| 0mph | 0mph |
| Lexus | RX Hybrid 2018 | All | Yes | Yes<sup>2</sup>| 0mph | 0mph |
| Toyota | Camry 2018<sup>4</sup>| All | Yes | Stock | 0mph<sup>5</sup> | 0mph |
Expand Down Expand Up @@ -113,7 +117,7 @@ In Progress Cars
- 'All-Speed Range Dynamic Radar Cruise Control' is required to enable stop-and-go. Only the GS, GSH, F, RX, RXH, LX, NX, NXH, LC, LCH, LS, LSH have this option.
- Even though the LX have TSS-P, it does not have Steering Assist and is not supported.
- All Hyundai with SmartSense.
- All Kia with ACC and LKAS.
- All Kia with SCC and LKAS.

How can I add support for my car?
------
Expand Down
Binary file modified apk/ai.comma.plus.offroad.apk
Binary file not shown.
2 changes: 2 additions & 0 deletions cereal/car.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct CarEvent @0x9b1657f34caf3ad3 {
preDriverUnresponsive @43;
promptDriverUnresponsive @44;
driverUnresponsive @45;
belowSteerSpeed @46;
}
}

Expand Down Expand Up @@ -284,6 +285,7 @@ struct CarParams {
enableApgs @28 :Bool; # advanced parking guidance system

minEnableSpeed @17 :Float32;
minSteerSpeed @49 :Float32;
safetyModel @18 :Int16;
safetyParam @41 :Int16;

Expand Down
2 changes: 1 addition & 1 deletion panda/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.1.3
v1.1.4
9 changes: 6 additions & 3 deletions panda/board/safety/safety_gm.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const int GM_MAX_BRAKE = 350;
int gm_brake_prev = 0;
int gm_gas_prev = 0;
int gm_speed = 0;
// silence everything if stock ECUs are still online
// silence everything if stock car control ECUs are still online
int gm_ascm_detected = 0;
int gm_ignition_started = 0;
int gm_rt_torque_last = 0;
Expand Down Expand Up @@ -63,8 +63,11 @@ static void gm_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
gm_speed = to_push->RDLR & 0xFFFF;
}

// check if stock ASCM ECU is still online
if (bus_number == 0 && addr == 715) {
// Check if ASCM or LKA camera are online
// on powertrain bus.
// 384 = ASCMLKASteeringCmd
// 715 = ASCMGasRegenCmd
if (bus_number == 0 && (addr == 384 || addr == 715)) {
gm_ascm_detected = 1;
controls_allowed = 0;
}
Expand Down
27 changes: 17 additions & 10 deletions panda/board/safety/safety_hyundai.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const int HYUNDAI_DRIVER_TORQUE_ALLOWANCE = 50;
const int HYUNDAI_DRIVER_TORQUE_FACTOR = 2;

int hyundai_camera_detected = 0;
int hyundai_camera_bus = 0;
int hyundai_giraffe_switch_2 = 0; // is giraffe switch 2 high?
int hyundai_rt_torque_last = 0;
int hyundai_desired_torque_last = 0;
Expand Down Expand Up @@ -39,6 +40,11 @@ static void hyundai_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
controls_allowed = 0;
}

// Find out which bus the camera is on
if (addr == 832) {
hyundai_camera_bus = bus;
}

// enter controls on rising edge of ACC, exit controls on ACC off
if ((to_push->RIR>>21) == 1057) {
// 2 bits: 13-14
Expand All @@ -51,8 +57,8 @@ static void hyundai_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
hyundai_cruise_engaged_last = cruise_engaged;
}

// 832 is lkas cmd. If it is on bus 2, then giraffe switch 2 is high
if ((to_push->RIR>>21) == 832 && (bus == 2)) {
// 832 is lkas cmd. If it is on camera bus, then giraffe switch 2 is high
if ((to_push->RIR>>21) == 832 && (bus == hyundai_camera_bus) && (hyundai_camera_bus != 0)) {
hyundai_giraffe_switch_2 = 1;
}
}
Expand Down Expand Up @@ -123,21 +129,22 @@ static int hyundai_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
// FORCE CANCEL: safety check only relevant when spamming the cancel button.
// ensuring that only the cancel button press is sent (VAL 4) when controls are off.
// This avoids unintended engagements while still allowing resume spam
if (((to_send->RIR>>21) == 1265) && !controls_allowed && ((to_send->RDTR >> 4) & 0xFF) == 0) {
if ((to_send->RDLR & 0x7) != 4) return 0;
}
// TODO: fix bug preventing the button msg to be fwd'd on bus 2
//if (((to_send->RIR>>21) == 1265) && !controls_allowed && ((to_send->RDTR >> 4) & 0xFF) == 0) {
// if ((to_send->RDLR & 0x7) != 4) return 0;
//}

// 1 allows the message through
return true;
}

static int hyundai_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {

// forward cam to ccan and viceversa, except lkas cmd
if ((bus_num == 0 || bus_num == 2) && hyundai_giraffe_switch_2) {
int addr = to_fwd->RIR>>21;
bool is_lkas_msg = addr == 832 && bus_num == 2;
return is_lkas_msg? -1 : (uint8_t)(~bus_num & 0x2);
if ((bus_num == 0 || bus_num == hyundai_camera_bus) && hyundai_giraffe_switch_2) {

if ((to_fwd->RIR>>21) == 832 && bus_num == hyundai_camera_bus) return -1;
if (bus_num == 0) return hyundai_camera_bus;
if (bus_num == hyundai_camera_bus) return 0;
}
return -1;
}
Expand Down
24 changes: 12 additions & 12 deletions panda/tests/safety/test_hyundai.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,18 @@ def test_realtime_limits(self):
self.assertTrue(self.safety.hyundai_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA + 1))))


def test_spam_cancel_safety_check(self):
RESUME_BTN = 1
SET_BTN = 2
CANCEL_BTN = 4
BUTTON_MSG = 1265
self.safety.set_controls_allowed(0)
self.assertTrue(self.safety.hyundai_tx_hook(self._button_msg(CANCEL_BTN)))
self.assertFalse(self.safety.hyundai_tx_hook(self._button_msg(RESUME_BTN)))
self.assertFalse(self.safety.hyundai_tx_hook(self._button_msg(SET_BTN)))
# do not block resume if we are engaged already
self.safety.set_controls_allowed(1)
self.assertTrue(self.safety.hyundai_tx_hook(self._button_msg(RESUME_BTN)))
#def test_spam_cancel_safety_check(self):
# RESUME_BTN = 1
# SET_BTN = 2
# CANCEL_BTN = 4
# BUTTON_MSG = 1265
# self.safety.set_controls_allowed(0)
# self.assertTrue(self.safety.hyundai_tx_hook(self._button_msg(CANCEL_BTN)))
# self.assertFalse(self.safety.hyundai_tx_hook(self._button_msg(RESUME_BTN)))
# self.assertFalse(self.safety.hyundai_tx_hook(self._button_msg(SET_BTN)))
# # do not block resume if we are engaged already
# self.safety.set_controls_allowed(1)
# self.assertTrue(self.safety.hyundai_tx_hook(self._button_msg(RESUME_BTN)))


if __name__ == "__main__":
Expand Down
7 changes: 6 additions & 1 deletion selfdrive/car/gm/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def actuator_hystereses(final_pedal, pedal_steady):


class CarController(object):
def __init__(self, canbus, car_fingerprint):
def __init__(self, canbus, car_fingerprint, allow_controls):
self.pedal_steady = 0.
self.start_time = sec_since_boot()
self.chime = 0
Expand All @@ -64,6 +64,7 @@ def __init__(self, canbus, car_fingerprint):
self.steer_idx = 0
self.apply_steer_last = 0
self.car_fingerprint = car_fingerprint
self.allow_controls = allow_controls

# Setup detection helper. Routes commands to
# an appropriate CAN bus number.
Expand All @@ -77,6 +78,10 @@ def update(self, sendcan, enabled, CS, frame, actuators, \
hud_v_cruise, hud_show_lanes, hud_show_car, chime, chime_cnt):
""" Controls thread """

# Sanity check.
if not self.allow_controls:
return

P = self.params

# Send CAN commands.
Expand Down
19 changes: 10 additions & 9 deletions selfdrive/car/gm/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,17 @@ class CM:
LOW_CHIME = 0x86
HIGH_CHIME = 0x87

# GM cars have 4 CAN buses, which creates many ways
# of how the car can be connected to.
# This ia a helper class for the interface to be setup-agnostic.
# Supports single Panda setup (connected to OBDII port),
# and a CAN forwarding setup (connected to camera module connector).

class CanBus(object):
def __init__(self):
self.powertrain = 0
self.obstacle = 1
self.chassis = 2
self.sw_gmlan = 3

# 384 = "ASCMLKASteeringCmd"
# 715 = "ASCMGasRegenCmd"
CONTROL_MSGS = [384, 715]

class CarInterface(object):
def __init__(self, CP, sendcan=None):
self.CP = CP
Expand All @@ -54,7 +52,7 @@ def __init__(self, CP, sendcan=None):
# sending if read only is False
if sendcan is not None:
self.sendcan = sendcan
self.CC = CarController(canbus, CP.carFingerprint)
self.CC = CarController(canbus, CP.carFingerprint, CP.enableCamera)

@staticmethod
def compute_gb(accel, speed):
Expand All @@ -73,8 +71,11 @@ def get_params(candidate, fingerprint):

ret.enableCruise = False

# TODO: gate this on detection
ret.enableCamera = True
# Presence of a camera on the object bus is ok.
# Have to go passive if ASCM is online (ACC-enabled cars),
# or camera is on powertrain bus (LKA cars without ACC).
ret.enableCamera = not any(x for x in CONTROL_MSGS if x in fingerprint)

std_cargo = 136

if candidate == CAR.VOLT:
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def update(self, sendcan, enabled, CS, actuators, pcm_cancel_cmd, hud_alert):
if (self.cnt % 7) == 0:
can_sends.append(create_1156())

can_sends.append(create_lkas11(self.packer, apply_steer, steer_req, self.lkas11_cnt,
can_sends.append(create_lkas11(self.packer, self.car_fingerprint, apply_steer, steer_req, self.lkas11_cnt,
enabled, CS.lkas11, hud_alert, keep_stock=(not self.camera_disconnected)))

if pcm_cancel_cmd:
Expand Down
4 changes: 3 additions & 1 deletion selfdrive/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ def get_can_parser(CP):
("YAW_RATE", "ESP12", 0),

("CF_Gway_DrvSeatBeltInd", "CGW4", 1),

("CF_Gway_DrvSeatBeltSw", "CGW1", 0),
("CF_Gway_TSigLHSw", "CGW1", 0),
("CF_Gway_TurnSigLh", "CGW1", 0),
("CF_Gway_TSigRHSw", "CGW1", 0),
("CF_Gway_TurnSigRh", "CGW1", 0),
("CF_Gway_ParkBrakeSw", "CGW1", 0),

("BRAKE_ACT", "EMS12", 0),
("PV_AV_CAN", "EMS12", 0),
Expand Down Expand Up @@ -149,7 +151,7 @@ def update(self, cp, cp_cam):
self.brake_pressed = cp.vl["TCS13"]['DriverBraking']
self.esp_disabled = cp.vl["TCS15"]['ESC_Off_Step']

self.park_brake = False
self.park_brake = cp.vl["CGW1"]['CF_Gway_ParkBrakeSw']
self.main_on = True
self.acc_active = cp.vl["SCC12"]['ACCMode'] != 0
self.pcm_acc_status = int(self.acc_active)
Expand Down
22 changes: 17 additions & 5 deletions selfdrive/car/hyundai/hyundaican.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import crcmod
from selfdrive.car.hyundai.values import CHECKSUM

hyundai_checksum = crcmod.mkCrcFun(0x11D, initCrc=0xFD, rev=False, xorOut=0xdf)

def make_can_msg(addr, dat, alt):
return [addr, 0, dat, alt]

def create_lkas11(packer, apply_steer, steer_req, cnt, enabled, lkas11, hud_alert, keep_stock=False):
def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, lkas11, hud_alert, keep_stock=False):
values = {
"CF_Lkas_Icon": 3 if enabled else 0,
"CF_Lkas_LdwsSysState": lkas11["CF_Lkas_LdwsSysState"] if keep_stock else 1,
"CF_Lkas_LdwsSysState": 3 if steer_req else 1,
"CF_Lkas_SysWarning": hud_alert,
"CF_Lkas_LdwsLHWarning": lkas11["CF_Lkas_LdwsLHWarning"] if keep_stock else 0,
"CF_Lkas_LdwsRHWarning": lkas11["CF_Lkas_LdwsRHWarning"] if keep_stock else 0,
"CF_Lkas_HbaLamp": lkas11["CF_Lkas_HbaLamp"] if keep_stock else 0,
"CF_Lkas_FcwBasReq": lkas11["CF_Lkas_FcwBasReq"] if keep_stock else 0,
"CR_Lkas_StrToqReq": apply_steer,
"CF_Lkas_ActToi": steer_req,
"CF_Lkas_ToiFlt": lkas11["CF_Lkas_ToiFlt"] if keep_stock else 0,
"CF_Lkas_ToiFlt": 0,
"CF_Lkas_HbaSysState": lkas11["CF_Lkas_HbaSysState"] if keep_stock else 1,
"CF_Lkas_FcwOpt": lkas11["CF_Lkas_FcwOpt"] if keep_stock else 0,
"CF_Lkas_HbaOpt": lkas11["CF_Lkas_HbaOpt"] if keep_stock else 3,
Expand All @@ -30,8 +31,19 @@ def create_lkas11(packer, apply_steer, steer_req, cnt, enabled, lkas11, hud_aler
}

dat = packer.make_can_msg("LKAS11", 0, values)[2]
dat = dat[:6] + dat[7]
checksum = hyundai_checksum(dat)

if car_fingerprint in CHECKSUM["crc8"]:
# CRC Checksum as seen on 2019 Hyundai Santa Fe
dat = dat[:6] + dat[7]
checksum = hyundai_checksum(dat)
elif car_fingerprint in CHECKSUM["6B"]:
# Checksum of first 6 Bytes, as seen on 2018 Kia Sorento
dat = [ord(i) for i in dat]
checksum = sum(dat[:6]) % 256
elif car_fingerprint in CHECKSUM["7B"]:
# Checksum of first 6 Bytes and last Byte as seen on 2018 Kia Stinger
dat = [ord(i) for i in dat]
checksum = (sum(dat[:6]) + dat[7]) % 256

values["CF_Lkas_Chksum"] = checksum

Expand Down
Loading