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

merge devel #13

Merged
merged 6 commits into from
Dec 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Supported Cars
| Acura | RDX 2018 | AcuraWatch Plus | Yes | Yes | 25mph<sup>1</sup>| 12mph | Nidec |
| 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>|
| 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 |
| Honda | Civic 2016-18 | Honda Sensing | Yes | Yes | 0mph | 12mph | Nidec |
| Honda | Civic 2017-18 *(Hatch)* | Honda Sensing | Yes | Stock | 0mph | 12mph | Bosch |
Expand Down
1 change: 1 addition & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Version 0.5.6 (2018-11-16)
* More tuning to Honda positive accelerations
* Reduce brake pump use on Hondas
* Chevrolet Malibu support thanks to tylergets!
* Holden Astra support thanks to AlexHill!

Version 0.5.5 (2018-10-20)
========================
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 in (CAR.VOLT, CAR.MALIBU):
if car_fingerprint in (CAR.VOLT, CAR.MALIBU, CAR.HOLDEN_ASTRA):
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 in (CAR.VOLT, CAR.MALIBU):
if self.car_fingerprint in (CAR.VOLT, CAR.MALIBU, CAR.HOLDEN_ASTRA):
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 in (CAR.VOLT, CAR.MALIBU):
if self.car_fingerprint in (CAR.VOLT, CAR.MALIBU, CAR.HOLDEN_ASTRA):
# no output if not enabled, but keep sending keepalive messages
# treat pedals as one
final_pedal = actuators.gas - actuators.brake
Expand Down
14 changes: 10 additions & 4 deletions selfdrive/car/gm/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ def get_powertrain_can_parser(CP, canbus):
if CP.carFingerprint in (CAR.VOLT, CAR.MALIBU):
signals += [
("RegenPaddle", "EBCMRegenPaddle", 0),
]
if CP.carFingerprint in (CAR.VOLT, CAR.MALIBU, CAR.HOLDEN_ASTRA):
signals += [
("TractionControlOn", "ESPStatus", 0),
("EPBClosed", "EPBStatus", 0),
("CruiseMainOn", "ECMEngineStatus", 0),
("CruiseState", "AcceleratorPedal2", 0),
]
elif CP.carFingerprint == CAR.CADILLAC_CT6:
if CP.carFingerprint == CAR.CADILLAC_CT6:
signals += [
("ACCCmdActive", "ASCMActiveCruiseControlStatus", 0)
]
Expand Down Expand Up @@ -117,14 +120,17 @@ 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 in (CAR.VOLT, CAR.MALIBU):
if self.car_fingerprint in (CAR.VOLT, CAR.MALIBU, CAR.HOLDEN_ASTRA):
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:
if self.car_fingerprint in (CAR.VOLT, CAR.MALIBU):
self.regen_pressed = bool(pt_cp.vl["EBCMRegenPaddle"]['RegenPaddle'])
else:
self.regen_pressed = False
if self.car_fingerprint == CAR.CADILLAC_CT6:
self.park_brake = False
self.main_on = False
self.acc_active = pt_cp.vl["ASCMActiveCruiseControlStatus"]['ACCCmdActive']
Expand Down
27 changes: 14 additions & 13 deletions selfdrive/car/gm/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
except ImportError:
CarController = None

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

class CanBus(object):
def __init__(self):
self.powertrain = 0
Expand Down Expand Up @@ -77,7 +68,7 @@ def get_params(candidate, fingerprint):
if candidate == CAR.VOLT:
# supports stop and go, but initial engage must be above 18mph (which include conservatism)
ret.minEnableSpeed = 18 * CV.MPH_TO_MS
# kg of standard extra cargo to count for drive, gas, etc...
# kg of standard extra cargo to count for driver, gas, etc...
ret.mass = 1607 + std_cargo
ret.safetyModel = car.CarParams.SafetyModels.gm
ret.wheelbase = 2.69
Expand All @@ -95,10 +86,21 @@ def get_params(candidate, fingerprint):
ret.steerRatioRear = 0.
ret.centerToFront = ret.wheelbase * 0.4 # wild guess

elif candidate == CAR.HOLDEN_ASTRA:
# kg of standard extra cargo to count for driver, gas, etc...
ret.mass = 1363 + std_cargo
ret.wheelbase = 2.662
# Remaining parameters copied from Volt for now
ret.centerToFront = ret.wheelbase * 0.4
ret.minEnableSpeed = 18 * CV.MPH_TO_MS
ret.safetyModel = car.CarParams.SafetyModels.gm
ret.steerRatio = 15.7
ret.steerRatioRear = 0.

elif candidate == CAR.CADILLAC_CT6:
# engage speed is decided by pcm
ret.minEnableSpeed = -1
# kg of standard extra cargo to count for drive, gas, etc...
# kg of standard extra cargo to count for driver, gas, etc...
ret.mass = 4016. * CV.LB_TO_KG + std_cargo
ret.safetyModel = car.CarParams.SafetyModels.cadillac
ret.wheelbase = 3.11
Expand Down Expand Up @@ -264,8 +266,7 @@ def update(self, c):
if ret.seatbeltUnlatched:
events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE]))

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

if self.CS.car_fingerprint in (CAR.VOLT, CAR.MALIBU, CAR.HOLDEN_ASTRA):
if self.CS.brake_error:
events.append(create_event('brakeUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
if not self.CS.gear_shifter_valid:
Expand Down
2 changes: 1 addition & 1 deletion 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 in (CAR.VOLT, CAR.MALIBU):
if car_fingerprint in (CAR.VOLT, CAR.MALIBU, CAR.HOLDEN_ASTRA):
# C1A-ARS3-A by Continental
radar_targets = range(SLOT_1_MSG, SLOT_1_MSG + NUM_SLOTS)
signals = zip(['FLRRNumValidTargets',
Expand Down
9 changes: 8 additions & 1 deletion selfdrive/car/gm/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
AudibleAlert = car.CarControl.HUDControl.AudibleAlert

class CAR:
HOLDEN_ASTRA = "HOLDEN ASTRA RS-V BK 2017"
VOLT = "CHEVROLET VOLT PREMIER 2017"
CADILLAC_CT6 = "CADILLAC CT6 SUPERCRUISE 2018"
MALIBU = "CHEVROLET MALIBU PREMIER 2017"
Expand Down Expand Up @@ -36,7 +37,7 @@ class CM:

def is_eps_status_ok(eps_status, car_fingerprint):
valid_eps_status = []
if car_fingerprint in (CAR.VOLT, CAR.MALIBU):
if car_fingerprint in (CAR.VOLT, CAR.MALIBU, CAR.HOLDEN_ASTRA):
valid_eps_status += [0, 1]
elif car_fingerprint == CAR.CADILLAC_CT6:
valid_eps_status += [0, 1, 4, 5, 6]
Expand All @@ -55,6 +56,10 @@ def parse_gear_shifter(can_gear):
return car.CarState.GearShifter.unknown

FINGERPRINTS = {
# Astra BK MY17, ASCM unplugged
CAR.HOLDEN_ASTRA: [{
190: 8, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 8, 241: 6, 249: 8, 288: 5, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 328: 1, 352: 5, 381: 6, 386: 8, 388: 8, 393: 8, 398: 8, 401: 8, 413: 8, 417: 8, 419: 8, 422: 1, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 8, 455: 7, 456: 8, 458: 5, 479: 8, 481: 7, 485: 8, 489: 8, 497: 8, 499: 3, 500: 8, 501: 8, 508: 8, 528: 5, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 567: 5, 647: 5, 707: 8, 723: 8, 753: 5, 761: 7, 806: 1, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1009: 8, 1011: 6, 1017: 8, 1019: 3, 1020: 8, 1105: 6, 1217: 8, 1221: 5, 1225: 8, 1233: 8, 1249: 8, 1257: 6, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 8, 1280: 4, 1300: 8, 1328: 4, 1417: 8, 1906: 7, 1907: 7, 1908: 7, 1912: 7, 1919: 7,
}],
CAR.VOLT: [
# Volt Premier w/ ACC 2017
{
Expand All @@ -77,12 +82,14 @@ def parse_gear_shifter(can_gear):
STEER_THRESHOLD = 1.0

STOCK_CONTROL_MSGS = {
CAR.HOLDEN_ASTRA: [384, 715],
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.HOLDEN_ASTRA: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'),
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'),
Expand Down
5 changes: 4 additions & 1 deletion selfdrive/car/honda/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,15 @@ def update(self, c):
events.append(create_event('commIssue', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
else:
self.can_invalid_count = 0

if not self.CS.cam_can_valid and self.CP.enableCamera:
self.cam_can_invalid_count += 1
if self.cam_can_invalid_count >= 5 and self.CS.CP.carFingerprint not in HONDA_BOSCH:
# wait 1.0s before throwing the alert to avoid it popping when you turn off the car
if self.cam_can_invalid_count >= 100 and self.CS.CP.carFingerprint not in HONDA_BOSCH:
events.append(create_event('invalidGiraffeHonda', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
else:
self.cam_can_invalid_count = 0

if self.CS.steer_error:
events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
elif self.CS.steer_warning:
Expand Down
12 changes: 5 additions & 7 deletions selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,12 @@
from selfdrive.controls.lib.alertmanager import AlertManager
from selfdrive.controls.lib.vehicle_model import VehicleModel
from selfdrive.controls.lib.driver_monitor import DriverStatus
from selfdrive.locationd.calibration_values import Calibration, Filter

ThermalStatus = log.ThermalData.ThermalStatus
State = log.Live100Data.ControlState


class Calibration:
UNCALIBRATED = 0
CALIBRATED = 1
INVALID = 2


def isActive(state):
"""Check if the actuators are enabled"""
return state in [State.enabled, State.softDisabling]
Expand Down Expand Up @@ -293,7 +288,10 @@ def state_control(plan, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last,
extra_text_1, extra_text_2 = "", ""
if e == "calibrationIncomplete":
extra_text_1 = str(cal_perc) + "%"
extra_text_2 = "35 kph" if is_metric else "15 mph"
if is_metric:
extra_text_2 = str(int(round(Filter.MIN_SPEED * CV.MS_TO_KPH))) + " kph"
else:
extra_text_2 = str(int(round(Filter.MIN_SPEED * CV.MS_TO_MPH))) + " mph"
AM.add(str(e) + "Permanent", enabled, extra_text_1=extra_text_1, extra_text_2=extra_text_2)

AM.process_alerts(sec_since_boot())
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/controls/lib/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,9 @@ def update(self, CS, LaC, LoC, v_cruise_kph, force_slow_decel):
if self.model_dead:
events.append(create_event('modelCommIssue', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
if self.radar_dead or 'commIssue' in self.radar_errors:
events.append(create_event('radarCommIssue', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
events.append(create_event('radarCommIssue', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if 'fault' in self.radar_errors:
events.append(create_event('radarFault', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
events.append(create_event('radarFault', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if LaC.mpc_solution[0].cost > 10000. or LaC.mpc_nans: # TODO: find a better way to detect when MPC did not converge
events.append(create_event('plannerError', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))

Expand Down
11 changes: 11 additions & 0 deletions selfdrive/locationd/calibration_values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import math

class Filter:
MIN_SPEED = 7 # m/s (~15.5mph)
MAX_YAW_RATE = math.radians(3) # per second

class Calibration:
UNCALIBRATED = 0
CALIBRATED = 1
INVALID = 2

14 changes: 3 additions & 11 deletions selfdrive/locationd/calibrationd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import zmq
import cv2
import copy
import math
import json
import numpy as np
import selfdrive.messaging as messaging
from selfdrive.locationd.calibration_values import Calibration, Filter
from selfdrive.swaglog import cloudlog
from selfdrive.services import service_list
from common.params import Params
Expand All @@ -17,8 +17,6 @@
eon_intrinsics, get_calib_from_vp, normalize, denormalize, H, W


MIN_SPEED_FILTER = 7 # m/s (~15.5mph)
MAX_YAW_RATE_FILTER = math.radians(3) # per second
FRAMES_NEEDED = 120 # allow to update VP every so many frames
VP_CYCLES_NEEDED = 2
CALIBRATION_CYCLES_NEEDED = FRAMES_NEEDED * VP_CYCLES_NEEDED
Expand All @@ -42,12 +40,6 @@
ffi, lib = ffi_wrap('get_vp', c_code, c_header)


class Calibration:
UNCALIBRATED = 0
CALIBRATED = 1
INVALID = 2


def increment_grid_c(grid, lines, n):
lib.increment_grid(ffi.cast("double *", grid.ctypes.data),
ffi.cast("double *", lines.ctypes.data),
Expand Down Expand Up @@ -131,8 +123,8 @@ def rescale_grid(self):

def update(self, uvs, yaw_rate, speed):
if len(uvs) < 10 or \
abs(yaw_rate) > MAX_YAW_RATE_FILTER or \
speed < MIN_SPEED_FILTER:
abs(yaw_rate) > Filter.MAX_YAW_RATE or \
speed < Filter.MIN_SPEED:
return
rot_speeds = np.array([0.,0.,-yaw_rate])
uvs[:,1,:] = denormalize(correct_pts(normalize(uvs[:,1,:]), rot_speeds, self.dt))
Expand Down