openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
6.6 KiB

5 years ago
from cereal import car
GM: Bolt EUV 2022-23 port (#24875) * Switch to ECMPRDNL2 for GM gear * Removing manumatic gear # * values.py almost complete * Silverado and Bolt EUV val and CP * GM controller updated * Cam hrns supp done (in theory) * cleanup for new cars * Remove extra constant * WS, etc cleanup * removing the unused * Fix kpBP typo * Updated docs * Skip's PIF tune * Dropped LKA CAN error patch * Add silverado sigmoid ff * CAN Err & LKA latch patch * Remove EPS fault fix (another PR) * Remove Silverado (another PR) * clean up some common params * Remove Escalade FP Remove Escalade FP * comment * Premier is just a trim Premier is just a trim Premier is just a trim * no footnote: new Bolt is like most other cars, older GM were outliers not at the camera * clean up clean up * bump panda * bump panda * bump panda * bump panda * bump panda * remove comments * try spamming buttons on bus 2 * bump panda * bumping opendbc w btn rc * not needed for this port This reverts commit 6af1f0ba799e075f877d7acc8ca0f117d97da361. * add button safety * Send next rc when spamming btns * forward other signals in message * missing DriveModeButton * fill cruiseState.speed * see if resume works without counter * try the whole message * send immediately and at 10Hz * no resume, back to just button signal * even holding random buttons it cancels * Use torque controller with base tune * stock long GM don't auto-resume yet * Testing GM zero min steer speed * Revert latcontrol * revert opendbc * latActive is basically lkas_enabled * Update Bolt torque params * comment * clean up * Add to releases * Add test route * Don't specify segment * bump panda * bump panda * no harness for Bolt just yet * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * We support all and 2023 * move safetyParam up to first cam check * Bump panda and update docs * Update RELEASES.md Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Shane Smiskol <shane@smiskol.com> Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
3 years ago
from common.conversions import Conversions as CV
5 years ago
from common.numpy_fast import mean
from opendbc.can.can_define import CANDefine
5 years ago
from opendbc.can.parser import CANParser
from selfdrive.car.interfaces import CarStateBase
from selfdrive.car.gm.values import DBC, AccState, CanBus, STEER_THRESHOLD
TransmissionType = car.CarParams.TransmissionType
GM: Bolt EUV 2022-23 port (#24875) * Switch to ECMPRDNL2 for GM gear * Removing manumatic gear # * values.py almost complete * Silverado and Bolt EUV val and CP * GM controller updated * Cam hrns supp done (in theory) * cleanup for new cars * Remove extra constant * WS, etc cleanup * removing the unused * Fix kpBP typo * Updated docs * Skip's PIF tune * Dropped LKA CAN error patch * Add silverado sigmoid ff * CAN Err & LKA latch patch * Remove EPS fault fix (another PR) * Remove Silverado (another PR) * clean up some common params * Remove Escalade FP Remove Escalade FP * comment * Premier is just a trim Premier is just a trim Premier is just a trim * no footnote: new Bolt is like most other cars, older GM were outliers not at the camera * clean up clean up * bump panda * bump panda * bump panda * bump panda * bump panda * remove comments * try spamming buttons on bus 2 * bump panda * bumping opendbc w btn rc * not needed for this port This reverts commit 6af1f0ba799e075f877d7acc8ca0f117d97da361. * add button safety * Send next rc when spamming btns * forward other signals in message * missing DriveModeButton * fill cruiseState.speed * see if resume works without counter * try the whole message * send immediately and at 10Hz * no resume, back to just button signal * even holding random buttons it cancels * Use torque controller with base tune * stock long GM don't auto-resume yet * Testing GM zero min steer speed * Revert latcontrol * revert opendbc * latActive is basically lkas_enabled * Update Bolt torque params * comment * clean up * Add to releases * Add test route * Don't specify segment * bump panda * bump panda * no harness for Bolt just yet * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * We support all and 2023 * move safetyParam up to first cam check * Bump panda and update docs * Update RELEASES.md Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Shane Smiskol <shane@smiskol.com> Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
3 years ago
NetworkLocation = car.CarParams.NetworkLocation
5 years ago
class CarState(CarStateBase):
def __init__(self, CP):
super().__init__(CP)
can_define = CANDefine(DBC[CP.carFingerprint]["pt"])
self.shifter_values = can_define.dv["ECMPRDNL2"]["PRNDL2"]
self.lka_steering_cmd_counter = 0
5 years ago
GM: Bolt EUV 2022-23 port (#24875) * Switch to ECMPRDNL2 for GM gear * Removing manumatic gear # * values.py almost complete * Silverado and Bolt EUV val and CP * GM controller updated * Cam hrns supp done (in theory) * cleanup for new cars * Remove extra constant * WS, etc cleanup * removing the unused * Fix kpBP typo * Updated docs * Skip's PIF tune * Dropped LKA CAN error patch * Add silverado sigmoid ff * CAN Err & LKA latch patch * Remove EPS fault fix (another PR) * Remove Silverado (another PR) * clean up some common params * Remove Escalade FP Remove Escalade FP * comment * Premier is just a trim Premier is just a trim Premier is just a trim * no footnote: new Bolt is like most other cars, older GM were outliers not at the camera * clean up clean up * bump panda * bump panda * bump panda * bump panda * bump panda * remove comments * try spamming buttons on bus 2 * bump panda * bumping opendbc w btn rc * not needed for this port This reverts commit 6af1f0ba799e075f877d7acc8ca0f117d97da361. * add button safety * Send next rc when spamming btns * forward other signals in message * missing DriveModeButton * fill cruiseState.speed * see if resume works without counter * try the whole message * send immediately and at 10Hz * no resume, back to just button signal * even holding random buttons it cancels * Use torque controller with base tune * stock long GM don't auto-resume yet * Testing GM zero min steer speed * Revert latcontrol * revert opendbc * latActive is basically lkas_enabled * Update Bolt torque params * comment * clean up * Add to releases * Add test route * Don't specify segment * bump panda * bump panda * no harness for Bolt just yet * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * We support all and 2023 * move safetyParam up to first cam check * Bump panda and update docs * Update RELEASES.md Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Shane Smiskol <shane@smiskol.com> Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
3 years ago
def update(self, pt_cp, cam_cp, loopback_cp):
ret = car.CarState.new_message()
5 years ago
self.prev_cruise_buttons = self.cruise_buttons
self.cruise_buttons = pt_cp.vl["ASCMSteeringButton"]["ACCButtons"]
5 years ago
ret.wheelSpeeds = self.get_wheel_speeds(
pt_cp.vl["EBCMWheelSpdFront"]["FLWheelSpd"],
pt_cp.vl["EBCMWheelSpdFront"]["FRWheelSpd"],
pt_cp.vl["EBCMWheelSpdRear"]["RLWheelSpd"],
pt_cp.vl["EBCMWheelSpdRear"]["RRWheelSpd"],
)
ret.vEgoRaw = mean([ret.wheelSpeeds.fl, ret.wheelSpeeds.fr, ret.wheelSpeeds.rl, ret.wheelSpeeds.rr])
ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw)
ret.standstill = ret.vEgoRaw < 0.01
if pt_cp.vl["ECMPRDNL2"]["ManualMode"] == 1:
ret.gearShifter = self.parse_gear_shifter("T")
else:
ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(pt_cp.vl["ECMPRDNL2"]["PRNDL2"], None))
# Brake pedal's potentiometer returns near-zero reading even when pedal is not pressed.
ret.brake = pt_cp.vl["EBCMBrakePedalPosition"]["BrakePedalPosition"] / 0xd0
ret.brakePressed = pt_cp.vl["EBCMBrakePedalPosition"]["BrakePedalPosition"] >= 10
# Regen braking is braking
if self.CP.transmissionType == TransmissionType.direct:
ret.brakePressed = ret.brakePressed or pt_cp.vl["EBCMRegenPaddle"]["RegenPaddle"] != 0
5 years ago
ret.gas = pt_cp.vl["AcceleratorPedal2"]["AcceleratorPedal2"] / 254.
ret.gasPressed = ret.gas > 1e-5
5 years ago
ret.steeringAngleDeg = pt_cp.vl["PSCMSteeringAngle"]["SteeringWheelAngle"]
ret.steeringRateDeg = pt_cp.vl["PSCMSteeringAngle"]["SteeringWheelRate"]
ret.steeringTorque = pt_cp.vl["PSCMStatus"]["LKADriverAppldTrq"]
ret.steeringTorqueEps = pt_cp.vl["PSCMStatus"]["LKATorqueDelivered"]
ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD
self.lka_steering_cmd_counter = loopback_cp.vl["ASCMLKASteeringCmd"]["RollingCounter"]
5 years ago
# 0 inactive, 1 active, 2 temporarily limited, 3 failed
self.lkas_status = pt_cp.vl["PSCMStatus"]["LKATorqueDeliveredStatus"]
ret.steerFaultTemporary = self.lkas_status == 2
ret.steerFaultPermanent = self.lkas_status == 3
5 years ago
# 1 - open, 0 - closed
ret.doorOpen = (pt_cp.vl["BCMDoorBeltStatus"]["FrontLeftDoor"] == 1 or
pt_cp.vl["BCMDoorBeltStatus"]["FrontRightDoor"] == 1 or
pt_cp.vl["BCMDoorBeltStatus"]["RearLeftDoor"] == 1 or
pt_cp.vl["BCMDoorBeltStatus"]["RearRightDoor"] == 1)
5 years ago
# 1 - latched
ret.seatbeltUnlatched = pt_cp.vl["BCMDoorBeltStatus"]["LeftSeatBelt"] == 0
ret.leftBlinker = pt_cp.vl["BCMTurnSignals"]["TurnSignals"] == 1
ret.rightBlinker = pt_cp.vl["BCMTurnSignals"]["TurnSignals"] == 2
5 years ago
ret.parkingBrake = pt_cp.vl["VehicleIgnitionAlt"]["ParkBrake"] == 1
ret.cruiseState.available = pt_cp.vl["ECMEngineStatus"]["CruiseMainOn"] != 0
ret.espDisabled = pt_cp.vl["ESPStatus"]["TractionControlOn"] != 1
ret.accFaulted = pt_cp.vl["AcceleratorPedal2"]["CruiseState"] == AccState.FAULTED
ret.cruiseState.enabled = pt_cp.vl["AcceleratorPedal2"]["CruiseState"] != AccState.OFF
ret.cruiseState.standstill = pt_cp.vl["AcceleratorPedal2"]["CruiseState"] == AccState.STANDSTILL
GM: Bolt EUV 2022-23 port (#24875) * Switch to ECMPRDNL2 for GM gear * Removing manumatic gear # * values.py almost complete * Silverado and Bolt EUV val and CP * GM controller updated * Cam hrns supp done (in theory) * cleanup for new cars * Remove extra constant * WS, etc cleanup * removing the unused * Fix kpBP typo * Updated docs * Skip's PIF tune * Dropped LKA CAN error patch * Add silverado sigmoid ff * CAN Err & LKA latch patch * Remove EPS fault fix (another PR) * Remove Silverado (another PR) * clean up some common params * Remove Escalade FP Remove Escalade FP * comment * Premier is just a trim Premier is just a trim Premier is just a trim * no footnote: new Bolt is like most other cars, older GM were outliers not at the camera * clean up clean up * bump panda * bump panda * bump panda * bump panda * bump panda * remove comments * try spamming buttons on bus 2 * bump panda * bumping opendbc w btn rc * not needed for this port This reverts commit 6af1f0ba799e075f877d7acc8ca0f117d97da361. * add button safety * Send next rc when spamming btns * forward other signals in message * missing DriveModeButton * fill cruiseState.speed * see if resume works without counter * try the whole message * send immediately and at 10Hz * no resume, back to just button signal * even holding random buttons it cancels * Use torque controller with base tune * stock long GM don't auto-resume yet * Testing GM zero min steer speed * Revert latcontrol * revert opendbc * latActive is basically lkas_enabled * Update Bolt torque params * comment * clean up * Add to releases * Add test route * Don't specify segment * bump panda * bump panda * no harness for Bolt just yet * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * We support all and 2023 * move safetyParam up to first cam check * Bump panda and update docs * Update RELEASES.md Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Shane Smiskol <shane@smiskol.com> Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
3 years ago
if self.CP.networkLocation == NetworkLocation.fwdCamera:
ret.cruiseState.speed = cam_cp.vl["ASCMActiveCruiseControlStatus"]["ACCSpeedSetpoint"] * CV.KPH_TO_MS
return ret
GM: Bolt EUV 2022-23 port (#24875) * Switch to ECMPRDNL2 for GM gear * Removing manumatic gear # * values.py almost complete * Silverado and Bolt EUV val and CP * GM controller updated * Cam hrns supp done (in theory) * cleanup for new cars * Remove extra constant * WS, etc cleanup * removing the unused * Fix kpBP typo * Updated docs * Skip's PIF tune * Dropped LKA CAN error patch * Add silverado sigmoid ff * CAN Err & LKA latch patch * Remove EPS fault fix (another PR) * Remove Silverado (another PR) * clean up some common params * Remove Escalade FP Remove Escalade FP * comment * Premier is just a trim Premier is just a trim Premier is just a trim * no footnote: new Bolt is like most other cars, older GM were outliers not at the camera * clean up clean up * bump panda * bump panda * bump panda * bump panda * bump panda * remove comments * try spamming buttons on bus 2 * bump panda * bumping opendbc w btn rc * not needed for this port This reverts commit 6af1f0ba799e075f877d7acc8ca0f117d97da361. * add button safety * Send next rc when spamming btns * forward other signals in message * missing DriveModeButton * fill cruiseState.speed * see if resume works without counter * try the whole message * send immediately and at 10Hz * no resume, back to just button signal * even holding random buttons it cancels * Use torque controller with base tune * stock long GM don't auto-resume yet * Testing GM zero min steer speed * Revert latcontrol * revert opendbc * latActive is basically lkas_enabled * Update Bolt torque params * comment * clean up * Add to releases * Add test route * Don't specify segment * bump panda * bump panda * no harness for Bolt just yet * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * We support all and 2023 * move safetyParam up to first cam check * Bump panda and update docs * Update RELEASES.md Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Shane Smiskol <shane@smiskol.com> Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
3 years ago
@staticmethod
def get_cam_can_parser(CP):
signals = []
checks = []
if CP.networkLocation == NetworkLocation.fwdCamera:
signals.append(("ACCSpeedSetpoint", "ASCMActiveCruiseControlStatus"))
checks.append(("ASCMActiveCruiseControlStatus", 25))
return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, CanBus.CAMERA)
@staticmethod
def get_can_parser(CP):
signals = [
# sig_name, sig_address
("BrakePedalPosition", "EBCMBrakePedalPosition"),
("FrontLeftDoor", "BCMDoorBeltStatus"),
("FrontRightDoor", "BCMDoorBeltStatus"),
("RearLeftDoor", "BCMDoorBeltStatus"),
("RearRightDoor", "BCMDoorBeltStatus"),
("LeftSeatBelt", "BCMDoorBeltStatus"),
("RightSeatBelt", "BCMDoorBeltStatus"),
("TurnSignals", "BCMTurnSignals"),
("AcceleratorPedal2", "AcceleratorPedal2"),
("CruiseState", "AcceleratorPedal2"),
("ACCButtons", "ASCMSteeringButton"),
("SteeringWheelAngle", "PSCMSteeringAngle"),
("SteeringWheelRate", "PSCMSteeringAngle"),
("FLWheelSpd", "EBCMWheelSpdFront"),
("FRWheelSpd", "EBCMWheelSpdFront"),
("RLWheelSpd", "EBCMWheelSpdRear"),
("RRWheelSpd", "EBCMWheelSpdRear"),
("PRNDL2", "ECMPRDNL2"),
("ManualMode", "ECMPRDNL2"),
("LKADriverAppldTrq", "PSCMStatus"),
("LKATorqueDelivered", "PSCMStatus"),
("LKATorqueDeliveredStatus", "PSCMStatus"),
("TractionControlOn", "ESPStatus"),
("ParkBrake", "VehicleIgnitionAlt"),
("CruiseMainOn", "ECMEngineStatus"),
]
checks = [
("BCMTurnSignals", 1),
("ECMPRDNL2", 10),
("PSCMStatus", 10),
("ESPStatus", 10),
("BCMDoorBeltStatus", 10),
("VehicleIgnitionAlt", 10),
("EBCMWheelSpdFront", 20),
("EBCMWheelSpdRear", 20),
("AcceleratorPedal2", 33),
("ASCMSteeringButton", 33),
("ECMEngineStatus", 100),
("PSCMSteeringAngle", 100),
("EBCMBrakePedalPosition", 100),
]
if CP.transmissionType == TransmissionType.direct:
signals.append(("RegenPaddle", "EBCMRegenPaddle"))
checks.append(("EBCMRegenPaddle", 50))
return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, CanBus.POWERTRAIN)
@staticmethod
def get_loopback_can_parser(CP):
signals = [
("RollingCounter", "ASCMLKASteeringCmd"),
]
checks = [
("ASCMLKASteeringCmd", 10), # 10 Hz is the stock inactive rate (every 100ms).
# While active 50 Hz (every 20 ms) is normal
# EPS will tolerate around 200ms when active before faulting
]
return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, CanBus.LOOPBACK)