From b87dc53c39d808c3303597bb8e72555abff4e5ee Mon Sep 17 00:00:00 2001 From: Vasily Tarasov Date: Tue, 4 Sep 2018 00:16:09 -0700 Subject: [PATCH 1/7] Fix pre-enable engagement on GM (#348) In 2017 Volts, PCM fault occurs for a few seconds if ACC gas is commanded while user presses gas pedal. PID winds up, and when PCM fault clears, car gets a "max gas" jolt. In 2018 Volts, PCM fault doesn't time out, which means pre-enable doesn't work at all, and car would slowly decelerate, while openpilot thinks it's engaged. --- selfdrive/car/gm/interface.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index bf39272fc..ec531d3db 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -325,7 +325,11 @@ class CarInterface(object): "chimeRepeated": (CM.LOW_CHIME, -1), "chimeContinuous": (CM.LOW_CHIME, -1)}[str(c.hudControl.audibleAlert)] - self.CC.update(self.sendcan, c.enabled, self.CS, self.frame, \ + # For Openpilot, "enabled" includes pre-enable. + # In GM, PCM faults out if ACC command overlaps user gas. + enabled = c.enabled and not self.CS.user_gas_pressed + + self.CC.update(self.sendcan, enabled, self.CS, self.frame, \ c.actuators, hud_v_cruise, c.hudControl.lanesVisible, \ c.hudControl.leadVisible, \ From 5acc12852a74639b8678c0a39389272c7de85a5e Mon Sep 17 00:00:00 2001 From: Vasily Tarasov Date: Tue, 4 Sep 2018 00:21:04 -0700 Subject: [PATCH 2/7] Change dashboard command of GM to use packer (#347) * Change dashboard command of GM to use packer Also, separate "follow distance" from "engaged". * Fix dashboard setSpeed scaling --- selfdrive/car/gm/carcontroller.py | 2 +- selfdrive/car/gm/gmcan.py | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/selfdrive/car/gm/carcontroller.py b/selfdrive/car/gm/carcontroller.py index 3625a6b1d..cea62a3c7 100644 --- a/selfdrive/car/gm/carcontroller.py +++ b/selfdrive/car/gm/carcontroller.py @@ -137,7 +137,7 @@ class CarController(object): # Send dashboard UI commands (ACC status), 25hz if (frame % 4) == 0: - can_sends.append(gmcan.create_acc_dashboard_command(canbus.powertrain, enabled, hud_v_cruise / CV.MS_TO_KPH, hud_show_car)) + can_sends.append(gmcan.create_acc_dashboard_command(self.packer_pt, canbus.powertrain, enabled, hud_v_cruise * CV.MS_TO_KPH, hud_show_car)) # Radar needs to know current speed and yaw rate (50hz), # and that ADAS is alive (10hz) diff --git a/selfdrive/car/gm/gmcan.py b/selfdrive/car/gm/gmcan.py index 0c84df422..47b0d8b38 100644 --- a/selfdrive/car/gm/gmcan.py +++ b/selfdrive/car/gm/gmcan.py @@ -84,14 +84,21 @@ def create_friction_brake_command(packer, bus, apply_brake, idx, near_stop, at_f return packer.make_can_msg("EBCMFrictionBrakeCmd", bus, values) -def create_acc_dashboard_command(bus, acc_engaged, target_speed_ms, lead_car_in_sight): - engaged = 0x90 if acc_engaged else 0 - lead_car = 0x10 if lead_car_in_sight else 0 - target_speed = int(target_speed_ms * 208) & 0xfff - speed_high = target_speed >> 8 - speed_low = target_speed & 0xff - dat = [0x01, 0x00, engaged | speed_high, speed_low, 0x01, lead_car] - return [0x370, 0, "".join(map(chr, dat)), bus] +def create_acc_dashboard_command(packer, bus, acc_engaged, target_speed_kph, lead_car_in_sight): + # Not a bit shift, dash can round up based on low 4 bits. + target_speed = int(target_speed_kph * 16) & 0xfff + + values = { + "ACCAlwaysOne" : 1, + "ACCResumeButton" : 0, + "ACCSpeedSetpoint" : target_speed, + "ACCGapLevel" : 3 * acc_engaged, # 3 "far", 0 "inactive" + "ACCCmdActive" : acc_engaged, + "ACCAlwaysOne2" : 1, + "ACCLeadCar" : lead_car_in_sight + } + + return packer.make_can_msg("ASCMActiveCruiseControlStatus", bus, values) def create_adas_time_status(bus, tt, idx): dat = [(tt >> 20) & 0xff, (tt >> 12) & 0xff, (tt >> 4) & 0xff, From 4888d075673b4acdfec7a5fb274baaa2301fcc7b Mon Sep 17 00:00:00 2001 From: daehahn Date: Wed, 5 Sep 2018 15:29:36 -0700 Subject: [PATCH 3/7] Correct typo for Highlander (#349) --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index eae938037..0cc746f32 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -2,7 +2,7 @@ Version 0.5.3 (2018-09-03) ======================== * Hyundai Santa Fe support! * Honda Pilot 2019 support thanks to energee! - * Toyota Hyghlander support thanks to daehahn! + * Toyota Highlander support thanks to daehahn! * Improve steering tuning for Honda Odyssey Version 0.5.2 (2018-08-16) From d845a258de6759c031026bb512faa7e2faa3a349 Mon Sep 17 00:00:00 2001 From: Vasily Tarasov Date: Thu, 6 Sep 2018 11:59:05 -0700 Subject: [PATCH 4/7] GM: go passive if detected ASCM or LKA camera (#350) Since fingerprint is powertrain CAN only, camera still present on object bus is not an issue. --- selfdrive/car/gm/carcontroller.py | 7 ++++++- selfdrive/car/gm/interface.py | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/selfdrive/car/gm/carcontroller.py b/selfdrive/car/gm/carcontroller.py index cea62a3c7..080393230 100644 --- a/selfdrive/car/gm/carcontroller.py +++ b/selfdrive/car/gm/carcontroller.py @@ -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 @@ -64,6 +64,7 @@ class CarController(object): 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. @@ -77,6 +78,10 @@ class CarController(object): 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. diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index ec531d3db..a9530d65a 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -21,12 +21,6 @@ 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 @@ -34,6 +28,10 @@ class CanBus(object): 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 @@ -54,7 +52,7 @@ class CarInterface(object): # 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): @@ -73,8 +71,11 @@ class CarInterface(object): 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: From ff3df00e0f02279db09f2b05a4e03538b8bf9a1e Mon Sep 17 00:00:00 2001 From: Vasily Tarasov Date: Thu, 6 Sep 2018 20:01:53 -0700 Subject: [PATCH 5/7] GM: update readme, ACC is a required package (#354) ACC implies Driver Confidence II, but not the other way around. Openpilot requires front, long range radar that only comes with ACC package. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dec4d00ae..dd0b9aac1 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,8 @@ Supported Cars | Acura | ILX 2016 | AcuraWatch Plus | Yes | Yes | 25mph1| 25mph | | Acura | ILX 2017 | AcuraWatch Plus | Yes | Yes | 25mph1| 25mph | | Acura | RDX 2018 | AcuraWatch Plus | Yes | Yes | 25mph1| 12mph | -| GM3 | Volt 2017 | Driver Confidence II | Yes | Yes | 0mph | 7mph | -| GM3 | Volt 2018 | Driver Confidence II | Yes | Yes | 0mph | 7mph | +| GM3 | Volt 2017 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | +| GM3 | 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 | From f94419ccb09d8b88aa2bab3fc8745de2fe97ac26 Mon Sep 17 00:00:00 2001 From: zeeexsixare <32753720+zeeexsixare@users.noreply.github.com> Date: Thu, 6 Sep 2018 23:03:10 -0400 Subject: [PATCH 6/7] Tried native Stop and Go on Highlander ICE with no comma pedal: Works! (#353) * Trying to make Highlander ICE stop and go * Making acceleration slow for fuel efficiency * Removing annoying commanded disengage beep * Raised accel_max by 50% and commented on chime * Testing if Highlander ICE can resume follow from 0 * Returned to 1.5 m/s2 for testing stop and go * Prep for merging upstream * Prep for upstream merge item #2 * Added Highlander ICE/Hybrid to Stop and Go Also updated table of vehicles * Rollback advertising stop and go for Highlanders * Fix whitespace --- README.md | 2 +- selfdrive/car/toyota/interface.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dd0b9aac1..74b90eaaa 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Supported Cars | Toyota | C-HR 20184 | All | Yes | Stock | 0mph | 0mph | | Toyota | Corolla 2017 | All | Yes | Yes2| 20mph | 0mph | | Toyota | Corolla 2018 | All | Yes | Yes2| 20mph | 0mph | -| Toyota | Highlander 2017 | All | Yes | Yes2| 20mph | 0mph | +| Toyota | Highlander 2017 | All | Yes | Yes2| 0mph | 0mph | | Toyota | Highlander Hybrid 2018| All | Yes | Yes2| 0mph | 0mph | | Toyota | Prius 2016 | TSS-P | Yes | Yes2| 0mph | 0mph | | Toyota | Prius 2017 | All | Yes | Yes2| 0mph | 0mph | diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index a14cfb53a..cddd34d38 100755 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -147,9 +147,9 @@ class CarInterface(object): # to a negative value, so it won't matter. # hybrid models can't do stop and go even though the stock ACC can't if candidate in [CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.CHR, - CAR.CHRH, CAR.CAMRY, CAR.CAMRYH, CAR.HIGHLANDERH]: + CAR.CHRH, CAR.CAMRY, CAR.CAMRYH, CAR.HIGHLANDERH, CAR.HIGHLANDER]: ret.minEnableSpeed = -1. - elif candidate in [CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER]: # TODO: hack ICE to do stop and go + elif candidate in [CAR.RAV4, CAR.COROLLA]: # TODO: hack ICE to do stop and go ret.minEnableSpeed = 19. * CV.MPH_TO_MS centerToRear = ret.wheelbase - ret.centerToFront @@ -244,7 +244,7 @@ class CarInterface(object): ret.cruiseState.speed = self.CS.v_cruise_pcm * CV.KPH_TO_MS ret.cruiseState.available = bool(self.CS.main_on) ret.cruiseState.speedOffset = 0. - if self.CP.carFingerprint in [CAR.RAV4H, CAR.HIGHLANDERH]: + if self.CP.carFingerprint in [CAR.RAV4H, CAR.HIGHLANDERH, CAR.HIGHLANDER]: # ignore standstill in hybrid vehicles, since pcm allows to restart without # receiving any special command ret.cruiseState.standstill = False From 7abb07b402e4cac55e529186aae93bf40b43d834 Mon Sep 17 00:00:00 2001 From: rbiasini Date: Sat, 8 Sep 2018 06:19:48 +0200 Subject: [PATCH 7/7] fixed sign in after Google change (#357)