Skip to content

Commit

Permalink
Merge branch 'devel' of https://github.com/commaai/openpilot into dam…
Browse files Browse the repository at this point in the history
…pen-mpc-interp
  • Loading branch information
Gernby committed Mar 24, 2019
2 parents 463c80b + 27e0adc commit 16624bd
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 60 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -25,6 +25,7 @@ clcache

board/obj/
selfdrive/boardd/boardd
selfdrive/visiond/visiond
selfdrive/logcatd/logcatd
selfdrive/proclogd/proclogd
selfdrive/ui/ui
Expand Down
6 changes: 4 additions & 2 deletions README.md
@@ -1,4 +1,4 @@
[![](https://i.imgur.com/UetIFyH.jpg)](#)
[![](https://i.imgur.com/xY2gdHv.png)](#)

Welcome to openpilot
======
Expand Down Expand Up @@ -66,7 +66,8 @@ Supported Cars
| Chevrolet<sup>3</sup>| Malibu 2017 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom<sup>7</sup>|
| Chevrolet<sup>3</sup>| Volt 2017-18 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom<sup>7</sup>|
| Cadillac<sup>3</sup> | ATS 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom<sup>7</sup>|
| Chrysler | Pacifica Hybrid 2017 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | FCA |
| Chrysler | Pacifica 2018 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | FCA |
| Chrysler | Pacifica Hybrid 2017-18 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | FCA |
| GMC<sup>3</sup> | Acadia Denali 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom<sup>7</sup>|
| Holden<sup>3</sup> | Astra 2017 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom<sup>7</sup>|
| Honda | Accord 2018 | All | Yes | Stock | 0mph | 3mph | Bosch |
Expand All @@ -82,6 +83,7 @@ Supported Cars
| Hyundai | Santa Fe 2019 | All | Yes | Stock | 0mph | 0mph | Custom<sup>6</sup>|
| Hyundai | Elantra 2017 | SCC + LKAS | Yes | Stock | 19mph | 34mph | Custom<sup>6</sup>|
| Hyundai | Genesis 2018 | All | Yes | Stock | 19mph | 34mph | Custom<sup>6</sup>|
| Jeep | Grand Cherokee 2017-19 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | FCA |
| Kia | Optima 2019 | SCC + LKAS | Yes | Stock | 0mph | 0mph | Custom<sup>6</sup>|
| Kia | Sorento 2018 | All | Yes | Stock | 0mph | 0mph | Custom<sup>6</sup>|
| Kia | Stinger 2018 | SCC + LKAS | Yes | Stock | 0mph | 0mph | Custom<sup>6</sup>|
Expand Down
1 change: 1 addition & 0 deletions RELEASES.md
Expand Up @@ -8,6 +8,7 @@ Version 0.5.9 (2019-02-10)
* Kia Optima support thanks to emmertex!
* Buick Regal 2018 support thanks to HOYS!
* Comma pedal support for Toyota thanks to wocsor! Note: tuning needed and not maintained by comma
* Chrysler Pacifica and Jeep Grand Cherokee suppor thanks to adhintz!

Version 0.5.8 (2019-01-17)
========================
Expand Down
1 change: 1 addition & 0 deletions opendbc/chrysler_pacifica_2017_hybrid.dbc
Expand Up @@ -122,6 +122,7 @@ BO_ 678 LKAS_HUD: 8 XXX
SG_ LKAS_ICON_COLOR : 1|2@0+ (1,0) [0|3] "" XXX
SG_ LKAS_LANE_LINES : 19|4@0+ (1,0) [0|1] "" XXX
SG_ LKAS_ALERTS : 27|4@0+ (1,0) [0|1] "" XXX
SG_ CAR_MODEL : 15|8@0+ (1,0) [0|255] "" XXX

BO_ 705 AUTO_PARK_BUTTON: 8 XXX
SG_ AUTO_PARK_TOGGLE_2 : 8|1@0+ (1,0) [0|1] "" XXX
Expand Down
7 changes: 5 additions & 2 deletions selfdrive/car/chrysler/carcontroller.py
Expand Up @@ -25,6 +25,7 @@ def __init__(self, dbc_name, car_fingerprint, enable_camera):
self.apply_steer_last = 0
self.ccframe = 0
self.prev_frame = -1
self.hud_count = 0
self.car_fingerprint = car_fingerprint
self.alert_active = False
self.send_chime = False
Expand All @@ -39,7 +40,7 @@ def __init__(self, dbc_name, car_fingerprint, enable_camera):
def update(self, sendcan, enabled, CS, frame, actuators,
pcm_cancel_cmd, hud_alert, audible_alert):

# this seems needed to avoid steerign faults and to force the sync with the EPS counter
# this seems needed to avoid steering faults and to force the sync with the EPS counter
if self.prev_frame == frame:
return

Expand Down Expand Up @@ -81,8 +82,10 @@ def update(self, sendcan, enabled, CS, frame, actuators,
can_sends.append(new_msg)

if (self.ccframe % 25 == 0): # 0.25s period
new_msg = create_lkas_hud(CS.gear_shifter, lkas_active, hud_alert, self.car_fingerprint)
new_msg = create_lkas_hud(self.packer, CS.gear_shifter, lkas_active, hud_alert, self.car_fingerprint,
self.hud_count)
can_sends.append(new_msg)
self.hud_count += 1

new_msg = create_lkas_command(self.packer, int(apply_steer), frame)
can_sends.append(new_msg)
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/car/chrysler/carstate.py
Expand Up @@ -13,6 +13,8 @@ def parse_gear_shifter(can_gear):
return "neutral"
elif can_gear == 0x4:
return "drive"
elif can_gear == 0x5:
return "low"
return "unknown"


Expand Down
62 changes: 35 additions & 27 deletions selfdrive/car/chrysler/chryslercan.py
Expand Up @@ -5,6 +5,13 @@
VisualAlert = car.CarControl.HUDControl.VisualAlert
AudibleAlert = car.CarControl.HUDControl.AudibleAlert

MODEL_TO_CONSTANT = {
CAR.PACIFICA_2017_HYBRID: 0,
CAR.PACIFICA_2018: 0x64,
CAR.PACIFICA_2018_HYBRID: 0xa8,
CAR.PACIFICA_2019_HYBRID: 0x68,
CAR.JEEP_CHEROKEE: 0xa4,
}

def calc_checksum(data):
"""This function does not want the checksum byte in the input data.
Expand Down Expand Up @@ -51,40 +58,41 @@ def create_lkas_heartbit(car_fingerprint):
msg = '0000000820'.decode('hex') # 2017
return make_can_msg(0x2d9, msg)

def create_lkas_hud(gear, lkas_active, hud_alert, car_fingerprint):
# LKAS_HUD (678) Controls what lane-keeping icon is displayed.
def create_lkas_hud(packer, gear, lkas_active, hud_alert, car_fingerprint, hud_count):
# LKAS_HUD 0x2a6 (678) Controls what lane-keeping icon is displayed.

if hud_alert == VisualAlert.steerRequired:
msg = '0000000300000000'.decode('hex')
return make_can_msg(0x2a6, msg)

# TODO: use can packer
msg = '0000000000000000'.decode('hex') # park or neutral
if car_fingerprint == CAR.PACIFICA_2018:
msg = '0064000000000000'.decode('hex') # Have not verified 2018 park with a real car.
elif car_fingerprint == CAR.JEEP_CHEROKEE:
msg = '00a4000000000000'.decode('hex') # Have not verified 2018 park with a real car.
elif car_fingerprint == CAR.PACIFICA_2018_HYBRID:
msg = '01a8010000000000'.decode('hex')
if (gear == 'drive' or gear == 'reverse'):
color = 0 # default values are for park or neutral
lines = 0
alerts = 0

if hud_count < (3 *4): # first 3 seconds, 4Hz
lines = 1
alerts = 1
elif hud_count < (6 * 4): # next 3 seconds, 4Hz
lines = 1
alerts = 0
# CAR.PACIFICA_2018_HYBRID and CAR.PACIFICA_2019_HYBRID
# had color = 1 and lines = 1 but trying 2017 hybrid style for now.
if gear in ('drive', 'reverse', 'low'):
if lkas_active:
msg = '0200060000000000'.decode('hex') # control active, display green.
if car_fingerprint == CAR.PACIFICA_2018:
msg = '0264060000000000'.decode('hex')
elif car_fingerprint == CAR.JEEP_CHEROKEE:
msg = '02a4060000000000'.decode('hex')
elif car_fingerprint == CAR.PACIFICA_2018_HYBRID:
msg = '02a8060000000000'.decode('hex')
color = 2 # control active, display green.
lines = 6
else:
msg = '0100010000000000'.decode('hex') # control off, display white.
if car_fingerprint == CAR.PACIFICA_2018:
msg = '0164010000000000'.decode('hex')
elif car_fingerprint == CAR.JEEP_CHEROKEE:
msg = '01a4010000000000'.decode('hex')
elif car_fingerprint == CAR.PACIFICA_2018_HYBRID:
msg = '01a8010000000000'.decode('hex')

return make_can_msg(0x2a6, msg)
color = 1 # control off, display white.
lines = 1

values = {
"LKAS_ICON_COLOR": color, # byte 0, last 2 bits
"CAR_MODEL": MODEL_TO_CONSTANT[car_fingerprint], # byte 1
"LKAS_LANE_LINES": lines, # byte 2, last 4 bits
"LKAS_ALERTS": alerts, # byte 3, last 4 bits
}

return packer.make_can_msg("LKAS_HUD", 0, values) # 0x2a6


def create_lkas_command(packer, apply_steer, frame):
Expand Down
48 changes: 48 additions & 0 deletions selfdrive/car/chrysler/chryslercan_test.py
@@ -0,0 +1,48 @@
import chryslercan
from values import CAR
from carcontroller import CarController
from selfdrive.can.packer import CANPacker

from cereal import car
VisualAlert = car.CarControl.HUDControl.VisualAlert
AudibleAlert = car.CarControl.HUDControl.AudibleAlert

import unittest


class TestChryslerCan(unittest.TestCase):

def test_checksum(self):
self.assertEqual(0x75, chryslercan.calc_checksum([0x01, 0x20]))
self.assertEqual(0xcc, chryslercan.calc_checksum([0x14, 0, 0, 0, 0x20]))

def test_heartbit(self):
self.assertEqual(
[0x2d9, 0, '0000000820'.decode('hex'), 0],
chryslercan.create_lkas_heartbit(CAR.PACIFICA_2017_HYBRID))

def test_hud(self):
packer = CANPacker('chrysler_pacifica_2017_hybrid')
self.assertEqual(
[0x2a6, 0, '0000010100000000'.decode('hex'), 0],
chryslercan.create_lkas_hud(packer,
'park', False, False, CAR.PACIFICA_2017_HYBRID, 1))
self.assertEqual(
[0x2a6, 0, '0000010000000000'.decode('hex'), 0],
chryslercan.create_lkas_hud(packer,
'park', False, False, CAR.PACIFICA_2017_HYBRID, 5*4))
self.assertEqual(
[0x2a6, 0, '0000000000000000'.decode('hex'), 0],
chryslercan.create_lkas_hud(packer,
'park', False, False, CAR.PACIFICA_2017_HYBRID, 99999))
self.assertEqual(
[0x2a6, 0, '0200060000000000'.decode('hex'), 0],
chryslercan.create_lkas_hud(packer,
'drive', True, False, CAR.PACIFICA_2017_HYBRID, 99999))
self.assertEqual(
[0x2a6, 0, '0264060000000000'.decode('hex'), 0],
chryslercan.create_lkas_hud(packer,
'drive', True, False, CAR.PACIFICA_2018, 99999))

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion selfdrive/car/chrysler/interface.py
Expand Up @@ -220,7 +220,7 @@ def update(self, c):
events.append(create_event('commIssue', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
else:
self.can_invalid_count = 0
if not ret.gearShifter == 'drive':
if not (ret.gearShifter in ('drive', 'low')):
events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if ret.doorOpen:
events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
Expand Down
1 change: 1 addition & 0 deletions selfdrive/car/chrysler/run_tests.sh
@@ -0,0 +1 @@
PYTHONPATH=`realpath ../../../` python chryslercan_test.py

0 comments on commit 16624bd

Please sign in to comment.