mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-07 01:06:01 +08:00
button
This commit is contained in:
@@ -315,14 +315,8 @@ class CarState(CarStateBase):
|
||||
self.lkas_enabled = pt_cp.vl["ASCMSteeringButton"]["LKAButton"]
|
||||
self.pcm_acc_status = pt_cp.vl["AcceleratorPedal2"]["CruiseState"]
|
||||
|
||||
# Only activate cancel remap when panda safety was configured for it at startup.
|
||||
remap_cancel_to_distance = bool(self.CP.alternativeExperience & ALTERNATIVE_EXPERIENCE.GM_REMAP_CANCEL_TO_DISTANCE)
|
||||
if not remap_cancel_to_distance:
|
||||
remap_cancel_to_distance = (
|
||||
getattr(starpilot_toggles, "remap_cancel_to_distance", False) and
|
||||
self.CP.openpilotLongitudinalControl and
|
||||
bool(self.CP.flags & GMFlags.PEDAL_LONG.value) and
|
||||
self.CP.carFingerprint in (BOLT_CANCEL_BUTTON_CARS | {CAR.CHEVROLET_MALIBU_HYBRID_CC})
|
||||
)
|
||||
malibu_cancel_passthrough = (
|
||||
remap_cancel_to_distance and
|
||||
self.CP.carFingerprint == CAR.CHEVROLET_MALIBU_HYBRID_CC and
|
||||
|
||||
@@ -11,6 +11,8 @@ import opendbc.car.gm.interface as gm_interface
|
||||
from opendbc.car.common.conversions import Conversions as CV
|
||||
from opendbc.car.gm.fingerprints import FINGERPRINTS
|
||||
from opendbc.car.gm.values import CAMERA_ACC_CAR, CAR, CC_ONLY_CAR, DBC, GM_RX_OFFSET, GMFlags, GMSafetyFlags
|
||||
from opendbc.safety import ALTERNATIVE_EXPERIENCE
|
||||
from openpilot.common.params import Params
|
||||
|
||||
CAMERA_DIAGNOSTIC_ADDRESS = 0x24b
|
||||
VOLT_CARS = (
|
||||
@@ -32,6 +34,7 @@ def _test_starpilot_toggles():
|
||||
cluster_offset=1.0,
|
||||
disable_openpilot_long=False,
|
||||
force_fingerprint=False,
|
||||
remap_cancel_to_distance=False,
|
||||
vEgoStopping=0.5,
|
||||
volt_sng=False,
|
||||
)
|
||||
@@ -121,6 +124,23 @@ class TestGMInterface:
|
||||
assert "ECMAcceleratorPos" not in pt_parser.vl
|
||||
assert "EBCMBrakePedalPosition" in pt_parser.vl
|
||||
|
||||
def test_bolt_gen2_pedal_cancel_remap_sets_alt_exp(self):
|
||||
CarInterface = interfaces[CAR.CHEVROLET_BOLT_ACC_2022_2023_PEDAL]
|
||||
fingerprint = _empty_fingerprint()
|
||||
fingerprint[0][0x201] = 8
|
||||
|
||||
params = Params()
|
||||
toggles = _test_starpilot_toggles()
|
||||
try:
|
||||
params.put_bool("RemapCancelToDistance", True)
|
||||
car_params = CarInterface.get_params(CAR.CHEVROLET_BOLT_ACC_2022_2023_PEDAL, fingerprint, [], alpha_long=False,
|
||||
is_release=False, docs=False, starpilot_toggles=toggles)
|
||||
finally:
|
||||
params.remove("RemapCancelToDistance")
|
||||
|
||||
assert car_params.alternativeExperience & ALTERNATIVE_EXPERIENCE.GM_REMAP_CANCEL_TO_DISTANCE
|
||||
assert car_params.safetyConfigs[0].safetyParam & GMSafetyFlags.FLAG_GM_BOLT_2022_PEDAL.value
|
||||
|
||||
|
||||
class TestGMCarController:
|
||||
def test_dash_speed_spoof_respects_live_stock_acc_toggles(self):
|
||||
|
||||
@@ -225,8 +225,8 @@ static void gm_rx_hook(const CANPacket_t *msg) {
|
||||
// Malibu Hybrid pedal-long frames use byte3 bit0 in combinations that can alias
|
||||
// CANCEL semantics; don't force a safety disengage on those RX edges.
|
||||
bool malibu_cancel_passthrough = remap_cancel_to_distance && gm_bolt_2022_pedal && gm_pedal_long && ((msg->data[3] & 0x1U) != 0U);
|
||||
// Gen1 Bolt pedal-long uses CANCEL as an auxiliary input path.
|
||||
bool bolt_cancel_passthrough = remap_cancel_to_distance && gm_pedal_long && !gm_has_acc && !gm_bolt_2022_pedal;
|
||||
// No-ACC pedal-long Bolt paths use CANCEL as an auxiliary input path.
|
||||
bool bolt_cancel_passthrough = remap_cancel_to_distance && gm_pedal_long && !gm_has_acc;
|
||||
|
||||
// enter controls on falling edge of set or rising edge of resume (avoids fault)
|
||||
bool set = (button != GM_BTN_SET) && (cruise_button_prev == GM_BTN_SET);
|
||||
|
||||
@@ -414,6 +414,20 @@ class TestGmInterceptorSafety(common.GasInterceptorSafetyTest, TestGmCameraSafet
|
||||
self._rx(self._pcm_status_msg(enabled))
|
||||
self.assertEqual(enabled, self._tx(self._button_msg(Buttons.CANCEL)))
|
||||
|
||||
def test_cancel_remap_passthrough_does_not_disable_controls(self):
|
||||
for extra_safety_param in (0, GMSafetyFlags.FLAG_GM_BOLT_2022_PEDAL):
|
||||
self.safety.set_safety_hooks(
|
||||
CarParams.SafetyModel.gm,
|
||||
GMSafetyFlags.HW_CAM | GMSafetyFlags.FLAG_GM_NO_ACC | GMSafetyFlags.FLAG_GM_PEDAL_LONG |
|
||||
GMSafetyFlags.FLAG_GM_GAS_INTERCEPTOR | extra_safety_param,
|
||||
)
|
||||
self.safety.init_tests()
|
||||
self.safety.set_alternative_experience(0x40)
|
||||
self._rx(self._pcm_status_msg(True))
|
||||
self.safety.set_controls_allowed(True)
|
||||
self._rx(self._button_msg(Buttons.CANCEL))
|
||||
self.assertTrue(self.safety.get_controls_allowed())
|
||||
|
||||
def test_disable_control_allowed_from_cruise(self):
|
||||
pass
|
||||
|
||||
@@ -517,23 +531,6 @@ class TestGmCcLongitudinalPandaSchedSafety(TestGmCcLongitudinalSafety):
|
||||
self.assertTrue(self.safety.get_longitudinal_allowed())
|
||||
self._rx(self._interceptor_user_gas(0))
|
||||
self.assertTrue(self.safety.get_longitudinal_allowed())
|
||||
|
||||
def test_buttons(self):
|
||||
self.safety.set_controls_allowed(0)
|
||||
for btn in range(8):
|
||||
self.assertFalse(self._tx(self._button_msg(btn)))
|
||||
|
||||
self.safety.set_controls_allowed(1)
|
||||
for btn in range(8):
|
||||
self.assertFalse(self._tx(self._button_msg(btn)))
|
||||
|
||||
allowed_btns = {Buttons.UNPRESS, Buttons.RES_ACCEL, Buttons.DECEL_SET, Buttons.CANCEL}
|
||||
for enabled in (True, False):
|
||||
self._rx(self._pcm_status_msg(enabled))
|
||||
for btn in range(8):
|
||||
self.assertEqual(enabled and btn in allowed_btns, self._tx(self._button_msg(btn)))
|
||||
|
||||
|
||||
class TestGmVoltAutoHoldCameraSafety(TestGmCameraSafetyBase):
|
||||
TX_MSGS = TestGmCameraSafety.TX_MSGS + [[0x315, 0]]
|
||||
EXTRA_SAFETY_PARAM = GMSafetyFlags.FLAG_GM_PANDA_PADDLE_SCHED
|
||||
|
||||
Reference in New Issue
Block a user