#ifndef MISSION_CONTROLLER_ACSCONTROLLER_H_ #define MISSION_CONTROLLER_ACSCONTROLLER_H_ #include #include #include #include #include "acs/ActuatorCmd.h" #include "acs/Guidance.h" #include "acs/Navigation.h" #include "acs/SensorProcessing.h" #include "acs/control/Detumble.h" #include "acs/control/PtgCtrl.h" #include "acs/control/SafeCtrl.h" #include "controllerdefinitions/AcsCtrlDefinitions.h" #include "eive/objects.h" #include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" #include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" #include "mission/devices/devicedefinitions/SusDefinitions.h" #include "mission/devices/devicedefinitions/imtqHandlerDefinitions.h" class AcsController : public ExtendedControllerBase, public ReceivesParameterMessagesIF { public: static constexpr dur_millis_t INIT_DELAY = 500; AcsController(object_id_t objectId); static const Submode_t SUBMODE_SAFE = 2; static const Submode_t SUBMODE_DETUMBLE = 3; static const Submode_t SUBMODE_IDLE = 4; static const Submode_t SUBMODE_PTG_NADIR = 5; static const Submode_t SUBMODE_PTG_TARGET = 6; static const Submode_t SUBMODE_PTG_TARGET_GS = 7; static const Submode_t SUBMODE_PTG_INERTIAL = 8; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::ACS_SUBSYSTEM; static const Event SAFE_RATE_VIOLATION = MAKE_EVENT(0, severity::MEDIUM); //!< The limits for the rotation in safe mode were violated. MessageQueueId_t getCommandQueue() const; ReturnValue_t getParameter(uint8_t domainId, uint8_t parameterId, ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues, uint16_t startAtIndex) override; protected: void performSafe(); void performDetumble(); void performPointingCtrl(); private: AcsParameters acsParameters; SensorProcessing sensorProcessing; Navigation navigation; ActuatorCmd actuatorCmd; Guidance guidance; SafeCtrl safeCtrl; Detumble detumble; PtgCtrl ptgCtrl; uint8_t detumbleCounter; ParameterHelper parameterHelper; enum class InternalState { STARTUP, INITIAL_DELAY, READY }; InternalState internalState = InternalState::STARTUP; ReturnValue_t handleCommandMessage(CommandMessage* message) override; void performControlOperation() override; ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; // Mode abstract functions ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode) override; /* ACS Datasets */ IMTQ::DipoleActuationSet dipoleSet = IMTQ::DipoleActuationSet(objects::IMTQ_HANDLER); // MGMs acsctrl::MgmDataRaw mgmDataRaw; PoolEntry mgm0VecRaw = PoolEntry(3); PoolEntry mgm1VecRaw = PoolEntry(3); PoolEntry mgm2VecRaw = PoolEntry(3); PoolEntry mgm3VecRaw = PoolEntry(3); PoolEntry imtqMgmVecRaw = PoolEntry(3); PoolEntry imtqCalActStatus = PoolEntry(); void copyMgmData(); acsctrl::MgmDataProcessed mgmDataProcessed; PoolEntry mgm0VecProc = PoolEntry(3); PoolEntry mgm1VecProc = PoolEntry(3); PoolEntry mgm2VecProc = PoolEntry(3); PoolEntry mgm3VecProc = PoolEntry(3); PoolEntry mgm4VecProc = PoolEntry(3); PoolEntry mgmVecTot = PoolEntry(3); PoolEntry mgmVecTotDer = PoolEntry(3); PoolEntry magIgrf = PoolEntry(3); // SUSs acsctrl::SusDataRaw susDataRaw; PoolEntry sus0ValRaw = PoolEntry(6); PoolEntry sus1ValRaw = PoolEntry(6); PoolEntry sus2ValRaw = PoolEntry(6); PoolEntry sus3ValRaw = PoolEntry(6); PoolEntry sus4ValRaw = PoolEntry(6); PoolEntry sus5ValRaw = PoolEntry(6); PoolEntry sus6ValRaw = PoolEntry(6); PoolEntry sus7ValRaw = PoolEntry(6); PoolEntry sus8ValRaw = PoolEntry(6); PoolEntry sus9ValRaw = PoolEntry(6); PoolEntry sus10ValRaw = PoolEntry(6); PoolEntry sus11ValRaw = PoolEntry(6); void copySusData(); acsctrl::SusDataProcessed susDataProcessed; PoolEntry sus0VecProc = PoolEntry(3); PoolEntry sus1VecProc = PoolEntry(3); PoolEntry sus2VecProc = PoolEntry(3); PoolEntry sus3VecProc = PoolEntry(3); PoolEntry sus4VecProc = PoolEntry(3); PoolEntry sus5VecProc = PoolEntry(3); PoolEntry sus6VecProc = PoolEntry(3); PoolEntry sus7VecProc = PoolEntry(3); PoolEntry sus8VecProc = PoolEntry(3); PoolEntry sus9VecProc = PoolEntry(3); PoolEntry sus10VecProc = PoolEntry(3); PoolEntry sus11VecProc = PoolEntry(3); PoolEntry susVecTot = PoolEntry(3); PoolEntry susVecTotDer = PoolEntry(3); PoolEntry sunIjk = PoolEntry(3); // GYRs acsctrl::GyrDataRaw gyrDataRaw; PoolEntry gyr0VecRaw = PoolEntry(3); PoolEntry gyr1VecRaw = PoolEntry(3); PoolEntry gyr2VecRaw = PoolEntry(3); PoolEntry gyr3VecRaw = PoolEntry(3); void copyGyrData(); acsctrl::GyrDataProcessed gyrDataProcessed; PoolEntry gyr0VecProc = PoolEntry(3); PoolEntry gyr1VecProc = PoolEntry(3); PoolEntry gyr2VecProc = PoolEntry(3); PoolEntry gyr3VecProc = PoolEntry(3); PoolEntry gyrVecTot = PoolEntry(3); // GPS acsctrl::GpsDataProcessed gpsDataProcessed; PoolEntry gcLatitude = PoolEntry(); PoolEntry gdLongitude = PoolEntry(); PoolEntry gpsPosition = PoolEntry(3); PoolEntry gpsVelocity = PoolEntry(3); // MEKF acsctrl::MekfData mekfData; PoolEntry quatMekf = PoolEntry(4); PoolEntry satRotRateMekf = PoolEntry(3); // Ctrl Values acsctrl::CtrlValData ctrlValData; PoolEntry tgtQuat = PoolEntry(4); PoolEntry errQuat = PoolEntry(4); PoolEntry errAng = PoolEntry(); // Actuator CMD acsctrl::ActuatorCmdData actuatorCmdData; PoolEntry rwTargetTorque = PoolEntry(4); PoolEntry rwTargetSpeed = PoolEntry(4); PoolEntry mtqTargetDipole = PoolEntry(3); // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(INIT_DELAY); }; #endif /* MISSION_CONTROLLER_ACSCONTROLLER_H_ */