Star Tracker : Tweaks and fixes #443

Merged
muellerr merged 7 commits from startracker_try_cfg_time_reduction into develop 2023-03-08 01:26:04 +01:00
3 changed files with 83 additions and 47 deletions
Showing only changes of commit 01e97c8381 - Show all commits

2
fsfw

@ -1 +1 @@
Subproject commit 7f6ba5f40b47bc32802efdc4ed41b4bad4b8071b
Subproject commit 1b7493f945302b3785ceba6e7a34a727e3898a13

View File

@ -3,7 +3,9 @@
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw/timemanager/Stopwatch.h>
#include <atomic>
#include <fstream>
#include <thread>
#include "OBSWConfig.h"
#include "StarTrackerJsonCommands.h"
@ -15,6 +17,8 @@ extern "C" {
#include "common/misc.h"
}
std::atomic_bool JCFG_DONE(false);
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
const char* jsonFileStr, StrHelper* strHelper,
power::Switch_t powerSwitch)
@ -62,23 +66,10 @@ ReturnValue_t StarTrackerHandler::initialize() {
return result;
}
// TODO: This takes 200-250ms. Move it into a separate thread, use a mutexed boolean
// to check whether init was done. Or move it into the helper class..
// Also move update of these classes into the helper class.
tracking.init(paramJsonFile);
logLevel.init(paramJsonFile);
logSubscription.init(paramJsonFile);
debugCamera.init(paramJsonFile);
algo.init(paramJsonFile);
validation.init(paramJsonFile);
matching.init(paramJsonFile);
lisa.init(paramJsonFile);
centroiding.init(paramJsonFile);
camera.init(paramJsonFile);
imageProcessor.init(paramJsonFile);
mounting.init(paramJsonFile);
limits.init(paramJsonFile);
subscription.init(paramJsonFile);
// Spin up a thread to do the JSON initialization, takes 200-250 ms which would
// delay whole satellite boot process.
jcfgCountdown.resetTimer();
jsonCfgTask = std::thread{setUpJsonCfgs, std::ref(jcfgs), paramJsonFile.c_str()};
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
if (manager == nullptr) {
@ -261,8 +252,19 @@ void StarTrackerHandler::doStartUp() {
// the device handler's submode to the star tracker's mode
return;
case StartupState::DONE:
if (jcfgCountdown.isBusy()) {
startupState = StartupState::WAIT_JCFG;
return;
}
startupState = StartupState::IDLE;
break;
case StartupState::WAIT_JCFG: {
if (jcfgCountdown.hasTimedOut()) {
startupState = StartupState::IDLE;
break;
}
return;
}
default:
return;
}
@ -440,7 +442,7 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
return returnvalue::OK;
}
case (startracker::SUBSCRIPTION): {
result = prepareParamCommand(commandData, commandDataLen, subscription);
result = prepareParamCommand(commandData, commandDataLen, jcfgs.subscription);
return returnvalue::OK;
}
case (startracker::REQ_SOLUTION): {
@ -456,55 +458,55 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
return returnvalue::OK;
}
case (startracker::LIMITS): {
result = prepareParamCommand(commandData, commandDataLen, limits);
result = prepareParamCommand(commandData, commandDataLen, jcfgs.limits);
return result;
}
case (startracker::MOUNTING): {
result = prepareParamCommand(commandData, commandDataLen, mounting);
result = prepareParamCommand(commandData, commandDataLen, jcfgs.mounting);
return result;
}
case (startracker::IMAGE_PROCESSOR): {
result = prepareParamCommand(commandData, commandDataLen, imageProcessor);
result = prepareParamCommand(commandData, commandDataLen, jcfgs.imageProcessor);
return result;
}
case (startracker::CAMERA): {
result = prepareParamCommand(commandData, commandDataLen, camera);
result = prepareParamCommand(commandData, commandDataLen, jcfgs.camera);
return result;
}
case (startracker::CENTROIDING): {
result = prepareParamCommand(commandData, commandDataLen, centroiding);
result = prepareParamCommand(commandData, commandDataLen, jcfgs.centroiding);
return result;
}
case (startracker::LISA): {
result = prepareParamCommand(commandData, commandDataLen, lisa);
result = prepareParamCommand(commandData, commandDataLen, jcfgs.lisa);
return result;
}
case (startracker::MATCHING): {
result = prepareParamCommand(commandData, commandDataLen, matching);
result = prepareParamCommand(commandData, commandDataLen, jcfgs.matching);
return result;
}
case (startracker::VALIDATION): {
result = prepareParamCommand(commandData, commandDataLen, validation);
result = prepareParamCommand(commandData, commandDataLen, jcfgs.validation);
return result;
}
case (startracker::ALGO): {
result = prepareParamCommand(commandData, commandDataLen, algo);
result = prepareParamCommand(commandData, commandDataLen, jcfgs.algo);
return result;
}
case (startracker::TRACKING): {
result = prepareParamCommand(commandData, commandDataLen, tracking);
result = prepareParamCommand(commandData, commandDataLen, jcfgs.tracking);
return result;
}
case (startracker::LOGLEVEL): {
result = prepareParamCommand(commandData, commandDataLen, logLevel);
result = prepareParamCommand(commandData, commandDataLen, jcfgs.logLevel);
return result;
}
case (startracker::LOGSUBSCRIPTION): {
result = prepareParamCommand(commandData, commandDataLen, logSubscription);
result = prepareParamCommand(commandData, commandDataLen, jcfgs.logSubscription);
return result;
}
case (startracker::DEBUG_CAMERA): {
result = prepareParamCommand(commandData, commandDataLen, debugCamera);
result = prepareParamCommand(commandData, commandDataLen, jcfgs.debugCamera);
return result;
}
case (startracker::CHECKSUM): {
@ -753,6 +755,24 @@ void StarTrackerHandler::bootFirmware(Mode_t toMode) {
}
}
void StarTrackerHandler::setUpJsonCfgs(JsonConfigs& cfgs, const char* paramJsonFile) {
cfgs.tracking.init(paramJsonFile);
cfgs.logLevel.init(paramJsonFile);
cfgs.logSubscription.init(paramJsonFile);
cfgs.debugCamera.init(paramJsonFile);
cfgs.algo.init(paramJsonFile);
cfgs.validation.init(paramJsonFile);
cfgs.matching.init(paramJsonFile);
cfgs.lisa.init(paramJsonFile);
cfgs.centroiding.init(paramJsonFile);
cfgs.camera.init(paramJsonFile);
cfgs.imageProcessor.init(paramJsonFile);
cfgs.mounting.init(paramJsonFile);
cfgs.limits.init(paramJsonFile);
cfgs.subscription.init(paramJsonFile);
JCFG_DONE = true;
}
void StarTrackerHandler::bootBootloader() {
if (internalState == InternalState::IDLE) {
internalState = InternalState::BOOT_BOOTLOADER;

View File

@ -4,6 +4,8 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include <linux/devices/startracker/StarTrackerJsonCommands.h>
#include <thread>
#include "ArcsecDatalinkLayer.h"
#include "ArcsecJsonParamBase.h"
#include "OBSWConfig.h"
@ -217,20 +219,27 @@ class StarTrackerHandler : public DeviceHandlerBase {
// Loading firmware requires some time and the command will not trigger a reply when executed
Countdown bootCountdown;
Tracking tracking;
LogLevel logLevel;
LogSubscription logSubscription;
DebugCamera debugCamera;
Algo algo;
Validation validation;
Matching matching;
Lisa lisa;
Centroiding centroiding;
Camera camera;
ImageProcessor imageProcessor;
Mounting mounting;
Limits limits;
Subscription subscription;
struct JsonConfigs {
Tracking tracking;
LogLevel logLevel;
LogSubscription logSubscription;
DebugCamera debugCamera;
Algo algo;
Validation validation;
Matching matching;
Lisa lisa;
Centroiding centroiding;
Camera camera;
ImageProcessor imageProcessor;
Mounting mounting;
Limits limits;
Subscription subscription;
};
JsonConfigs jcfgs;
Countdown jcfgCountdown = Countdown(250);
bool commandExecuted = false;
std::thread jsonCfgTask;
static void setUpJsonCfgs(JsonConfigs& cfgs, const char* paramJsonFile);
std::string paramJsonFile;
@ -270,7 +279,14 @@ class StarTrackerHandler : public DeviceHandlerBase {
InternalState internalState = InternalState::IDLE;
enum class StartupState { IDLE, CHECK_PROGRAM, WAIT_CHECK_PROGRAM, BOOT_BOOTLOADER, DONE };
enum class StartupState {
IDLE,
CHECK_PROGRAM,
WAIT_CHECK_PROGRAM,
BOOT_BOOTLOADER,
WAIT_JCFG,
DONE
};
StartupState startupState = StartupState::IDLE;