Fix wide camera disable runtime gating

This commit is contained in:
firestar5683
2026-05-20 10:44:10 -05:00
parent 8846b907d7
commit 1f8652d809
4 changed files with 22 additions and 13 deletions
@@ -50,6 +50,7 @@ class DeveloperLayoutMici(NavScroller):
self._adb_toggle = BigCircleParamControl(gui_app.texture("icons_mici/adb_short.png", 82, 82), "AdbEnabled", icon_offset=(0, 12))
self._ssh_toggle = BigCircleParamControl(gui_app.texture("icons_mici/ssh_short.png", 82, 82), "SshEnabled", icon_offset=(0, 12))
self._use_prebuilt_toggle = BigParamControl("use prebuilt binaries", "UsePrebuilt")
self._disable_wide_road_toggle = BigParamControl("disable wide road camera", "DisableWideRoad", toggle_callback=restart_needed_callback)
self._joystick_toggle = BigToggle("joystick debug mode",
initial_state=ui_state.params.get_bool("JoystickDebugMode"),
toggle_callback=self._on_joystick_debug_mode)
@@ -71,6 +72,7 @@ class DeveloperLayoutMici(NavScroller):
self._ssh_toggle,
self._ssh_keys_btn,
self._use_prebuilt_toggle,
self._disable_wide_road_toggle,
self._joystick_toggle,
self._long_maneuver_toggle,
self._lat_maneuver_toggle,
@@ -83,6 +85,7 @@ class DeveloperLayoutMici(NavScroller):
("AdbEnabled", self._adb_toggle),
("SshEnabled", self._ssh_toggle),
("UsePrebuilt", self._use_prebuilt_toggle),
("DisableWideRoad", self._disable_wide_road_toggle),
("JoystickDebugMode", self._joystick_toggle),
("LongitudinalManeuverMode", self._long_maneuver_toggle),
("LateralManeuverMode", self._lat_maneuver_toggle),
@@ -92,6 +95,7 @@ class DeveloperLayoutMici(NavScroller):
onroad_blocked_toggles = (
self._adb_toggle,
self._use_prebuilt_toggle,
self._disable_wide_road_toggle,
self._joystick_toggle,
)
engaged_blocked_toggles = (self._long_maneuver_toggle, self._lat_maneuver_toggle, self._alpha_long_toggle)
+3 -2
View File
@@ -158,8 +158,9 @@ void AnnotatedCameraWidget::paintEvent(QPaintEvent *event) {
}
wide_cam_requested = wide_cam_requested && sm["selfdriveState"].getSelfdriveState().getExperimentalMode() && starpilot_toggles.value("camera_view").toInt() == 0;
}
CameraWidget::setStreamType(starpilot_toggles.value("camera_view").toInt() == 1 ? VISION_STREAM_DRIVER :
starpilot_toggles.value("camera_view").toInt() == 3 || wide_cam_requested ? VISION_STREAM_WIDE_ROAD :
int camera_view = starpilot_toggles.value("camera_view").toInt();
CameraWidget::setStreamType(camera_view == 1 ? VISION_STREAM_DRIVER :
((camera_view == 3 && has_wide_cam) || wide_cam_requested) ? VISION_STREAM_WIDE_ROAD :
VISION_STREAM_ROAD);
CameraWidget::setFrameId(sm["modelV2"].getModelV2().getFrameId());
+13
View File
@@ -27,6 +27,19 @@ struct CameraConfig {
SpectraOutputType output_type;
};
inline bool camera_enabled_at_runtime(int camera_num) {
switch (camera_num) {
case 0:
return getenv("DISABLE_WIDE_ROAD") == nullptr;
case 1:
return getenv("DISABLE_ROAD") == nullptr;
case 2:
return getenv("DISABLE_DRIVER") == nullptr;
default:
return true;
}
}
// NOTE: to be able to disable road and wide road, we still have to configure the sensor over i2c
// If you don't do this, the strobe GPIO is an output (even in reset it seems!)
const CameraConfig WIDE_ROAD_CAMERA_CONFIG = {
+2 -11
View File
@@ -235,16 +235,7 @@ void SpectraMaster::init() {
SpectraCamera::SpectraCamera(SpectraMaster *master, const CameraConfig &config)
: m(master),
cc(config) {
// Runtime check for disable environment variables (must happen after main() sets them)
bool should_disable = false;
if (config.camera_num == 0 && getenv("DISABLE_WIDE_ROAD")) {
should_disable = true;
} else if (config.camera_num == 1 && getenv("DISABLE_ROAD")) {
should_disable = true;
} else if (config.camera_num == 2 && getenv("DISABLE_DRIVER")) {
should_disable = true;
}
enabled = !should_disable;
enabled = camera_enabled_at_runtime(config.camera_num);
ife_buf_depth = VIPC_BUFFER_COUNT;
assert(ife_buf_depth < MAX_IFE_BUFS);
@@ -1483,7 +1474,7 @@ bool SpectraCamera::syncFirstFrame(int camera_id, uint64_t request_id, uint64_t
// Ensure all cameras are up
int enabled_camera_count = std::count_if(std::begin(ALL_CAMERA_CONFIGS), std::end(ALL_CAMERA_CONFIGS),
[](const auto &config) { return config.enabled; });
[](const auto &config) { return camera_enabled_at_runtime(config.camera_num); });
bool all_cams_up = camera_sync_data.size() == enabled_camera_count;
// Wait until the timestamps line up