Skip to content

Commit

Permalink
openpilot v0.5.6 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Vehicle Researcher committed Nov 17, 2018
1 parent 92c5965 commit 860a487
Show file tree
Hide file tree
Showing 55 changed files with 1,661 additions and 1,087 deletions.
131 changes: 70 additions & 61 deletions README.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Version 0.5.6 (2018-11-16)
========================
* Refresh settings layout and add feature descriptions
* In Honda, keep stock camera on for logging and extra stock features; new openpilot giraffe setting is 0111!
* In Toyota, option to keep stock camera on for logging and extra stock features (e.g. AHB); 120Ohm resistor required on giraffe.
* Improve camera calibration stability
* More tuning to Honda positive accelerations
* Reduce brake pump use on Hondas
* Chevrolet Malibu support thanks to tylergets!

Version 0.5.5 (2018-10-20)
========================
* Increase allowed Honda positive accelerations
Expand Down
Binary file modified apk/ai.comma.plus.frame.apk
Binary file not shown.
Binary file modified apk/ai.comma.plus.offroad.apk
Binary file not shown.
15 changes: 8 additions & 7 deletions cereal/car.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct CarEvent @0x9b1657f34caf3ad3 {
belowSteerSpeed @46;
calibrationProgress @47;
lowBattery @48;
invalidGiraffeHonda @49;
}
}

Expand Down Expand Up @@ -260,13 +261,13 @@ struct CarControl {
# these are the choices from the Honda
# map as good as you can for your car
none @0;
beepSingle @1;
beepTriple @2;
beepRepeated @3;
chimeSingle @4;
chimeDouble @5;
chimeRepeated @6;
chimeContinuous @7;
chimeEngage @1;
chimeDisengage @2;
chimeError @3;
chimeWarning1 @4;
chimeWarning2 @5;
chimeWarningRepeat @6;
chimePrompt @7;
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions cereal/log.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ struct Live100Data {
alertSize @39 :AlertSize;
alertBlinkingRate @42 :Float32;
alertType @44 :Text;
alertSound @45 :Text;
awarenessStatus @26 :Float32;
angleOffset @27 :Float32;
gpsPlannerActive @40 :Bool;
Expand Down Expand Up @@ -1565,6 +1566,11 @@ struct LiveParametersData {
angleOffset @2 :Float32;
}

struct LiveMapData {
valid @0 :Bool;
speedLimit @1 :Float32;
}


struct Event {
# in nanoseconds?
Expand Down Expand Up @@ -1632,5 +1638,6 @@ struct Event {
driverMonitoring @59 :DriverMonitoring;
boot @60 :Boot;
liveParameters @61 :LiveParametersData;
liveMapData @62 :LiveMapData;
}
}
Binary file added selfdrive/assets/sounds/disengaged.wav
Binary file not shown.
Binary file added selfdrive/assets/sounds/engaged.wav
Binary file not shown.
Binary file added selfdrive/assets/sounds/error.wav
Binary file not shown.
Binary file removed selfdrive/assets/sounds/hq_disengaged.mp3
Binary file not shown.
Binary file removed selfdrive/assets/sounds/hq_engaged.mp3
Binary file not shown.
Binary file removed selfdrive/assets/sounds/hq_warning_0.mp3
Binary file not shown.
Binary file removed selfdrive/assets/sounds/hq_warning_1.mp3
Binary file not shown.
Binary file removed selfdrive/assets/sounds/hq_warning_2.mp3
Binary file not shown.
Binary file added selfdrive/assets/sounds/warning_1.wav
Binary file not shown.
Binary file added selfdrive/assets/sounds/warning_2.wav
Binary file not shown.
6 changes: 4 additions & 2 deletions selfdrive/boardd/boardd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env python

# TODO: merge the extra functionalities of this file (like MOCK) in boardd.c and
# delete this python version of boardd

import os
import struct
import zmq
Expand All @@ -16,8 +20,6 @@
except Exception:
pass

# TODO: rewrite in C to save CPU

SAFETY_NOOUTPUT = 0
SAFETY_HONDA = 1
SAFETY_TOYOTA = 2
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/car/gm/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class CarControllerParams():
def __init__(self, car_fingerprint):
if car_fingerprint == CAR.VOLT:
if car_fingerprint in (CAR.VOLT, CAR.MALIBU):
self.STEER_MAX = 300
self.STEER_STEP = 2 # how often we update the steer cmd
self.STEER_DELTA_UP = 7 # ~0.75s time to peak torque (255/50hz/0.75s)
Expand Down Expand Up @@ -104,7 +104,7 @@ def update(self, sendcan, enabled, CS, frame, actuators, \
self.apply_steer_last = apply_steer
idx = (frame / P.STEER_STEP) % 4

if self.car_fingerprint == CAR.VOLT:
if self.car_fingerprint in (CAR.VOLT, CAR.MALIBU):
can_sends.append(gmcan.create_steering_control(self.packer_pt,
canbus.powertrain, apply_steer, idx, lkas_enabled))
if self.car_fingerprint == CAR.CADILLAC_CT6:
Expand All @@ -113,7 +113,7 @@ def update(self, sendcan, enabled, CS, frame, actuators, \

### GAS/BRAKE ###

if self.car_fingerprint == CAR.VOLT:
if self.car_fingerprint in (CAR.VOLT, CAR.MALIBU):
# no output if not enabled, but keep sending keepalive messages
# treat pedals as one
final_pedal = actuators.gas - actuators.brake
Expand Down
7 changes: 3 additions & 4 deletions selfdrive/car/gm/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def get_powertrain_can_parser(CP, canbus):
("LKATorqueDeliveredStatus", "PSCMStatus", 0),
]

if CP.carFingerprint == CAR.VOLT:
if CP.carFingerprint in (CAR.VOLT, CAR.MALIBU):
signals += [
("RegenPaddle", "EBCMRegenPaddle", 0),
("TractionControlOn", "ESPStatus", 0),
Expand Down Expand Up @@ -117,14 +117,14 @@ def update(self, pt_cp):
self.left_blinker_on = pt_cp.vl["BCMTurnSignals"]['TurnSignals'] == 1
self.right_blinker_on = pt_cp.vl["BCMTurnSignals"]['TurnSignals'] == 2

if self.car_fingerprint == CAR.VOLT:
if self.car_fingerprint in (CAR.VOLT, CAR.MALIBU):
self.park_brake = pt_cp.vl["EPBStatus"]['EPBClosed']
self.main_on = pt_cp.vl["ECMEngineStatus"]['CruiseMainOn']
self.acc_active = False
self.esp_disabled = pt_cp.vl["ESPStatus"]['TractionControlOn'] != 1
self.regen_pressed = bool(pt_cp.vl["EBCMRegenPaddle"]['RegenPaddle'])
self.pcm_acc_status = pt_cp.vl["AcceleratorPedal2"]['CruiseState']
else:
else:
self.park_brake = False
self.main_on = False
self.acc_active = pt_cp.vl["ASCMActiveCruiseControlStatus"]['ACCCmdActive']
Expand All @@ -141,4 +141,3 @@ def update(self, pt_cp):
self.brake_pressed = self.user_brake > 10 or self.regen_pressed

self.gear_shifter_valid = self.gear_shifter == car.CarState.GearShifter.drive

24 changes: 13 additions & 11 deletions selfdrive/car/gm/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from selfdrive.config import Conversions as CV
from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET
from selfdrive.controls.lib.vehicle_model import VehicleModel
from selfdrive.car.gm.values import DBC, CAR, STOCK_CONTROL_MSGS
from selfdrive.car.gm.values import DBC, CAR, STOCK_CONTROL_MSGS, AUDIO_HUD
from selfdrive.car.gm.carstate import CarState, CruiseButtons, get_powertrain_can_parser

try:
Expand Down Expand Up @@ -85,6 +85,16 @@ def get_params(candidate, fingerprint):
ret.steerRatioRear = 0.
ret.centerToFront = ret.wheelbase * 0.4 # wild guess

elif candidate == CAR.MALIBU:
# supports stop and go, but initial engage must be above 18mph (which include conservatism)
ret.minEnableSpeed = 18 * CV.MPH_TO_MS
ret.mass = 1496 + std_cargo
ret.safetyModel = car.CarParams.SafetyModels.gm
ret.wheelbase = 2.83
ret.steerRatio = 15.8
ret.steerRatioRear = 0.
ret.centerToFront = ret.wheelbase * 0.4 # wild guess

elif candidate == CAR.CADILLAC_CT6:
# engage speed is decided by pcm
ret.minEnableSpeed = -1
Expand Down Expand Up @@ -254,7 +264,7 @@ def update(self, c):
if ret.seatbeltUnlatched:
events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE]))

if self.CS.car_fingerprint == CAR.VOLT:
if self.CS.car_fingerprint in (CAR.VOLT, CAR.MALIBU):

if self.CS.brake_error:
events.append(create_event('brakeUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
Expand Down Expand Up @@ -312,15 +322,7 @@ def apply(self, c, perception_state=log.Live20Data.new_message()):
if hud_v_cruise > 70:
hud_v_cruise = 0

chime, chime_count = {
"none": (0, 0),
"beepSingle": (CM.HIGH_CHIME, 1),
"beepTriple": (CM.HIGH_CHIME, 3),
"beepRepeated": (CM.LOW_CHIME, -1),
"chimeSingle": (CM.LOW_CHIME, 1),
"chimeDouble": (CM.LOW_CHIME, 2),
"chimeRepeated": (CM.LOW_CHIME, -1),
"chimeContinuous": (CM.LOW_CHIME, -1)}[str(c.hudControl.audibleAlert)]
chime, chime_count = AUDIO_HUD[c.hudControl.audibleAlert.raw]

# For Openpilot, "enabled" includes pre-enable.
# In GM, PCM faults out if ACC command overlaps user gas.
Expand Down
4 changes: 1 addition & 3 deletions selfdrive/car/gm/radar_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
def create_radard_can_parser(canbus, car_fingerprint):

dbc_f = DBC[car_fingerprint]['radar']
if car_fingerprint == CAR.VOLT:
if car_fingerprint in (CAR.VOLT, CAR.MALIBU):
# C1A-ARS3-A by Continental
radar_targets = range(SLOT_1_MSG, SLOT_1_MSG + NUM_SLOTS)
signals = zip(['FLRRNumValidTargets',
Expand Down Expand Up @@ -125,5 +125,3 @@ def update(self):
ret = RI.update()
print(chr(27) + "[2J")
print ret


31 changes: 30 additions & 1 deletion selfdrive/car/gm/values.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from cereal import car
from selfdrive.car import dbc_dict

AudibleAlert = car.CarControl.HUDControl.AudibleAlert

class CAR:
VOLT = "CHEVROLET VOLT PREMIER 2017"
CADILLAC_CT6 = "CADILLAC CT6 SUPERCRUISE 2018"
MALIBU = "CHEVROLET MALIBU PREMIER 2017"

class CruiseButtons:
UNPRESS = 1
Expand All @@ -12,9 +15,28 @@ class CruiseButtons:
MAIN = 5
CANCEL = 6

# Car chimes, beeps, blinker sounds etc
class CM:
TOCK = 0x81
TICK = 0x82
LOW_BEEP = 0x84
HIGH_BEEP = 0x85
LOW_CHIME = 0x86
HIGH_CHIME = 0x87

AUDIO_HUD = {
AudibleAlert.none: (0, 0),
AudibleAlert.chimeEngage: (CM.HIGH_CHIME, 1),
AudibleAlert.chimeDisengage: (CM.HIGH_CHIME, 1),
AudibleAlert.chimeError: (CM.LOW_CHIME, 2),
AudibleAlert.chimePrompt: (CM.LOW_CHIME, 1),
AudibleAlert.chimeWarning1: (CM.LOW_CHIME, 2),
AudibleAlert.chimeWarning2: (CM.LOW_CHIME, -1),
AudibleAlert.chimeWarningRepeat: (CM.LOW_CHIME, -1)}

def is_eps_status_ok(eps_status, car_fingerprint):
valid_eps_status = []
if car_fingerprint == CAR.VOLT:
if car_fingerprint in (CAR.VOLT, CAR.MALIBU):
valid_eps_status += [0, 1]
elif car_fingerprint == CAR.CADILLAC_CT6:
valid_eps_status += [0, 1, 4, 5, 6]
Expand Down Expand Up @@ -45,16 +67,23 @@ def parse_gear_shifter(can_gear):
CAR.CADILLAC_CT6: [{
190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 298: 8, 304: 1, 309: 8, 313: 8, 320: 3, 322: 7, 328: 1, 336: 1, 338: 6, 340: 6, 352: 5, 354: 5, 356: 8, 368: 3, 372: 5, 381: 8, 386: 8, 393: 7, 398: 8, 407: 7, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 455: 7, 456: 8, 458: 5, 460: 5, 462: 4, 463: 3, 479: 3, 481: 7, 485: 8, 487: 8, 489: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 528: 5, 532: 6, 534: 2, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 567: 5, 569: 3, 573: 1, 577: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 715: 8, 717: 5, 719: 5, 723: 2, 753: 5, 761: 7, 800: 6, 801: 8, 804: 3, 810: 8, 832: 8, 833: 8, 834: 8, 835: 6, 836: 5, 837: 8, 838: 8, 839: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 884: 8, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1011: 6, 1013: 1, 1017: 8, 1019: 2, 1020: 8, 1105: 6, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1233: 8, 1249: 8, 1257: 6, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 1, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1417: 8, 1601: 8, 1906: 7, 1907: 7, 1912: 7, 1914: 7, 1918: 7, 1919: 7, 1934: 7, 2016: 8, 2024: 8
}],
CAR.MALIBU: [
# Malibu Premier w/ ACC 2017
{
190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 328: 1, 352: 5, 381: 6, 384: 4, 386: 8, 388: 8, 393: 7, 398: 8, 407: 7, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 455: 7, 456: 8, 479: 3, 481: 7, 485: 8, 487: 8, 489: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 528: 5, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 567: 5, 573: 1, 577: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 715: 8, 717: 5, 753: 5, 761: 7, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1223: 2, 1225: 7, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1417: 8, 1601: 8, 1906: 7, 1907: 7, 1912: 7, 1919: 7, 1930: 7, 2016: 8, 2024: 8,
}],
}

STEER_THRESHOLD = 1.0

STOCK_CONTROL_MSGS = {
CAR.VOLT: [384, 715], # 384 = "ASCMLKASteeringCmd", 715 = "ASCMGasRegenCmd"
CAR.MALIBU: [384, 715], # 384 = "ASCMLKASteeringCmd", 715 = "ASCMGasRegenCmd"
CAR.CADILLAC_CT6: [], # Cadillac does not require ASCMs to be disconnected
}

DBC = {
CAR.VOLT: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'),
CAR.MALIBU: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'),
CAR.CADILLAC_CT6: dbc_dict('cadillac_ct6_powertrain', 'cadillac_ct6_object', chassis_dbc='cadillac_ct6_chassis'),
}
52 changes: 30 additions & 22 deletions selfdrive/car/honda/carcontroller.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from cereal import car
from collections import namedtuple
from common.realtime import sec_since_boot
from selfdrive.boardd.boardd import can_list_to_can_capnp
from selfdrive.controls.lib.drive_helpers import rate_limit
from common.numpy_fast import clip
Expand All @@ -8,7 +8,7 @@
from selfdrive.can.packer import CANPacker

def actuator_hystereses(brake, braking, brake_steady, v_ego, car_fingerprint):
# hyst params... TODO: move these to VehicleParams
# hyst params
brake_hyst_on = 0.02 # to activate brakes exceed this value
brake_hyst_off = 0.005 # to deactivate brakes below this value
brake_hyst_gap = 0.01 # don't change brake command for small ocilalitons within this value
Expand All @@ -33,6 +33,24 @@ def actuator_hystereses(brake, braking, brake_steady, v_ego, car_fingerprint):
return brake, braking, brake_steady


def brake_pump_hysteresys(apply_brake, apply_brake_last, last_pump_ts):
ts = sec_since_boot()
pump_on = False

# reset pump timer if:
# - there is an increment in brake request
# - we are applying steady state brakes and we haven't been running the pump
# for more than 20s (to prevent pressure bleeding)
if apply_brake > apply_brake_last or (ts - last_pump_ts > 20 and apply_brake > 0):
last_pump_ts = ts

# once the pump is on, run it for at least 0.2s
if ts - last_pump_ts < 0.2 and apply_brake > 0:
pump_on = True

return pump_on, last_pump_ts


def process_hud_alert(hud_alert):
# initialize to no alert
fcw_display = 0
Expand Down Expand Up @@ -60,6 +78,8 @@ def __init__(self, dbc_name, enable_camera=True):
self.braking = False
self.brake_steady = 0.
self.brake_last = 0.
self.apply_brake_last = 0
self.last_pump_ts = 0
self.enable_camera = enable_camera
self.packer = CANPacker(dbc_name)
self.new_radar_config = False
Expand Down Expand Up @@ -109,9 +129,6 @@ def update(self, sendcan, enabled, CS, frame, actuators, \
hud = HUDData(int(pcm_accel), int(round(hud_v_cruise)), 1, hud_car,
0xc1, hud_lanes, int(snd_beep), snd_chime, fcw_display, acc_alert, steer_required)

if not all(isinstance(x, int) and 0 <= x < 256 for x in hud):
hud = HUDData(0xc6, 255, 64, 0xc0, 209, 0x40, 0, 0, 0, 0)

# **** process the car messages ****

# *** compute control surfaces ***
Expand All @@ -128,15 +145,15 @@ def update(self, sendcan, enabled, CS, frame, actuators, \
apply_brake = int(clip(self.brake_last * BRAKE_MAX, 0, BRAKE_MAX - 1))
apply_steer = int(clip(-actuators.steer * STEER_MAX, -STEER_MAX, STEER_MAX))

# any other cp.vl[0x18F]['STEER_STATUS'] is common and can happen during user override. sending 0 torque to avoid EPS sending error 5
lkas_active = enabled and not CS.steer_not_allowed

# Send CAN commands.
can_sends = []

# Send steering command.
idx = frame % 4
can_sends.append(hondacan.create_steering_control(self.packer, apply_steer, lkas_active, CS.CP.carFingerprint, idx))
can_sends.append(hondacan.create_steering_control(self.packer, apply_steer,
lkas_active, CS.CP.carFingerprint, idx))

# Send dashboard UI commands.
if (frame % 10) == 0:
Expand All @@ -149,28 +166,19 @@ def update(self, sendcan, enabled, CS, frame, actuators, \
can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.CANCEL, idx))
elif CS.stopped:
can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.RES_ACCEL, idx))

else:
# Send gas and brake commands.
if (frame % 2) == 0:
idx = (frame / 2) % 4
can_sends.append(
hondacan.create_brake_command(self.packer, apply_brake, pcm_override,
pcm_cancel_cmd, hud.chime, hud.fcw, idx))
pump_on, self.last_pump_ts = brake_pump_hysteresys(apply_brake, self.apply_brake_last, self.last_pump_ts)
can_sends.append(hondacan.create_brake_command(self.packer, apply_brake, pump_on,
pcm_override, pcm_cancel_cmd, hud.chime, hud.fcw, idx))
self.apply_brake_last = apply_brake

if CS.CP.enableGasInterceptor:
# send exactly zero if apply_gas is zero. Interceptor will send the max between read value and apply_gas.
# This prevents unexpected pedal range rescaling
can_sends.append(hondacan.create_gas_command(self.packer, apply_gas, idx))

# radar at 20Hz, but these msgs need to be sent at 50Hz on ilx (seems like an Acura bug)
if CS.CP.carFingerprint == CAR.ACURA_ILX:
radar_send_step = 2
else:
radar_send_step = 5

if (frame % radar_send_step) == 0:
idx = (frame/radar_send_step) % 4
if not self.new_radar_config: # only change state once
self.new_radar_config = car.RadarState.Error.wrongConfig in radar_error
can_sends.extend(hondacan.create_radar_commands(CS.v_ego, CS.CP.carFingerprint, self.new_radar_config, idx))

sendcan.send(can_list_to_can_capnp(can_sends, msgtype='sendcan').to_bytes())
Loading

0 comments on commit 860a487

Please sign in to comment.