Show the Low gear requirement on early Bolt pedal profiles

This commit is contained in:
firestar5683
2026-11-22 13:23:41 -06:00
parent f2c632ef11
commit ae4df1725c
7 changed files with 79 additions and 5 deletions
+5
View File
@@ -951,6 +951,11 @@ def is_bolt_pedal_profile(cp, *, stock_only=False):
return _bolt_pedal_profile(cp, stock_only=stock_only)
def bolt_pedal_in_drive_requires_low(cp, gear):
return (gear == 'drive' and getattr(cp, 'carFingerprint', None) in (CAR.CHEVROLET_BOLT_CC_2017, CAR.CHEVROLET_BOLT_CC_2018_2021) and
is_bolt_pedal_profile(cp))
@cached_config
def _bolt_pedal_profile(cp, *, stock_only=False):
"""Exact selected interceptor profile, including its startup authority reduction."""
+13 -1
View File
@@ -42,7 +42,7 @@ from opendbc.car.gm.steering_authority import monitored_profile
from openpilot.starpilot.car.gm.steering_companion import SteeringCompanion
from openpilot.starpilot.car.hyundai.aol import qualified_ioniq6
from opendbc.car.gm.values import CAR as GM_CAR
from opendbc.car.gm.values import GMFlags, is_ordinary_camera_profile, is_volt_ascm_longitudinal, malibu_hybrid_profile
from opendbc.car.gm.values import GMFlags, bolt_pedal_in_drive_requires_low, is_ordinary_camera_profile, is_volt_ascm_longitudinal, malibu_hybrid_profile
from openpilot.starpilot.aol.intent import read_settings
from openpilot.starpilot.aol.intent_companion import IntentCompanion
from openpilot.starpilot.aol.transport_pause import AvailabilityPause, TransportPause, availability_only, cp_identity, healthy_transport
@@ -1188,6 +1188,18 @@ class SelfdriveD:
[ET.SOFT_DISABLE], [self.CP, CS, self.sm, self.is_metric, 0, pers]) if alert.alert_type != 'doorOpen/softDisable')
alerts.extend(alert for alert in getattr(self, 'tesla_stock_alerts', [])
if alert.event_type in self.state_machine.current_alert_types)
shift_alert_type = 'boltPedalShiftToLow/permanent'
if bolt_pedal_in_drive_requires_low(self.CP, CS.gearShifter):
samples = getattr(self, 'car_state_samples', ()) or ((CS, getattr(self, 'conditional_car_state_valid', False)),)
if any(valid and sample.canValid and not sample.canTimeout and sample.gearShifter == 'drive' and sample.buttonEnable
for sample, valid in samples):
alert = Alert("Shift to L for speed control", "", log.SelfdriveState.AlertStatus.normal,
log.SelfdriveState.AlertSize.small, AlertPriority.LOW, car.CarControl.HUDControl.VisualAlert.none,
log.SelfdriveState.AudibleAlert.none, 3.)
alert.alert_type, alert.event_type = shift_alert_type, ET.PERMANENT
alerts.append(alert)
else:
self.AM.alerts.pop(shift_alert_type, None)
now_ns = time.monotonic_ns()
drive = int(self.sm['deviceState'].startedMonoTime) if self.sm['deviceState'].started else 0
from openpilot.starpilot.audio.blindspot_alert import ALERT_TYPE as BSM_ALERT, blindspot_alert
@@ -3,6 +3,7 @@
from openpilot.starpilot.ui.raylib import rl
from openpilot.cereal import log
from opendbc.car.gm.values import bolt_pedal_in_drive_requires_low
from openpilot.selfdrive.ui.ui_state import ui_state
from openpilot.starpilot.ui.onroad_personality import PersonalityWidget
from openpilot.system.ui.widgets import Widget
@@ -20,7 +21,9 @@ class LongIndicator(Widget):
def _render(self, rect: rl.Rectangle) -> None:
sm = ui_state.sm
if (sm.recv_frame['selfdriveState'] < ui_state.started_frame or
not sm['selfdriveState'].enabled or not ui_state.has_longitudinal_control):
not sm['selfdriveState'].enabled or not ui_state.has_longitudinal_control or
(sm.alive['carState'] and sm.valid['carState'] and sm.recv_frame['carState'] >= ui_state.started_frame and
bolt_pedal_in_drive_requires_low(ui_state.CP, sm['carState'].gearShifter))):
self.indicator.reset()
return
self.indicator.draw(
@@ -105,3 +105,42 @@ def test_trax_keeps_braking_below_entry_speed_only_when_engaged(engaged):
cs.brakePressed = True
_, _, control = step(len(speeds) + 1, observed_state=cs)
assert not control.longActive
@pytest.mark.parametrize(('candidate', 'pedal', 'show_alert'), [
(CAR.CHEVROLET_BOLT_CC_2017, True, True),
(CAR.CHEVROLET_BOLT_CC_2018_2021, True, True),
(CAR.CHEVROLET_BOLT_CC_2017, False, False),
(CAR.CHEVROLET_BOLT_CC_2022_2023, True, False),
(CAR.CHEVROLET_BOLT_ACC_2022_2023_PEDAL, True, False),
])
def test_bolt_shift_to_low_is_a_display_only_button_alert(candidate, pedal, show_alert):
from opendbc.car.gm.carstate import CarState
from opendbc.car.gm.tests.test_bolt_pedal import params as bolt_params
with OpenpilotPrefix(), ExitStack() as cleanup:
cp = bolt_params(candidate, pedal=pedal)
car_state = CarState(cp)
case = fixture.IoniqAvailabilityTests(methodName='runTest')
cleanup.callback(case.doCleanups)
sd, _, step = case._authority_callers(True, cp=cp, genuine_events=True)
sd.aol_settings = read_settings(sd.params)
message = 'Shift to L for speed control'
for tick, (gear, button, pressed) in enumerate((
('drive', 'decelCruise', True),
('drive', 'decelCruise', False),
('low', 'decelCruise', False),
('drive', 'accelCruise', True),
('low', 'accelCruise', True),
)):
cs = fixture.car_state()
cs.gearShifter = gear
cs.vCruise = 65.
cs.cruiseState.enabled = True
cs.buttonEvents = [structs.CarState.ButtonEvent(type=button, pressed=pressed)]
cs.buttonEnable = car_state.update_button_enable(cs.buttonEvents)
axis, host, control = step(tick, observed_state=cs)
assert (host.alertText1 == message) == (show_alert and tick in (1, 3))
if show_alert:
assert axis.longitudinalActive and control.longActive
assert axis.lateralActive and control.latActive
+4 -2
View File
@@ -39,6 +39,7 @@ from openpilot.starpilot.ui.live_developer_sidebar import DeveloperMetrics
from openpilot.cereal import log
from openpilot.cereal.services import SERVICE_LIST
from openpilot.tools.replay.display_clock import BOOT_TIME_SERVICES
from opendbc.car.gm.values import bolt_pedal_in_drive_requires_low
from opendbc.car.structs import car as car_schema
from openpilot.starpilot.ui.device_state import DeviceRequest, DeviceState
from openpilot.starpilot.ui.home_state import DriveStatsData, HomeMode, HomeState
@@ -692,8 +693,9 @@ class RuntimeSnapshotAdapter:
display_control is not None and not getattr(getattr(display_control, 'hudControl', None), 'lanesVisible', True)
)
display_lat_active = bool(display_control.latActive) if (display_control is not None and not legacy_2025_lateral_off) else False
display_long_active = bool(display_control.longActive) if display_control is not None else False
long_engaged = bool(display_selfdrive is not None and getattr(display_selfdrive, 'enabled', False))
bolt_needs_low = display_car_valid and bolt_pedal_in_drive_requires_low(cp, getattr(display_car, 'gearShifter', None))
display_long_active = bool(display_control is not None and display_control.longActive and not bolt_needs_low)
long_engaged = bool(display_selfdrive is not None and getattr(display_selfdrive, 'enabled', False) and not bolt_needs_low)
if getattr(ui, 'aol_runtime', False):
# Display only: the control-side 30 ms proof window would blink the override edge whenever a frame runs late.
axis = display_message(sm, 'aolAxisState', now_ns, after_frame=after) if started else None
@@ -59,6 +59,19 @@ class TestOnroadAxes(unittest.TestCase):
intent = IntentState('card-ui', 1, NOW, NOW, NOW + 200_000_000, False, True, False, True, armed)
self.ui.sm.put('aolIntentWire', encode_intent(replace(intent, **changes)))
def test_older_bolt_pedal_in_drive_displays_lateral_without_speed_control(self):
from opendbc.car.gm.tests.test_bolt_pedal import params
from opendbc.car.gm.values import CAR
for candidate in (CAR.CHEVROLET_BOLT_CC_2017, CAR.CHEVROLET_BOLT_CC_2018_2021, CAR.CHEVROLET_BOLT_CC_2022_2023):
self.ui.CP = params(candidate, pedal=True)
for gear in ('drive', 'low'):
with self.subTest(candidate=candidate, gear=gear):
self.ui.sm['carState'].gearShifter = gear
state = self.state(True, True)
self.assertTrue(state.lateral_active)
self.assertEqual(state.longitudinal_active, gear == 'low' or candidate == CAR.CHEVROLET_BOLT_CC_2022_2023)
def test_armed_latch_keeps_intent_but_not_active_color_when_steering_pauses(self):
self.ui.aol_runtime = True
self.publish_latch()
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "936329cf7999bc9c7f993132857879b62f64a5da290cd77b8d6c8868f1f73834", "schema_version": 1}
{"protected_inventory_sha256": "024d2fb0df2ea1ba92ff4188ccb345f90f5f0307b396910f333d8507f7c50af7", "schema_version": 1}