eive-obsw/mission/controller/AcsController.h

181 lines
7.0 KiB
C
Raw Normal View History

2022-08-12 12:29:28 +02:00
#ifndef MISSION_CONTROLLER_ACSCONTROLLER_H_
#define MISSION_CONTROLLER_ACSCONTROLLER_H_
#include <fsfw/controller/ExtendedControllerBase.h>
#include <fsfw/globalfunctions/math/VectorOperations.h>
#include <fsfw/parameters/ParameterHelper.h>
#include <fsfw/parameters/ReceivesParameterMessagesIF.h>
#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"
2022-10-20 11:07:45 +02:00
#include "acs/control/SafeCtrl.h"
#include "controllerdefinitions/AcsCtrlDefinitions.h"
2022-09-16 12:28:39 +02:00
#include "eive/objects.h"
2022-08-15 10:50:19 +02:00
#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h"
#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h"
2022-08-17 09:27:19 +02:00
#include "mission/devices/devicedefinitions/SusDefinitions.h"
2022-10-20 15:08:33 +02:00
#include "mission/devices/devicedefinitions/imtqHandlerDefinitions.h"
2022-08-12 12:29:28 +02:00
class AcsController : public ExtendedControllerBase, public ReceivesParameterMessagesIF {
2022-08-15 09:58:18 +02:00
public:
2022-08-15 10:50:19 +02:00
static constexpr dur_millis_t INIT_DELAY = 500;
2022-08-15 09:58:18 +02:00
AcsController(object_id_t objectId);
2022-08-12 12:29:28 +02:00
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;
2023-01-09 09:36:00 +01:00
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();
2022-08-15 09:58:18 +02:00
private:
2022-10-06 15:37:41 +02:00
AcsParameters acsParameters;
SensorProcessing sensorProcessing;
Navigation navigation;
ActuatorCmd actuatorCmd;
Guidance guidance;
SafeCtrl safeCtrl;
Detumble detumble;
PtgCtrl ptgCtrl;
2022-10-06 15:37:41 +02:00
uint8_t detumbleCounter;
ParameterHelper parameterHelper;
2022-08-15 10:50:19 +02:00
enum class InternalState { STARTUP, INITIAL_DELAY, READY };
InternalState internalState = InternalState::STARTUP;
2022-08-12 12:29:28 +02:00
ReturnValue_t handleCommandMessage(CommandMessage* message) override;
void performControlOperation() override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
2022-08-15 09:58:18 +02:00
LocalDataPoolManager& poolManager) override;
2022-08-12 12:29:28 +02:00
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
// Mode abstract functions
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
2022-08-15 09:58:18 +02:00
uint32_t* msToReachTheMode) override;
2022-08-12 12:29:28 +02:00
/* ACS Datasets */
2022-12-01 15:56:55 +01:00
IMTQ::DipoleActuationSet dipoleSet = IMTQ::DipoleActuationSet(objects::IMTQ_HANDLER);
2022-08-12 12:29:28 +02:00
// MGMs
acsctrl::MgmDataRaw mgmDataRaw;
PoolEntry<float> mgm0VecRaw = PoolEntry<float>(3);
PoolEntry<float> mgm1VecRaw = PoolEntry<float>(3);
PoolEntry<float> mgm2VecRaw = PoolEntry<float>(3);
PoolEntry<float> mgm3VecRaw = PoolEntry<float>(3);
PoolEntry<float> imtqMgmVecRaw = PoolEntry<float>(3);
2022-08-15 11:19:08 +02:00
PoolEntry<uint8_t> imtqCalActStatus = PoolEntry<uint8_t>();
2022-08-15 10:50:19 +02:00
void copyMgmData();
2022-08-12 12:29:28 +02:00
acsctrl::MgmDataProcessed mgmDataProcessed;
PoolEntry<float> mgm0VecProc = PoolEntry<float>(3);
PoolEntry<float> mgm1VecProc = PoolEntry<float>(3);
PoolEntry<float> mgm2VecProc = PoolEntry<float>(3);
PoolEntry<float> mgm3VecProc = PoolEntry<float>(3);
PoolEntry<float> mgm4VecProc = PoolEntry<float>(3);
2022-10-25 11:31:54 +02:00
PoolEntry<double> mgmVecTot = PoolEntry<double>(3);
PoolEntry<double> mgmVecTotDer = PoolEntry<double>(3);
PoolEntry<double> magIgrf = PoolEntry<double>(3);
// SUSs
acsctrl::SusDataRaw susDataRaw;
PoolEntry<uint16_t> sus0ValRaw = PoolEntry<uint16_t>(6);
PoolEntry<uint16_t> sus1ValRaw = PoolEntry<uint16_t>(6);
PoolEntry<uint16_t> sus2ValRaw = PoolEntry<uint16_t>(6);
PoolEntry<uint16_t> sus3ValRaw = PoolEntry<uint16_t>(6);
PoolEntry<uint16_t> sus4ValRaw = PoolEntry<uint16_t>(6);
PoolEntry<uint16_t> sus5ValRaw = PoolEntry<uint16_t>(6);
PoolEntry<uint16_t> sus6ValRaw = PoolEntry<uint16_t>(6);
PoolEntry<uint16_t> sus7ValRaw = PoolEntry<uint16_t>(6);
PoolEntry<uint16_t> sus8ValRaw = PoolEntry<uint16_t>(6);
PoolEntry<uint16_t> sus9ValRaw = PoolEntry<uint16_t>(6);
PoolEntry<uint16_t> sus10ValRaw = PoolEntry<uint16_t>(6);
PoolEntry<uint16_t> sus11ValRaw = PoolEntry<uint16_t>(6);
2022-09-28 15:27:51 +02:00
void copySusData();
acsctrl::SusDataProcessed susDataProcessed;
PoolEntry<float> sus0VecProc = PoolEntry<float>(3);
PoolEntry<float> sus1VecProc = PoolEntry<float>(3);
PoolEntry<float> sus2VecProc = PoolEntry<float>(3);
PoolEntry<float> sus3VecProc = PoolEntry<float>(3);
PoolEntry<float> sus4VecProc = PoolEntry<float>(3);
PoolEntry<float> sus5VecProc = PoolEntry<float>(3);
PoolEntry<float> sus6VecProc = PoolEntry<float>(3);
PoolEntry<float> sus7VecProc = PoolEntry<float>(3);
PoolEntry<float> sus8VecProc = PoolEntry<float>(3);
PoolEntry<float> sus9VecProc = PoolEntry<float>(3);
PoolEntry<float> sus10VecProc = PoolEntry<float>(3);
PoolEntry<float> sus11VecProc = PoolEntry<float>(3);
PoolEntry<double> susVecTot = PoolEntry<double>(3);
PoolEntry<double> susVecTotDer = PoolEntry<double>(3);
PoolEntry<double> sunIjk = PoolEntry<double>(3);
// GYRs
acsctrl::GyrDataRaw gyrDataRaw;
PoolEntry<double> gyr0VecRaw = PoolEntry<double>(3);
PoolEntry<float> gyr1VecRaw = PoolEntry<float>(3);
PoolEntry<double> gyr2VecRaw = PoolEntry<double>(3);
PoolEntry<float> gyr3VecRaw = PoolEntry<float>(3);
void copyGyrData();
acsctrl::GyrDataProcessed gyrDataProcessed;
PoolEntry<double> gyr0VecProc = PoolEntry<double>(3);
PoolEntry<double> gyr1VecProc = PoolEntry<double>(3);
PoolEntry<double> gyr2VecProc = PoolEntry<double>(3);
PoolEntry<double> gyr3VecProc = PoolEntry<double>(3);
PoolEntry<double> gyrVecTot = PoolEntry<double>(3);
// GPS
acsctrl::GpsDataProcessed gpsDataProcessed;
PoolEntry<double> gcLatitude = PoolEntry<double>();
PoolEntry<double> gdLongitude = PoolEntry<double>();
2023-01-11 13:42:48 +01:00
PoolEntry<double> gpsPosition = PoolEntry<double>(3);
PoolEntry<double> gpsVelocity = PoolEntry<double>(3);
// MEKF
acsctrl::MekfData mekfData;
PoolEntry<double> quatMekf = PoolEntry<double>(4);
PoolEntry<double> satRotRateMekf = PoolEntry<double>(3);
// Ctrl Values
acsctrl::CtrlValData ctrlValData;
PoolEntry<double> tgtQuat = PoolEntry<double>(4);
PoolEntry<double> errQuat = PoolEntry<double>(4);
PoolEntry<double> errAng = PoolEntry<double>();
// Actuator CMD
acsctrl::ActuatorCmdData actuatorCmdData;
PoolEntry<double> rwTargetTorque = PoolEntry<double>(4);
2022-11-08 10:56:12 +01:00
PoolEntry<int32_t> rwTargetSpeed = PoolEntry<int32_t>(4);
PoolEntry<int16_t> mtqTargetDipole = PoolEntry<int16_t>(3);
2022-08-15 10:50:19 +02:00
// Initial delay to make sure all pool variables have been initialized their owners
Countdown initialCountdown = Countdown(INIT_DELAY);
2022-08-12 12:29:28 +02:00
};
#endif /* MISSION_CONTROLLER_ACSCONTROLLER_H_ */