mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 16:23:46 +08:00
Remove Cadillac CT6 port (#1359)
* remove CT6 port * dont need this route * extra char * fix carcontroller params old-commit-hash: e22482eb31f0dd7851fec6ecf448cf99a14b7f5c
This commit is contained in:
@@ -4,27 +4,19 @@ from common.numpy_fast import interp
|
|||||||
from selfdrive.config import Conversions as CV
|
from selfdrive.config import Conversions as CV
|
||||||
from selfdrive.car import apply_std_steer_torque_limits
|
from selfdrive.car import apply_std_steer_torque_limits
|
||||||
from selfdrive.car.gm import gmcan
|
from selfdrive.car.gm import gmcan
|
||||||
from selfdrive.car.gm.values import DBC, SUPERCRUISE_CARS, CanBus
|
from selfdrive.car.gm.values import DBC, CanBus
|
||||||
from opendbc.can.packer import CANPacker
|
from opendbc.can.packer import CANPacker
|
||||||
|
|
||||||
VisualAlert = car.CarControl.HUDControl.VisualAlert
|
VisualAlert = car.CarControl.HUDControl.VisualAlert
|
||||||
|
|
||||||
|
|
||||||
class CarControllerParams():
|
class CarControllerParams():
|
||||||
def __init__(self, car_fingerprint):
|
def __init__(self):
|
||||||
if car_fingerprint in SUPERCRUISE_CARS:
|
self.STEER_MAX = 300
|
||||||
self.STEER_MAX = 150
|
self.STEER_STEP = 2 # how often we update the steer cmd
|
||||||
self.STEER_STEP = 1 # how often we update the steer cmd
|
self.STEER_DELTA_UP = 7 # ~0.75s time to peak torque (255/50hz/0.75s)
|
||||||
self.STEER_DELTA_UP = 2 # 0.75s time to peak torque
|
self.STEER_DELTA_DOWN = 17 # ~0.3s from peak torque to zero
|
||||||
self.STEER_DELTA_DOWN = 5 # 0.3s from peak torque to zero
|
self.MIN_STEER_SPEED = 3.
|
||||||
self.MIN_STEER_SPEED = -1. # can steer down to zero
|
|
||||||
else:
|
|
||||||
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)
|
|
||||||
self.STEER_DELTA_DOWN = 17 # ~0.3s from peak torque to zero
|
|
||||||
self.MIN_STEER_SPEED = 3.
|
|
||||||
|
|
||||||
self.STEER_DRIVER_ALLOWANCE = 50 # allowed driver torque before start limiting
|
self.STEER_DRIVER_ALLOWANCE = 50 # allowed driver torque before start limiting
|
||||||
self.STEER_DRIVER_MULTIPLIER = 4 # weight driver torque heavily
|
self.STEER_DRIVER_MULTIPLIER = 4 # weight driver torque heavily
|
||||||
self.STEER_DRIVER_FACTOR = 100 # from dbc
|
self.STEER_DRIVER_FACTOR = 100 # from dbc
|
||||||
@@ -61,23 +53,15 @@ def actuator_hystereses(final_pedal, pedal_steady):
|
|||||||
|
|
||||||
return final_pedal, pedal_steady
|
return final_pedal, pedal_steady
|
||||||
|
|
||||||
def process_hud_alert(hud_alert):
|
|
||||||
# initialize to no alert
|
|
||||||
steer = 0
|
|
||||||
if hud_alert == VisualAlert.steerRequired:
|
|
||||||
steer = 1
|
|
||||||
return steer
|
|
||||||
|
|
||||||
class CarController():
|
class CarController():
|
||||||
def __init__(self, dbc_name, CP, VM):
|
def __init__(self, dbc_name, CP, VM):
|
||||||
self.pedal_steady = 0.
|
self.pedal_steady = 0.
|
||||||
self.start_time = 0.
|
self.start_time = 0.
|
||||||
self.apply_steer_last = 0
|
self.apply_steer_last = 0
|
||||||
self.car_fingerprint = CP.carFingerprint
|
|
||||||
self.lka_icon_status_last = (False, False)
|
self.lka_icon_status_last = (False, False)
|
||||||
self.steer_rate_limited = False
|
self.steer_rate_limited = False
|
||||||
|
|
||||||
self.params = CarControllerParams(CP.carFingerprint)
|
self.params = CarControllerParams()
|
||||||
|
|
||||||
self.packer_pt = CANPacker(DBC[CP.carFingerprint]['pt'])
|
self.packer_pt = CANPacker(DBC[CP.carFingerprint]['pt'])
|
||||||
self.packer_ch = CANPacker(DBC[CP.carFingerprint]['chassis'])
|
self.packer_ch = CANPacker(DBC[CP.carFingerprint]['chassis'])
|
||||||
@@ -90,9 +74,6 @@ class CarController():
|
|||||||
# Send CAN commands.
|
# Send CAN commands.
|
||||||
can_sends = []
|
can_sends = []
|
||||||
|
|
||||||
alert_out = process_hud_alert(hud_alert)
|
|
||||||
steer = alert_out
|
|
||||||
|
|
||||||
### STEER ###
|
### STEER ###
|
||||||
|
|
||||||
if (frame % P.STEER_STEP) == 0:
|
if (frame % P.STEER_STEP) == 0:
|
||||||
@@ -107,76 +88,72 @@ class CarController():
|
|||||||
self.apply_steer_last = apply_steer
|
self.apply_steer_last = apply_steer
|
||||||
idx = (frame // P.STEER_STEP) % 4
|
idx = (frame // P.STEER_STEP) % 4
|
||||||
|
|
||||||
if self.car_fingerprint in SUPERCRUISE_CARS:
|
can_sends.append(gmcan.create_steering_control(self.packer_pt,
|
||||||
can_sends += gmcan.create_steering_control_ct6(self.packer_pt,
|
CanBus.POWERTRAIN, apply_steer, idx, lkas_enabled))
|
||||||
CanBus, apply_steer, CS.out.vEgo, idx, lkas_enabled)
|
|
||||||
else:
|
|
||||||
can_sends.append(gmcan.create_steering_control(self.packer_pt,
|
|
||||||
CanBus.POWERTRAIN, apply_steer, idx, lkas_enabled))
|
|
||||||
|
|
||||||
### GAS/BRAKE ###
|
### GAS/BRAKE ###
|
||||||
|
|
||||||
if self.car_fingerprint not in SUPERCRUISE_CARS:
|
# no output if not enabled, but keep sending keepalive messages
|
||||||
# no output if not enabled, but keep sending keepalive messages
|
# treat pedals as one
|
||||||
# treat pedals as one
|
final_pedal = actuators.gas - actuators.brake
|
||||||
final_pedal = actuators.gas - actuators.brake
|
|
||||||
|
|
||||||
# *** apply pedal hysteresis ***
|
# *** apply pedal hysteresis ***
|
||||||
final_brake, self.brake_steady = actuator_hystereses(
|
final_brake, self.brake_steady = actuator_hystereses(
|
||||||
final_pedal, self.pedal_steady)
|
final_pedal, self.pedal_steady)
|
||||||
|
|
||||||
if not enabled:
|
if not enabled:
|
||||||
# Stock ECU sends max regen when not enabled.
|
# Stock ECU sends max regen when not enabled.
|
||||||
apply_gas = P.MAX_ACC_REGEN
|
apply_gas = P.MAX_ACC_REGEN
|
||||||
apply_brake = 0
|
apply_brake = 0
|
||||||
else:
|
else:
|
||||||
apply_gas = int(round(interp(final_pedal, P.GAS_LOOKUP_BP, P.GAS_LOOKUP_V)))
|
apply_gas = int(round(interp(final_pedal, P.GAS_LOOKUP_BP, P.GAS_LOOKUP_V)))
|
||||||
apply_brake = int(round(interp(final_pedal, P.BRAKE_LOOKUP_BP, P.BRAKE_LOOKUP_V)))
|
apply_brake = int(round(interp(final_pedal, P.BRAKE_LOOKUP_BP, P.BRAKE_LOOKUP_V)))
|
||||||
|
|
||||||
# Gas/regen and brakes - all at 25Hz
|
# Gas/regen and brakes - all at 25Hz
|
||||||
if (frame % 4) == 0:
|
if (frame % 4) == 0:
|
||||||
idx = (frame // 4) % 4
|
idx = (frame // 4) % 4
|
||||||
|
|
||||||
at_full_stop = enabled and CS.out.standstill
|
at_full_stop = enabled and CS.out.standstill
|
||||||
near_stop = enabled and (CS.out.vEgo < P.NEAR_STOP_BRAKE_PHASE)
|
near_stop = enabled and (CS.out.vEgo < P.NEAR_STOP_BRAKE_PHASE)
|
||||||
can_sends.append(gmcan.create_friction_brake_command(self.packer_ch, CanBus.CHASSIS, apply_brake, idx, near_stop, at_full_stop))
|
can_sends.append(gmcan.create_friction_brake_command(self.packer_ch, CanBus.CHASSIS, apply_brake, idx, near_stop, at_full_stop))
|
||||||
|
|
||||||
at_full_stop = enabled and CS.out.standstill
|
at_full_stop = enabled and CS.out.standstill
|
||||||
can_sends.append(gmcan.create_gas_regen_command(self.packer_pt, CanBus.POWERTRAIN, apply_gas, idx, enabled, at_full_stop))
|
can_sends.append(gmcan.create_gas_regen_command(self.packer_pt, CanBus.POWERTRAIN, apply_gas, idx, enabled, at_full_stop))
|
||||||
|
|
||||||
# Send dashboard UI commands (ACC status), 25hz
|
# Send dashboard UI commands (ACC status), 25hz
|
||||||
if (frame % 4) == 0:
|
if (frame % 4) == 0:
|
||||||
can_sends.append(gmcan.create_acc_dashboard_command(self.packer_pt, 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),
|
# Radar needs to know current speed and yaw rate (50hz),
|
||||||
# and that ADAS is alive (10hz)
|
# and that ADAS is alive (10hz)
|
||||||
time_and_headlights_step = 10
|
time_and_headlights_step = 10
|
||||||
tt = frame * DT_CTRL
|
tt = frame * DT_CTRL
|
||||||
|
|
||||||
if frame % time_and_headlights_step == 0:
|
if frame % time_and_headlights_step == 0:
|
||||||
idx = (frame // time_and_headlights_step) % 4
|
idx = (frame // time_and_headlights_step) % 4
|
||||||
can_sends.append(gmcan.create_adas_time_status(CanBus.OBSTACLE, int((tt - self.start_time) * 60), idx))
|
can_sends.append(gmcan.create_adas_time_status(CanBus.OBSTACLE, int((tt - self.start_time) * 60), idx))
|
||||||
can_sends.append(gmcan.create_adas_headlights_status(CanBus.OBSTACLE))
|
can_sends.append(gmcan.create_adas_headlights_status(CanBus.OBSTACLE))
|
||||||
|
|
||||||
speed_and_accelerometer_step = 2
|
speed_and_accelerometer_step = 2
|
||||||
if frame % speed_and_accelerometer_step == 0:
|
if frame % speed_and_accelerometer_step == 0:
|
||||||
idx = (frame // speed_and_accelerometer_step) % 4
|
idx = (frame // speed_and_accelerometer_step) % 4
|
||||||
can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx))
|
can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx))
|
||||||
can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx))
|
can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx))
|
||||||
|
|
||||||
if frame % P.ADAS_KEEPALIVE_STEP == 0:
|
if frame % P.ADAS_KEEPALIVE_STEP == 0:
|
||||||
can_sends += gmcan.create_adas_keepalive(CanBus.POWERTRAIN)
|
can_sends += gmcan.create_adas_keepalive(CanBus.POWERTRAIN)
|
||||||
|
|
||||||
# Show green icon when LKA torque is applied, and
|
# Show green icon when LKA torque is applied, and
|
||||||
# alarming orange icon when approaching torque limit.
|
# alarming orange icon when approaching torque limit.
|
||||||
# If not sent again, LKA icon disappears in about 5 seconds.
|
# If not sent again, LKA icon disappears in about 5 seconds.
|
||||||
# Conveniently, sending camera message periodically also works as a keepalive.
|
# Conveniently, sending camera message periodically also works as a keepalive.
|
||||||
lka_active = CS.lkas_status == 1
|
lka_active = CS.lkas_status == 1
|
||||||
lka_critical = lka_active and abs(actuators.steer) > 0.9
|
lka_critical = lka_active and abs(actuators.steer) > 0.9
|
||||||
lka_icon_status = (lka_active, lka_critical)
|
lka_icon_status = (lka_active, lka_critical)
|
||||||
if frame % P.CAMERA_KEEPALIVE_STEP == 0 \
|
if frame % P.CAMERA_KEEPALIVE_STEP == 0 \
|
||||||
or lka_icon_status != self.lka_icon_status_last:
|
or lka_icon_status != self.lka_icon_status_last:
|
||||||
can_sends.append(gmcan.create_lka_icon_command(CanBus.SW_GMLAN, lka_active, lka_critical, steer))
|
steer_alert = hud_alert == VisualAlert.steerRequired
|
||||||
self.lka_icon_status_last = lka_icon_status
|
can_sends.append(gmcan.create_lka_icon_command(CanBus.SW_GMLAN, lka_active, lka_critical, steer_alert))
|
||||||
|
self.lka_icon_status_last = lka_icon_status
|
||||||
|
|
||||||
return can_sends
|
return can_sends
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from opendbc.can.parser import CANParser
|
|||||||
from selfdrive.car.interfaces import CarStateBase
|
from selfdrive.car.interfaces import CarStateBase
|
||||||
from selfdrive.car.gm.values import DBC, CAR, AccState, CanBus, \
|
from selfdrive.car.gm.values import DBC, CAR, AccState, CanBus, \
|
||||||
CruiseButtons, is_eps_status_ok, \
|
CruiseButtons, is_eps_status_ok, \
|
||||||
STEER_THRESHOLD, SUPERCRUISE_CARS
|
STEER_THRESHOLD
|
||||||
|
|
||||||
|
|
||||||
class CarState(CarStateBase):
|
class CarState(CarStateBase):
|
||||||
@@ -53,21 +53,14 @@ class CarState(CarStateBase):
|
|||||||
ret.leftBlinker = pt_cp.vl["BCMTurnSignals"]['TurnSignals'] == 1
|
ret.leftBlinker = pt_cp.vl["BCMTurnSignals"]['TurnSignals'] == 1
|
||||||
ret.rightBlinker = pt_cp.vl["BCMTurnSignals"]['TurnSignals'] == 2
|
ret.rightBlinker = pt_cp.vl["BCMTurnSignals"]['TurnSignals'] == 2
|
||||||
|
|
||||||
if self.car_fingerprint in SUPERCRUISE_CARS:
|
self.park_brake = pt_cp.vl["EPBStatus"]['EPBClosed']
|
||||||
self.park_brake = False
|
ret.cruiseState.available = bool(pt_cp.vl["ECMEngineStatus"]['CruiseMainOn'])
|
||||||
ret.cruiseState.available = False
|
ret.espDisabled = pt_cp.vl["ESPStatus"]['TractionControlOn'] != 1
|
||||||
ret.espDisabled = False
|
self.pcm_acc_status = pt_cp.vl["AcceleratorPedal2"]['CruiseState']
|
||||||
regen_pressed = False
|
|
||||||
self.pcm_acc_status = int(pt_cp.vl["ASCMActiveCruiseControlStatus"]['ACCCmdActive'])
|
regen_pressed = False
|
||||||
else:
|
if self.car_fingerprint == CAR.VOLT:
|
||||||
self.park_brake = pt_cp.vl["EPBStatus"]['EPBClosed']
|
regen_pressed = bool(pt_cp.vl["EBCMRegenPaddle"]['RegenPaddle'])
|
||||||
ret.cruiseState.available = bool(pt_cp.vl["ECMEngineStatus"]['CruiseMainOn'])
|
|
||||||
ret.espDisabled = pt_cp.vl["ESPStatus"]['TractionControlOn'] != 1
|
|
||||||
self.pcm_acc_status = pt_cp.vl["AcceleratorPedal2"]['CruiseState']
|
|
||||||
if self.car_fingerprint == CAR.VOLT:
|
|
||||||
regen_pressed = bool(pt_cp.vl["EBCMRegenPaddle"]['RegenPaddle'])
|
|
||||||
else:
|
|
||||||
regen_pressed = False
|
|
||||||
|
|
||||||
# Regen braking is braking
|
# Regen braking is braking
|
||||||
ret.brakePressed = ret.brake > 1e-5 or regen_pressed
|
ret.brakePressed = ret.brake > 1e-5 or regen_pressed
|
||||||
@@ -94,6 +87,7 @@ class CarState(CarStateBase):
|
|||||||
("RightSeatBelt", "BCMDoorBeltStatus", 0),
|
("RightSeatBelt", "BCMDoorBeltStatus", 0),
|
||||||
("TurnSignals", "BCMTurnSignals", 0),
|
("TurnSignals", "BCMTurnSignals", 0),
|
||||||
("AcceleratorPedal", "AcceleratorPedal", 0),
|
("AcceleratorPedal", "AcceleratorPedal", 0),
|
||||||
|
("CruiseState", "AcceleratorPedal2", 0),
|
||||||
("ACCButtons", "ASCMSteeringButton", CruiseButtons.UNPRESS),
|
("ACCButtons", "ASCMSteeringButton", CruiseButtons.UNPRESS),
|
||||||
("SteeringWheelAngle", "PSCMSteeringAngle", 0),
|
("SteeringWheelAngle", "PSCMSteeringAngle", 0),
|
||||||
("FLWheelSpd", "EBCMWheelSpdFront", 0),
|
("FLWheelSpd", "EBCMWheelSpdFront", 0),
|
||||||
@@ -103,22 +97,14 @@ class CarState(CarStateBase):
|
|||||||
("PRNDL", "ECMPRDNL", 0),
|
("PRNDL", "ECMPRDNL", 0),
|
||||||
("LKADriverAppldTrq", "PSCMStatus", 0),
|
("LKADriverAppldTrq", "PSCMStatus", 0),
|
||||||
("LKATorqueDeliveredStatus", "PSCMStatus", 0),
|
("LKATorqueDeliveredStatus", "PSCMStatus", 0),
|
||||||
|
("TractionControlOn", "ESPStatus", 0),
|
||||||
|
("EPBClosed", "EPBStatus", 0),
|
||||||
|
("CruiseMainOn", "ECMEngineStatus", 0),
|
||||||
]
|
]
|
||||||
|
|
||||||
if CP.carFingerprint == CAR.VOLT:
|
if CP.carFingerprint == CAR.VOLT:
|
||||||
signals += [
|
signals += [
|
||||||
("RegenPaddle", "EBCMRegenPaddle", 0),
|
("RegenPaddle", "EBCMRegenPaddle", 0),
|
||||||
]
|
]
|
||||||
if CP.carFingerprint in SUPERCRUISE_CARS:
|
|
||||||
signals += [
|
|
||||||
("ACCCmdActive", "ASCMActiveCruiseControlStatus", 0)
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
signals += [
|
|
||||||
("TractionControlOn", "ESPStatus", 0),
|
|
||||||
("EPBClosed", "EPBStatus", 0),
|
|
||||||
("CruiseMainOn", "ECMEngineStatus", 0),
|
|
||||||
("CruiseState", "AcceleratorPedal2", 0),
|
|
||||||
]
|
|
||||||
|
|
||||||
return CANParser(DBC[CP.carFingerprint]['pt'], signals, [], CanBus.POWERTRAIN)
|
return CANParser(DBC[CP.carFingerprint]['pt'], signals, [], CanBus.POWERTRAIN)
|
||||||
|
|||||||
@@ -11,32 +11,6 @@ def create_steering_control(packer, bus, apply_steer, idx, lkas_active):
|
|||||||
|
|
||||||
return packer.make_can_msg("ASCMLKASteeringCmd", bus, values)
|
return packer.make_can_msg("ASCMLKASteeringCmd", bus, values)
|
||||||
|
|
||||||
def create_steering_control_ct6(packer, CanBus, apply_steer, v_ego, idx, enabled):
|
|
||||||
|
|
||||||
values = {
|
|
||||||
"LKASteeringCmdActive": 1 if enabled else 0,
|
|
||||||
"LKASteeringCmd": apply_steer,
|
|
||||||
"RollingCounter": idx,
|
|
||||||
"SetMe1": 1,
|
|
||||||
"LKASVehicleSpeed": abs(v_ego * 3.6),
|
|
||||||
"LKASMode": 2 if enabled else 0,
|
|
||||||
"LKASteeringCmdChecksum": 0 # assume zero and then manually compute it
|
|
||||||
}
|
|
||||||
|
|
||||||
dat = packer.make_can_msg("ASCMLKASteeringCmd", 0, values)[2]
|
|
||||||
# the checksum logic is weird
|
|
||||||
values['LKASteeringCmdChecksum'] = (0x2a +
|
|
||||||
sum(dat[:4]) +
|
|
||||||
values['LKASMode']) & 0x3ff
|
|
||||||
# pack again with checksum
|
|
||||||
dat = packer.make_can_msg("ASCMLKASteeringCmd", 0, values)[2]
|
|
||||||
|
|
||||||
return [0x152, 0, dat, CanBus.POWERTRAIN], \
|
|
||||||
[0x154, 0, dat, CanBus.POWERTRAIN], \
|
|
||||||
[0x151, 0, dat, CanBus.CHASSIS], \
|
|
||||||
[0x153, 0, dat, CanBus.CHASSIS]
|
|
||||||
|
|
||||||
|
|
||||||
def create_adas_keepalive(bus):
|
def create_adas_keepalive(bus):
|
||||||
dat = b"\x00\x00\x00\x00\x00\x00\x00"
|
dat = b"\x00\x00\x00\x00\x00\x00\x00"
|
||||||
return [make_can_msg(0x409, dat, bus), make_can_msg(0x40a, dat, bus)]
|
return [make_can_msg(0x409, dat, bus), make_can_msg(0x40a, dat, bus)]
|
||||||
@@ -147,47 +121,3 @@ def create_lka_icon_command(bus, active, critical, steer):
|
|||||||
dat = b"\x00\x00\x00"
|
dat = b"\x00\x00\x00"
|
||||||
return make_can_msg(0x104c006c, dat, bus)
|
return make_can_msg(0x104c006c, dat, bus)
|
||||||
|
|
||||||
# TODO: WIP
|
|
||||||
'''
|
|
||||||
def create_friction_brake_command_ct6(packer, bus, apply_brake, idx, near_stop, at_full_stop):
|
|
||||||
|
|
||||||
# counters loops across [0, 29, 42, 55] but checksum only considers 0, 1, 2, 3
|
|
||||||
cntrs = [0, 29, 42, 55]
|
|
||||||
if apply_brake == 0:
|
|
||||||
mode = 0x1
|
|
||||||
else:
|
|
||||||
mode = 0xa
|
|
||||||
|
|
||||||
if at_full_stop:
|
|
||||||
mode = 0xd
|
|
||||||
elif near_stop:
|
|
||||||
mode = 0xb
|
|
||||||
|
|
||||||
brake = (0x1000 - apply_brake) & 0xfff
|
|
||||||
checksum = (0x10000 - (mode << 12) - brake - idx) & 0xffff
|
|
||||||
|
|
||||||
values = {
|
|
||||||
"RollingCounter" : cntrs[idx],
|
|
||||||
"FrictionBrakeMode" : mode,
|
|
||||||
"FrictionBrakeChecksum": checksum,
|
|
||||||
"FrictionBrakeCmd" : -apply_brake
|
|
||||||
}
|
|
||||||
|
|
||||||
dat = packer.make_can_msg("EBCMFrictionBrakeCmd", 0, values)[2]
|
|
||||||
# msg is 0x315 but we are doing the panda forwarding
|
|
||||||
return make_can_msg(0x314, dat, 2)
|
|
||||||
|
|
||||||
def create_gas_regen_command_ct6(bus, throttle, idx, acc_engaged, at_full_stop):
|
|
||||||
cntrs = [0, 7, 10, 13]
|
|
||||||
eng_bit = 1 if acc_engaged else 0
|
|
||||||
gas_high = (throttle >> 8) | 0x80
|
|
||||||
gas_low = (throttle) & 0xff
|
|
||||||
full_stop = 0x20 if at_full_stop else 0
|
|
||||||
|
|
||||||
chk1 = (0x100 - gas_high - 1) & 0xff
|
|
||||||
chk2 = (0x100 - gas_low - idx) & 0xff
|
|
||||||
dat = [(idx << 6) | eng_bit, 0xc2 | full_stop, gas_high, gas_low,
|
|
||||||
(1 - eng_bit) | (cntrs[idx] << 1), 0x5d - full_stop, chk1, chk2]
|
|
||||||
return make_can_msg(0x2cb, "".join(map(chr, dat)), bus)
|
|
||||||
|
|
||||||
'''
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from cereal import car
|
|||||||
from selfdrive.config import Conversions as CV
|
from selfdrive.config import Conversions as CV
|
||||||
from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET
|
from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET
|
||||||
from selfdrive.car.gm.values import CAR, Ecu, ECU_FINGERPRINT, CruiseButtons, \
|
from selfdrive.car.gm.values import CAR, Ecu, ECU_FINGERPRINT, CruiseButtons, \
|
||||||
SUPERCRUISE_CARS, AccState, FINGERPRINTS
|
AccState, FINGERPRINTS
|
||||||
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, is_ecu_disconnected, gen_empty_fingerprint
|
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, is_ecu_disconnected, gen_empty_fingerprint
|
||||||
from selfdrive.car.interfaces import CarInterfaceBase
|
from selfdrive.car.interfaces import CarInterfaceBase
|
||||||
|
|
||||||
@@ -29,9 +29,7 @@ class CarInterface(CarInterfaceBase):
|
|||||||
# Presence of a camera on the object bus is ok.
|
# Presence of a camera on the object bus is ok.
|
||||||
# Have to go to read_only if ASCM is online (ACC-enabled cars),
|
# Have to go to read_only if ASCM is online (ACC-enabled cars),
|
||||||
# or camera is on powertrain bus (LKA cars without ACC).
|
# or camera is on powertrain bus (LKA cars without ACC).
|
||||||
ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, Ecu.fwdCamera) or \
|
ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, Ecu.fwdCamera) or has_relay
|
||||||
has_relay or \
|
|
||||||
candidate == CAR.CADILLAC_CT6
|
|
||||||
ret.openpilotLongitudinalControl = ret.enableCamera
|
ret.openpilotLongitudinalControl = ret.enableCamera
|
||||||
tire_stiffness_factor = 0.444 # not optimized yet
|
tire_stiffness_factor = 0.444 # not optimized yet
|
||||||
|
|
||||||
@@ -93,16 +91,6 @@ class CarInterface(CarInterfaceBase):
|
|||||||
ret.steerRatioRear = 0.
|
ret.steerRatioRear = 0.
|
||||||
ret.centerToFront = ret.wheelbase * 0.49
|
ret.centerToFront = ret.wheelbase * 0.49
|
||||||
|
|
||||||
elif candidate == CAR.CADILLAC_CT6:
|
|
||||||
# engage speed is decided by pcm
|
|
||||||
ret.minEnableSpeed = -1.
|
|
||||||
ret.mass = 4016. * CV.LB_TO_KG + STD_CARGO_KG
|
|
||||||
ret.safetyModel = car.CarParams.SafetyModel.cadillac
|
|
||||||
ret.wheelbase = 3.11
|
|
||||||
ret.steerRatio = 14.6 # it's 16.3 without rear active steering
|
|
||||||
ret.steerRatioRear = 0. # TODO: there is RAS on this car!
|
|
||||||
ret.centerToFront = ret.wheelbase * 0.465
|
|
||||||
|
|
||||||
# TODO: get actual value, for now starting with reasonable value for
|
# TODO: get actual value, for now starting with reasonable value for
|
||||||
# civic and scaling by mass and wheelbase
|
# civic and scaling by mass and wheelbase
|
||||||
ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase)
|
ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase)
|
||||||
@@ -159,28 +147,25 @@ class CarInterface(CarInterfaceBase):
|
|||||||
|
|
||||||
ret.buttonEvents = buttonEvents
|
ret.buttonEvents = buttonEvents
|
||||||
|
|
||||||
supercruise = self.CS.car_fingerprint in SUPERCRUISE_CARS
|
events = self.create_common_events(ret, pcm_enable=False)
|
||||||
events = self.create_common_events(ret, pcm_enable=supercruise)
|
|
||||||
|
|
||||||
if not supercruise:
|
if ret.vEgo < self.CP.minEnableSpeed:
|
||||||
# TODO: why is this only not supercruise? ignore supercruise?
|
events.append(create_event('speedTooLow', [ET.NO_ENTRY]))
|
||||||
if ret.vEgo < self.CP.minEnableSpeed:
|
if self.CS.park_brake:
|
||||||
events.append(create_event('speedTooLow', [ET.NO_ENTRY]))
|
events.append(create_event('parkBrake', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||||
if self.CS.park_brake:
|
if ret.cruiseState.standstill:
|
||||||
events.append(create_event('parkBrake', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
events.append(create_event('resumeRequired', [ET.WARNING]))
|
||||||
if ret.cruiseState.standstill:
|
if self.CS.pcm_acc_status == AccState.FAULTED:
|
||||||
events.append(create_event('resumeRequired', [ET.WARNING]))
|
events.append(create_event('controlsFailed', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
|
||||||
if self.CS.pcm_acc_status == AccState.FAULTED:
|
|
||||||
events.append(create_event('controlsFailed', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
|
|
||||||
|
|
||||||
# handle button presses
|
# handle button presses
|
||||||
for b in ret.buttonEvents:
|
for b in ret.buttonEvents:
|
||||||
# do enable on both accel and decel buttons
|
# do enable on both accel and decel buttons
|
||||||
if b.type in [ButtonType.accelCruise, ButtonType.decelCruise] and not b.pressed:
|
if b.type in [ButtonType.accelCruise, ButtonType.decelCruise] and not b.pressed:
|
||||||
events.append(create_event('buttonEnable', [ET.ENABLE]))
|
events.append(create_event('buttonEnable', [ET.ENABLE]))
|
||||||
# do disable on button down
|
# do disable on button down
|
||||||
if b.type == ButtonType.cancel and b.pressed:
|
if b.type == ButtonType.cancel and b.pressed:
|
||||||
events.append(create_event('buttonCancel', [ET.USER_DISABLE]))
|
events.append(create_event('buttonCancel', [ET.USER_DISABLE]))
|
||||||
|
|
||||||
ret.events = events
|
ret.events = events
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,10 @@ class CAR:
|
|||||||
HOLDEN_ASTRA = "HOLDEN ASTRA RS-V BK 2017"
|
HOLDEN_ASTRA = "HOLDEN ASTRA RS-V BK 2017"
|
||||||
VOLT = "CHEVROLET VOLT PREMIER 2017"
|
VOLT = "CHEVROLET VOLT PREMIER 2017"
|
||||||
CADILLAC_ATS = "CADILLAC ATS Premium Performance 2018"
|
CADILLAC_ATS = "CADILLAC ATS Premium Performance 2018"
|
||||||
CADILLAC_CT6 = "CADILLAC CT6 SUPERCRUISE 2018"
|
|
||||||
MALIBU = "CHEVROLET MALIBU PREMIER 2017"
|
MALIBU = "CHEVROLET MALIBU PREMIER 2017"
|
||||||
ACADIA = "GMC ACADIA DENALI 2018"
|
ACADIA = "GMC ACADIA DENALI 2018"
|
||||||
BUICK_REGAL = "BUICK REGAL ESSENCE 2018"
|
BUICK_REGAL = "BUICK REGAL ESSENCE 2018"
|
||||||
|
|
||||||
SUPERCRUISE_CARS = [CAR.CADILLAC_CT6]
|
|
||||||
|
|
||||||
class CruiseButtons:
|
class CruiseButtons:
|
||||||
INIT = 0
|
INIT = 0
|
||||||
UNPRESS = 1
|
UNPRESS = 1
|
||||||
@@ -34,12 +31,7 @@ class CanBus:
|
|||||||
SW_GMLAN = 3
|
SW_GMLAN = 3
|
||||||
|
|
||||||
def is_eps_status_ok(eps_status, car_fingerprint):
|
def is_eps_status_ok(eps_status, car_fingerprint):
|
||||||
valid_eps_status = []
|
return eps_status in [0, 1]
|
||||||
if car_fingerprint in SUPERCRUISE_CARS:
|
|
||||||
valid_eps_status += [0, 1, 4, 5, 6]
|
|
||||||
else:
|
|
||||||
valid_eps_status += [0, 1]
|
|
||||||
return eps_status in valid_eps_status
|
|
||||||
|
|
||||||
FINGERPRINTS = {
|
FINGERPRINTS = {
|
||||||
# Astra BK MY17, ASCM unplugged
|
# Astra BK MY17, ASCM unplugged
|
||||||
@@ -65,9 +57,6 @@ FINGERPRINTS = {
|
|||||||
{
|
{
|
||||||
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, 322: 7, 328: 1, 352: 5, 368: 3, 381: 6, 384: 4, 386: 8, 388: 8, 393: 7, 398: 8, 401: 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, 462: 4, 479: 3, 481: 7, 485: 8, 487: 8, 489: 8, 491: 2, 493: 8, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 528: 5, 532: 6, 534: 2, 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, 719: 5, 723: 2, 753: 5, 761: 7, 801: 8, 804: 3, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 882: 8, 890: 1, 892: 2, 893: 2, 894: 1, 961: 8, 967: 4, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1011: 6, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1233: 8, 1241: 3, 1249: 8, 1257: 6, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 1, 1271: 8, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1417: 8, 1601: 8, 1904: 7, 1906: 7, 1907: 7, 1912: 7, 1916: 7, 1917: 7, 1918: 7, 1919: 7, 1920: 7, 1930: 7, 2016: 8, 2024: 8
|
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, 322: 7, 328: 1, 352: 5, 368: 3, 381: 6, 384: 4, 386: 8, 388: 8, 393: 7, 398: 8, 401: 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, 462: 4, 479: 3, 481: 7, 485: 8, 487: 8, 489: 8, 491: 2, 493: 8, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 528: 5, 532: 6, 534: 2, 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, 719: 5, 723: 2, 753: 5, 761: 7, 801: 8, 804: 3, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 882: 8, 890: 1, 892: 2, 893: 2, 894: 1, 961: 8, 967: 4, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1011: 6, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1233: 8, 1241: 3, 1249: 8, 1257: 6, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 1, 1271: 8, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1417: 8, 1601: 8, 1904: 7, 1906: 7, 1907: 7, 1912: 7, 1916: 7, 1917: 7, 1918: 7, 1919: 7, 1920: 7, 1930: 7, 2016: 8, 2024: 8
|
||||||
}],
|
}],
|
||||||
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: [
|
CAR.MALIBU: [
|
||||||
# Malibu Premier w/ ACC 2017
|
# Malibu Premier w/ ACC 2017
|
||||||
{
|
{
|
||||||
@@ -93,5 +82,4 @@ DBC = {
|
|||||||
CAR.ACADIA: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'),
|
CAR.ACADIA: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'),
|
||||||
CAR.CADILLAC_ATS: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'),
|
CAR.CADILLAC_ATS: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'),
|
||||||
CAR.BUICK_REGAL: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'),
|
CAR.BUICK_REGAL: 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'),
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,10 +76,6 @@ routes = {
|
|||||||
'carFingerprint': FORD.FUSION,
|
'carFingerprint': FORD.FUSION,
|
||||||
'enableCamera': True,
|
'enableCamera': True,
|
||||||
},
|
},
|
||||||
"7ed9cdf8d0c5f43e|2018-05-17--09-31-36": {
|
|
||||||
'carFingerprint': GM.CADILLAC_CT6,
|
|
||||||
'enableCamera': True,
|
|
||||||
},
|
|
||||||
"c950e28c26b5b168|2018-05-30--22-03-41": {
|
"c950e28c26b5b168|2018-05-30--22-03-41": {
|
||||||
'carFingerprint': GM.VOLT,
|
'carFingerprint': GM.VOLT,
|
||||||
'enableCamera': True,
|
'enableCamera': True,
|
||||||
|
|||||||
Reference in New Issue
Block a user