From 1b5c4d908947da2721167f60b43563dcb4844d1e Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Thu, 4 Mar 2021 14:40:16 +0100 Subject: [PATCH] ui: check sensor list size --- selfdrive/ui/ui.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index f1ae604898..e8e8080e04 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -212,9 +212,15 @@ static void update_sockets(UIState *s) { if (sensor.which() == cereal::SensorEventData::LIGHT) { scene.light_sensor = sensor.getLight(); } else if (!scene.started && sensor.which() == cereal::SensorEventData::ACCELERATION) { - scene.accel_sensor = sensor.getAcceleration().getV()[2]; + 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) { - scene.gyro_sensor = sensor.getGyroUncalibrated().getV()[1]; + auto gyro = sensor.getGyroUncalibrated().getV(); + if (gyro.totalSize().wordCount){ + scene.gyro_sensor = gyro[1]; + } } } }