UI: remove imu tap detection (#25924)

old-commit-hash: 391780551a
taco
Adeeb Shihadeh 3 years ago committed by GitHub
parent 025098b819
commit bcd69adc33
  1. 32
      selfdrive/ui/ui.cc
  2. 2
      selfdrive/ui/ui.h

@ -162,21 +162,6 @@ static void update_state(UIState *s) {
if (sm.updated("carParams")) {
scene.longitudinal_control = sm["carParams"].getCarParams().getOpenpilotLongitudinalControl();
}
if (!scene.started && sm.updated("sensorEvents")) {
for (auto sensor : sm["sensorEvents"].getSensorEvents()) {
if (sensor.which() == cereal::SensorEventData::ACCELERATION) {
auto accel = sensor.getAcceleration().getV();
if (accel.totalSize().wordCount) { // TODO: sometimes empty lists are received. Figure out why
scene.accel_sensor = accel[2];
}
} else if (sensor.which() == cereal::SensorEventData::GYRO_UNCALIBRATED) {
auto gyro = sensor.getGyroUncalibrated().getV();
if (gyro.totalSize().wordCount) {
scene.gyro_sensor = gyro[1];
}
}
}
}
if (sm.updated("wideRoadCameraState")) {
scene.light_sensor = 100.0f - sm["wideRoadCameraState"].getWideRoadCameraState().getExposureValPercent();
}
@ -221,7 +206,7 @@ void UIState::updateStatus() {
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",
"pandaStates", "carParams", "driverMonitoringState", "carState", "liveLocationKalman",
"wideRoadCameraState", "managerState", "navInstruction", "navRoute", "gnssMeasurements",
});
@ -304,24 +289,11 @@ void Device::updateBrightness(const UIState &s) {
}
}
bool Device::motionTriggered(const UIState &s) {
static float accel_prev = 0;
static float gyro_prev = 0;
bool accel_trigger = abs(s.scene.accel_sensor - accel_prev) > 0.2;
bool gyro_trigger = abs(s.scene.gyro_sensor - gyro_prev) > 0.15;
gyro_prev = s.scene.gyro_sensor;
accel_prev = (accel_prev * (accel_samples - 1) + s.scene.accel_sensor) / accel_samples;
return (!awake && accel_trigger && gyro_trigger);
}
void Device::updateWakefulness(const UIState &s) {
bool ignition_just_turned_off = !s.scene.ignition && ignition_on;
ignition_on = s.scene.ignition;
if (ignition_just_turned_off || motionTriggered(s)) {
if (ignition_just_turned_off) {
resetInteractiveTimout();
} else if (interactive_timeout > 0 && --interactive_timeout == 0) {
emit interactiveTimout();

@ -100,7 +100,7 @@ typedef struct UIScene {
// lead
QPointF lead_vertices[2];
float light_sensor, accel_sensor, gyro_sensor;
float light_sensor;
bool started, ignition, is_metric, map_on_left, longitudinal_control, end_to_end_long;
uint64_t started_frame;
} UIScene;

Loading…
Cancel
Save