mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-24 04:53:52 +08:00
Honda carstate: use common gas pedal signal (#22010)
* Honda carstate: refactor GAS_PEDAL handling * collapse SCM signal cases * stop using CAR_GAS signal (combined user pedal + computer) * cleanup * update refs * update refs Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
This commit is contained in:
@@ -10,7 +10,7 @@ from selfdrive.car.honda.values import CAR, DBC, STEER_THRESHOLD, SPEED_FACTOR,
|
||||
TransmissionType = car.CarParams.TransmissionType
|
||||
|
||||
|
||||
def get_can_signals(CP, gearbox_msg="GEARBOX"):
|
||||
def get_can_signals(CP, gearbox_msg):
|
||||
# this function generates lists for signal, messages and initial values
|
||||
signals = [
|
||||
("XMISSION_SPEED", "ENGINE_DATA", 0),
|
||||
@@ -78,13 +78,11 @@ def get_can_signals(CP, gearbox_msg="GEARBOX"):
|
||||
|
||||
if CP.carFingerprint in HONDA_BOSCH:
|
||||
signals += [
|
||||
("CAR_GAS", "GAS_PEDAL_2", 0),
|
||||
("MAIN_ON", "SCM_FEEDBACK", 0),
|
||||
("EPB_STATE", "EPB_STATUS", 0),
|
||||
]
|
||||
checks += [
|
||||
("EPB_STATUS", 50),
|
||||
("GAS_PEDAL_2", 100),
|
||||
]
|
||||
|
||||
if not CP.openpilotLongitudinalControl:
|
||||
@@ -126,43 +124,22 @@ def get_can_signals(CP, gearbox_msg="GEARBOX"):
|
||||
]
|
||||
|
||||
if CP.carFingerprint == CAR.CIVIC:
|
||||
signals += [("CAR_GAS", "GAS_PEDAL_2", 0),
|
||||
("MAIN_ON", "SCM_FEEDBACK", 0),
|
||||
signals += [("MAIN_ON", "SCM_FEEDBACK", 0),
|
||||
("IMPERIAL_UNIT", "HUD_SETTING", 0),
|
||||
("EPB_STATE", "EPB_STATUS", 0)]
|
||||
checks += [
|
||||
("HUD_SETTING", 50),
|
||||
("EPB_STATUS", 50),
|
||||
("GAS_PEDAL_2", 100),
|
||||
]
|
||||
elif CP.carFingerprint == CAR.ACURA_ILX:
|
||||
signals += [("CAR_GAS", "GAS_PEDAL_2", 0),
|
||||
("MAIN_ON", "SCM_BUTTONS", 0)]
|
||||
checks += [
|
||||
("GAS_PEDAL_2", 100),
|
||||
]
|
||||
elif CP.carFingerprint in (CAR.CRV, CAR.CRV_EU, CAR.ACURA_RDX, CAR.PILOT_2019, CAR.RIDGELINE):
|
||||
elif CP.carFingerprint in (CAR.ACURA_ILX, CAR.CRV, CAR.CRV_EU, CAR.ACURA_RDX, CAR.PILOT, CAR.PILOT_2019, CAR.RIDGELINE):
|
||||
signals += [("MAIN_ON", "SCM_BUTTONS", 0)]
|
||||
elif CP.carFingerprint == CAR.FIT:
|
||||
signals += [("CAR_GAS", "GAS_PEDAL_2", 0),
|
||||
("MAIN_ON", "SCM_BUTTONS", 0),
|
||||
("BRAKE_HOLD_ACTIVE", "VSA_STATUS", 0)]
|
||||
checks += [
|
||||
("GAS_PEDAL_2", 100),
|
||||
]
|
||||
elif CP.carFingerprint == CAR.HRV:
|
||||
elif CP.carFingerprint in (CAR.FIT, CAR.HRV):
|
||||
signals += [("MAIN_ON", "SCM_BUTTONS", 0),
|
||||
("BRAKE_HOLD_ACTIVE", "VSA_STATUS", 0)]
|
||||
elif CP.carFingerprint == CAR.ODYSSEY:
|
||||
signals += [("MAIN_ON", "SCM_FEEDBACK", 0),
|
||||
("EPB_STATE", "EPB_STATUS", 0)]
|
||||
checks += [("EPB_STATUS", 50)]
|
||||
elif CP.carFingerprint == CAR.PILOT:
|
||||
signals += [("MAIN_ON", "SCM_BUTTONS", 0),
|
||||
("CAR_GAS", "GAS_PEDAL_2", 0)]
|
||||
checks += [
|
||||
("GAS_PEDAL_2", 0), # TODO: fix this freq, seems this signal isn't present at all on some models
|
||||
]
|
||||
elif CP.carFingerprint == CAR.ODYSSEY_CHN:
|
||||
signals += [("MAIN_ON", "SCM_BUTTONS", 0),
|
||||
("EPB_STATE", "EPB_STATUS", 0)]
|
||||
@@ -277,20 +254,15 @@ class CarState(CarStateBase):
|
||||
gear = int(cp.vl[self.gearbox_msg]["GEAR_SHIFTER"])
|
||||
ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(gear, None))
|
||||
|
||||
pedal_gas = cp.vl["POWERTRAIN_DATA"]["PEDAL_GAS"]
|
||||
# crv doesn't include cruise control
|
||||
if self.CP.carFingerprint in (CAR.CRV, CAR.CRV_EU, CAR.HRV, CAR.ODYSSEY, CAR.ACURA_RDX, CAR.RIDGELINE, CAR.PILOT_2019, CAR.ODYSSEY_CHN):
|
||||
ret.gas = pedal_gas / 256.
|
||||
else:
|
||||
ret.gas = cp.vl["GAS_PEDAL_2"]["CAR_GAS"] / 256.
|
||||
ret.gas = cp.vl["POWERTRAIN_DATA"]["PEDAL_GAS"]
|
||||
|
||||
# this is a hack for the interceptor. This is now only used in the simulation
|
||||
# TODO: Replace tests by toyota so this can go away
|
||||
if self.CP.enableGasInterceptor:
|
||||
user_gas = (cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS"] + cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS2"]) / 2.
|
||||
ret.gasPressed = user_gas > 1e-5 # this works because interceptor read < 0 when pedal position is 0. Once calibrated, this will change
|
||||
ret.gasPressed = user_gas > 1e-5 # this works because interceptor reads < 0 when pedal position is 0. Once calibrated, this will change
|
||||
else:
|
||||
ret.gasPressed = pedal_gas > 1e-5
|
||||
ret.gasPressed = ret.gas > 1e-5
|
||||
|
||||
ret.steeringTorque = cp.vl["STEER_STATUS"]["STEER_TORQUE_SENSOR"]
|
||||
ret.steeringTorqueEps = cp.vl["STEER_MOTOR_TORQUE"]["MOTOR_TORQUE"]
|
||||
|
||||
@@ -1 +1 @@
|
||||
68db6ee0d2afb80b0d271788b3028de6db2da45e
|
||||
b631f006877b2576163e66435d800fc0a565189f
|
||||
Reference in New Issue
Block a user