eive-obsw/mission/controller/acs/Navigation.cpp

74 lines
3.1 KiB
C++
Raw Normal View History

2022-09-20 14:15:55 +02:00
#include "Navigation.h"
2024-02-27 16:05:05 +01:00
Navigation::Navigation(AcsParameters *acsParameters) : multiplicativeKalmanFilter(acsParameters) {}
2022-09-20 14:15:55 +02:00
Navigation::~Navigation() {}
2024-02-27 16:05:05 +01:00
ReturnValue_t Navigation::useMekf(const ACS::SensorValues *sensorValues,
const acsctrl::GyrDataProcessed *gyrDataProcessed,
const acsctrl::MgmDataProcessed *mgmDataProcessed,
const acsctrl::SusDataProcessed *susDataProcessed,
const double timeDelta,
acsctrl::AttitudeEstimationData *attitudeEstimationData,
const bool allowStr) {
2024-02-27 16:05:05 +01:00
multiplicativeKalmanFilter.setStrData(
sensorValues->strSet.caliQx.value, sensorValues->strSet.caliQy.value,
sensorValues->strSet.caliQz.value, sensorValues->strSet.caliQw.value,
sensorValues->strSet.caliQx.isValid(), allowStr);
2023-02-23 11:26:43 +01:00
if (mekfStatus == MultiplicativeKalmanFilter::MEKF_UNINITIALIZED) {
2024-02-27 16:05:05 +01:00
mekfStatus = multiplicativeKalmanFilter.init(susDataProcessed, mgmDataProcessed,
gyrDataProcessed, attitudeEstimationData);
return mekfStatus;
} else {
mekfStatus = multiplicativeKalmanFilter.mekfEst(
2024-02-27 16:05:05 +01:00
susDataProcessed, mgmDataProcessed, gyrDataProcessed, timeDelta, attitudeEstimationData);
return mekfStatus;
}
2022-09-20 14:15:55 +02:00
}
2023-11-23 16:56:36 +01:00
void Navigation::resetMekf(acsctrl::AttitudeEstimationData *mekfData) {
mekfStatus = multiplicativeKalmanFilter.reset(mekfData);
}
2023-08-07 11:23:10 +02:00
2023-08-09 13:41:25 +02:00
ReturnValue_t Navigation::useSpg4(timeval now, acsctrl::GpsDataProcessed *gpsDataProcessed) {
2023-08-07 11:23:10 +02:00
double position[3] = {0, 0, 0};
double velocity[3] = {0, 0, 0};
ReturnValue_t result = sgp4Propagator.propagate(position, velocity, now, 0);
if (result == returnvalue::OK) {
{
PoolReadGuard pg(gpsDataProcessed);
if (pg.getReadResult() == returnvalue::OK) {
2023-11-27 10:37:40 +01:00
gpsDataProcessed->source = acs::gps::Source::SPG4;
2023-08-07 13:37:05 +02:00
gpsDataProcessed->source.setValid(true);
2023-08-07 11:23:10 +02:00
std::memcpy(gpsDataProcessed->gpsPosition.value, position, 3 * sizeof(double));
gpsDataProcessed->gpsPosition.setValid(true);
std::memcpy(gpsDataProcessed->gpsVelocity.value, velocity, 3 * sizeof(double));
gpsDataProcessed->gpsVelocity.setValid(true);
}
}
} else {
{
PoolReadGuard pg(gpsDataProcessed);
if (pg.getReadResult() == returnvalue::OK) {
2023-11-27 10:37:40 +01:00
gpsDataProcessed->source = acs::gps::Source::NONE;
2023-08-07 13:37:05 +02:00
gpsDataProcessed->source.setValid(true);
2023-08-07 11:23:10 +02:00
std::memcpy(gpsDataProcessed->gpsPosition.value, position, 3 * sizeof(double));
gpsDataProcessed->gpsPosition.setValid(false);
std::memcpy(gpsDataProcessed->gpsVelocity.value, velocity, 3 * sizeof(double));
gpsDataProcessed->gpsVelocity.setValid(false);
}
}
}
2023-08-09 13:41:25 +02:00
return result;
2023-08-07 11:23:10 +02:00
}
ReturnValue_t Navigation::updateTle(const uint8_t *line1, const uint8_t *line2) {
return sgp4Propagator.initialize(line1, line2);
}
2024-02-27 16:05:05 +01:00
void Navigation::updateMekfStandardDeviations(const AcsParameters *acsParameters) {
multiplicativeKalmanFilter.updateStandardDeviations(acsParameters);
}