small cleanup

pull/1729/head
Adeeb Shihadeh 5 years ago
parent 58c1504f1a
commit 9272927bf3
  1. 8
      selfdrive/car/gm/carcontroller.py
  2. 12
      selfdrive/car/gm/carstate.py
  3. 10
      selfdrive/car/gm/gmcan.py
  4. 3
      selfdrive/car/gm/values.py

@ -98,16 +98,14 @@ class CarController():
at_full_stop = enabled and CS.out.standstill
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))
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))
# Send dashboard UI commands (ACC status), 25hz
if (frame % 4) == 0:
# Send FCW if applicable
send_fcw = 0
send_fcw = False
if self.fcw_frames > 0:
send_fcw = 0x3
send_fcw = True
self.fcw_frames -= 1
can_sends.append(gmcan.create_acc_dashboard_command(self.packer_pt, CanBus.POWERTRAIN, enabled, hud_v_cruise * CV.MS_TO_KPH, hud_show_car, send_fcw))
@ -120,7 +118,7 @@ class CarController():
if frame % time_and_headlights_step == 0:
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_headlights_status(CanBus.OBSTACLE))
can_sends.append(gmcan.create_adas_headlights_status(self.packer_ch, CanBus.OBSTACLE))
speed_and_accelerometer_step = 2
if frame % speed_and_accelerometer_step == 0:

@ -5,8 +5,7 @@ from opendbc.can.can_define import CANDefine
from opendbc.can.parser import CANParser
from selfdrive.car.interfaces import CarStateBase
from selfdrive.car.gm.values import DBC, CAR, AccState, CanBus, \
CruiseButtons, is_eps_status_ok, \
STEER_THRESHOLD
CruiseButtons, STEER_THRESHOLD
class CarState(CarStateBase):
@ -58,18 +57,17 @@ class CarState(CarStateBase):
ret.espDisabled = pt_cp.vl["ESPStatus"]['TractionControlOn'] != 1
self.pcm_acc_status = pt_cp.vl["AcceleratorPedal2"]['CruiseState']
regen_pressed = False
ret.brakePressed = ret.brake > 1e-5
# Regen braking is braking
if self.car_fingerprint == CAR.VOLT:
regen_pressed = bool(pt_cp.vl["EBCMRegenPaddle"]['RegenPaddle'])
ret.brakePressed = ret.brakePressed or bool(pt_cp.vl["EBCMRegenPaddle"]['RegenPaddle'])
# Regen braking is braking
ret.brakePressed = ret.brake > 1e-5 or regen_pressed
ret.cruiseState.enabled = self.pcm_acc_status != AccState.OFF
ret.cruiseState.standstill = self.pcm_acc_status == AccState.STANDSTILL
# 0 - inactive, 1 - active, 2 - temporary limited, 3 - failed
self.lkas_status = pt_cp.vl["PSCMStatus"]['LKATorqueDeliveredStatus']
ret.steerWarning = not is_eps_status_ok(self.lkas_status, self.car_fingerprint)
ret.steerWarning = self.lkas_status not in [0, 1]
return ret

@ -72,7 +72,7 @@ def create_acc_dashboard_command(packer, bus, acc_engaged, target_speed_kph, lea
"ACCCmdActive" : acc_engaged,
"ACCAlwaysOne2" : 1,
"ACCLeadCar" : lead_car_in_sight,
"FCWAlert": fcw
"FCWAlert": 0x3 if fcw else 0
}
return packer.make_can_msg("ASCMActiveCruiseControlStatus", bus, values)
@ -104,8 +104,12 @@ def create_adas_accelerometer_speed_status(bus, speed_ms, idx):
dat += [(idx << 5) + (far_range_mode << 4) + (near_range_mode << 3) + (chksum >> 8), chksum & 0xff]
return make_can_msg(0x308, bytes(dat), bus)
def create_adas_headlights_status(bus):
return make_can_msg(0x310, b"\x42\x04", bus)
def create_adas_headlights_status(packer, bus):
values = {
"Always42": 0x42,
"Always4": 0x4,
}
return packer.make_can_msg("ASCMHeadlight", values, bus)
def create_lka_icon_command(bus, active, critical, steer):
if active and steer == 1:

@ -32,9 +32,6 @@ class CanBus:
CHASSIS = 2
SW_GMLAN = 3
def is_eps_status_ok(eps_status, car_fingerprint):
return eps_status in [0, 1]
FINGERPRINTS = {
# Astra BK MY17, ASCM unplugged
CAR.HOLDEN_ASTRA: [{

Loading…
Cancel
Save