From 6a6789ae99ecfe95be7581fdb7a368c70e1b0625 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 2 Oct 2023 16:11:17 +0200 Subject: [PATCH 01/25] STR extensions --- mission/acs/str/StarTrackerHandler.cpp | 124 +++++++++++++++++++++++-- mission/acs/str/StarTrackerHandler.h | 7 ++ mission/acs/str/strHelpers.h | 44 ++++++++- tmtc | 2 +- 4 files changed, 164 insertions(+), 13 deletions(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index a6091d7c..fb895d78 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -607,6 +607,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareRequestLisaParams(); return result; } + case (startracker::REQ_MATCHED_CENTROIDS): { + result = prepareRequestMatchedCentroids(); + return result; + } case (startracker::REQ_MATCHING): { result = prepareRequestMatchingParams(); return result; @@ -729,6 +733,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() { startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::REQ_DEBUG_CAMERA, 3, &debugCameraSet, startracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(startracker::REQ_MATCHED_CENTROIDS, 3, &matchedCentroids, + startracker::MAX_FRAME_SIZE * 2 + 2); } ReturnValue_t StarTrackerHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) { @@ -860,6 +866,16 @@ void StarTrackerHandler::setUpJsonCfgs(JsonConfigs& cfgs, const char* paramJsonF JCFG_DONE = true; } +ReturnValue_t StarTrackerHandler::statusFieldCheck(const uint8_t* rawFrame) { + uint8_t status = startracker::getStatusField(rawFrame); + if (status != startracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleTm: Reply error: " + << static_cast(status) << std::endl; + return REPLY_ERROR; + } + return returnvalue::OK; +} + void StarTrackerHandler::bootBootloader() { if (internalState == InternalState::IDLE) { internalState = InternalState::BOOT_BOOTLOADER; @@ -896,24 +912,24 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t rema } case TMTC_ACTIONREPLY: { *foundLen = remainingSize; + fullPacketLen = remainingSize; return scanForActionReply(startracker::getId(start), foundId); - break; } case TMTC_SETPARAMREPLY: { *foundLen = remainingSize; + fullPacketLen = remainingSize; return scanForSetParameterReply(startracker::getId(start), foundId); - break; } case TMTC_PARAMREPLY: { *foundLen = remainingSize; + fullPacketLen = remainingSize; return scanForGetParameterReply(startracker::getId(start), foundId); - break; } case TMTC_TELEMETRYREPLYA: case TMTC_TELEMETRYREPLY: { *foundLen = remainingSize; + fullPacketLen = remainingSize; return scanForTmReply(startracker::getId(start), foundId); - break; } default: { sif::debug << "StarTrackerHandler::scanForReply: Reply has invalid type id" << std::endl; @@ -970,6 +986,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, result = handleTm(packet, solutionSet, startracker::SolutionSet::SIZE, "REQ_SOLUTION"); break; } + case (startracker::REQ_MATCHED_CENTROIDS): { + result = handleMatchedCentroidTm(packet); + break; + } case (startracker::REQ_TEMPERATURE): { result = handleTm(packet, temperatureSet, startracker::TemperatureSet::SIZE, "REQ_TEMP"); break; @@ -1032,6 +1052,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, handleParamRequest(packet, trackingSet, startracker::TrackingSet::SIZE); break; } + case (startracker::REQ_MATCHED_CENTROIDS): { + handleParamRequest(packet, matchedCentroids, startracker::MatchedCentroidsSet::SIZE); + break; + } case (startracker::REQ_VALIDATION): { handleParamRequest(packet, validationSet, startracker::ValidationSet::SIZE); break; @@ -1328,6 +1352,20 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(startracker::DEBUG_CAMERA_TEST, new PoolEntry({0})); localDataPoolMap.emplace(startracker::CHKSUM, new PoolEntry({0})); + localDataPoolMap.emplace(startracker::PoolIds::NUM_MATCHED_CENTROIDS, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_STAR_IDS, + new PoolEntry(16)); + localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_X_COORDS, + new PoolEntry(16)); + localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_Y_COORDS, + new PoolEntry(16)); + localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_X_ERRORS, + new PoolEntry(16)); + localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_Y_ERRORS, + new PoolEntry(16)); + localDataPoolMap.emplace(startracker::PoolIds::TICKS_MATCHED_CENTROIDS, + new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::TIME_MATCHED_CENTROIDS, new PoolEntry()); poolManager.subscribeForDiagPeriodicPacket( subdp::DiagnosticsHkPeriodicParams(temperatureSet.getSid(), false, 10.0)); @@ -1760,6 +1798,14 @@ void StarTrackerHandler::prepareHistogramRequest() { rawPacketLen = length; } +ReturnValue_t StarTrackerHandler::prepareRequestMatchedCentroids() { + uint32_t length = 0; + arc_tm_pack_matchedcentroids_req(commandBuffer, &length); + rawPacket = commandBuffer; + rawPacketLen = length; + return returnvalue::OK; +} + ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, ArcsecJsonParamBase& paramSet, @@ -2039,12 +2085,9 @@ ReturnValue_t StarTrackerHandler::checkProgram() { ReturnValue_t StarTrackerHandler::handleTm(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset, size_t size, const char* context) { - ReturnValue_t result = returnvalue::OK; - uint8_t status = startracker::getStatusField(rawFrame); - if (status != startracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleTm: Reply error: " - << static_cast(status) << std::endl; - return REPLY_ERROR; + ReturnValue_t result = statusFieldCheck(rawFrame); + if (result != returnvalue::OK) { + return result; } result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != returnvalue::OK) { @@ -2069,6 +2112,66 @@ ReturnValue_t StarTrackerHandler::handleTm(const uint8_t* rawFrame, LocalPoolDat return result; } +ReturnValue_t StarTrackerHandler::handleMatchedCentroidTm(const uint8_t* rawFrame) { + ReturnValue_t result = statusFieldCheck(rawFrame); + if (result != returnvalue::OK) { + return result; + } + const uint8_t* reply = rawFrame + TICKS_OFFSET; + size_t remainingLen = fullPacketLen; + PoolReadGuard pg(&matchedCentroids); + result = pg.getReadResult(); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&matchedCentroids.ticks, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&matchedCentroids.timeUs, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&matchedCentroids.numberOfMatchedCentroids, &rawFrame, + &remainingLen, SerializeIF::Endianness::LITTLE); + + if (result != returnvalue::OK) { + return result; + } + // Yeah, we serialize it like that because I can't model anything with that local datapool crap. + for (unsigned idx = 0; idx < 16; idx++) { + result = SerializeAdapter::deSerialize(&matchedCentroids.starIds[idx], &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&matchedCentroids.xCoords[idx], &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&matchedCentroids.yCoords[idx], &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&matchedCentroids.xErrors[idx], &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&matchedCentroids.yErrors[idx], &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + } + matchedCentroids.setValidity(true, true); + return returnvalue::OK; +} + ReturnValue_t StarTrackerHandler::handleActionReplySet(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset, size_t size) { ReturnValue_t result = returnvalue::OK; @@ -2204,6 +2307,7 @@ ReturnValue_t StarTrackerHandler::checkCommand(ActionId_t actionId) { case startracker::REQ_SUBSCRIPTION: case startracker::REQ_LOG_SUBSCRIPTION: case startracker::REQ_DEBUG_CAMERA: + case startracker::REQ_MATCHED_CENTROIDS: if (getMode() == MODE_ON and getSubmode() != startracker::Program::FIRMWARE) { return STARTRACKER_NOT_RUNNING_FIRMWARE; } diff --git a/mission/acs/str/StarTrackerHandler.h b/mission/acs/str/StarTrackerHandler.h index 1e790695..723a8aa8 100644 --- a/mission/acs/str/StarTrackerHandler.h +++ b/mission/acs/str/StarTrackerHandler.h @@ -204,6 +204,7 @@ class StarTrackerHandler : public DeviceHandlerBase { startracker::SubscriptionSet subscriptionSet; startracker::LogSubscriptionSet logSubscriptionSet; startracker::DebugCameraSet debugCameraSet; + startracker::MatchedCentroidsSet matchedCentroids; // Pointer to object responsible for uploading and downloading images to/from the star tracker StrComHandler* strHelper = nullptr; @@ -297,6 +298,8 @@ class StarTrackerHandler : public DeviceHandlerBase { const power::Switch_t powerSwitch = power::NO_SWITCH; + size_t fullPacketLen = 0; + /** * @brief Handles internal state */ @@ -429,6 +432,7 @@ class StarTrackerHandler : public DeviceHandlerBase { ReturnValue_t prepareRequestCentroidingParams(); ReturnValue_t prepareRequestLisaParams(); ReturnValue_t prepareRequestMatchingParams(); + ReturnValue_t prepareRequestMatchedCentroids(); ReturnValue_t prepareRequestTrackingParams(); ReturnValue_t prepareRequestValidationParams(); ReturnValue_t prepareRequestAlgoParams(); @@ -477,6 +481,7 @@ class StarTrackerHandler : public DeviceHandlerBase { */ void handleStartup(uint8_t tmType, uint8_t parameterId); + ReturnValue_t statusFieldCheck(const uint8_t* rawFrame); /** * @brief Handles telemtry replies and fills the appropriate dataset * @@ -488,6 +493,8 @@ class StarTrackerHandler : public DeviceHandlerBase { ReturnValue_t handleTm(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset, size_t size, const char* context); + ReturnValue_t handleMatchedCentroidTm(const uint8_t* rawFrame); + /** * @brief Checks if star tracker is in valid mode for executing the received command. * diff --git a/mission/acs/str/strHelpers.h b/mission/acs/str/strHelpers.h index c6336186..b6a64f29 100644 --- a/mission/acs/str/strHelpers.h +++ b/mission/acs/str/strHelpers.h @@ -272,7 +272,16 @@ enum PoolIds : lp_id_t { LOG_SUBSCRIPTION_LEVEL2, LOG_SUBSCRIPTION_MODULE2, DEBUG_CAMERA_TIMING, - DEBUG_CAMERA_TEST + DEBUG_CAMERA_TEST, + + TICKS_MATCHED_CENTROIDS, + TIME_MATCHED_CENTROIDS, + NUM_MATCHED_CENTROIDS, + MATCHED_CENTROIDS_STAR_IDS, + MATCHED_CENTROIDS_X_COORDS, + MATCHED_CENTROIDS_Y_COORDS, + MATCHED_CENTROIDS_X_ERRORS, + MATCHED_CENTROIDS_Y_ERRORS, }; static const DeviceCommandId_t PING_REQUEST = 0; @@ -328,6 +337,7 @@ 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 constexpr DeviceCommandId_t REQ_MATCHED_CENTROIDS = 89; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; @@ -352,6 +362,7 @@ static const uint32_t ALGO_SET_ID = REQ_ALGO; static const uint32_t SUBSCRIPTION_SET_ID = REQ_SUBSCRIPTION; static const uint32_t LOG_SUBSCRIPTION_SET_ID = REQ_LOG_SUBSCRIPTION; static const uint32_t DEBUG_CAMERA_SET_ID = REQ_DEBUG_CAMERA; +static const uint32_t MATCHED_CENTROIDS_SET_ID = REQ_MATCHED_CENTROIDS; /** Max size of unencoded frame */ static const size_t MAX_FRAME_SIZE = 1200; @@ -666,7 +677,7 @@ class SolutionSet : public StaticLocalDataSet { // Ticks timestamp lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_SOLUTION_SET, this); - /// Unix time stamp + // Unix time stamp lp_var_t timeUs = lp_var_t(sid.objectId, PoolIds::TIME_SOLUTION_SET, this); // Calibrated quaternion (takes into account the mounting quaternion), typically same as // track q values @@ -1381,6 +1392,35 @@ class ValidationSet : public StaticLocalDataSet { } }; +class MatchedCentroidsSet : public StaticLocalDataSet<20> { + public: + static constexpr size_t SIZE = 321; + MatchedCentroidsSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, MATCHED_CENTROIDS_SET_ID) {} + MatchedCentroidsSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, MATCHED_CENTROIDS_SET_ID)) {} + // Ticks timestamp + lp_var_t ticks = + lp_var_t(sid.objectId, PoolIds::TICKS_MATCHED_CENTROIDS, this); + // Unix time stamp + lp_var_t timeUs = + lp_var_t(sid.objectId, PoolIds::TIME_MATCHED_CENTROIDS, this); + lp_var_t numberOfMatchedCentroids = + lp_var_t(sid.objectId, PoolIds::NUM_MATCHED_CENTROIDS, this); + lp_vec_t starIds = + lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_STAR_IDS); + lp_vec_t xCoords = + lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_X_COORDS); + lp_vec_t yCoords = + lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_Y_COORDS); + lp_vec_t xErrors = + lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_X_ERRORS); + lp_vec_t yErrors = + lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_Y_ERRORS); + + private: +}; + /** * @brief Will store the requested algo parameters */ diff --git a/tmtc b/tmtc index 22a42108..783bdd29 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 22a42108b431bafa707de2b3a24cad9de95b70d0 +Subproject commit 783bdd297a931a96c8b077ec2c2456a203b23ffc -- 2.43.0 From a46f712538355d4faa015178e9a2863277700e94 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 4 Oct 2023 10:44:03 +0200 Subject: [PATCH 02/25] STR handler --- mission/acs/str/StarTrackerHandler.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index fb895d78..d6aae0d8 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -49,6 +49,7 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, subscriptionSet(this), logSubscriptionSet(this), debugCameraSet(this), + matchedCentroids(this), strHelper(strHelper), paramJsonFile(jsonFileStr), powerSwitch(powerSwitch) { @@ -1052,10 +1053,6 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, handleParamRequest(packet, trackingSet, startracker::TrackingSet::SIZE); break; } - case (startracker::REQ_MATCHED_CENTROIDS): { - handleParamRequest(packet, matchedCentroids, startracker::MatchedCentroidsSet::SIZE); - break; - } case (startracker::REQ_VALIDATION): { handleParamRequest(packet, validationSet, startracker::ValidationSet::SIZE); break; @@ -2117,7 +2114,6 @@ ReturnValue_t StarTrackerHandler::handleMatchedCentroidTm(const uint8_t* rawFram if (result != returnvalue::OK) { return result; } - const uint8_t* reply = rawFrame + TICKS_OFFSET; size_t remainingLen = fullPacketLen; PoolReadGuard pg(&matchedCentroids); result = pg.getReadResult(); -- 2.43.0 From d64372833c306a323c5baf5c3376bbf4cf2572d9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 6 Oct 2023 11:23:31 +0200 Subject: [PATCH 03/25] added blob tm --- mission/acs/str/StarTrackerHandler.cpp | 137 +++++++++++++++++++++++++ mission/acs/str/StarTrackerHandler.h | 6 ++ mission/acs/str/strHelpers.h | 42 ++++++++ 3 files changed, 185 insertions(+) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index d6aae0d8..0f9c86de 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -50,6 +50,7 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, logSubscriptionSet(this), debugCameraSet(this), matchedCentroids(this), + blobsSet(this), strHelper(strHelper), paramJsonFile(jsonFileStr), powerSwitch(powerSwitch) { @@ -612,6 +613,14 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareRequestMatchedCentroids(); return result; } + case (startracker::REQ_BLOB): { + result = prepareRequestBlobTm(); + return result; + } + case (startracker::REQ_BLOBS): { + result = prepareRequestBlobsTm(); + return result; + } case (startracker::REQ_MATCHING): { result = prepareRequestMatchingParams(); return result; @@ -736,6 +745,10 @@ void StarTrackerHandler::fillCommandAndReplyMap() { startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::REQ_MATCHED_CENTROIDS, 3, &matchedCentroids, startracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(startracker::REQ_BLOB, 3, &blobsSet, + startracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(startracker::REQ_BLOBS, 3, &blobsSet, + startracker::MAX_FRAME_SIZE * 2 + 2); } ReturnValue_t StarTrackerHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) { @@ -991,6 +1004,14 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, result = handleMatchedCentroidTm(packet); break; } + case (startracker::REQ_BLOB): { + result = handleBlobTm(packet); + break; + } + case (startracker::REQ_BLOBS): { + result = handleBlobsTm(packet); + break; + } case (startracker::REQ_TEMPERATURE): { result = handleTm(packet, temperatureSet, startracker::TemperatureSet::SIZE, "REQ_TEMP"); break; @@ -1364,6 +1385,14 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l new PoolEntry()); localDataPoolMap.emplace(startracker::PoolIds::TIME_MATCHED_CENTROIDS, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::BLOB_COUNT, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::BLOBS_COUNT, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::BLOBS_COUNT_USED, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::BLOBS_NR_4LINES_SKIPPED, + new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::BLOBS_X_COORDS, new PoolEntry(8)); + localDataPoolMap.emplace(startracker::PoolIds::BLOBS_Y_COORDS, new PoolEntry(8)); + poolManager.subscribeForDiagPeriodicPacket( subdp::DiagnosticsHkPeriodicParams(temperatureSet.getSid(), false, 10.0)); poolManager.subscribeForRegularPeriodicPacket( @@ -1803,6 +1832,22 @@ ReturnValue_t StarTrackerHandler::prepareRequestMatchedCentroids() { return returnvalue::OK; } +ReturnValue_t StarTrackerHandler::prepareRequestBlobTm() { + uint32_t length = 0; + arc_tm_pack_blob_req(commandBuffer, &length); + rawPacket = commandBuffer; + rawPacketLen = length; + return returnvalue::OK; +} + +ReturnValue_t StarTrackerHandler::prepareRequestBlobsTm() { + uint32_t length = 0; + arc_tm_pack_blobs_req(commandBuffer, &length); + rawPacket = commandBuffer; + rawPacketLen = length; + return returnvalue::OK; +} + ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, ArcsecJsonParamBase& paramSet, @@ -2168,6 +2213,96 @@ ReturnValue_t StarTrackerHandler::handleMatchedCentroidTm(const uint8_t* rawFram return returnvalue::OK; } +ReturnValue_t StarTrackerHandler::handleBlobTm(const uint8_t* rawFrame) { + ReturnValue_t result = statusFieldCheck(rawFrame); + if (result != returnvalue::OK) { + return result; + } + size_t remainingLen = fullPacketLen; + PoolReadGuard pg(&blobsSet); + result = pg.getReadResult(); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&blobsSet.ticksBlobTm, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&blobsSet.timeUsBlobTm, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&blobsSet.blobCount, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + blobsSet.ticksBlobTm.setValid(true); + blobsSet.timeUsBlobTm.setValid(true); + blobsSet.blobCount.setValid(true); + return returnvalue::OK; +} + +ReturnValue_t StarTrackerHandler::handleBlobsTm(const uint8_t* rawFrame) { + ReturnValue_t result = statusFieldCheck(rawFrame); + if (result != returnvalue::OK) { + return result; + } + size_t remainingLen = fullPacketLen; + PoolReadGuard pg(&blobsSet); + result = pg.getReadResult(); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&blobsSet.ticksBlobsTm, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&blobsSet.timeUsBlobsTm, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&blobsSet.blobsCount, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&blobsSet.blobsCountUsed, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&blobsSet.nr4LinesSkipped, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + for (unsigned idx = 0; idx < 8; idx++) { + result = SerializeAdapter::deSerialize(&blobsSet.xCoords[idx], &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&blobsSet.yCoords[idx], &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + } + blobsSet.ticksBlobsTm.setValid(true); + blobsSet.timeUsBlobsTm.setValid(true); + blobsSet.blobsCount.setValid(true); + blobsSet.blobsCountUsed.setValid(true); + blobsSet.nr4LinesSkipped.setValid(true); + blobsSet.xCoords.setValid(true); + blobsSet.yCoords.setValid(true); + return returnvalue::OK; +} + ReturnValue_t StarTrackerHandler::handleActionReplySet(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset, size_t size) { ReturnValue_t result = returnvalue::OK; @@ -2304,6 +2439,8 @@ ReturnValue_t StarTrackerHandler::checkCommand(ActionId_t actionId) { case startracker::REQ_LOG_SUBSCRIPTION: case startracker::REQ_DEBUG_CAMERA: case startracker::REQ_MATCHED_CENTROIDS: + case startracker::REQ_BLOB: + case startracker::REQ_BLOBS: if (getMode() == MODE_ON and getSubmode() != startracker::Program::FIRMWARE) { return STARTRACKER_NOT_RUNNING_FIRMWARE; } diff --git a/mission/acs/str/StarTrackerHandler.h b/mission/acs/str/StarTrackerHandler.h index 723a8aa8..db8335b0 100644 --- a/mission/acs/str/StarTrackerHandler.h +++ b/mission/acs/str/StarTrackerHandler.h @@ -151,6 +151,7 @@ class StarTrackerHandler : public DeviceHandlerBase { static const uint8_t PARAMS_OFFSET = 2; static const uint8_t TICKS_OFFSET = 3; static const uint8_t TIME_OFFSET = 7; + static const uint8_t TM_PARAM_OFFSET = 15; static const uint8_t PARAMETER_ID_OFFSET = 1; static const uint8_t ACTION_ID_OFFSET = 1; static const uint8_t ACTION_DATA_OFFSET = 3; @@ -205,6 +206,7 @@ class StarTrackerHandler : public DeviceHandlerBase { startracker::LogSubscriptionSet logSubscriptionSet; startracker::DebugCameraSet debugCameraSet; startracker::MatchedCentroidsSet matchedCentroids; + startracker::BlobsSet blobsSet; // Pointer to object responsible for uploading and downloading images to/from the star tracker StrComHandler* strHelper = nullptr; @@ -433,6 +435,8 @@ class StarTrackerHandler : public DeviceHandlerBase { ReturnValue_t prepareRequestLisaParams(); ReturnValue_t prepareRequestMatchingParams(); ReturnValue_t prepareRequestMatchedCentroids(); + ReturnValue_t prepareRequestBlobTm(); + ReturnValue_t prepareRequestBlobsTm(); ReturnValue_t prepareRequestTrackingParams(); ReturnValue_t prepareRequestValidationParams(); ReturnValue_t prepareRequestAlgoParams(); @@ -494,6 +498,8 @@ class StarTrackerHandler : public DeviceHandlerBase { const char* context); ReturnValue_t handleMatchedCentroidTm(const uint8_t* rawFrame); + ReturnValue_t handleBlobTm(const uint8_t* rawFrame); + ReturnValue_t handleBlobsTm(const uint8_t* rawFrame); /** * @brief Checks if star tracker is in valid mode for executing the received command. diff --git a/mission/acs/str/strHelpers.h b/mission/acs/str/strHelpers.h index b6a64f29..96692c0b 100644 --- a/mission/acs/str/strHelpers.h +++ b/mission/acs/str/strHelpers.h @@ -282,6 +282,18 @@ enum PoolIds : lp_id_t { MATCHED_CENTROIDS_Y_COORDS, MATCHED_CENTROIDS_X_ERRORS, MATCHED_CENTROIDS_Y_ERRORS, + + BLOB_TICKS, + BLOB_TIME, + BLOB_COUNT, + + BLOBS_TICKS, + BLOBS_TIME, + BLOBS_COUNT, + BLOBS_COUNT_USED, + BLOBS_NR_4LINES_SKIPPED, + BLOBS_X_COORDS, + BLOBS_Y_COORDS, }; static const DeviceCommandId_t PING_REQUEST = 0; @@ -338,6 +350,8 @@ 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 constexpr DeviceCommandId_t REQ_MATCHED_CENTROIDS = 89; +static constexpr DeviceCommandId_t REQ_BLOB = 90; +static constexpr DeviceCommandId_t REQ_BLOBS = 91; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; @@ -363,6 +377,7 @@ static const uint32_t SUBSCRIPTION_SET_ID = REQ_SUBSCRIPTION; static const uint32_t LOG_SUBSCRIPTION_SET_ID = REQ_LOG_SUBSCRIPTION; static const uint32_t DEBUG_CAMERA_SET_ID = REQ_DEBUG_CAMERA; static const uint32_t MATCHED_CENTROIDS_SET_ID = REQ_MATCHED_CENTROIDS; +static const uint32_t BLOBS_SET_ID = REQ_BLOBS; /** Max size of unencoded frame */ static const size_t MAX_FRAME_SIZE = 1200; @@ -1421,6 +1436,33 @@ class MatchedCentroidsSet : public StaticLocalDataSet<20> { private: }; +class BlobsSet : public StaticLocalDataSet<20> { + public: + BlobsSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BLOBS_SET_ID) {} + + private: + // The blob count received from the Blob Telemetry Set (ID 25) + // Ticks timestamp + lp_var_t ticksBlobTm = lp_var_t(sid.objectId, PoolIds::BLOB_TICKS, this); + // Unix time stamp + lp_var_t timeUsBlobTm = lp_var_t(sid.objectId, PoolIds::BLOB_TIME, this); + lp_var_t blobCount = lp_var_t(sid.objectId, PoolIds::BLOB_COUNT, this); + + // Ticks timestamp + lp_var_t ticksBlobsTm = lp_var_t(sid.objectId, PoolIds::BLOBS_TICKS, this); + // Unix time stamp + lp_var_t timeUsBlobsTm = lp_var_t(sid.objectId, PoolIds::BLOBS_TIME, this); + lp_var_t blobsCount = lp_var_t(sid.objectId, PoolIds::BLOBS_COUNT, this); + lp_var_t blobsCountUsed = + lp_var_t(sid.objectId, PoolIds::BLOBS_COUNT_USED, this); + lp_var_t nr4LinesSkipped = + lp_var_t(sid.objectId, PoolIds::BLOBS_NR_4LINES_SKIPPED, this); + lp_vec_t xCoords = + lp_vec_t(sid.objectId, PoolIds::BLOBS_X_COORDS, this); + lp_vec_t yCoords = + lp_vec_t(sid.objectId, PoolIds::BLOBS_Y_COORDS, this); +}; + /** * @brief Will store the requested algo parameters */ -- 2.43.0 From f2ee6995f969e9aefff25f980c38fadfc64b0886 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 6 Oct 2023 11:35:57 +0200 Subject: [PATCH 04/25] compile fixes --- mission/acs/str/StarTrackerHandler.cpp | 5 +++++ mission/acs/str/strHelpers.h | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 0f9c86de..97f3944d 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -1385,7 +1385,12 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l new PoolEntry()); localDataPoolMap.emplace(startracker::PoolIds::TIME_MATCHED_CENTROIDS, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::BLOB_TICKS, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::BLOB_TIME, new PoolEntry()); localDataPoolMap.emplace(startracker::PoolIds::BLOB_COUNT, new PoolEntry()); + + localDataPoolMap.emplace(startracker::PoolIds::BLOBS_TICKS, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::BLOBS_TIME, new PoolEntry()); localDataPoolMap.emplace(startracker::PoolIds::BLOBS_COUNT, new PoolEntry()); localDataPoolMap.emplace(startracker::PoolIds::BLOBS_COUNT_USED, new PoolEntry()); localDataPoolMap.emplace(startracker::PoolIds::BLOBS_NR_4LINES_SKIPPED, diff --git a/mission/acs/str/strHelpers.h b/mission/acs/str/strHelpers.h index 96692c0b..5d9c483f 100644 --- a/mission/acs/str/strHelpers.h +++ b/mission/acs/str/strHelpers.h @@ -1440,7 +1440,6 @@ class BlobsSet : public StaticLocalDataSet<20> { public: BlobsSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BLOBS_SET_ID) {} - private: // The blob count received from the Blob Telemetry Set (ID 25) // Ticks timestamp lp_var_t ticksBlobTm = lp_var_t(sid.objectId, PoolIds::BLOB_TICKS, this); -- 2.43.0 From e9e8a93cf40a71407749e2ed8987cd03633e1b55 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 6 Oct 2023 11:41:03 +0200 Subject: [PATCH 05/25] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ae7901e..88d29e9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ will consitute of a breaking change warranting a new major release: # [unreleased] +## Added + +- STR: Added new TM sets: Blob, Blobs, MatchedCentroids. + ## Changed - Changed internals for MPSoC boot process to make the code more understandable and some -- 2.43.0 From cc1be69764795be1c3da195f19d6842b04425613 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 9 Oct 2023 15:16:48 +0200 Subject: [PATCH 06/25] finished STR extensions TMTC --- mission/acs/str/StarTrackerHandler.cpp | 163 ++++++++++++++++++++++--- mission/acs/str/StarTrackerHandler.h | 7 ++ mission/acs/str/strHelpers.h | 68 +++++++++-- 3 files changed, 214 insertions(+), 24 deletions(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 97f3944d..20c2b511 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -50,7 +50,10 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, logSubscriptionSet(this), debugCameraSet(this), matchedCentroids(this), + blobSet(this), blobsSet(this), + centroidSet(this), + centroidsSet(this), strHelper(strHelper), paramJsonFile(jsonFileStr), powerSwitch(powerSwitch) { @@ -474,6 +477,12 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi prepareTimeRequest(); return returnvalue::OK; } + case (startracker::REQ_CENTROID): { + return returnvalue::OK; + } + case (startracker::REQ_CENTROIDS): { + return returnvalue::OK; + } case (startracker::BOOT): { prepareBootCommand(); return returnvalue::OK; @@ -745,10 +754,14 @@ void StarTrackerHandler::fillCommandAndReplyMap() { startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::REQ_MATCHED_CENTROIDS, 3, &matchedCentroids, startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::REQ_BLOB, 3, &blobsSet, + this->insertInCommandAndReplyMap(startracker::REQ_BLOB, 3, &blobSet, startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::REQ_BLOBS, 3, &blobsSet, startracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(startracker::REQ_CENTROID, 3, ¢roidSet, + startracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(startracker::REQ_CENTROIDS, 3, ¢roidsSet, + startracker::MAX_FRAME_SIZE * 2 + 2); } ReturnValue_t StarTrackerHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) { @@ -1012,6 +1025,14 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, result = handleBlobsTm(packet); break; } + case (startracker::REQ_CENTROID): { + result = handleCentroidTm(packet); + break; + } + case (startracker::REQ_CENTROIDS): { + result = handleCentroidsTm(packet); + break; + } case (startracker::REQ_TEMPERATURE): { result = handleTm(packet, temperatureSet, startracker::TemperatureSet::SIZE, "REQ_TEMP"); break; @@ -1398,6 +1419,17 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(startracker::PoolIds::BLOBS_X_COORDS, new PoolEntry(8)); localDataPoolMap.emplace(startracker::PoolIds::BLOBS_Y_COORDS, new PoolEntry(8)); + localDataPoolMap.emplace(startracker::PoolIds::CENTROID_TICKS, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::CENTROID_TIME, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::CENTROID_COUNT, new PoolEntry()); + + localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_TICKS, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_TIME, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_COUNT, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_X_COORDS, new PoolEntry(16)); + localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_Y_COORDS, new PoolEntry(16)); + localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_MAGNITUDES, new PoolEntry(16)); + poolManager.subscribeForDiagPeriodicPacket( subdp::DiagnosticsHkPeriodicParams(temperatureSet.getSid(), false, 10.0)); poolManager.subscribeForRegularPeriodicPacket( @@ -1412,6 +1444,16 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l subdp::RegularHkPeriodicParams(histogramSet.getSid(), false, 10.0)); poolManager.subscribeForRegularPeriodicPacket( subdp::RegularHkPeriodicParams(lisaSet.getSid(), false, 10.0)); + poolManager.subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams(matchedCentroids.getSid(), false, 10.0)); + poolManager.subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams(blobSet.getSid(), false, 10.0)); + poolManager.subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams(blobsSet.getSid(), false, 10.0)); + poolManager.subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams(centroidSet.getSid(), false, 10.0)); + poolManager.subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams(centroidsSet.getSid(), false, 10.0)); return returnvalue::OK; } @@ -1853,6 +1895,22 @@ ReturnValue_t StarTrackerHandler::prepareRequestBlobsTm() { return returnvalue::OK; } +ReturnValue_t StarTrackerHandler::prepareRequestCentroidTm() { + uint32_t length = 0; + arc_tm_pack_centroid_req(commandBuffer, &length); + rawPacket = commandBuffer; + rawPacketLen = length; + return returnvalue::OK; +} + +ReturnValue_t StarTrackerHandler::prepareRequestCentroidsTm() { + uint32_t length = 0; + arc_tm_pack_centroids_req(commandBuffer, &length); + rawPacket = commandBuffer; + rawPacketLen = length; + return returnvalue::OK; +} + ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, ArcsecJsonParamBase& paramSet, @@ -2229,24 +2287,22 @@ ReturnValue_t StarTrackerHandler::handleBlobTm(const uint8_t* rawFrame) { if (result != returnvalue::OK) { return result; } - result = SerializeAdapter::deSerialize(&blobsSet.ticksBlobTm, &rawFrame, &remainingLen, + result = SerializeAdapter::deSerialize(&blobSet.ticks, &rawFrame, &remainingLen, SerializeIF::Endianness::LITTLE); if (result != returnvalue::OK) { return result; } - result = SerializeAdapter::deSerialize(&blobsSet.timeUsBlobTm, &rawFrame, &remainingLen, + result = SerializeAdapter::deSerialize(&blobSet.timeUs, &rawFrame, &remainingLen, SerializeIF::Endianness::LITTLE); if (result != returnvalue::OK) { return result; } - result = SerializeAdapter::deSerialize(&blobsSet.blobCount, &rawFrame, &remainingLen, + result = SerializeAdapter::deSerialize(&blobSet.blobCount, &rawFrame, &remainingLen, SerializeIF::Endianness::LITTLE); if (result != returnvalue::OK) { return result; } - blobsSet.ticksBlobTm.setValid(true); - blobsSet.timeUsBlobTm.setValid(true); - blobsSet.blobCount.setValid(true); + blobSet.setValidity(true, true); return returnvalue::OK; } @@ -2261,12 +2317,12 @@ ReturnValue_t StarTrackerHandler::handleBlobsTm(const uint8_t* rawFrame) { if (result != returnvalue::OK) { return result; } - result = SerializeAdapter::deSerialize(&blobsSet.ticksBlobsTm, &rawFrame, &remainingLen, + result = SerializeAdapter::deSerialize(&blobsSet.ticks, &rawFrame, &remainingLen, SerializeIF::Endianness::LITTLE); if (result != returnvalue::OK) { return result; } - result = SerializeAdapter::deSerialize(&blobsSet.timeUsBlobsTm, &rawFrame, &remainingLen, + result = SerializeAdapter::deSerialize(&blobsSet.timeUs, &rawFrame, &remainingLen, SerializeIF::Endianness::LITTLE); if (result != returnvalue::OK) { return result; @@ -2298,13 +2354,86 @@ ReturnValue_t StarTrackerHandler::handleBlobsTm(const uint8_t* rawFrame) { return result; } } - blobsSet.ticksBlobsTm.setValid(true); - blobsSet.timeUsBlobsTm.setValid(true); - blobsSet.blobsCount.setValid(true); - blobsSet.blobsCountUsed.setValid(true); - blobsSet.nr4LinesSkipped.setValid(true); - blobsSet.xCoords.setValid(true); - blobsSet.yCoords.setValid(true); + blobsSet.setValidity(true, true); + return returnvalue::OK; +} + +ReturnValue_t StarTrackerHandler::handleCentroidTm(const uint8_t* rawFrame) { + ReturnValue_t result = statusFieldCheck(rawFrame); + if (result != returnvalue::OK) { + return result; + } + size_t remainingLen = fullPacketLen; + PoolReadGuard pg(¢roidsSet); + result = pg.getReadResult(); + if (result != returnvalue::OK) { + return result; + } + + result = SerializeAdapter::deSerialize(¢roidSet.ticks, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(¢roidSet.timeUs, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(¢roidSet.centroidCount, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + centroidSet.setValidity(true, true); + return returnvalue::OK; +} + +ReturnValue_t StarTrackerHandler::handleCentroidsTm(const uint8_t* rawFrame) { + ReturnValue_t result = statusFieldCheck(rawFrame); + if (result != returnvalue::OK) { + return result; + } + size_t remainingLen = fullPacketLen; + PoolReadGuard pg(¢roidsSet); + result = pg.getReadResult(); + if (result != returnvalue::OK) { + return result; + } + + result = SerializeAdapter::deSerialize(¢roidsSet.ticksCentroidsTm, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(¢roidsSet.timeUsCentroidsTm, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(¢roidsSet.centroidsCount, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + for (unsigned idx = 0; idx < 16; idx++) { + result = SerializeAdapter::deSerialize(¢roidsSet.centroidsXCoords[idx], &rawFrame, + &remainingLen, SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(¢roidsSet.centroidsYCoords[idx], &rawFrame, + &remainingLen, SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(¢roidsSet.centroidsMagnitudes[idx], &rawFrame, + &remainingLen, SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + } + centroidsSet.setValidity(true, true); return returnvalue::OK; } @@ -2446,6 +2575,8 @@ ReturnValue_t StarTrackerHandler::checkCommand(ActionId_t actionId) { case startracker::REQ_MATCHED_CENTROIDS: case startracker::REQ_BLOB: case startracker::REQ_BLOBS: + case startracker::REQ_CENTROID: + case startracker::REQ_CENTROIDS: if (getMode() == MODE_ON and getSubmode() != startracker::Program::FIRMWARE) { return STARTRACKER_NOT_RUNNING_FIRMWARE; } diff --git a/mission/acs/str/StarTrackerHandler.h b/mission/acs/str/StarTrackerHandler.h index db8335b0..e7fdc307 100644 --- a/mission/acs/str/StarTrackerHandler.h +++ b/mission/acs/str/StarTrackerHandler.h @@ -206,7 +206,10 @@ class StarTrackerHandler : public DeviceHandlerBase { startracker::LogSubscriptionSet logSubscriptionSet; startracker::DebugCameraSet debugCameraSet; startracker::MatchedCentroidsSet matchedCentroids; + startracker::BlobSet blobSet; startracker::BlobsSet blobsSet; + startracker::CentroidSet centroidSet; + startracker::CentroidsSet centroidsSet; // Pointer to object responsible for uploading and downloading images to/from the star tracker StrComHandler* strHelper = nullptr; @@ -437,6 +440,8 @@ class StarTrackerHandler : public DeviceHandlerBase { ReturnValue_t prepareRequestMatchedCentroids(); ReturnValue_t prepareRequestBlobTm(); ReturnValue_t prepareRequestBlobsTm(); + ReturnValue_t prepareRequestCentroidTm(); + ReturnValue_t prepareRequestCentroidsTm(); ReturnValue_t prepareRequestTrackingParams(); ReturnValue_t prepareRequestValidationParams(); ReturnValue_t prepareRequestAlgoParams(); @@ -500,6 +505,8 @@ class StarTrackerHandler : public DeviceHandlerBase { ReturnValue_t handleMatchedCentroidTm(const uint8_t* rawFrame); ReturnValue_t handleBlobTm(const uint8_t* rawFrame); ReturnValue_t handleBlobsTm(const uint8_t* rawFrame); + ReturnValue_t handleCentroidTm(const uint8_t* rawFrame); + ReturnValue_t handleCentroidsTm(const uint8_t* rawFrame); /** * @brief Checks if star tracker is in valid mode for executing the received command. diff --git a/mission/acs/str/strHelpers.h b/mission/acs/str/strHelpers.h index 5d9c483f..8bd63512 100644 --- a/mission/acs/str/strHelpers.h +++ b/mission/acs/str/strHelpers.h @@ -294,6 +294,17 @@ enum PoolIds : lp_id_t { BLOBS_NR_4LINES_SKIPPED, BLOBS_X_COORDS, BLOBS_Y_COORDS, + + CENTROID_TICKS, + CENTROID_TIME, + CENTROID_COUNT, + + CENTROIDS_TICKS, + CENTROIDS_TIME, + CENTROIDS_COUNT, + CENTROIDS_X_COORDS, + CENTROIDS_Y_COORDS, + CENTROIDS_MAGNITUDES, }; static const DeviceCommandId_t PING_REQUEST = 0; @@ -352,6 +363,8 @@ static constexpr DeviceCommandId_t AUTO_THRESHOLD = 88; static constexpr DeviceCommandId_t REQ_MATCHED_CENTROIDS = 89; static constexpr DeviceCommandId_t REQ_BLOB = 90; static constexpr DeviceCommandId_t REQ_BLOBS = 91; +static constexpr DeviceCommandId_t REQ_CENTROID = 92; +static constexpr DeviceCommandId_t REQ_CENTROIDS = 93; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; @@ -377,7 +390,10 @@ static const uint32_t SUBSCRIPTION_SET_ID = REQ_SUBSCRIPTION; static const uint32_t LOG_SUBSCRIPTION_SET_ID = REQ_LOG_SUBSCRIPTION; static const uint32_t DEBUG_CAMERA_SET_ID = REQ_DEBUG_CAMERA; static const uint32_t MATCHED_CENTROIDS_SET_ID = REQ_MATCHED_CENTROIDS; +static const uint32_t BLOB_SET_ID = REQ_BLOB; static const uint32_t BLOBS_SET_ID = REQ_BLOBS; +static const uint32_t CENTROID_SET_ID = REQ_CENTROID; +static const uint32_t CENTROIDS_SET_ID = REQ_CENTROIDS; /** Max size of unencoded frame */ static const size_t MAX_FRAME_SIZE = 1200; @@ -1436,21 +1452,23 @@ class MatchedCentroidsSet : public StaticLocalDataSet<20> { private: }; -class BlobsSet : public StaticLocalDataSet<20> { +class BlobSet : public StaticLocalDataSet<5> { public: - BlobsSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BLOBS_SET_ID) {} - + BlobSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BLOB_SET_ID) {} // The blob count received from the Blob Telemetry Set (ID 25) // Ticks timestamp - lp_var_t ticksBlobTm = lp_var_t(sid.objectId, PoolIds::BLOB_TICKS, this); + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::BLOB_TICKS, this); // Unix time stamp - lp_var_t timeUsBlobTm = lp_var_t(sid.objectId, PoolIds::BLOB_TIME, this); + lp_var_t timeUs = lp_var_t(sid.objectId, PoolIds::BLOB_TIME, this); lp_var_t blobCount = lp_var_t(sid.objectId, PoolIds::BLOB_COUNT, this); - +}; +class BlobsSet : public StaticLocalDataSet<10> { + public: + BlobsSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BLOBS_SET_ID) {} // Ticks timestamp - lp_var_t ticksBlobsTm = lp_var_t(sid.objectId, PoolIds::BLOBS_TICKS, this); + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::BLOBS_TICKS, this); // Unix time stamp - lp_var_t timeUsBlobsTm = lp_var_t(sid.objectId, PoolIds::BLOBS_TIME, this); + lp_var_t timeUs = lp_var_t(sid.objectId, PoolIds::BLOBS_TIME, this); lp_var_t blobsCount = lp_var_t(sid.objectId, PoolIds::BLOBS_COUNT, this); lp_var_t blobsCountUsed = lp_var_t(sid.objectId, PoolIds::BLOBS_COUNT_USED, this); @@ -1462,6 +1480,40 @@ class BlobsSet : public StaticLocalDataSet<20> { lp_vec_t(sid.objectId, PoolIds::BLOBS_Y_COORDS, this); }; +class CentroidSet : public StaticLocalDataSet<5> { + public: + CentroidSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CENTROID_SET_ID) {} + + // Data received from the Centroid Telemetry Set (ID 26) + // Ticks timestamp + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::CENTROID_TICKS, this); + // Unix time stamp + lp_var_t timeUs = lp_var_t(sid.objectId, PoolIds::CENTROID_TIME, this); + // The centroid count received from the Centroid Telemetry Set (ID 26) + lp_var_t centroidCount = + lp_var_t(sid.objectId, PoolIds::CENTROID_COUNT, this); +}; + +class CentroidsSet : public StaticLocalDataSet<10> { + public: + CentroidsSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CENTROIDS_SET_ID) {} + + // Data received from the Centroids Telemetry Set (ID 37) + lp_var_t ticksCentroidsTm = + lp_var_t(sid.objectId, PoolIds::CENTROIDS_TICKS, this); + // Unix time stamp + lp_var_t timeUsCentroidsTm = + lp_var_t(sid.objectId, PoolIds::CENTROIDS_TIME, this); + lp_var_t centroidsCount = + lp_var_t(sid.objectId, PoolIds::CENTROIDS_COUNT, this); + lp_vec_t centroidsXCoords = + lp_vec_t(sid.objectId, PoolIds::CENTROIDS_X_COORDS, this); + lp_vec_t centroidsYCoords = + lp_vec_t(sid.objectId, PoolIds::CENTROIDS_Y_COORDS, this); + lp_vec_t centroidsMagnitudes = + lp_vec_t(sid.objectId, PoolIds::CENTROIDS_MAGNITUDES, this); +}; + /** * @brief Will store the requested algo parameters */ -- 2.43.0 From 8fe4a85998569057f3343d9f241639308ac4c7c3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 9 Oct 2023 15:18:40 +0200 Subject: [PATCH 07/25] missing API calls --- mission/acs/str/StarTrackerHandler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 20c2b511..7630120f 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -478,9 +478,11 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi return returnvalue::OK; } case (startracker::REQ_CENTROID): { + prepareRequestCentroidTm(); return returnvalue::OK; } case (startracker::REQ_CENTROIDS): { + prepareRequestCentroidsTm(); return returnvalue::OK; } case (startracker::BOOT): { -- 2.43.0 From e65352818f0cd986d3b7ebdb9f1606ea143c8c0a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 9 Oct 2023 15:29:04 +0200 Subject: [PATCH 08/25] added logic for secondary TM handling --- mission/acs/str/StarTrackerHandler.cpp | 15 ++++++++++++--- mission/acs/str/StarTrackerHandler.h | 8 ++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 7630120f..087780eb 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -64,6 +64,8 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; } eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); + additionalRequestedTm.emplace(startracker::REQ_TEMPERATURE); + currentSecondaryTmIter = additionalRequestedTm.begin(); } StarTrackerHandler::~StarTrackerHandler() {} @@ -311,13 +313,20 @@ ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id return NOTHING_TO_SEND; } switch (normalState) { - case NormalState::TEMPERATURE_REQUEST: - *id = startracker::REQ_TEMPERATURE; + case NormalState::SECONDARY_REQUEST: + if (additionalRequestedTm.size() == 0) { + break; + } + *id = *currentSecondaryTmIter; + currentSecondaryTmIter++; + if (currentSecondaryTmIter == additionalRequestedTm.end()) { + currentSecondaryTmIter = additionalRequestedTm.begin(); + } normalState = NormalState::SOLUTION_REQUEST; break; case NormalState::SOLUTION_REQUEST: *id = startracker::REQ_SOLUTION; - normalState = NormalState::TEMPERATURE_REQUEST; + normalState = NormalState::SECONDARY_REQUEST; break; default: sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid normal step" diff --git a/mission/acs/str/StarTrackerHandler.h b/mission/acs/str/StarTrackerHandler.h index e7fdc307..ac5812a9 100644 --- a/mission/acs/str/StarTrackerHandler.h +++ b/mission/acs/str/StarTrackerHandler.h @@ -8,6 +8,7 @@ #include #include +#include #include #include "OBSWConfig.h" @@ -245,9 +246,9 @@ class StarTrackerHandler : public DeviceHandlerBase { std::string paramJsonFile; - enum class NormalState { TEMPERATURE_REQUEST, SOLUTION_REQUEST }; + enum class NormalState { SECONDARY_REQUEST, SOLUTION_REQUEST }; - NormalState normalState = NormalState::TEMPERATURE_REQUEST; + NormalState normalState = NormalState::SECONDARY_REQUEST; enum class StartupState { IDLE, @@ -305,6 +306,9 @@ class StarTrackerHandler : public DeviceHandlerBase { size_t fullPacketLen = 0; + std::set additionalRequestedTm{}; + std::set::iterator currentSecondaryTmIter; + /** * @brief Handles internal state */ -- 2.43.0 From 93939f95414734cd73158acf25e26f3039c639bd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 9 Oct 2023 15:56:48 +0200 Subject: [PATCH 09/25] that should do the job --- mission/acs/str/StarTrackerHandler.cpp | 38 ++++++++++++++++++++++++++ mission/acs/str/StarTrackerHandler.h | 12 ++++++++ mission/acs/str/strHelpers.h | 3 ++ 3 files changed, 53 insertions(+) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 087780eb..bf31c99a 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -172,6 +172,35 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu ReturnValue_t result = returnvalue::OK; switch (actionId) { + case (startracker::ADD_SECONDARY_TM_TO_NORMAL_MODE): { + if (size < 4) { + return HasActionsIF::INVALID_PARAMETERS; + } + DeviceCommandId_t idToAdd; + result = + SerializeAdapter::deSerialize(&idToAdd, data, &size, SerializeIF::Endianness::NETWORK); + if (result != returnvalue::OK) { + return result; + } + addSecondaryTmForNormalMode(idToAdd); + return EXECUTION_FINISHED; + } + case (startracker::RESET_SECONDARY_TM_SET): { + resetSecondaryTmSet(); + return EXECUTION_FINISHED; + } + case (startracker::READ_SECONDARY_TM_SET): { + std::vector dataVec(additionalRequestedTm.size() * 4); + unsigned idx = 0; + size_t serLen = 0; + for (const auto& cmd : additionalRequestedTm) { + SerializeAdapter::serialize(&cmd, dataVec.data() + idx * 4, &serLen, dataVec.size(), + SerializeIF::Endianness::NETWORK); + idx++; + } + actionHelper.reportData(commandedBy, actionId, dataVec.data(), dataVec.size()); + return EXECUTION_FINISHED; + } case (startracker::STOP_IMAGE_LOADER): { strHelper->stopProcess(); return EXECUTION_FINISHED; @@ -914,6 +943,15 @@ ReturnValue_t StarTrackerHandler::statusFieldCheck(const uint8_t* rawFrame) { return returnvalue::OK; } +void StarTrackerHandler::addSecondaryTmForNormalMode(DeviceCommandId_t cmd) { + additionalRequestedTm.emplace(cmd); +} + +void StarTrackerHandler::resetSecondaryTmSet() { + additionalRequestedTm.clear(); + additionalRequestedTm.emplace(startracker::REQ_TEMPERATURE); +} + void StarTrackerHandler::bootBootloader() { if (internalState == InternalState::IDLE) { internalState = InternalState::BOOT_BOOTLOADER; diff --git a/mission/acs/str/StarTrackerHandler.h b/mission/acs/str/StarTrackerHandler.h index ac5812a9..b239559a 100644 --- a/mission/acs/str/StarTrackerHandler.h +++ b/mission/acs/str/StarTrackerHandler.h @@ -357,6 +357,18 @@ class StarTrackerHandler : public DeviceHandlerBase { */ ReturnValue_t executeFlashReadCommand(const uint8_t* commandData, size_t commandDataLen); + /** + * Add a TM request to the list of telemetry which will be polled in the secondary step of + * the device communication. + * @param cmd + */ + void addSecondaryTmForNormalMode(DeviceCommandId_t cmd); + + /** + * Reset the secondary set, which will only contain a TEMPERATURE set request after the reset. + */ + void resetSecondaryTmSet(); + /** * @brief Fills command buffer with data to boot image (works only when star tracker is * in bootloader mode). diff --git a/mission/acs/str/strHelpers.h b/mission/acs/str/strHelpers.h index 8bd63512..31ac0c05 100644 --- a/mission/acs/str/strHelpers.h +++ b/mission/acs/str/strHelpers.h @@ -365,6 +365,9 @@ static constexpr DeviceCommandId_t REQ_BLOB = 90; static constexpr DeviceCommandId_t REQ_BLOBS = 91; static constexpr DeviceCommandId_t REQ_CENTROID = 92; static constexpr DeviceCommandId_t REQ_CENTROIDS = 93; +static constexpr DeviceCommandId_t ADD_SECONDARY_TM_TO_NORMAL_MODE = 94; +static constexpr DeviceCommandId_t RESET_SECONDARY_TM_SET = 95; +static constexpr DeviceCommandId_t READ_SECONDARY_TM_SET = 96; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; -- 2.43.0 From 0f4fd6b452c8edbb5e201eff77cc8be2aa728b6e Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 18 Oct 2023 16:09:36 +0200 Subject: [PATCH 10/25] auto blob --- mission/acs/str/strHelpers.h | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/mission/acs/str/strHelpers.h b/mission/acs/str/strHelpers.h index 31ac0c05..1d107a58 100644 --- a/mission/acs/str/strHelpers.h +++ b/mission/acs/str/strHelpers.h @@ -274,6 +274,8 @@ enum PoolIds : lp_id_t { DEBUG_CAMERA_TIMING, DEBUG_CAMERA_TEST, + AUTO_BLOB_THRESHOLD, + TICKS_MATCHED_CENTROIDS, TIME_MATCHED_CENTROIDS, NUM_MATCHED_CENTROIDS, @@ -360,14 +362,15 @@ 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 constexpr DeviceCommandId_t REQ_MATCHED_CENTROIDS = 89; -static constexpr DeviceCommandId_t REQ_BLOB = 90; -static constexpr DeviceCommandId_t REQ_BLOBS = 91; -static constexpr DeviceCommandId_t REQ_CENTROID = 92; -static constexpr DeviceCommandId_t REQ_CENTROIDS = 93; -static constexpr DeviceCommandId_t ADD_SECONDARY_TM_TO_NORMAL_MODE = 94; -static constexpr DeviceCommandId_t RESET_SECONDARY_TM_SET = 95; -static constexpr DeviceCommandId_t READ_SECONDARY_TM_SET = 96; +static constexpr DeviceCommandId_t REQ_AUTO_BLOB = 89; +static constexpr DeviceCommandId_t REQ_MATCHED_CENTROIDS = 90; +static constexpr DeviceCommandId_t REQ_BLOB = 91; +static constexpr DeviceCommandId_t REQ_BLOBS = 92; +static constexpr DeviceCommandId_t REQ_CENTROID = 93; +static constexpr DeviceCommandId_t REQ_CENTROIDS = 94; +static constexpr DeviceCommandId_t ADD_SECONDARY_TM_TO_NORMAL_MODE = 95; +static constexpr DeviceCommandId_t RESET_SECONDARY_TM_SET = 96; +static constexpr DeviceCommandId_t READ_SECONDARY_TM_SET = 97; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; @@ -392,6 +395,7 @@ static const uint32_t ALGO_SET_ID = REQ_ALGO; static const uint32_t SUBSCRIPTION_SET_ID = REQ_SUBSCRIPTION; static const uint32_t LOG_SUBSCRIPTION_SET_ID = REQ_LOG_SUBSCRIPTION; static const uint32_t DEBUG_CAMERA_SET_ID = REQ_DEBUG_CAMERA; +static const uint32_t AUTO_BLOB_SET_ID = REQ_AUTO_BLOB; static const uint32_t MATCHED_CENTROIDS_SET_ID = REQ_MATCHED_CENTROIDS; static const uint32_t BLOB_SET_ID = REQ_BLOB; static const uint32_t BLOBS_SET_ID = REQ_BLOBS; @@ -1426,6 +1430,14 @@ class ValidationSet : public StaticLocalDataSet { } }; +class AutoBlobSet : StaticLocalDataSet<1> { + public: + AutoBlobSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, AUTO_BLOB_SET_ID) {} + lp_var_t threshold = lp_var_t(sid.objectId, PoolIds::AUTO_BLOB_THRESHOLD, this); + + private: +}; + class MatchedCentroidsSet : public StaticLocalDataSet<20> { public: static constexpr size_t SIZE = 321; @@ -1465,6 +1477,7 @@ class BlobSet : public StaticLocalDataSet<5> { lp_var_t timeUs = lp_var_t(sid.objectId, PoolIds::BLOB_TIME, this); lp_var_t blobCount = lp_var_t(sid.objectId, PoolIds::BLOB_COUNT, this); }; + class BlobsSet : public StaticLocalDataSet<10> { public: BlobsSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BLOBS_SET_ID) {} -- 2.43.0 From e911d8b13efb9ebc898bbe50322673e5bfd39898 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 18 Oct 2023 16:15:33 +0200 Subject: [PATCH 11/25] i guess we do this --- mission/acs/str/strHelpers.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mission/acs/str/strHelpers.h b/mission/acs/str/strHelpers.h index 1d107a58..235fd31a 100644 --- a/mission/acs/str/strHelpers.h +++ b/mission/acs/str/strHelpers.h @@ -1433,6 +1433,12 @@ class ValidationSet : public StaticLocalDataSet { class AutoBlobSet : StaticLocalDataSet<1> { public: AutoBlobSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, AUTO_BLOB_SET_ID) {} + // Ticks timestamp + lp_var_t ticks = + lp_var_t(sid.objectId, PoolIds::TICKS_MATCHED_CENTROIDS, this); + // Unix time stamp + lp_var_t timeUs = + lp_var_t(sid.objectId, PoolIds::TIME_MATCHED_CENTROIDS, this); lp_var_t threshold = lp_var_t(sid.objectId, PoolIds::AUTO_BLOB_THRESHOLD, this); private: -- 2.43.0 From 12909cb3b96140070a6ce6c5a92d8311a15b1a7b Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 19 Oct 2023 09:26:28 +0200 Subject: [PATCH 12/25] now for the fun part --- mission/acs/str/StarTrackerHandler.cpp | 67 +++++++++++++++++++------- mission/acs/str/StarTrackerHandler.h | 4 +- 2 files changed, 52 insertions(+), 19 deletions(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index bf31c99a..6278739e 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -49,7 +49,8 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, subscriptionSet(this), logSubscriptionSet(this), debugCameraSet(this), - matchedCentroids(this), + autoBlobSet(this), + matchedCentroidsSet(this), blobSet(this), blobsSet(this), centroidSet(this), @@ -792,7 +793,7 @@ void StarTrackerHandler::fillCommandAndReplyMap() { startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::REQ_DEBUG_CAMERA, 3, &debugCameraSet, startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::REQ_MATCHED_CENTROIDS, 3, &matchedCentroids, + this->insertInCommandAndReplyMap(startracker::REQ_MATCHED_CENTROIDS, 3, &matchedCentroidsSet, startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::REQ_BLOB, 3, &blobSet, startracker::MAX_FRAME_SIZE * 2 + 2); @@ -1494,7 +1495,7 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l poolManager.subscribeForRegularPeriodicPacket( subdp::RegularHkPeriodicParams(lisaSet.getSid(), false, 10.0)); poolManager.subscribeForRegularPeriodicPacket( - subdp::RegularHkPeriodicParams(matchedCentroids.getSid(), false, 10.0)); + subdp::RegularHkPeriodicParams(matchedCentroidsSet.getSid(), false, 10.0)); poolManager.subscribeForRegularPeriodicPacket( subdp::RegularHkPeriodicParams(blobSet.getSid(), false, 10.0)); poolManager.subscribeForRegularPeriodicPacket( @@ -2266,28 +2267,58 @@ ReturnValue_t StarTrackerHandler::handleTm(const uint8_t* rawFrame, LocalPoolDat return result; } +ReturnValue_t StarTrackerHandler::handleAutoBlobTm(const uint8_t* rawFrame) { + ReturnValue_t result = statusFieldCheck(rawFrame); + if (result != returnvalue::OK) { + return result; + } + size_t remainingLen = fullPacketLen; + PoolReadGuard pg(&autoBlobSet); + result = pg.getReadResult(); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&autoBlobSet.ticks, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&autoBlobSet.timeUs, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&autoBlobSet.threshold, &rawFrame, &remainingLen, + SerializeIF::Endianness::LITTLE); + if (result != returnvalue::OK) { + return result; + } + autoBlobSet.setValidity(true, true); + return returnvalue::OK; +} + ReturnValue_t StarTrackerHandler::handleMatchedCentroidTm(const uint8_t* rawFrame) { ReturnValue_t result = statusFieldCheck(rawFrame); if (result != returnvalue::OK) { return result; } size_t remainingLen = fullPacketLen; - PoolReadGuard pg(&matchedCentroids); + PoolReadGuard pg(&matchedCentroidsSet); result = pg.getReadResult(); if (result != returnvalue::OK) { return result; } - result = SerializeAdapter::deSerialize(&matchedCentroids.ticks, &rawFrame, &remainingLen, + result = SerializeAdapter::deSerialize(&matchedCentroidsSet.ticks, &rawFrame, &remainingLen, SerializeIF::Endianness::LITTLE); if (result != returnvalue::OK) { return result; } - result = SerializeAdapter::deSerialize(&matchedCentroids.timeUs, &rawFrame, &remainingLen, + result = SerializeAdapter::deSerialize(&matchedCentroidsSet.timeUs, &rawFrame, &remainingLen, SerializeIF::Endianness::LITTLE); if (result != returnvalue::OK) { return result; } - result = SerializeAdapter::deSerialize(&matchedCentroids.numberOfMatchedCentroids, &rawFrame, + result = SerializeAdapter::deSerialize(&matchedCentroidsSet.numberOfMatchedCentroids, &rawFrame, &remainingLen, SerializeIF::Endianness::LITTLE); if (result != returnvalue::OK) { @@ -2295,33 +2326,33 @@ ReturnValue_t StarTrackerHandler::handleMatchedCentroidTm(const uint8_t* rawFram } // Yeah, we serialize it like that because I can't model anything with that local datapool crap. for (unsigned idx = 0; idx < 16; idx++) { - result = SerializeAdapter::deSerialize(&matchedCentroids.starIds[idx], &rawFrame, &remainingLen, - SerializeIF::Endianness::LITTLE); + result = SerializeAdapter::deSerialize(&matchedCentroidsSet.starIds[idx], &rawFrame, + &remainingLen, SerializeIF::Endianness::LITTLE); if (result != returnvalue::OK) { return result; } - result = SerializeAdapter::deSerialize(&matchedCentroids.xCoords[idx], &rawFrame, &remainingLen, - SerializeIF::Endianness::LITTLE); + result = SerializeAdapter::deSerialize(&matchedCentroidsSet.xCoords[idx], &rawFrame, + &remainingLen, SerializeIF::Endianness::LITTLE); if (result != returnvalue::OK) { return result; } - result = SerializeAdapter::deSerialize(&matchedCentroids.yCoords[idx], &rawFrame, &remainingLen, - SerializeIF::Endianness::LITTLE); + result = SerializeAdapter::deSerialize(&matchedCentroidsSet.yCoords[idx], &rawFrame, + &remainingLen, SerializeIF::Endianness::LITTLE); if (result != returnvalue::OK) { return result; } - result = SerializeAdapter::deSerialize(&matchedCentroids.xErrors[idx], &rawFrame, &remainingLen, - SerializeIF::Endianness::LITTLE); + result = SerializeAdapter::deSerialize(&matchedCentroidsSet.xErrors[idx], &rawFrame, + &remainingLen, SerializeIF::Endianness::LITTLE); if (result != returnvalue::OK) { return result; } - result = SerializeAdapter::deSerialize(&matchedCentroids.yErrors[idx], &rawFrame, &remainingLen, - SerializeIF::Endianness::LITTLE); + result = SerializeAdapter::deSerialize(&matchedCentroidsSet.yErrors[idx], &rawFrame, + &remainingLen, SerializeIF::Endianness::LITTLE); if (result != returnvalue::OK) { return result; } } - matchedCentroids.setValidity(true, true); + matchedCentroidsSet.setValidity(true, true); return returnvalue::OK; } diff --git a/mission/acs/str/StarTrackerHandler.h b/mission/acs/str/StarTrackerHandler.h index b239559a..90261285 100644 --- a/mission/acs/str/StarTrackerHandler.h +++ b/mission/acs/str/StarTrackerHandler.h @@ -206,7 +206,8 @@ class StarTrackerHandler : public DeviceHandlerBase { startracker::SubscriptionSet subscriptionSet; startracker::LogSubscriptionSet logSubscriptionSet; startracker::DebugCameraSet debugCameraSet; - startracker::MatchedCentroidsSet matchedCentroids; + startracker::AutoBlobSet autoBlobSet; + startracker::MatchedCentroidsSet matchedCentroidsSet; startracker::BlobSet blobSet; startracker::BlobsSet blobsSet; startracker::CentroidSet centroidSet; @@ -518,6 +519,7 @@ class StarTrackerHandler : public DeviceHandlerBase { ReturnValue_t handleTm(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset, size_t size, const char* context); + ReturnValue_t handleAutoBlobTm(const uint8_t* rawFrame); ReturnValue_t handleMatchedCentroidTm(const uint8_t* rawFrame); ReturnValue_t handleBlobTm(const uint8_t* rawFrame); ReturnValue_t handleBlobsTm(const uint8_t* rawFrame); -- 2.43.0 From 58d967861391e52a6802e89d2195237132d2f107 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 19 Oct 2023 09:32:21 +0200 Subject: [PATCH 13/25] woops --- mission/acs/str/strHelpers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/acs/str/strHelpers.h b/mission/acs/str/strHelpers.h index 235fd31a..fe8755f2 100644 --- a/mission/acs/str/strHelpers.h +++ b/mission/acs/str/strHelpers.h @@ -1430,7 +1430,7 @@ class ValidationSet : public StaticLocalDataSet { } }; -class AutoBlobSet : StaticLocalDataSet<1> { +class AutoBlobSet : public StaticLocalDataSet<1> { public: AutoBlobSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, AUTO_BLOB_SET_ID) {} // Ticks timestamp -- 2.43.0 From 440375e64bc0f3a90593457fafd62c7698d6034d Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 19 Oct 2023 09:37:01 +0200 Subject: [PATCH 14/25] add cmd --- mission/acs/str/StarTrackerHandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 6278739e..1b1300b5 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -1063,6 +1063,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, result = handleTm(packet, solutionSet, startracker::SolutionSet::SIZE, "REQ_SOLUTION"); break; } + case (startracker::REQ_AUTO_BLOB): { + result = handleAutoBlobTm(packet); + break; + } case (startracker::REQ_MATCHED_CENTROIDS): { result = handleMatchedCentroidTm(packet); break; -- 2.43.0 From feb64598783af99abdb66ce6ee668446a168efe9 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 19 Oct 2023 14:54:12 +0200 Subject: [PATCH 15/25] might wanna push this --- mission/acs/str/StarTrackerHandler.cpp | 19 +++++++++++++++++-- mission/acs/str/StarTrackerHandler.h | 3 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 1b1300b5..0e81b7e4 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -660,7 +660,7 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi return result; } case (startracker::REQ_MATCHED_CENTROIDS): { - result = prepareRequestMatchedCentroids(); + result = prepareRequestMatchedCentroidsTm(); return result; } case (startracker::REQ_BLOB): { @@ -793,6 +793,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() { startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::REQ_DEBUG_CAMERA, 3, &debugCameraSet, startracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(startracker::REQ_AUTO_BLOB, 3, &autoBlobSet, + startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::REQ_MATCHED_CENTROIDS, 3, &matchedCentroidsSet, startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::REQ_BLOB, 3, &blobSet, @@ -1445,6 +1447,9 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(startracker::DEBUG_CAMERA_TEST, new PoolEntry({0})); localDataPoolMap.emplace(startracker::CHKSUM, new PoolEntry({0})); + + localDataPoolMap.emplace(startracker::AUTO_BLOB_THRESHOLD, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::NUM_MATCHED_CENTROIDS, new PoolEntry()); localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_STAR_IDS, new PoolEntry(16)); @@ -1498,6 +1503,8 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l subdp::RegularHkPeriodicParams(histogramSet.getSid(), false, 10.0)); poolManager.subscribeForRegularPeriodicPacket( subdp::RegularHkPeriodicParams(lisaSet.getSid(), false, 10.0)); + poolManager.subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams(autoBlobSet.getSid(), false, 10.0)); poolManager.subscribeForRegularPeriodicPacket( subdp::RegularHkPeriodicParams(matchedCentroidsSet.getSid(), false, 10.0)); poolManager.subscribeForRegularPeriodicPacket( @@ -1925,7 +1932,15 @@ void StarTrackerHandler::prepareHistogramRequest() { rawPacketLen = length; } -ReturnValue_t StarTrackerHandler::prepareRequestMatchedCentroids() { +ReturnValue_t StarTrackerHandler::prepareRequestAutoBlobTm() { + uint32_t length = 0; + arc_tm_pack_autoblob_req(commandBuffer, &length); + rawPacket = commandBuffer; + rawPacketLen = length; + return returnvalue::OK; +} + +ReturnValue_t StarTrackerHandler::prepareRequestMatchedCentroidsTm() { uint32_t length = 0; arc_tm_pack_matchedcentroids_req(commandBuffer, &length); rawPacket = commandBuffer; diff --git a/mission/acs/str/StarTrackerHandler.h b/mission/acs/str/StarTrackerHandler.h index 90261285..d63335ae 100644 --- a/mission/acs/str/StarTrackerHandler.h +++ b/mission/acs/str/StarTrackerHandler.h @@ -454,7 +454,8 @@ class StarTrackerHandler : public DeviceHandlerBase { ReturnValue_t prepareRequestCentroidingParams(); ReturnValue_t prepareRequestLisaParams(); ReturnValue_t prepareRequestMatchingParams(); - ReturnValue_t prepareRequestMatchedCentroids(); + ReturnValue_t prepareRequestAutoBlobTm(); + ReturnValue_t prepareRequestMatchedCentroidsTm(); ReturnValue_t prepareRequestBlobTm(); ReturnValue_t prepareRequestBlobsTm(); ReturnValue_t prepareRequestCentroidTm(); -- 2.43.0 From 54c2fc964662bb655af4f001c4d5c423e4bb4de9 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 26 Oct 2023 09:52:25 +0200 Subject: [PATCH 16/25] validity handling --- mission/acs/str/StarTrackerHandler.cpp | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 0e81b7e4..94a29f01 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -953,6 +953,42 @@ void StarTrackerHandler::addSecondaryTmForNormalMode(DeviceCommandId_t cmd) { void StarTrackerHandler::resetSecondaryTmSet() { additionalRequestedTm.clear(); additionalRequestedTm.emplace(startracker::REQ_TEMPERATURE); + { + PoolReadGuard pg(&autoBlobSet); + if (pg.getReadResult() == returnvalue::OK) { + autoBlobSet.setValidity(false, true); + } + } + { + PoolReadGuard pg(&matchedCentroidsSet); + if (pg.getReadResult() == returnvalue::OK) { + matchedCentroidsSet.setValidity(false, true); + } + } + { + PoolReadGuard pg(&blobSet); + if (pg.getReadResult() == returnvalue::OK) { + blobSet.setValidity(false, true); + } + } + { + PoolReadGuard pg(&blobsSet); + if (pg.getReadResult() == returnvalue::OK) { + blobsSet.setValidity(false, true); + } + } + { + PoolReadGuard pg(¢roidSet); + if (pg.getReadResult() == returnvalue::OK) { + centroidSet.setValidity(false, true); + } + } + { + PoolReadGuard pg(¢roidsSet); + if (pg.getReadResult() == returnvalue::OK) { + centroidsSet.setValidity(false, true); + } + } } void StarTrackerHandler::bootBootloader() { -- 2.43.0 From 1c7545bffa27d753b462b55988ddf97b94e4b812 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 26 Oct 2023 19:59:16 +0200 Subject: [PATCH 17/25] fix --- mission/acs/str/StarTrackerHandler.cpp | 26 +++++++++++++++++++++++++- mission/acs/str/strHelpers.h | 8 +++++++- tmtc | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 94a29f01..1bf35ca2 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -1792,8 +1792,32 @@ ReturnValue_t StarTrackerHandler::scanForTmReply(uint8_t replyId, DeviceCommandI *foundId = startracker::REQ_SOLUTION; break; } + case(startracker::ID::BLOB): { + *foundId = startracker::REQ_BLOB; + break; + } + case(startracker::ID::BLOBS): { + *foundId = startracker::REQ_BLOBS; + break; + } + case(startracker::ID::CENTROID): { + *foundId = startracker::REQ_CENTROID; + break; + } + case(startracker::ID::CENTROIDS): { + *foundId = startracker::REQ_CENTROIDS; + break; + } + case(startracker::ID::AUTO_BLOB): { + *foundId = startracker::REQ_AUTO_BLOB; + break; + } + case(startracker::ID::MATCHED_CENTROIDS): { + *foundId = startracker::REQ_MATCHED_CENTROIDS; + break; + } default: { - sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply id: " + sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply ID: " << static_cast(replyId) << std::endl; return returnvalue::FAILED; break; diff --git a/mission/acs/str/strHelpers.h b/mission/acs/str/strHelpers.h index fe8755f2..dff29f95 100644 --- a/mission/acs/str/strHelpers.h +++ b/mission/acs/str/strHelpers.h @@ -461,6 +461,12 @@ 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; +static constexpr uint8_t BLOB = 25; +static constexpr uint8_t BLOBS = 36; +static constexpr uint8_t CENTROID = 26; +static constexpr uint8_t CENTROIDS = 37; +static constexpr uint8_t AUTO_BLOB = 39; +static constexpr uint8_t MATCHED_CENTROIDS = 40; } // namespace ID namespace Program { @@ -1430,7 +1436,7 @@ class ValidationSet : public StaticLocalDataSet { } }; -class AutoBlobSet : public StaticLocalDataSet<1> { +class AutoBlobSet : public StaticLocalDataSet<3> { public: AutoBlobSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, AUTO_BLOB_SET_ID) {} // Ticks timestamp diff --git a/tmtc b/tmtc index f52f4b1c..c4598ff0 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit f52f4b1ce2f8932cb567a69e4972e562fd124134 +Subproject commit c4598ff05858952d0107d4f6f61cbef8ff2de691 -- 2.43.0 From 0beac793a161ec73e2c24f6a349ec9c2f03e6a3b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 26 Oct 2023 20:45:36 +0200 Subject: [PATCH 18/25] some more important bugfixes --- mission/acs/str/StarTrackerHandler.cpp | 12 ++++++++++++ mission/acs/str/strHelpers.h | 16 +++++++++------- tmtc | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 1bf35ca2..3ebc92fb 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -671,6 +671,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareRequestBlobsTm(); return result; } + case(startracker::REQ_AUTO_BLOB): { + result = prepareRequestAutoBlobTm(); + return returnvalue::OK; + } case (startracker::REQ_MATCHING): { result = prepareRequestMatchingParams(); return result; @@ -1484,6 +1488,8 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(startracker::CHKSUM, new PoolEntry({0})); + localDataPoolMap.emplace(startracker::TICKS_AUTO_BLOB, new PoolEntry()); + localDataPoolMap.emplace(startracker::TIME_AUTO_BLOB, new PoolEntry()); localDataPoolMap.emplace(startracker::AUTO_BLOB_THRESHOLD, new PoolEntry()); localDataPoolMap.emplace(startracker::PoolIds::NUM_MATCHED_CENTROIDS, new PoolEntry()); @@ -2351,6 +2357,7 @@ ReturnValue_t StarTrackerHandler::handleAutoBlobTm(const uint8_t* rawFrame) { if (result != returnvalue::OK) { return result; } + rawFrame += TICKS_OFFSET; size_t remainingLen = fullPacketLen; PoolReadGuard pg(&autoBlobSet); result = pg.getReadResult(); @@ -2381,6 +2388,7 @@ ReturnValue_t StarTrackerHandler::handleMatchedCentroidTm(const uint8_t* rawFram if (result != returnvalue::OK) { return result; } + rawFrame += TICKS_OFFSET; size_t remainingLen = fullPacketLen; PoolReadGuard pg(&matchedCentroidsSet); result = pg.getReadResult(); @@ -2440,6 +2448,7 @@ ReturnValue_t StarTrackerHandler::handleBlobTm(const uint8_t* rawFrame) { if (result != returnvalue::OK) { return result; } + rawFrame += TICKS_OFFSET; size_t remainingLen = fullPacketLen; PoolReadGuard pg(&blobsSet); result = pg.getReadResult(); @@ -2470,6 +2479,7 @@ ReturnValue_t StarTrackerHandler::handleBlobsTm(const uint8_t* rawFrame) { if (result != returnvalue::OK) { return result; } + rawFrame += TICKS_OFFSET; size_t remainingLen = fullPacketLen; PoolReadGuard pg(&blobsSet); result = pg.getReadResult(); @@ -2522,6 +2532,7 @@ ReturnValue_t StarTrackerHandler::handleCentroidTm(const uint8_t* rawFrame) { if (result != returnvalue::OK) { return result; } + rawFrame += TICKS_OFFSET; size_t remainingLen = fullPacketLen; PoolReadGuard pg(¢roidsSet); result = pg.getReadResult(); @@ -2553,6 +2564,7 @@ ReturnValue_t StarTrackerHandler::handleCentroidsTm(const uint8_t* rawFrame) { if (result != returnvalue::OK) { return result; } + rawFrame += TICKS_OFFSET; size_t remainingLen = fullPacketLen; PoolReadGuard pg(¢roidsSet); result = pg.getReadResult(); diff --git a/mission/acs/str/strHelpers.h b/mission/acs/str/strHelpers.h index dff29f95..2fe999c0 100644 --- a/mission/acs/str/strHelpers.h +++ b/mission/acs/str/strHelpers.h @@ -274,6 +274,8 @@ enum PoolIds : lp_id_t { DEBUG_CAMERA_TIMING, DEBUG_CAMERA_TEST, + TICKS_AUTO_BLOB, + TIME_AUTO_BLOB, AUTO_BLOB_THRESHOLD, TICKS_MATCHED_CENTROIDS, @@ -1441,10 +1443,10 @@ class AutoBlobSet : public StaticLocalDataSet<3> { AutoBlobSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, AUTO_BLOB_SET_ID) {} // Ticks timestamp lp_var_t ticks = - lp_var_t(sid.objectId, PoolIds::TICKS_MATCHED_CENTROIDS, this); + lp_var_t(sid.objectId, PoolIds::TICKS_AUTO_BLOB, this); // Unix time stamp lp_var_t timeUs = - lp_var_t(sid.objectId, PoolIds::TIME_MATCHED_CENTROIDS, this); + lp_var_t(sid.objectId, PoolIds::TIME_AUTO_BLOB, this); lp_var_t threshold = lp_var_t(sid.objectId, PoolIds::AUTO_BLOB_THRESHOLD, this); private: @@ -1466,15 +1468,15 @@ class MatchedCentroidsSet : public StaticLocalDataSet<20> { lp_var_t numberOfMatchedCentroids = lp_var_t(sid.objectId, PoolIds::NUM_MATCHED_CENTROIDS, this); lp_vec_t starIds = - lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_STAR_IDS); + lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_STAR_IDS, this); lp_vec_t xCoords = - lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_X_COORDS); + lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_X_COORDS, this); lp_vec_t yCoords = - lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_Y_COORDS); + lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_Y_COORDS, this); lp_vec_t xErrors = - lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_X_ERRORS); + lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_X_ERRORS, this); lp_vec_t yErrors = - lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_Y_ERRORS); + lp_vec_t(sid.objectId, PoolIds::MATCHED_CENTROIDS_Y_ERRORS, this); private: }; diff --git a/tmtc b/tmtc index c4598ff0..97b52931 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit c4598ff05858952d0107d4f6f61cbef8ff2de691 +Subproject commit 97b529318dbc654ec55fd765f892bff212918f39 -- 2.43.0 From 964d47b909cf776044bea7c5387a776954695735 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 27 Oct 2023 09:59:15 +0200 Subject: [PATCH 19/25] bugfix for reset function --- mission/acs/str/StarTrackerHandler.cpp | 1 + tmtc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 3ebc92fb..b7b4ee83 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -957,6 +957,7 @@ void StarTrackerHandler::addSecondaryTmForNormalMode(DeviceCommandId_t cmd) { void StarTrackerHandler::resetSecondaryTmSet() { additionalRequestedTm.clear(); additionalRequestedTm.emplace(startracker::REQ_TEMPERATURE); + currentSecondaryTmIter = additionalRequestedTm.begin(); { PoolReadGuard pg(&autoBlobSet); if (pg.getReadResult() == returnvalue::OK) { diff --git a/tmtc b/tmtc index 97b52931..d9530271 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 97b529318dbc654ec55fd765f892bff212918f39 +Subproject commit d9530271c38f8c81d6c5f3f11c6f3532085141e3 -- 2.43.0 From f8eb4fdd6f5d9114a9eb0b067ac927889f18a0e5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 27 Oct 2023 11:24:51 +0200 Subject: [PATCH 20/25] add contrast set --- mission/acs/str/StarTrackerHandler.cpp | 39 ++++++++++++++++++++++++++ mission/acs/str/StarTrackerHandler.h | 2 ++ mission/acs/str/strHelpers.h | 32 +++++++++++++++++++++ tmtc | 2 +- 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index b7b4ee83..f3550734 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -55,6 +55,7 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, blobsSet(this), centroidSet(this), centroidsSet(this), + contrastSet(this), strHelper(strHelper), paramJsonFile(jsonFileStr), powerSwitch(powerSwitch) { @@ -352,6 +353,7 @@ ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id if (currentSecondaryTmIter == additionalRequestedTm.end()) { currentSecondaryTmIter = additionalRequestedTm.begin(); } + sif::debug << "requesting ID " << *id << std::endl; normalState = NormalState::SOLUTION_REQUEST; break; case NormalState::SOLUTION_REQUEST: @@ -524,6 +526,9 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi prepareRequestCentroidsTm(); return returnvalue::OK; } + case (startracker::REQ_CONTRAST): { + return returnvalue::OK; + } case (startracker::BOOT): { prepareBootCommand(); return returnvalue::OK; @@ -809,6 +814,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() { startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::REQ_CENTROIDS, 3, ¢roidsSet, startracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(startracker::REQ_CONTRAST, 3, &contrastSet, + startracker::MAX_FRAME_SIZE * 2 + 2); } ReturnValue_t StarTrackerHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) { @@ -994,6 +1001,12 @@ void StarTrackerHandler::resetSecondaryTmSet() { centroidsSet.setValidity(false, true); } } + { + PoolReadGuard pg(&histogramSet); + if (pg.getReadResult() == returnvalue::OK) { + histogramSet.setValidity(false, true); + } + } } void StarTrackerHandler::bootBootloader() { @@ -1106,6 +1119,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, result = handleTm(packet, solutionSet, startracker::SolutionSet::SIZE, "REQ_SOLUTION"); break; } + case(startracker::REQ_CONTRAST): { + result = handleTm(packet, contrastSet, startracker::ContrastSet::SIZE, "REQ_CONTRAST"); + break; + } case (startracker::REQ_AUTO_BLOB): { result = handleAutoBlobTm(packet); break; @@ -1532,6 +1549,13 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_Y_COORDS, new PoolEntry(16)); localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_MAGNITUDES, new PoolEntry(16)); + localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_TICKS, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_TIME, new PoolEntry()); + localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_A, new PoolEntry(9)); + localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_B, new PoolEntry(9)); + localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_C, new PoolEntry(9)); + localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_D, new PoolEntry(9)); + poolManager.subscribeForDiagPeriodicPacket( subdp::DiagnosticsHkPeriodicParams(temperatureSet.getSid(), false, 10.0)); poolManager.subscribeForRegularPeriodicPacket( @@ -1558,6 +1582,8 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l subdp::RegularHkPeriodicParams(centroidSet.getSid(), false, 10.0)); poolManager.subscribeForRegularPeriodicPacket( subdp::RegularHkPeriodicParams(centroidsSet.getSid(), false, 10.0)); + poolManager.subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams(contrastSet.getSid(), false, 10.0)); return returnvalue::OK; } @@ -1823,6 +1849,10 @@ ReturnValue_t StarTrackerHandler::scanForTmReply(uint8_t replyId, DeviceCommandI *foundId = startracker::REQ_MATCHED_CENTROIDS; break; } + case(startracker::ID::CONTRAST): { + *foundId = startracker::REQ_CONTRAST; + break; + } default: { sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply ID: " << static_cast(replyId) << std::endl; @@ -2047,6 +2077,14 @@ ReturnValue_t StarTrackerHandler::prepareRequestCentroidsTm() { return returnvalue::OK; } +ReturnValue_t StarTrackerHandler::prepareRequestContrastTm() { + uint32_t length = 0; + arc_tm_pack_contrast_req(commandBuffer, &length); + rawPacket = commandBuffer; + rawPacketLen = length; + return returnvalue::OK; +} + ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, ArcsecJsonParamBase& paramSet, @@ -2749,6 +2787,7 @@ ReturnValue_t StarTrackerHandler::checkCommand(ActionId_t actionId) { case startracker::REQ_BLOBS: case startracker::REQ_CENTROID: case startracker::REQ_CENTROIDS: + case startracker::REQ_CONTRAST: if (getMode() == MODE_ON and getSubmode() != startracker::Program::FIRMWARE) { return STARTRACKER_NOT_RUNNING_FIRMWARE; } diff --git a/mission/acs/str/StarTrackerHandler.h b/mission/acs/str/StarTrackerHandler.h index d63335ae..c43d70fe 100644 --- a/mission/acs/str/StarTrackerHandler.h +++ b/mission/acs/str/StarTrackerHandler.h @@ -212,6 +212,7 @@ class StarTrackerHandler : public DeviceHandlerBase { startracker::BlobsSet blobsSet; startracker::CentroidSet centroidSet; startracker::CentroidsSet centroidsSet; + startracker::CentroidsSet contrastSet; // Pointer to object responsible for uploading and downloading images to/from the star tracker StrComHandler* strHelper = nullptr; @@ -460,6 +461,7 @@ class StarTrackerHandler : public DeviceHandlerBase { ReturnValue_t prepareRequestBlobsTm(); ReturnValue_t prepareRequestCentroidTm(); ReturnValue_t prepareRequestCentroidsTm(); + ReturnValue_t prepareRequestContrastTm(); ReturnValue_t prepareRequestTrackingParams(); ReturnValue_t prepareRequestValidationParams(); ReturnValue_t prepareRequestAlgoParams(); diff --git a/mission/acs/str/strHelpers.h b/mission/acs/str/strHelpers.h index 2fe999c0..834336a9 100644 --- a/mission/acs/str/strHelpers.h +++ b/mission/acs/str/strHelpers.h @@ -309,6 +309,13 @@ enum PoolIds : lp_id_t { CENTROIDS_X_COORDS, CENTROIDS_Y_COORDS, CENTROIDS_MAGNITUDES, + + CONTRAST_TICKS, + CONTRAST_TIME, + CONTRAST_A, + CONTRAST_B, + CONTRAST_C, + CONTRAST_D, }; static const DeviceCommandId_t PING_REQUEST = 0; @@ -327,6 +334,7 @@ static const DeviceCommandId_t IMAGE_PROCESSOR = 19; static const DeviceCommandId_t REQ_SOLUTION = 24; static const DeviceCommandId_t REQ_TEMPERATURE = 25; static const DeviceCommandId_t REQ_HISTOGRAM = 28; +static constexpr DeviceCommandId_t REQ_CONTRAST = 29; static const DeviceCommandId_t LIMITS = 40; static const DeviceCommandId_t MOUNTING = 41; static const DeviceCommandId_t CAMERA = 42; @@ -403,6 +411,7 @@ static const uint32_t BLOB_SET_ID = REQ_BLOB; static const uint32_t BLOBS_SET_ID = REQ_BLOBS; static const uint32_t CENTROID_SET_ID = REQ_CENTROID; static const uint32_t CENTROIDS_SET_ID = REQ_CENTROIDS; +static const uint32_t CONTRAST_SET_ID = REQ_CONTRAST; /** Max size of unencoded frame */ static const size_t MAX_FRAME_SIZE = 1200; @@ -1544,6 +1553,29 @@ class CentroidsSet : public StaticLocalDataSet<10> { lp_vec_t(sid.objectId, PoolIds::CENTROIDS_MAGNITUDES, this); }; +class ContrastSet: public StaticLocalDataSet<8> { + +public: + static constexpr size_t SIZE = 156; + + ContrastSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CONTRAST_SET_ID) {} + + // Data received from the Centroids Telemetry Set (ID 29) + lp_var_t ticks = + lp_var_t(sid.objectId, PoolIds::CONTRAST_TICKS, this); + // Unix time stamp + lp_var_t timeUs = + lp_var_t(sid.objectId, PoolIds::CONTRAST_TIME, this); + lp_vec_t contrastA = + lp_vec_t(sid.objectId, PoolIds::CONTRAST_A, this); + lp_vec_t contrastB = + lp_vec_t(sid.objectId, PoolIds::CONTRAST_B, this); + lp_vec_t contrastC = + lp_vec_t(sid.objectId, PoolIds::CONTRAST_C, this); + lp_vec_t contrastD = + lp_vec_t(sid.objectId, PoolIds::CONTRAST_D, this); +}; + /** * @brief Will store the requested algo parameters */ diff --git a/tmtc b/tmtc index d9530271..5821c60e 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit d9530271c38f8c81d6c5f3f11c6f3532085141e3 +Subproject commit 5821c60eb4743b014eb4641104bc35213f0b465b -- 2.43.0 From dcdceba07e56354322e80ecedeea62f0385c2474 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 27 Oct 2023 12:17:54 +0200 Subject: [PATCH 21/25] wrapping up --- mission/acs/str/StarTrackerHandler.cpp | 54 +++++++++++++++----------- mission/acs/str/StarTrackerHandler.h | 4 +- mission/acs/str/strHelpers.h | 44 +++++---------------- 3 files changed, 43 insertions(+), 59 deletions(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index f3550734..541301f1 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -353,7 +353,6 @@ ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id if (currentSecondaryTmIter == additionalRequestedTm.end()) { currentSecondaryTmIter = additionalRequestedTm.begin(); } - sif::debug << "requesting ID " << *id << std::endl; normalState = NormalState::SOLUTION_REQUEST; break; case NormalState::SOLUTION_REQUEST: @@ -527,6 +526,7 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi return returnvalue::OK; } case (startracker::REQ_CONTRAST): { + prepareRequestContrastTm(); return returnvalue::OK; } case (startracker::BOOT): { @@ -676,7 +676,7 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareRequestBlobsTm(); return result; } - case(startracker::REQ_AUTO_BLOB): { + case (startracker::REQ_AUTO_BLOB): { result = prepareRequestAutoBlobTm(); return returnvalue::OK; } @@ -995,6 +995,12 @@ void StarTrackerHandler::resetSecondaryTmSet() { centroidSet.setValidity(false, true); } } + { + PoolReadGuard pg(&contrastSet); + if (pg.getReadResult() == returnvalue::OK) { + contrastSet.setValidity(false, true); + } + } { PoolReadGuard pg(¢roidsSet); if (pg.getReadResult() == returnvalue::OK) { @@ -1082,7 +1088,7 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, break; } case (startracker::REQ_TIME): { - result = handleTm(packet, timeSet, startracker::TimeSet::SIZE, "REQ_TIME"); + result = handleTm(packet, timeSet, "REQ_TIME"); break; } case (startracker::PING_REQUEST): { @@ -1097,7 +1103,7 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, break; } case (startracker::REQ_VERSION): { - result = handleTm(packet, versionSet, startracker::VersionSet::SIZE, "REQ_VERSION"); + result = handleTm(packet, versionSet, "REQ_VERSION"); if (result != returnvalue::OK) { return result; } @@ -1108,19 +1114,19 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, break; } case (startracker::REQ_INTERFACE): { - result = handleTm(packet, interfaceSet, startracker::InterfaceSet::SIZE, "REQ_INTERFACE"); + result = handleTm(packet, interfaceSet, "REQ_INTERFACE"); break; } case (startracker::REQ_POWER): { - result = handleTm(packet, powerSet, startracker::PowerSet::SIZE, "REQ_POWER"); + result = handleTm(packet, powerSet, "REQ_POWER"); break; } case (startracker::REQ_SOLUTION): { - result = handleTm(packet, solutionSet, startracker::SolutionSet::SIZE, "REQ_SOLUTION"); + result = handleTm(packet, solutionSet, "REQ_SOLUTION"); break; } - case(startracker::REQ_CONTRAST): { - result = handleTm(packet, contrastSet, startracker::ContrastSet::SIZE, "REQ_CONTRAST"); + case (startracker::REQ_CONTRAST): { + result = handleTm(packet, contrastSet, "REQ_CONTRAST"); break; } case (startracker::REQ_AUTO_BLOB): { @@ -1148,11 +1154,11 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, break; } case (startracker::REQ_TEMPERATURE): { - result = handleTm(packet, temperatureSet, startracker::TemperatureSet::SIZE, "REQ_TEMP"); + result = handleTm(packet, temperatureSet, "REQ_TEMP"); break; } case (startracker::REQ_HISTOGRAM): { - result = handleTm(packet, histogramSet, startracker::HistogramSet::SIZE, "REQ_HISTO"); + result = handleTm(packet, histogramSet, "REQ_HISTO"); break; } case (startracker::SUBSCRIPTION): @@ -1825,31 +1831,31 @@ ReturnValue_t StarTrackerHandler::scanForTmReply(uint8_t replyId, DeviceCommandI *foundId = startracker::REQ_SOLUTION; break; } - case(startracker::ID::BLOB): { + case (startracker::ID::BLOB): { *foundId = startracker::REQ_BLOB; break; } - case(startracker::ID::BLOBS): { + case (startracker::ID::BLOBS): { *foundId = startracker::REQ_BLOBS; break; } - case(startracker::ID::CENTROID): { + case (startracker::ID::CENTROID): { *foundId = startracker::REQ_CENTROID; break; } - case(startracker::ID::CENTROIDS): { + case (startracker::ID::CENTROIDS): { *foundId = startracker::REQ_CENTROIDS; break; } - case(startracker::ID::AUTO_BLOB): { + case (startracker::ID::AUTO_BLOB): { *foundId = startracker::REQ_AUTO_BLOB; break; } - case(startracker::ID::MATCHED_CENTROIDS): { + case (startracker::ID::MATCHED_CENTROIDS): { *foundId = startracker::REQ_MATCHED_CENTROIDS; break; } - case(startracker::ID::CONTRAST): { + case (startracker::ID::CONTRAST): { *foundId = startracker::REQ_CONTRAST; break; } @@ -2363,7 +2369,7 @@ ReturnValue_t StarTrackerHandler::checkProgram() { } ReturnValue_t StarTrackerHandler::handleTm(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset, - size_t size, const char* context) { + const char* context) { ReturnValue_t result = statusFieldCheck(rawFrame); if (result != returnvalue::OK) { return result; @@ -2374,10 +2380,11 @@ ReturnValue_t StarTrackerHandler::handleTm(const uint8_t* rawFrame, LocalPoolDat } const uint8_t* reply = rawFrame + TICKS_OFFSET; dataset.setValidityBufferGeneration(false); - result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + size_t sizeLeft = fullPacketLen; + result = dataset.deSerialize(&reply, &sizeLeft, SerializeIF::Endianness::LITTLE); if (result != returnvalue::OK) { - sif::warning << "StarTrackerHandler::handleTm: Deserialization failed for " << context - << std::endl; + sif::warning << "StarTrackerHandler::handleTm: Deserialization failed for " << context << ": 0x" + << std::hex << std::setw(4) << result << std::dec << std::endl; } dataset.setValidityBufferGeneration(true); dataset.setValidity(true, true); @@ -2787,11 +2794,12 @@ ReturnValue_t StarTrackerHandler::checkCommand(ActionId_t actionId) { case startracker::REQ_BLOBS: case startracker::REQ_CENTROID: case startracker::REQ_CENTROIDS: - case startracker::REQ_CONTRAST: + case startracker::REQ_CONTRAST: { if (getMode() == MODE_ON and getSubmode() != startracker::Program::FIRMWARE) { return STARTRACKER_NOT_RUNNING_FIRMWARE; } break; + } case startracker::FIRMWARE_UPDATE: case startracker::FLASH_READ: if (getMode() != MODE_ON or getSubmode() != startracker::Program::BOOTLOADER) { diff --git a/mission/acs/str/StarTrackerHandler.h b/mission/acs/str/StarTrackerHandler.h index c43d70fe..3bfdc8fd 100644 --- a/mission/acs/str/StarTrackerHandler.h +++ b/mission/acs/str/StarTrackerHandler.h @@ -212,7 +212,7 @@ class StarTrackerHandler : public DeviceHandlerBase { startracker::BlobsSet blobsSet; startracker::CentroidSet centroidSet; startracker::CentroidsSet centroidsSet; - startracker::CentroidsSet contrastSet; + startracker::ContrastSet contrastSet; // Pointer to object responsible for uploading and downloading images to/from the star tracker StrComHandler* strHelper = nullptr; @@ -519,7 +519,7 @@ class StarTrackerHandler : public DeviceHandlerBase { * * @return returnvalue::OK if successful, otherwise error return value */ - ReturnValue_t handleTm(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset, size_t size, + ReturnValue_t handleTm(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset, const char* context); ReturnValue_t handleAutoBlobTm(const uint8_t* rawFrame); diff --git a/mission/acs/str/strHelpers.h b/mission/acs/str/strHelpers.h index 834336a9..808d6060 100644 --- a/mission/acs/str/strHelpers.h +++ b/mission/acs/str/strHelpers.h @@ -540,8 +540,6 @@ static const uint32_t FLASH_REGION_SIZE = 0x20000; */ class TemperatureSet : public StaticLocalDataSet { public: - static const size_t SIZE = 24; - TemperatureSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TEMPERATURE_SET_ID) {} TemperatureSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) {} @@ -571,8 +569,6 @@ class TemperatureSet : public StaticLocalDataSet { */ class VersionSet : public StaticLocalDataSet { public: - static const size_t SIZE = 15; - VersionSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, VERSION_SET_ID) {} VersionSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, VERSION_SET_ID)) {} @@ -602,8 +598,6 @@ class VersionSet : public StaticLocalDataSet { */ class InterfaceSet : public StaticLocalDataSet { public: - static const size_t SIZE = 20; - InterfaceSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, REQ_INTERFACE) {} InterfaceSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) {} @@ -631,8 +625,6 @@ class InterfaceSet : public StaticLocalDataSet { */ class PowerSet : public StaticLocalDataSet { public: - static const size_t SIZE = 76; - PowerSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, REQ_INTERFACE) {} PowerSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) {} @@ -696,8 +688,6 @@ class PowerSet : public StaticLocalDataSet { */ class TimeSet : public StaticLocalDataSet { public: - static const size_t SIZE = 24; - TimeSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TIME_SET_ID) {} TimeSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TIME_SET_ID)) {} @@ -724,8 +714,6 @@ class TimeSet : public StaticLocalDataSet { */ class SolutionSet : public StaticLocalDataSet { public: - static const size_t SIZE = 79; - SolutionSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SOLUTION_SET_ID) {} SolutionSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SOLUTION_SET_ID)) {} @@ -1451,11 +1439,9 @@ class AutoBlobSet : public StaticLocalDataSet<3> { public: AutoBlobSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, AUTO_BLOB_SET_ID) {} // Ticks timestamp - lp_var_t ticks = - lp_var_t(sid.objectId, PoolIds::TICKS_AUTO_BLOB, this); + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_AUTO_BLOB, this); // Unix time stamp - lp_var_t timeUs = - lp_var_t(sid.objectId, PoolIds::TIME_AUTO_BLOB, this); + lp_var_t timeUs = lp_var_t(sid.objectId, PoolIds::TIME_AUTO_BLOB, this); lp_var_t threshold = lp_var_t(sid.objectId, PoolIds::AUTO_BLOB_THRESHOLD, this); private: @@ -1463,7 +1449,6 @@ class AutoBlobSet : public StaticLocalDataSet<3> { class MatchedCentroidsSet : public StaticLocalDataSet<20> { public: - static constexpr size_t SIZE = 321; MatchedCentroidsSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, MATCHED_CENTROIDS_SET_ID) {} MatchedCentroidsSet(object_id_t objectId) @@ -1553,27 +1538,18 @@ class CentroidsSet : public StaticLocalDataSet<10> { lp_vec_t(sid.objectId, PoolIds::CENTROIDS_MAGNITUDES, this); }; -class ContrastSet: public StaticLocalDataSet<8> { - -public: - static constexpr size_t SIZE = 156; - +class ContrastSet : public StaticLocalDataSet<8> { + public: ContrastSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CONTRAST_SET_ID) {} // Data received from the Centroids Telemetry Set (ID 29) - lp_var_t ticks = - lp_var_t(sid.objectId, PoolIds::CONTRAST_TICKS, this); + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::CONTRAST_TICKS, this); // Unix time stamp - lp_var_t timeUs = - lp_var_t(sid.objectId, PoolIds::CONTRAST_TIME, this); - lp_vec_t contrastA = - lp_vec_t(sid.objectId, PoolIds::CONTRAST_A, this); - lp_vec_t contrastB = - lp_vec_t(sid.objectId, PoolIds::CONTRAST_B, this); - lp_vec_t contrastC = - lp_vec_t(sid.objectId, PoolIds::CONTRAST_C, this); - lp_vec_t contrastD = - lp_vec_t(sid.objectId, PoolIds::CONTRAST_D, this); + lp_var_t timeUs = lp_var_t(sid.objectId, PoolIds::CONTRAST_TIME, this); + lp_vec_t contrastA = lp_vec_t(sid.objectId, PoolIds::CONTRAST_A, this); + lp_vec_t contrastB = lp_vec_t(sid.objectId, PoolIds::CONTRAST_B, this); + lp_vec_t contrastC = lp_vec_t(sid.objectId, PoolIds::CONTRAST_C, this); + lp_vec_t contrastD = lp_vec_t(sid.objectId, PoolIds::CONTRAST_D, this); }; /** -- 2.43.0 From 656c69f85809b5a84633c3403da1f2a77f7db90a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 27 Oct 2023 12:32:59 +0200 Subject: [PATCH 22/25] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 5821c60e..72460fdb 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 5821c60eb4743b014eb4641104bc35213f0b465b +Subproject commit 72460fdb4960a5c3116826e1a8dbae4253c8ff25 -- 2.43.0 From a877edf40befd7baf0596ac0589f1517dd6b609b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 27 Oct 2023 12:34:33 +0200 Subject: [PATCH 23/25] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 72460fdb..0aaf6321 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 72460fdb4960a5c3116826e1a8dbae4253c8ff25 +Subproject commit 0aaf63215b5fe010a5447e5d64e1b4150d543847 -- 2.43.0 From 5a67ce56aab49c2ac28a1523cbcb8e000718a3dd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 27 Oct 2023 12:43:32 +0200 Subject: [PATCH 24/25] changelog --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0b669f9..3301f65f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,11 @@ will consitute of a breaking change warranting a new major release: ## Added +- STR: Added new TM sets: Blob, Blobs, MatchedCentroids, Contrast, AutoBlob +- STR: Added new mechanism where the secondary TM which is polled can now be a set instead of + being temperature only. An API is exposed which allows to add a data set to that set of secondary + telemetry, reset it back to temperature only, and read the whole set. This allows more debugging + capability. - CFDP source handler, which allows file downlink using the standardized CFDP interface. - Proper back pressure handling for the CFDP handler, where the `LiveTmTask` is able to throttle @@ -57,7 +62,6 @@ will consitute of a breaking change warranting a new major release: ## Added -- STR: Added new TM sets: Blob, Blobs, MatchedCentroids. - EPS Subsystem has been added to EIVE System Tree - Power Controller for calculating the State of Charge and FDIR regarding low SoC has been introduced. -- 2.43.0 From d2b5384f0586cb86d1031159a26be29b8354b757 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 27 Oct 2023 12:54:32 +0200 Subject: [PATCH 25/25] make marius happy --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3301f65f..9688a565 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ will consitute of a breaking change warranting a new major release: ## Added -- STR: Added new TM sets: Blob, Blobs, MatchedCentroids, Contrast, AutoBlob +- STR: Added new TM sets: Blob, Blobs, MatchedCentroids, Contrast, AutoBlob, Centroid, Centroids - STR: Added new mechanism where the secondary TM which is polled can now be a set instead of being temperature only. An API is exposed which allows to add a data set to that set of secondary telemetry, reset it back to temperature only, and read the whole set. This allows more debugging -- 2.43.0