From 7870a2015eed994ad55723f47d036ce39a451030 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 13 Jul 2023 20:49:42 +0200 Subject: [PATCH] add auto threshold config --- mission/acs/str/StarTrackerHandler.cpp | 23 +++++++++++++- mission/acs/str/StarTrackerHandler.h | 2 ++ mission/acs/str/arcsecJsonKeys.h | 7 ++++ mission/acs/str/strHelpers.h | 2 ++ mission/acs/str/strJsonCommands.cpp | 44 ++++++++++++++++++++++++++ mission/acs/str/strJsonCommands.h | 16 ++++++++++ tmtc | 2 +- 7 files changed, 94 insertions(+), 2 deletions(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index ca11a11c..04b5b103 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -408,6 +408,10 @@ ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id = startracker::DEBUG_CAMERA; return buildCommandFromCommand( *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); + case FwBootState::AUTO_THRESHOLD: + *id = startracker::AUTO_THRESHOLD; + return buildCommandFromCommand( + *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); default: { sif::error << "STR: Unexpected boot state" << (int)bootState << std::endl; return NOTHING_TO_SEND; @@ -556,6 +560,11 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareParamCommand(commandData, commandDataLen, jcfgs.logLevel, reinitNextSetParam); return result; } + case (startracker::AUTO_THRESHOLD): { + result = + prepareParamCommand(commandData, commandDataLen, jcfgs.autoThreshold, reinitNextSetParam); + return result; + } case (startracker::LOGSUBSCRIPTION): { result = prepareParamCommand(commandData, commandDataLen, jcfgs.logSubscription, reinitNextSetParam); @@ -668,6 +677,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() { startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::LIMITS, 3, nullptr, startracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(startracker::AUTO_THRESHOLD, 2, nullptr, + startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::MOUNTING, 3, nullptr, startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::IMAGE_PROCESSOR, 3, nullptr, @@ -845,6 +856,7 @@ void StarTrackerHandler::setUpJsonCfgs(JsonConfigs& cfgs, const char* paramJsonF cfgs.mounting.init(paramJsonFile); cfgs.limits.init(paramJsonFile); cfgs.subscription.init(paramJsonFile); + cfgs.autoThreshold.init(paramJsonFile); JCFG_DONE = true; } @@ -972,7 +984,8 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, case (startracker::TRACKING): case (startracker::VALIDATION): case (startracker::IMAGE_PROCESSOR): - case (startracker::ALGO): { + case (startracker::ALGO): + case (startracker::AUTO_THRESHOLD): { result = handleSetParamReply(packet); break; } @@ -1450,6 +1463,10 @@ ReturnValue_t StarTrackerHandler::scanForSetParameterReply(uint8_t replyId, *foundId = startracker::DEBUG_CAMERA; break; } + case (startracker::ID::AUTO_THRESHOLD): { + *foundId = startracker::AUTO_THRESHOLD; + break; + } case (startracker::ID::LOG_SUBSCRIPTION): { *foundId = startracker::LOGSUBSCRIPTION; break; @@ -2138,6 +2155,10 @@ void StarTrackerHandler::handleStartup(uint8_t tmType, uint8_t parameterId) { break; } case (startracker::ID::DEBUG_CAMERA): { + bootState = FwBootState::AUTO_THRESHOLD; + break; + } + case (startracker::ID::AUTO_THRESHOLD): { bootState = FwBootState::NONE; internalState = InternalState::DONE; break; diff --git a/mission/acs/str/StarTrackerHandler.h b/mission/acs/str/StarTrackerHandler.h index 34a10746..57553286 100644 --- a/mission/acs/str/StarTrackerHandler.h +++ b/mission/acs/str/StarTrackerHandler.h @@ -227,6 +227,7 @@ class StarTrackerHandler : public DeviceHandlerBase { Mounting mounting; Limits limits; Subscription subscription; + AutoThreshold autoThreshold; }; JsonConfigs jcfgs; Countdown jcfgCountdown = Countdown(250); @@ -280,6 +281,7 @@ class StarTrackerHandler : public DeviceHandlerBase { ALGO, LOG_SUBSCRIPTION, DEBUG_CAMERA, + AUTO_THRESHOLD, WAIT_FOR_EXECUTION, RETRY_CFG_CMD }; diff --git a/mission/acs/str/arcsecJsonKeys.h b/mission/acs/str/arcsecJsonKeys.h index f9e2f4f1..c44ece9f 100644 --- a/mission/acs/str/arcsecJsonKeys.h +++ b/mission/acs/str/arcsecJsonKeys.h @@ -176,6 +176,13 @@ static const char DEBUG_CAMERA[] = "DebugCamera"; static const char TIMING[] = "timing"; static const char TEST[] = "test"; +static constexpr char AUTO_THRESHOLD[] = "AutoThreshold"; +static constexpr char AT_MODE[] = "mode"; +static constexpr char AT_DESIRED_BLOB_COUNTS[] = "desiredBlobsCount"; +static constexpr char AT_MIN_THRESHOLD[] = "minThreshold"; +static constexpr char AT_MAX_THRESHOLD[] = "maxThreshold"; +static constexpr char AT_THRESHOLD_KP[] = "thresholdKp"; + } // namespace arcseckeys #endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_ARCSECJSONKEYS_H_ */ diff --git a/mission/acs/str/strHelpers.h b/mission/acs/str/strHelpers.h index 894ceac5..1c4b37cf 100644 --- a/mission/acs/str/strHelpers.h +++ b/mission/acs/str/strHelpers.h @@ -327,6 +327,7 @@ static const DeviceCommandId_t FIRMWARE_UPDATE = 84; static const DeviceCommandId_t DISABLE_TIMESTAMP_GENERATION = 85; static const DeviceCommandId_t ENABLE_TIMESTAMP_GENERATION = 86; static constexpr DeviceCommandId_t SET_TIME_FROM_SYS_TIME = 87; +static constexpr DeviceCommandId_t AUTO_THRESHOLD = 88; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; @@ -410,6 +411,7 @@ static const uint8_t TAKE_IMAGE = 15; static const uint8_t LOG_LEVEL = 3; static const uint8_t LOG_SUBSCRIPTION = 19; static const uint8_t DEBUG_CAMERA = 20; +static const uint8_t AUTO_THRESHOLD = 23; } // namespace ID namespace Program { diff --git a/mission/acs/str/strJsonCommands.cpp b/mission/acs/str/strJsonCommands.cpp index 134a00a0..522bb040 100644 --- a/mission/acs/str/strJsonCommands.cpp +++ b/mission/acs/str/strJsonCommands.cpp @@ -916,3 +916,47 @@ ReturnValue_t DebugCamera::createCommand(uint8_t* buffer) { adduint32(param, buffer + offset); return returnvalue::OK; } + +AutoThreshold::AutoThreshold() : ArcsecJsonParamBase(arcseckeys::AUTO_THRESHOLD) {} + +size_t AutoThreshold::getSize() { return COMMAND_SIZE; } + +ReturnValue_t AutoThreshold::createCommand(uint8_t* buffer) { + sif::debug << "creating auto threshold command" << std::endl; + ReturnValue_t result = returnvalue::OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, startracker::ID::LOG_SUBSCRIPTION); + offset = 2; + result = getParam(arcseckeys::AT_MODE, param); + if (result != returnvalue::OK) { + return result; + } + adduint8(param, buffer + offset); + offset += 1; + result = getParam(arcseckeys::AT_DESIRED_BLOB_COUNTS, param); + if (result != returnvalue::OK) { + return result; + } + adduint8(param, buffer + offset); + offset += 1; + result = getParam(arcseckeys::AT_MIN_THRESHOLD, param); + if (result != returnvalue::OK) { + return result; + } + adduint16(param, buffer + offset); + offset += 2; + result = getParam(arcseckeys::AT_MAX_THRESHOLD, param); + if (result != returnvalue::OK) { + return result; + } + adduint16(param, buffer + offset); + offset += 2; + result = getParam(arcseckeys::AT_THRESHOLD_KP, param); + if (result != returnvalue::OK) { + return result; + } + addfloat(param, buffer + offset); + offset += 4; + return returnvalue::OK; +} diff --git a/mission/acs/str/strJsonCommands.h b/mission/acs/str/strJsonCommands.h index 99588f9c..7e75c0b1 100644 --- a/mission/acs/str/strJsonCommands.h +++ b/mission/acs/str/strJsonCommands.h @@ -222,6 +222,22 @@ class LogSubscription : public ArcsecJsonParamBase { ReturnValue_t createCommand(uint8_t* buffer) override; }; +/** + * @brief Generates command to set log subscription parameters. + * + */ +class AutoThreshold : public ArcsecJsonParamBase { + public: + AutoThreshold(); + + size_t getSize(); + + private: + static const size_t COMMAND_SIZE = 12; + + ReturnValue_t createCommand(uint8_t* buffer) override; +}; + /** * @brief Generates command to set debug camera parameters * diff --git a/tmtc b/tmtc index 26cf1121..c6e2e2de 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 26cf112121782e730057cda0766d435ee2077b6d +Subproject commit c6e2e2de49e3d49fed1b5a43a94528c0c4aceafe