ui: only check sensorEvents when offroad (#22893)

pull/22902/head
Dean Lee 3 years ago committed by GitHub
parent c0b9c1f3af
commit 96e6c343e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      selfdrive/ui/ui.cc

@ -152,14 +152,14 @@ static void update_state(UIState *s) {
if (sm.updated("carParams")) {
scene.longitudinal_control = sm["carParams"].getCarParams().getOpenpilotLongitudinalControl();
}
if (sm.updated("sensorEvents")) {
if (!scene.started && sm.updated("sensorEvents")) {
for (auto sensor : sm["sensorEvents"].getSensorEvents()) {
if (!scene.started && sensor.which() == cereal::SensorEventData::ACCELERATION) {
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 (!scene.started && sensor.which() == cereal::SensorEventData::GYRO_UNCALIBRATED) {
} else if (sensor.which() == cereal::SensorEventData::GYRO_UNCALIBRATED) {
auto gyro = sensor.getGyroUncalibrated().getV();
if (gyro.totalSize().wordCount) {
scene.gyro_sensor = gyro[1];

Loading…
Cancel
Save