ui: only check sensorEvents when offroad (#22893)

old-commit-hash: 96e6c343e25b49a9b26462c63cb9975f1f9c8359
This commit is contained in:
Dean Lee
2021-11-14 04:06:05 +08:00
committed by GitHub
parent e0fa9b7909
commit 13b3a3583d
+3 -3
View File
@@ -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];