From 59a8003ad8b06dfed86971f6ba3f77c24447adff Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 18 Jan 2023 17:51:54 +0100 Subject: [PATCH] ok this should work --- mission/devices/GyroADIS1650XHandler.cpp | 15 +++++++++------ mission/devices/GyroADIS1650XHandler.h | 2 +- .../devicedefinitions/GyroADIS1650XDefinitions.h | 6 +++++- tmtc | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/mission/devices/GyroADIS1650XHandler.cpp b/mission/devices/GyroADIS1650XHandler.cpp index 6880ad5d..5b59d7f6 100644 --- a/mission/devices/GyroADIS1650XHandler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -228,15 +228,15 @@ ReturnValue_t GyroADIS1650XHandler::interpretDeviceReply(DeviceCommandId_t id, static_cast((rangMdlRaw >> 2) & 0b11); switch (bitfield) { case (ADIS1650X::RangMdlBitfield::RANGE_125_1BMLZ): { - range = GyroRange::MODEL_1BMLZ; + rangeMultiplicator = RANGE_1BMLZ; break; } case (ADIS1650X::RangMdlBitfield::RANGE_500_2BMLZ): { - range = GyroRange::MODEL_2BMLZ; + rangeMultiplicator = RANGE_2BMLZ; break; } case (ADIS1650X::RangMdlBitfield::RANGE_2000_3BMLZ): { - range = GyroRange::MODEL_3BMLZ; + rangeMultiplicator = RANGE_3BMLZ; break; } case (RangMdlBitfield::RESERVED): { @@ -298,11 +298,14 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { { PoolReadGuard pg(&primaryDataset); int16_t angVelocXRaw = packet[4] << 8 | packet[5]; - primaryDataset.angVelocX.value = static_cast(angVelocXRaw) / INT16_MAX * range; + primaryDataset.angVelocX.value = + static_cast(angVelocXRaw) / static_cast(INT16_MAX) * rangeMultiplicator; int16_t angVelocYRaw = packet[6] << 8 | packet[7]; - primaryDataset.angVelocY.value = static_cast(angVelocYRaw) / INT16_MAX * range; + primaryDataset.angVelocY.value = + static_cast(angVelocYRaw) / static_cast(INT16_MAX) * rangeMultiplicator; int16_t angVelocZRaw = packet[8] << 8 | packet[9]; - primaryDataset.angVelocZ.value = static_cast(angVelocZRaw) / INT16_MAX * range; + primaryDataset.angVelocZ.value = + static_cast(angVelocZRaw) / static_cast(INT16_MAX) * rangeMultiplicator; float accelScaling = 0; if (adisType == ADIS1650X::Type::ADIS16507) { diff --git a/mission/devices/GyroADIS1650XHandler.h b/mission/devices/GyroADIS1650XHandler.h index f565bd4c..f664407c 100644 --- a/mission/devices/GyroADIS1650XHandler.h +++ b/mission/devices/GyroADIS1650XHandler.h @@ -46,7 +46,7 @@ class GyroADIS1650XHandler : public DeviceHandlerBase { ADIS1650X::Type adisType; AdisGyroPrimaryDataset primaryDataset; AdisGyroConfigDataset configDataset; - ADIS1650X::GyroRange range = ADIS1650X::GyroRange::UNSET; + double rangeMultiplicator = ADIS1650X::RANGE_UNSET; bool goToNormalMode = false; bool warningSwitch = true; diff --git a/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h b/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h index aedbcdc2..fb9e4d44 100644 --- a/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h +++ b/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h @@ -13,7 +13,11 @@ enum class Type { ADIS16505, ADIS16507 }; static constexpr size_t MAXIMUM_REPLY_SIZE = 64; static constexpr uint8_t WRITE_MASK = 0b1000'0000; -enum GyroRange { UNSET = 0, MODEL_1BMLZ = 125, MODEL_2BMLZ = 500, MODEL_3BMLZ = 2000 }; +// Ranges in deg / s +static constexpr double RANGE_UNSET = 0.0; +static constexpr double RANGE_1BMLZ = 125.0; +static constexpr double RANGE_2BMLZ = 500.0; +static constexpr double RANGE_3BMLZ = 2000.0; enum RangMdlBitfield { RANGE_125_1BMLZ = 0b00, diff --git a/tmtc b/tmtc index c9790911..118b4392 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit c9790911ef085cd60c7d8a8a4bf75cc9c0f14c93 +Subproject commit 118b439272a1f541a0ba9ba5a2ffd992190d7ea7