From f456464f6ccf232f0d85718f2c7181701ea72717 Mon Sep 17 00:00:00 2001 From: Erki Date: Tue, 22 Jun 2021 16:21:29 +0300 Subject: [PATCH] Peripherals: make IrSensors return a struct. std::pair isn't trivially copyable, it seems. Which is weird. --- Peripherals/Inc/peripherals_ir_sensors.hpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Peripherals/Inc/peripherals_ir_sensors.hpp b/Peripherals/Inc/peripherals_ir_sensors.hpp index 46399f6..e6c135d 100644 --- a/Peripherals/Inc/peripherals_ir_sensors.hpp +++ b/Peripherals/Inc/peripherals_ir_sensors.hpp @@ -17,6 +17,15 @@ namespace Peripherals { +struct IrSensorsReading +{ + /// Distance as read by the sensor. + float distance; + + /// @c true if the @c distance is < the wall threshold. + bool sees_object; +}; + template class IrSensors { @@ -61,16 +70,16 @@ public: } } - std::array, N> getDistanceData() + std::array getDistanceData() { - std::array, N> data; + std::array data; for (std::size_t i = 0; i < N; i++) { const float interim = averages_[i] - offsets_[i]; - data[i].first = multipliers_[i] * std::pow(interim, exponents_[i]); - data[i].second = data[i].first < wall_thresholds_[i]; + data[i].distance = multipliers_[i] * std::pow(interim, exponents_[i]); + data[i].sees_object = data[i].distance < wall_thresholds_[i]; } return data;