mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-02 12:02:09 +08:00
Revert the changes to GM in 0.5.4 (#380)
* Revert 0.5.4 changes for GM for 18ers
* Redo the refactor of stock control msgs
* Fixed missing CONTROL_MSGS -> STOCK_CONTROL_MSGS
* Remove spacing
* Need candidate array idx
old-commit-hash: 8cc32df779
This commit is contained in:
@@ -4,7 +4,7 @@ from selfdrive.config import Conversions as CV
|
||||
from selfdrive.boardd.boardd import can_list_to_can_capnp
|
||||
from selfdrive.car import apply_std_steer_torque_limits
|
||||
from selfdrive.car.gm import gmcan
|
||||
from selfdrive.car.gm.values import CAR, DBC, AccState
|
||||
from selfdrive.car.gm.values import CAR, DBC
|
||||
from selfdrive.can.packer import CANPacker
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ class CarControllerParams():
|
||||
self.ADAS_KEEPALIVE_STEP = 10
|
||||
# pedal lookups, only for Volt
|
||||
MAX_GAS = 3072 # Only a safety limit
|
||||
self.ZERO_GAS = 2048
|
||||
ZERO_GAS = 2048
|
||||
MAX_BRAKE = 350 # Should be around 3.5m/s^2, including regen
|
||||
self.MAX_ACC_REGEN = 1404 # ACC Regen braking is slightly less powerful than max regen paddle
|
||||
self.GAS_LOOKUP_BP = [-0.25, 0., 0.5]
|
||||
self.GAS_LOOKUP_V = [self.MAX_ACC_REGEN, self.ZERO_GAS, MAX_GAS]
|
||||
self.GAS_LOOKUP_V = [self.MAX_ACC_REGEN, ZERO_GAS, MAX_GAS]
|
||||
self.BRAKE_LOOKUP_BP = [-1., -0.25]
|
||||
self.BRAKE_LOOKUP_V = [MAX_BRAKE, 0]
|
||||
|
||||
@@ -83,6 +83,7 @@ class CarController(object):
|
||||
return
|
||||
|
||||
P = self.params
|
||||
|
||||
# Send CAN commands.
|
||||
can_sends = []
|
||||
canbus = self.canbus
|
||||
@@ -130,18 +131,12 @@ class CarController(object):
|
||||
if (frame % 4) == 0:
|
||||
idx = (frame / 4) % 4
|
||||
|
||||
car_stopping = apply_gas < P.ZERO_GAS
|
||||
standstill = CS.pcm_acc_status == AccState.STANDSTILL
|
||||
at_full_stop = enabled and standstill and car_stopping
|
||||
near_stop = enabled and (CS.v_ego < P.NEAR_STOP_BRAKE_PHASE) and car_stopping
|
||||
at_full_stop = enabled and CS.standstill
|
||||
near_stop = enabled and (CS.v_ego < 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))
|
||||
|
||||
# Auto-resume from full stop by resetting ACC control
|
||||
acc_enabled = enabled
|
||||
if standstill and not car_stopping:
|
||||
acc_enabled = False
|
||||
|
||||
can_sends.append(gmcan.create_gas_regen_command(self.packer_pt, canbus.powertrain, apply_gas, idx, acc_enabled, at_full_stop))
|
||||
at_full_stop = enabled and CS.standstill
|
||||
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
|
||||
if (frame % 4) == 0:
|
||||
|
||||
@@ -60,15 +60,17 @@ def create_gas_regen_command(packer, bus, throttle, idx, acc_engaged, at_full_st
|
||||
|
||||
def create_friction_brake_command(packer, bus, apply_brake, idx, near_stop, at_full_stop):
|
||||
|
||||
mode = 0x1
|
||||
if apply_brake > 0:
|
||||
if apply_brake == 0:
|
||||
mode = 0x1
|
||||
else:
|
||||
mode = 0xa
|
||||
|
||||
if near_stop:
|
||||
mode = 0xb
|
||||
|
||||
if at_full_stop:
|
||||
mode = 0xd
|
||||
if at_full_stop:
|
||||
mode = 0xd
|
||||
# TODO: this is to have GM bringing the car to complete stop,
|
||||
# but currently it conflicts with OP controls, so turned off.
|
||||
#elif near_stop:
|
||||
# mode = 0xb
|
||||
|
||||
brake = (0x1000 - apply_brake) & 0xfff
|
||||
checksum = (0x10000 - (mode << 12) - brake - idx) & 0xffff
|
||||
|
||||
@@ -193,7 +193,7 @@ class CarInterface(object):
|
||||
ret.cruiseState.available = bool(self.CS.main_on)
|
||||
cruiseEnabled = self.CS.pcm_acc_status != 0
|
||||
ret.cruiseState.enabled = cruiseEnabled
|
||||
ret.cruiseState.standstill = False
|
||||
ret.cruiseState.standstill = self.CS.pcm_acc_status == 4
|
||||
|
||||
ret.leftBlinker = self.CS.left_blinker_on
|
||||
ret.rightBlinker = self.CS.right_blinker_on
|
||||
@@ -276,6 +276,8 @@ class CarInterface(object):
|
||||
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||
if ret.gasPressed:
|
||||
events.append(create_event('pedalPressed', [ET.PRE_ENABLE]))
|
||||
if ret.cruiseState.standstill:
|
||||
events.append(create_event('resumeRequired', [ET.WARNING]))
|
||||
|
||||
# handle button presses
|
||||
for b in ret.buttonEvents:
|
||||
|
||||
@@ -12,12 +12,6 @@ class CruiseButtons:
|
||||
MAIN = 5
|
||||
CANCEL = 6
|
||||
|
||||
class AccState:
|
||||
OFF = 0
|
||||
ACTIVE = 1
|
||||
FAULTED = 3
|
||||
STANDSTILL = 4
|
||||
|
||||
def is_eps_status_ok(eps_status, car_fingerprint):
|
||||
valid_eps_status = []
|
||||
if car_fingerprint == CAR.VOLT:
|
||||
@@ -55,7 +49,6 @@ FINGERPRINTS = {
|
||||
|
||||
STEER_THRESHOLD = 1.0
|
||||
|
||||
|
||||
STOCK_CONTROL_MSGS = {
|
||||
CAR.VOLT: [384, 715], # 384 = "ASCMLKASteeringCmd", 715 = "ASCMGasRegenCmd"
|
||||
CAR.CADILLAC_CT6: [], # Cadillac does not require ASCMs to be disconnected
|
||||
|
||||
Reference in New Issue
Block a user