Use Wide Road Camera as Light Sensor for Screen Brightness (#23610)

Using the narrow camera as a light sensor meant that the
reflection of our own headlights, tail lights, and head lights
of opposing vehicles dominated the sensor value at night
even though the broader overall scene is very dark.

This has very little effect during daylight hours.  The change
affects nightime driving the most, resulting in a dimmer
screen when it is dark.

I think this makes more sense as the wide angle camera's
field of view is much closer to the human eye's field of
view than the narrow road camera.
pull/23992/head
Kevin Robert Keegan 2022-01-25 02:13:59 -08:00 committed by GitHub
parent e50efd7671
commit 347583d423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 4 deletions

View File

@ -166,16 +166,22 @@ static void update_state(UIState *s) {
}
}
}
if (sm.updated("roadCameraState")) {
if (!Hardware::TICI() && sm.updated("roadCameraState")) {
auto camera_state = sm["roadCameraState"].getRoadCameraState();
float max_lines = Hardware::EON() ? 5408 : 1904;
float max_gain = Hardware::EON() ? 1.0: 10.0;
float max_ev = max_lines * max_gain;
if (Hardware::TICI()) {
max_ev /= 6;
}
float ev = camera_state.getGain() * float(camera_state.getIntegLines());
scene.light_sensor = std::clamp<float>(1.0 - (ev / max_ev), 0.0, 1.0);
} else if (Hardware::TICI() && sm.updated("wideRoadCameraState")) {
auto camera_state = sm["wideRoadCameraState"].getWideRoadCameraState();
float max_lines = 1904;
float max_gain = 10.0;
float max_ev = max_lines * max_gain / 6;
float ev = camera_state.getGain() * float(camera_state.getIntegLines());
@ -220,6 +226,7 @@ UIState::UIState(QObject *parent) : QObject(parent) {
sm = std::make_unique<SubMaster, const std::initializer_list<const char *>>({
"modelV2", "controlsState", "liveCalibration", "radarState", "deviceState", "roadCameraState",
"pandaStates", "carParams", "driverMonitoringState", "sensorEvents", "carState", "liveLocationKalman",
"wideRoadCameraState",
});
Params params;