2022-09-20 13:43:26 +02:00
|
|
|
#ifndef PTGCTRL_H_
|
|
|
|
#define PTGCTRL_H_
|
|
|
|
|
2023-04-27 11:21:02 +02:00
|
|
|
#include <math.h>
|
2023-11-02 16:59:09 +01:00
|
|
|
#include <mission/acs/defs.h>
|
2023-04-27 11:21:02 +02:00
|
|
|
#include <mission/controller/acs/AcsParameters.h>
|
|
|
|
#include <mission/controller/acs/SensorValues.h>
|
2022-09-20 13:43:26 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2022-10-12 15:06:24 +02:00
|
|
|
class PtgCtrl {
|
2023-03-10 17:21:52 +01:00
|
|
|
/*
|
|
|
|
* @brief: This class handles the pointing control mechanism. Calculation of an commanded
|
2023-11-02 16:59:09 +01:00
|
|
|
* torque for the reaction wheels, and magnetic Field strength for magnetorquer for desaturation
|
2023-03-10 17:21:52 +01:00
|
|
|
*
|
|
|
|
* @note: A description of the used algorithms can be found in
|
|
|
|
* https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_Studenten/Marquardt_Robin&openfile=896110
|
|
|
|
*/
|
2022-10-12 15:06:24 +02:00
|
|
|
public:
|
|
|
|
/* @brief: Constructor
|
|
|
|
* @param: acsParameters_ Pointer to object which defines the ACS configuration parameters
|
|
|
|
*/
|
|
|
|
PtgCtrl(AcsParameters *acsParameters_);
|
|
|
|
virtual ~PtgCtrl();
|
|
|
|
|
2023-11-23 16:56:36 +01:00
|
|
|
acs::ControlModeStrategy pointingCtrlStrategy(const bool magFieldValid, const bool mekfValid,
|
2023-11-24 11:30:27 +01:00
|
|
|
const bool strValid, const bool questValid,
|
|
|
|
const bool fusedRateValid,
|
|
|
|
const uint8_t rotRateSource,
|
|
|
|
const uint8_t mekfEnabled);
|
2023-11-02 16:59:09 +01:00
|
|
|
|
2022-10-12 15:06:24 +02:00
|
|
|
/* @brief: Calculates the needed torque for the pointing control mechanism
|
|
|
|
*/
|
2023-01-23 16:34:52 +01:00
|
|
|
void ptgLaw(AcsParameters::PointingLawParameters *pointingLawParameters, const double *qError,
|
|
|
|
const double *deltaRate, const double *rwPseudoInv, double *torqueRws);
|
2022-10-12 15:06:24 +02:00
|
|
|
|
2024-01-26 10:50:11 +01:00
|
|
|
void ptgNullspace(const bool allRwAvabilable,
|
|
|
|
AcsParameters::PointingLawParameters *pointingLawParameters,
|
2023-05-03 09:43:02 +02:00
|
|
|
const int32_t speedRw0, const int32_t speedRw1, const int32_t speedRw2,
|
|
|
|
const int32_t speedRw3, double *rwTrqNs);
|
2022-10-12 15:06:24 +02:00
|
|
|
|
2024-02-19 14:54:17 +01:00
|
|
|
void ptgDesaturation(const bool allRwAvabilable,
|
|
|
|
AcsParameters::PointingLawParameters *pointingLawParameters,
|
2023-05-03 09:35:46 +02:00
|
|
|
const double *magFieldB, const bool magFieldBValid, const double *satRate,
|
|
|
|
const int32_t speedRw0, const int32_t speedRw1, const int32_t speedRw2,
|
|
|
|
const int32_t speedRw3, double *mgtDpDes);
|
|
|
|
|
2022-11-08 13:48:50 +01:00
|
|
|
/* @brief: Commands the stiction torque in case wheel speed is to low
|
2023-11-02 16:59:09 +01:00
|
|
|
* torqueCommand modified torque after anti-stiction
|
2022-11-08 13:48:50 +01:00
|
|
|
*/
|
2023-03-10 17:21:52 +01:00
|
|
|
void rwAntistiction(ACS::SensorValues *sensorValues, int32_t *rwCmdSpeed);
|
2022-11-08 13:48:50 +01:00
|
|
|
|
2022-10-12 15:06:24 +02:00
|
|
|
private:
|
2023-02-28 10:47:37 +01:00
|
|
|
const AcsParameters *acsParameters;
|
2023-04-27 13:52:41 +02:00
|
|
|
static constexpr double RPM_TO_RAD_PER_SEC = (2 * M_PI) / 60;
|
2022-09-20 13:43:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* ACS_CONTROL_PTGCTRL_H_ */
|