From 2e11f067e2118e2e18f0c6ecee6919b0bbfe434c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 15:30:14 +0100 Subject: [PATCH 1/4] start replacing chained locks --- mission/controller/AcsController.cpp | 4 --- mission/controller/AcsController.h | 2 +- mission/controller/acs/SensorValues.cpp | 42 +++++++++++++++++-------- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 83088b41..10053da8 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -107,8 +107,6 @@ void AcsController::performControlOperation() { } void AcsController::performSafe() { - ACS::SensorValues sensorValues; - timeval now; Clock::getClock_timeval(&now); @@ -197,8 +195,6 @@ void AcsController::performSafe() { } void AcsController::performDetumble() { - ACS::SensorValues sensorValues; - timeval now; Clock::getClock_timeval(&now); diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index e1e31a2a..0ae4f338 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -38,6 +38,7 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes private: AcsParameters acsParameters; + ACS::SensorValues sensorValues; SensorProcessing sensorProcessing; Navigation navigation; ActuatorCmd actuatorCmd; @@ -70,7 +71,6 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes void announceMode(bool recursive); /* ACS Datasets */ - ACS::SensorValues sensorValues; IMTQ::DipoleActuationSet dipoleSet = IMTQ::DipoleActuationSet(objects::IMTQ_HANDLER); // MGMs acsctrl::MgmDataRaw mgmDataRaw; diff --git a/mission/controller/acs/SensorValues.cpp b/mission/controller/acs/SensorValues.cpp index 568a9e1c..a963f326 100644 --- a/mission/controller/acs/SensorValues.cpp +++ b/mission/controller/acs/SensorValues.cpp @@ -20,13 +20,34 @@ SensorValues::SensorValues() {} SensorValues::~SensorValues() {} ReturnValue_t SensorValues::updateMgm() { - ReturnValue_t result; - PoolReadGuard pgMgm0(&mgm0Lis3Set), pgMgm1(&mgm1Rm3100Set), pgMgm2(&mgm2Lis3Set), - pgMgm3(&mgm3Rm3100Set), pgImtq(&imtqMgmSet); + std::vector results; - result = (pgMgm0.getReadResult() || pgMgm1.getReadResult() || pgMgm2.getReadResult() || - pgMgm3.getReadResult() || pgImtq.getReadResult()); - return result; + { + PoolReadGuard pgMgm0(&mgm0Lis3Set); + results.push_back(pgMgm0.getReadResult()); + } + { + PoolReadGuard pgMgm(&mgm1Rm3100Set); + results.push_back(pgMgm.getReadResult()); + } + { + PoolReadGuard pgMgm(&mgm2Lis3Set); + results.push_back(pgMgm.getReadResult()); + } + { + PoolReadGuard pgMgm(&mgm3Rm3100Set); + results.push_back(pgMgm.getReadResult()); + } + { + PoolReadGuard pgMgm(&imtqMgmSet); + results.push_back(pgMgm.getReadResult()); + } + for (const auto& result : results) { + if (result != returnvalue::OK) { + return result; + } + } + return returnvalue::OK; } ReturnValue_t SensorValues::updateSus() { @@ -53,19 +74,14 @@ ReturnValue_t SensorValues::updateGyr() { } ReturnValue_t SensorValues::updateStr() { - ReturnValue_t result; PoolReadGuard pgStr(&strSet); - result = pgStr.getReadResult(); - return result; + return pgStr.getReadResult(); } ReturnValue_t SensorValues::updateGps() { - ReturnValue_t result; PoolReadGuard pgGps(&gpsSet); - - result = pgGps.getReadResult(); - return result; + return pgGps.getReadResult(); } ReturnValue_t SensorValues::updateRw() { -- 2.43.0 From 1d12d5f1445fc524911abf9e889ffdd20b5557cb Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 8 Feb 2023 17:02:22 +0100 Subject: [PATCH 2/4] removed sensorValues inits --- mission/controller/AcsController.cpp | 18 ++++++++---------- mission/controller/AcsController.h | 4 +++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 10053da8..1b4f54a9 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -254,8 +254,6 @@ void AcsController::performDetumble() { } void AcsController::performPointingCtrl() { - ACS::SensorValues sensorValues; - timeval now; Clock::getClock_timeval(&now); @@ -717,14 +715,6 @@ void AcsController::copySusData() { } } -ReturnValue_t AcsController::initialize() { - ReturnValue_t result = parameterHelper.initialize(); - if (result != returnvalue::OK) { - return result; - } - return ExtendedControllerBase::initialize(); -} - void AcsController::copyGyrData() { ACS::SensorValues sensorValues; { @@ -772,3 +762,11 @@ void AcsController::copyGyrData() { } } } + +ReturnValue_t AcsController::initialize() { + ReturnValue_t result = parameterHelper.initialize(); + if (result != returnvalue::OK) { + return result; + } + return ExtendedControllerBase::initialize(); +} diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index 0ae4f338..1e017099 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -38,7 +38,6 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes private: AcsParameters acsParameters; - ACS::SensorValues sensorValues; SensorProcessing sensorProcessing; Navigation navigation; ActuatorCmd actuatorCmd; @@ -70,6 +69,9 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes void modeChanged(Mode_t mode, Submode_t submode); void announceMode(bool recursive); + /* ACS Sensor Values */ + ACS::SensorValues sensorValues; + /* ACS Datasets */ IMTQ::DipoleActuationSet dipoleSet = IMTQ::DipoleActuationSet(objects::IMTQ_HANDLER); // MGMs -- 2.43.0 From 5f9a52977bd981effe3bde1db6a7872cacf3390c Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 8 Feb 2023 17:02:59 +0100 Subject: [PATCH 3/4] replaced all chained locks --- mission/controller/acs/SensorValues.cpp | 87 +++++++++++++++++-------- 1 file changed, 61 insertions(+), 26 deletions(-) diff --git a/mission/controller/acs/SensorValues.cpp b/mission/controller/acs/SensorValues.cpp index a963f326..e4026300 100644 --- a/mission/controller/acs/SensorValues.cpp +++ b/mission/controller/acs/SensorValues.cpp @@ -23,8 +23,8 @@ ReturnValue_t SensorValues::updateMgm() { std::vector results; { - PoolReadGuard pgMgm0(&mgm0Lis3Set); - results.push_back(pgMgm0.getReadResult()); + PoolReadGuard pgMgm(&mgm0Lis3Set); + results.push_back(pgMgm.getReadResult()); } { PoolReadGuard pgMgm(&mgm1Rm3100Set); @@ -51,31 +51,49 @@ ReturnValue_t SensorValues::updateMgm() { } ReturnValue_t SensorValues::updateSus() { - ReturnValue_t result; - PoolReadGuard pgSus0(&susSets[0]), pgSus1(&susSets[1]), pgSus2(&susSets[2]), pgSus3(&susSets[3]), - pgSus4(&susSets[4]), pgSus5(&susSets[5]), pgSus6(&susSets[6]), pgSus7(&susSets[7]), - pgSus8(&susSets[8]), pgSus9(&susSets[9]), pgSus10(&susSets[10]), pgSus11(&susSets[11]); - - result = (pgSus0.getReadResult() || pgSus1.getReadResult() || pgSus2.getReadResult() || - pgSus3.getReadResult() || pgSus4.getReadResult() || pgSus5.getReadResult() || - pgSus6.getReadResult() || pgSus7.getReadResult() || pgSus8.getReadResult() || - pgSus9.getReadResult() || pgSus10.getReadResult() || pgSus11.getReadResult()); - return result; + std::vector results; + for (auto& susSet : susSets) { + { + PoolReadGuard pgSus(&susSet); + results.push_back(pgSus.getReadResult()); + } + } + for (const auto& result : results) { + if (result != returnvalue::OK) { + return result; + } + } + return returnvalue::OK; } ReturnValue_t SensorValues::updateGyr() { - ReturnValue_t result; - PoolReadGuard pgGyr0(&gyr0AdisSet), pgGyr1(&gyr1L3gSet), pgGyr2(&gyr2AdisSet), - pgGyr3(&gyr3L3gSet); - - result = (pgGyr0.getReadResult() || pgGyr1.getReadResult() || pgGyr2.getReadResult() || - pgGyr3.getReadResult()); - return result; + std::vector results; + { + PoolReadGuard pgGyr(&gyr0AdisSet); + results.push_back(pgGyr.getReadResult()); + } + { + PoolReadGuard pgGyr(&gyr1L3gSet); + results.push_back(pgGyr.getReadResult()); + } + { + PoolReadGuard pgGyr(&gyr2AdisSet); + results.push_back(pgGyr.getReadResult()); + } + { + PoolReadGuard pgGyr(&gyr3L3gSet); + results.push_back(pgGyr.getReadResult()); + } + for (const auto& result : results) { + if (result != returnvalue::OK) { + return result; + } + } + return returnvalue::OK; } ReturnValue_t SensorValues::updateStr() { PoolReadGuard pgStr(&strSet); - return pgStr.getReadResult(); } @@ -85,12 +103,29 @@ ReturnValue_t SensorValues::updateGps() { } ReturnValue_t SensorValues::updateRw() { - ReturnValue_t result; - PoolReadGuard pgRw1(&rw1Set), pgRw2(&rw2Set), pgRw3(&rw3Set), pgRw4(&rw4Set); - - result = (pgRw1.getReadResult() || pgRw2.getReadResult() || pgRw3.getReadResult() || - pgRw4.getReadResult()); - return result; + std::vector results; + { + PoolReadGuard pgRw(&rw1Set); + results.push_back(pgRw.getReadResult()); + } + { + PoolReadGuard pgRw(&rw2Set); + results.push_back(pgRw.getReadResult()); + } + { + PoolReadGuard pgRw(&rw3Set); + results.push_back(pgRw.getReadResult()); + } + { + PoolReadGuard pgRw(&rw4Set); + results.push_back(pgRw.getReadResult()); + } + for (const auto& result : results) { + if (result != returnvalue::OK) { + return result; + } + } + return returnvalue::OK; } ReturnValue_t SensorValues::update() { -- 2.43.0 From b943fee5158a04e1fcce4dd58339c5e624cf51e0 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 8 Feb 2023 17:17:19 +0100 Subject: [PATCH 4/4] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c545da36..b112aeef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ change warranting a new major release: # [unreleased] +## Changed + +- Replaced chained locks for polling new sensor data to the `AcsController` + # [v1.26.1] 2023-02-08 - Initialize parameter helper in ACS controller. -- 2.43.0