Merge remote-tracking branch 'sunnypilot/sunnypilot/master' into hkg-angle-steering-2025

This commit is contained in:
Jason Wen
2026-02-09 01:46:00 -05:00
12 changed files with 235 additions and 42 deletions
+1 -1
View File
@@ -249,7 +249,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"OsmStateTitle", {PERSISTENT, STRING}},
{"OsmWayTest", {PERSISTENT, STRING}},
{"RoadName", {CLEAR_ON_ONROAD_TRANSITION, STRING}},
{"RoadNameToggle", {PERSISTENT, STRING}},
{"RoadNameToggle", {PERSISTENT | BACKUP, BOOL, "0"}},
// Speed Limit
{"SpeedLimitMode", {PERSISTENT | BACKUP, INT, "1"}},
@@ -5,9 +5,18 @@ This file is part of sunnypilot and is licensed under the MIT License.
See the LICENSE.md file in the root directory for more details.
"""
from openpilot.common.params import Params
from openpilot.selfdrive.ui.ui_state import ui_state
from openpilot.system.ui.lib.multilang import tr, tr_noop
from openpilot.system.ui.sunnypilot.widgets.list_view import toggle_item_sp, multiple_button_item_sp
from openpilot.system.ui.widgets.scroller_tici import Scroller
from openpilot.system.ui.widgets import Widget
CHEVRON_INFO_DESCRIPTION = {
"enabled": tr_noop("Display useful metrics below the chevron that tracks the lead car " +
"only applicable to cars with sunnypilot longitudinal control."),
"disabled": tr_noop("This feature requires sunnypilot longitudinal control to be available.")
}
class VisualsLayout(Widget):
def __init__(self):
@@ -18,13 +27,128 @@ class VisualsLayout(Widget):
self._scroller = Scroller(items, line_separator=True, spacing=0)
def _initialize_items(self):
items = [
self._toggle_defs = {
"BlindSpot": (
lambda: tr("Show Blind Spot Warnings"),
tr("Enabling this will display warnings when a vehicle is detected in your " +
"blind spot as long as your car has BSM supported."),
None,
),
"TorqueBar": (
lambda: tr("Steering Arc"),
tr("Display steering arc on the driving screen when lateral control is enabled."),
None,
),
"RainbowMode": (
lambda: tr("Enable Tesla Rainbow Mode"),
tr("A beautiful rainbow effect on the path the model wants to take. " +
"It does not affect driving in any way."),
None,
),
"StandstillTimer": (
lambda: tr("Enable Standstill Timer"),
tr("Show a timer on the HUD when the car is at a standstill."),
None,
),
"RoadNameToggle": (
lambda: tr("Display Road Name"),
tr("Displays the name of the road the car is traveling on." +
"<br>The OpenStreetMap database of the location must be downloaded from " +
"the OSM panel to fetch the road name."),
None,
),
"GreenLightAlert": (
lambda: tr("Green Traffic Light Alert (Beta)"),
tr("A chime and on-screen alert will play when the traffic light you are waiting for " +
"turns green and you have no vehicle in front of you." +
"<br>Note: This chime is only designed as a notification. " +
"It is the driver's responsibility to observe their environment and make decisions accordingly."),
None,
),
"LeadDepartAlert": (
lambda: tr("Lead Departure Alert (Beta)"),
tr("A chime and on-screen alert will play when you are stopped, and the vehicle in front of you start moving." +
"<br>Note: This chime is only designed as a notification. " +
"It is the driver's responsibility to observe their environment and make decisions accordingly."),
None,
),
"TrueVEgoUI": (
lambda: tr("Speedometer: Always Display True Speed"),
tr("For applicable vehicles, always display the true vehicle current speed from wheel speed sensors."),
None,
),
"HideVEgoUI": (
lambda: tr("Speedometer: Hide from Onroad Screen"),
tr("When enabled, the speedometer on the onroad screen is not displayed."),
None,
),
"ShowTurnSignals": (
lambda: tr("Display Turn Signals"),
tr("When enabled, visual turn indicators are drawn on the HUD."),
None,
),
"RocketFuel": (
lambda: tr("Real-time Acceleration Bar"),
tr("Show an indicator on the left side of the screen to display real-time vehicle acceleration and deceleration. " +
"This displays what the car is currently doing, not what the planner is requesting."),
None,
),
}
self._toggles = {}
for param, (title, desc, callback) in self._toggle_defs.items():
toggle = toggle_item_sp(
title=title,
description=desc,
param=param,
initial_state=ui_state.params.get_bool(param),
callback=callback,
)
self._toggles[param] = toggle
self._chevron_info = multiple_button_item_sp(
title=lambda: tr("Display Metrics Below Chevron"),
description="",
buttons=[lambda: tr("Off"), lambda: tr("Distance"), lambda: tr("Speed"), lambda: tr("Time"), lambda: tr("All")],
param="ChevronInfo",
inline=False
)
self._dev_ui_info = multiple_button_item_sp(
title=lambda: tr("Developer UI"),
description=lambda: tr("Display real-time parameters and metrics from various sources."),
buttons=[lambda: tr("Off"), lambda: tr("Bottom"), lambda: tr("Right"), lambda: tr("Right & Bottom")],
param="DevUIInfo",
button_width=350,
inline=False
)
items = list(self._toggles.values()) + [
self._chevron_info,
self._dev_ui_info,
]
return items
def _update_state(self):
super()._update_state()
for param in self._toggle_defs:
self._toggles[param].action_item.set_state(self._params.get_bool(param))
self._dev_ui_info.action_item.set_selected_button(ui_state.params.get("DevUIInfo", return_default=True))
if ui_state.has_longitudinal_control:
self._chevron_info.set_description(tr(CHEVRON_INFO_DESCRIPTION["enabled"]))
self._chevron_info.action_item.set_selected_button(ui_state.params.get("ChevronInfo", return_default=True))
self._chevron_info.action_item.set_enabled(True)
else:
self._chevron_info.set_description(tr(CHEVRON_INFO_DESCRIPTION["disabled"]))
self._chevron_info.action_item.set_enabled(False)
ui_state.params.put("ChevronInfo", 0)
def _render(self, rect):
self._scroller.render(rect)
def show_event(self):
self._scroller.show_event()
if not ui_state.has_longitudinal_control:
self._chevron_info.set_description(tr(CHEVRON_INFO_DESCRIPTION["disabled"]))
self._chevron_info.show_description(True)
@@ -31,6 +31,9 @@ class BlindSpotIndicators:
return self._blind_spot_left_alpha_filter.x > 0.01 or self._blind_spot_right_alpha_filter.x > 0.01
def render(self, rect: rl.Rectangle) -> None:
if not ui_state.blindspot:
return
BLIND_SPOT_MARGIN_X = 20 # Distance from edge of screen
BLIND_SPOT_Y_OFFSET = 100 # Distance from top of screen
@@ -23,7 +23,6 @@ class CircularAlertsRenderer:
self._e2e_alert_frame = 0
self._green_light_alert = False
self._lead_depart_alert = False
self._standstill_timer = False
self._standstill_elapsed_time = 0.0
self._is_standstill = False
self._alert_text = ""
@@ -36,7 +35,6 @@ class CircularAlertsRenderer:
car_state = sm['carState']
self._green_light_alert = lp_sp.e2eAlerts.greenLightAlert
self._lead_depart_alert = lp_sp.e2eAlerts.leadDepartAlert
self._standstill_timer = ui_state.standstill_timer
self._is_standstill = car_state.standstill
if not ui_state.started:
@@ -61,7 +59,7 @@ class CircularAlertsRenderer:
self._alert_text = "LEAD VEHICLE\nDEPARTING"
self._alert_img = self._lead_depart_alert_img
elif self._standstill_timer and self._is_standstill:
elif ui_state.standstill_timer and self._is_standstill:
self._alert_img = None
self._standstill_elapsed_time += 1.0 / gui_app.target_fps
minute = int(self._standstill_elapsed_time / 60)
@@ -75,7 +73,7 @@ class CircularAlertsRenderer:
self._standstill_elapsed_time = 0.0
def render(self, rect: rl.Rectangle) -> None:
if not self._allow_e2e_alerts or (self._e2e_alert_display_timer <= 0 and not (self._standstill_timer and self._is_standstill)):
if not self._allow_e2e_alerts or (self._e2e_alert_display_timer <= 0 and not (ui_state.standstill_timer and self._is_standstill)):
return
e2e_alert_size = 250
@@ -91,7 +89,7 @@ class CircularAlertsRenderer:
is_pulsing = (self._e2e_alert_frame % gui_app.target_fps) < (gui_app.target_fps / 2.5)
# Standstill Timer (STOPPED) should be static white
if self._e2e_alert_display_timer == 0 and self._standstill_timer and self._is_standstill:
if self._e2e_alert_display_timer == 0 and ui_state.standstill_timer and self._is_standstill:
frame_color = rl.Color(255, 255, 255, 75)
else:
frame_color = rl.Color(255, 255, 255, 75) if is_pulsing else rl.Color(0, 255, 0, 75)
@@ -121,7 +119,7 @@ class CircularAlertsRenderer:
# Draw lines upwards from bottom
current_y = bottom_y - (len(lines) * text_size * FONT_SCALE)
if self._e2e_alert_display_timer == 0 and self._standstill_timer and self._is_standstill:
if self._e2e_alert_display_timer == 0 and ui_state.standstill_timer and self._is_standstill:
# Standstill Timer Text
alert_alt_text = "STOPPED"
top_text_size = 80
@@ -16,6 +16,7 @@ from openpilot.selfdrive.ui.sunnypilot.onroad.speed_limit import SpeedLimitRende
from openpilot.selfdrive.ui.sunnypilot.onroad.smart_cruise_control import SmartCruiseControlRenderer
from openpilot.selfdrive.ui.sunnypilot.onroad.turn_signal import TurnSignalController
from openpilot.selfdrive.ui.sunnypilot.onroad.circular_alerts import CircularAlertsRenderer
from openpilot.selfdrive.ui.sunnypilot.onroad.speed_renderer import SpeedRenderer
class HudRendererSP(HudRenderer):
@@ -28,6 +29,7 @@ class HudRendererSP(HudRenderer):
self.smart_cruise_control_renderer = SmartCruiseControlRenderer()
self.turn_signal_controller = TurnSignalController()
self.circular_alerts_renderer = CircularAlertsRenderer()
self.speed_renderer = SpeedRenderer()
self._torque_bar = TorqueBar(scale=3.0, always=True)
def _update_state(self) -> None:
@@ -37,6 +39,10 @@ class HudRendererSP(HudRenderer):
self.smart_cruise_control_renderer.update()
self.turn_signal_controller.update()
self.circular_alerts_renderer.update()
self.speed_renderer.update()
def _draw_current_speed(self, rect: rl.Rectangle) -> None:
self.speed_renderer.render(rect)
def _render(self, rect: rl.Rectangle) -> None:
super()._render(rect)
@@ -53,6 +59,4 @@ class HudRendererSP(HudRenderer):
self.smart_cruise_control_renderer.render(rect)
self.turn_signal_controller.render(rect)
self.circular_alerts_renderer.render(rect)
if ui_state.rocket_fuel:
self.rocket_fuel.render(rect, ui_state.sm)
self.rocket_fuel.render(rect, ui_state.sm)
+1 -1
View File
@@ -31,7 +31,7 @@ class RoadNameRenderer(Widget):
self.road_name = lmd.roadName
def _render(self, rect: rl.Rectangle):
if not self.road_name:
if not self.road_name or not ui_state.road_name_toggle:
return
text = self.road_name
@@ -6,12 +6,17 @@ See the LICENSE.md file in the root directory for more details.
"""
import pyray as rl
from openpilot.selfdrive.ui.ui_state import ui_state
class RocketFuel:
def __init__(self):
self.vc_accel = 0.0
def render(self, rect: rl.Rectangle, sm) -> None:
if not ui_state.rocket_fuel:
return
vc_accel0 = sm['carState'].aEgo
# Smooth the acceleration
@@ -0,0 +1,46 @@
"""
Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
This file is part of sunnypilot and is licensed under the MIT License.
See the LICENSE.md file in the root directory for more details.
"""
import pyray as rl
from openpilot.common.constants import CV
from openpilot.selfdrive.ui.ui_state import ui_state
from openpilot.system.ui.lib.application import gui_app, FontWeight
from openpilot.system.ui.lib.multilang import tr
from openpilot.system.ui.lib.text_measure import measure_text_cached
from openpilot.selfdrive.ui.onroad.hud_renderer import FONT_SIZES, COLORS
class SpeedRenderer:
def __init__(self):
self.speed: float = 0.0
self.v_ego_cluster_seen: bool = False
self._font_bold: rl.Font = gui_app.font(FontWeight.BOLD)
self._font_medium: rl.Font = gui_app.font(FontWeight.MEDIUM)
def update(self) -> None:
car_state = ui_state.sm['carState']
v_ego_cluster = car_state.vEgoCluster
self.v_ego_cluster_seen = self.v_ego_cluster_seen or v_ego_cluster != 0.0
v_ego = v_ego_cluster if self.v_ego_cluster_seen and not ui_state.true_v_ego_ui else car_state.vEgo
speed_conversion = CV.MS_TO_KPH if ui_state.is_metric else CV.MS_TO_MPH
self.speed = max(0.0, v_ego * speed_conversion)
def render(self, rect: rl.Rectangle) -> None:
if ui_state.hide_v_ego_ui:
return
# Draw current speed and unit
speed_text = str(round(self.speed))
speed_text_size = measure_text_cached(self._font_bold, speed_text, FONT_SIZES.current_speed)
speed_pos = rl.Vector2(rect.x + rect.width / 2 - speed_text_size.x / 2, 180 - speed_text_size.y / 2)
rl.draw_text_ex(self._font_bold, speed_text, speed_pos, FONT_SIZES.current_speed, 0, COLORS.WHITE)
unit_text = tr("km/h") if ui_state.is_metric else tr("mph")
unit_text_size = measure_text_cached(self._font_medium, unit_text, FONT_SIZES.speed_unit)
unit_pos = rl.Vector2(rect.x + rect.width / 2 - unit_text_size.x / 2, 290 - unit_text_size.y / 2)
rl.draw_text_ex(self._font_medium, unit_text, unit_pos, FONT_SIZES.speed_unit, 0, COLORS.WHITE_TRANSLUCENT)
@@ -137,6 +137,9 @@ class TurnSignalController:
self._right_signal.deactivate()
def render(self, rect: rl.Rectangle):
if not ui_state.turn_signals:
return
x = rect.x + rect.width / 2
left_x = x - self._config.left_x - self._config.size
+13 -10
View File
@@ -120,20 +120,23 @@ class UIStateSP:
CP_SP_bytes = self.params.get("CarParamsSPPersistent")
if CP_SP_bytes is not None:
self.CP_SP = messaging.log_from_bytes(CP_SP_bytes, custom.CarParamsSP)
self.sunnylink_enabled = self.params.get_bool("SunnylinkEnabled")
self.developer_ui = self.params.get("DevUIInfo")
self.rocket_fuel = self.params.get_bool("RocketFuel")
self.rainbow_path = self.params.get_bool("RainbowMode")
self.chevron_metrics = self.params.get("ChevronInfo")
self.torque_bar = self.params.get_bool("TorqueBar")
self.active_bundle = self.params.get("ModelManager_ActiveBundle")
self.blindspot = self.params.get_bool("BlindSpot")
self.chevron_metrics = self.params.get("ChevronInfo")
self.custom_interactive_timeout = self.params.get("InteractivityTimeout", return_default=True)
self.speed_limit_mode = self.params.get("SpeedLimitMode", return_default=True)
self.standstill_timer = self.params.get_bool("StandstillTimer")
# Onroad Screen Brightness
self.developer_ui = self.params.get("DevUIInfo")
self.hide_v_ego_ui = self.params.get_bool("HideVEgoUI")
self.onroad_brightness = int(float(self.params.get("OnroadScreenOffBrightness", return_default=True)))
self.onroad_brightness_timer_param = self.params.get("OnroadScreenOffTimer", return_default=True)
self.rainbow_path = self.params.get_bool("RainbowMode")
self.road_name_toggle = self.params.get_bool("RoadNameToggle")
self.rocket_fuel = self.params.get_bool("RocketFuel")
self.speed_limit_mode = self.params.get("SpeedLimitMode", return_default=True)
self.standstill_timer = self.params.get_bool("StandstillTimer")
self.sunnylink_enabled = self.params.get_bool("SunnylinkEnabled")
self.torque_bar = self.params.get_bool("TorqueBar")
self.true_v_ego_ui = self.params.get_bool("TrueVEgoUI")
self.turn_signals = self.params.get_bool("ShowTurnSignals")
class DeviceSP:
+20 -20
View File
@@ -90,8 +90,8 @@
"description": ""
},
"BlindSpot": {
"title": "Blind Spot Detection",
"description": ""
"title": "[TIZI/TICI only] Blind Spot Detection",
"description": "Enabling this will display warnings when a vehicle is detected in your blind spot as long as your car has BSM supported."
},
"BlinkerMinLateralControlSpeed": {
"title": "Blinker Min Lateral Control Speed",
@@ -339,8 +339,8 @@
"description": ""
},
"GreenLightAlert": {
"title": "Green Light Alert",
"description": ""
"title": "Green Traffic Light Alert (Beta)",
"description": "A chime and on-screen alert (TIZI/TICI only) will play when the traffic light you are waiting for turns green and you have no vehicle in front of you. <br>Note: This chime is only designed as a notification. It is the driver's responsibility to observe their environment and make decisions accordingly."
},
"GsmApn": {
"title": "GSM APN",
@@ -367,8 +367,8 @@
"description": ""
},
"HideVEgoUI": {
"title": "Hide vEgo UI",
"description": ""
"title": "[TIZI/TICI only] Speedometer: Hide from Onroad Screen",
"description": "When enabled, the speedometer on the onroad screen is not displayed."
},
"HyundaiLongitudinalTuning": {
"title": "Hyundai Longitudinal Tuning",
@@ -585,8 +585,8 @@
"description": ""
},
"LeadDepartAlert": {
"title": "Lead Depart Alert",
"description": ""
"title": "Lead Departure Alert (Beta)",
"description": "A chime and on-screen alert (TIZI/TICI only) will play when you are stopped, and the vehicle in front of you start moving. <br>Note: This chime is only designed as a notification. It is the driver's responsibility to observe their environment and make decisions accordingly."
},
"LiveDelay": {
"title": "Live Delay",
@@ -1079,12 +1079,12 @@
"description": ""
},
"RoadNameToggle": {
"title": "Display Road Name",
"description": ""
"title": "[TIZI/TICI only] Display Road Name",
"description": "Displays the name of the road the car is traveling on. <br>The OpenStreetMap database of the location must be downloaded to fetch the road name."
},
"RocketFuel": {
"title": "Display Rocket Fuel Bar",
"description": "Show an indicator on the left side of the screen to display real-time vehicle acceleration and deceleration."
"title": "[TIZI/TICI only] Real-time Acceleration Bar",
"description": "Show an indicator on the left side of the screen to display real-time vehicle acceleration and deceleration. This displays what the car is currently doing, not what the planner is requesting."
},
"RouteCount": {
"title": "Route Count",
@@ -1103,8 +1103,8 @@
"description": ""
},
"ShowTurnSignals": {
"title": "Show Turn Signals",
"description": ""
"title": "[TIZI/TICI only] Display Turn Signals",
"description": "When enabled, visual turn indicators are drawn on the HUD."
},
"SmartCruiseControlMap": {
"title": "Smart Cruise Control - Map",
@@ -1196,8 +1196,8 @@
"description": ""
},
"StandstillTimer": {
"title": "Standstill Timer",
"description": ""
"title": "[TIZI/TICI only] Standstill Timer",
"description": "Show a timer on the HUD when the car is at a standstill."
},
"SubaruStopAndGo": {
"title": "Subaru Stop and Go",
@@ -1240,8 +1240,8 @@
"description": ""
},
"TorqueBar": {
"title": "Steering Arc",
"description": "[TIZI/TICI only] Display steering arc on the driving screen when lateral control is enabled."
"title": "[TIZI/TICI only] Steering Arc",
"description": "Display steering arc on the driving screen when lateral control is enabled."
},
"TorqueParamsOverrideEnabled": {
"title": "Manual Real-Time Tuning",
@@ -1271,8 +1271,8 @@
"description": ""
},
"TrueVEgoUI": {
"title": "True vEgo UI",
"description": ""
"title": "[TIZI/TICI only] Speedometer: Always Display True Speed",
"description": "For applicable vehicles, always display the true vehicle current speed from wheel speed sensors."
},
"UbloxAvailable": {
"title": "Ublox Available",
+7
View File
@@ -20,6 +20,7 @@ from openpilot.system.athena.registration import register, UNREGISTERED_DONGLE_I
from openpilot.common.swaglog import cloudlog, add_file_handler
from openpilot.system.version import get_build_metadata
from openpilot.system.hardware.hw import Paths
from openpilot.system.hardware import PC
def manager_init() -> None:
@@ -39,6 +40,12 @@ def manager_init() -> None:
if params.get("DeviceBootMode") == 1: # start in Always Offroad mode
params.put_bool("OffroadMode", True)
# quick boot
if params.get_bool("QuickBootToggle") and not PC:
prebuilt_path = "/data/openpilot/prebuilt"
if not os.path.exists(prebuilt_path):
open(prebuilt_path, 'x').close()
if params.get_bool("RecordFrontLock"):
params.put_bool("RecordFront", True)