v7.5.0 #828
@ -175,7 +175,7 @@ void ObjectFactory::produce(void* args) {
|
||||
createScexComponents(q7s::UART_SCEX_DEV, pwrSwitcher, *SdCardManager::instance(), false,
|
||||
power::Switches::PDU1_CH5_SOLAR_CELL_EXP_5V);
|
||||
#endif
|
||||
createAcsController(true, enableHkSets);
|
||||
createAcsController(true, enableHkSets, *SdCardManager::instance());
|
||||
HeaterHandler* heaterHandler;
|
||||
createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler);
|
||||
createThermalController(*heaterHandler, true);
|
||||
|
@ -130,6 +130,6 @@ void ObjectFactory::produce(void* args) {
|
||||
|
||||
createMiscComponents();
|
||||
createThermalController(*heaterHandler, false);
|
||||
createAcsController(true, enableHkSets);
|
||||
createAcsController(true, enableHkSets, *SdCardManager::instance());
|
||||
satsystem::init(false);
|
||||
}
|
||||
|
@ -335,8 +335,9 @@ void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF* pwr
|
||||
scexHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM);
|
||||
}
|
||||
|
||||
AcsController* ObjectFactory::createAcsController(bool connectSubsystem, bool enableHkSets) {
|
||||
auto acsCtrl = new AcsController(objects::ACS_CONTROLLER, enableHkSets);
|
||||
AcsController* ObjectFactory::createAcsController(bool connectSubsystem, bool enableHkSets,
|
||||
SdCardMountedIF& mountedIF) {
|
||||
auto acsCtrl = new AcsController(objects::ACS_CONTROLLER, enableHkSets, mountedIF);
|
||||
if (connectSubsystem) {
|
||||
acsCtrl->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM);
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ void createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher,
|
||||
|
||||
void gpioChecker(ReturnValue_t result, std::string output);
|
||||
|
||||
AcsController* createAcsController(bool connectSubsystem, bool enableHkSets);
|
||||
AcsController* createAcsController(bool connectSubsystem, bool enableHkSets,
|
||||
SdCardMountedIF& mountedIF);
|
||||
PowerController* createPowerController(bool connectSubsystem, bool enableHkSets);
|
||||
|
||||
} // namespace ObjectFactory
|
||||
|
@ -73,6 +73,8 @@ static constexpr Event MEKF_INVALID_MODE_VIOLATION = MAKE_EVENT(6, severity::HIG
|
||||
static constexpr Event SAFE_MODE_CONTROLLER_FAILURE = MAKE_EVENT(7, severity::HIGH);
|
||||
//! [EXPORT] : [COMMENT] The TLE for the SGP4 Propagator has become too old.
|
||||
static constexpr Event TLE_TOO_OLD = MAKE_EVENT(8, severity::INFO);
|
||||
//! [EXPORT] : [COMMENT] The TLE for the SGP4 Propagator has become too old.
|
||||
static constexpr Event TLE_FILE_READ_FAILED = MAKE_EVENT(9, severity::LOW);
|
||||
|
||||
extern const char* getModeStr(AcsMode mode);
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
#include "AcsController.h"
|
||||
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <mission/acs/defs.h>
|
||||
#include <mission/config/torquer.h>
|
||||
|
||||
AcsController::AcsController(object_id_t objectId, bool enableHkSets)
|
||||
AcsController::AcsController(object_id_t objectId, bool enableHkSets, SdCardMountedIF &sdcMan)
|
||||
: ExtendedControllerBase(objectId),
|
||||
enableHkSets(enableHkSets),
|
||||
sdcMan(sdcMan),
|
||||
fusedRotationEstimation(&acsParameters),
|
||||
guidance(&acsParameters),
|
||||
safeCtrl(&acsParameters),
|
||||
@ -1040,8 +1037,11 @@ ReturnValue_t AcsController::updateTle(const uint8_t *line1, const uint8_t *line
|
||||
}
|
||||
|
||||
ReturnValue_t AcsController::writeTleToFs(const uint8_t *tle) {
|
||||
// ToDo: check which SD card is active via sdcMan
|
||||
std::string path = SD_0 + TLE_FILE;
|
||||
auto mntPrefix = sdcMan.getCurrentMountPrefix();
|
||||
if (mntPrefix == nullptr or !sdcMan.isSdCardUsable(std::nullopt)) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
std::string path = mntPrefix + TLE_FILE;
|
||||
// Clear existing TLE from file
|
||||
std::ofstream tleFile(path.c_str(), std::ofstream::out | std::ofstream::trunc);
|
||||
if (tleFile.is_open()) {
|
||||
@ -1049,27 +1049,34 @@ ReturnValue_t AcsController::writeTleToFs(const uint8_t *tle) {
|
||||
tleFile << "\n";
|
||||
tleFile.write(reinterpret_cast<const char *>(tle + 69), 69);
|
||||
} else {
|
||||
// return error
|
||||
return WRITE_FILE_FAILED;
|
||||
}
|
||||
tleFile.close();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t AcsController::readTleFromFs(uint8_t *line1, uint8_t *line2) {
|
||||
// ToDo: check which SD card is active via sdcMan
|
||||
std::string path = SD_0 + TLE_FILE;
|
||||
// Read existing TLE from file
|
||||
std::fstream tleFile = std::fstream(path.c_str(), std::fstream::in);
|
||||
if (tleFile.is_open()) {
|
||||
std::string tleLine1, tleLine2;
|
||||
getline(tleFile, tleLine1);
|
||||
std::memcpy(line1, tleLine1.c_str(), 69);
|
||||
getline(tleFile, tleLine2);
|
||||
std::memcpy(line2, tleLine2.c_str(), 69);
|
||||
} else {
|
||||
// return error
|
||||
auto mntPrefix = sdcMan.getCurrentMountPrefix();
|
||||
if (mntPrefix == nullptr or !sdcMan.isSdCardUsable(std::nullopt)) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
std::string path = mntPrefix + TLE_FILE;
|
||||
std::error_code e;
|
||||
if (std::filesystem::exists(path, e)) {
|
||||
// Read existing TLE from file
|
||||
std::fstream tleFile = std::fstream(path.c_str(), std::fstream::in);
|
||||
if (tleFile.is_open()) {
|
||||
std::string tleLine1, tleLine2;
|
||||
getline(tleFile, tleLine1);
|
||||
std::memcpy(line1, tleLine1.c_str(), 69);
|
||||
getline(tleFile, tleLine2);
|
||||
std::memcpy(line2, tleLine2.c_str(), 69);
|
||||
} else {
|
||||
triggerEvent(acs::TLE_FILE_READ_FAILED);
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
tleFile.close();
|
||||
}
|
||||
tleFile.close();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
|
@ -4,15 +4,18 @@
|
||||
#include <eive/objects.h>
|
||||
#include <fsfw/controller/ExtendedControllerBase.h>
|
||||
#include <fsfw/coordinates/Sgp4Propagator.h>
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <fsfw/globalfunctions/math/VectorOperations.h>
|
||||
#include <fsfw/health/HealthTable.h>
|
||||
#include <fsfw/parameters/ParameterHelper.h>
|
||||
#include <fsfw/parameters/ReceivesParameterMessagesIF.h>
|
||||
#include <fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h>
|
||||
#include <fsfw_hal/devicehandlers/MgmRM3100Handler.h>
|
||||
#include <mission/acs/defs.h>
|
||||
#include <mission/acs/imtqHelpers.h>
|
||||
#include <mission/acs/rwHelpers.h>
|
||||
#include <mission/acs/susMax1227Helpers.h>
|
||||
#include <mission/config/torquer.h>
|
||||
#include <mission/controller/acs/ActuatorCmd.h>
|
||||
#include <mission/controller/acs/FusedRotationEstimation.h>
|
||||
#include <mission/controller/acs/Guidance.h>
|
||||
@ -23,15 +26,18 @@
|
||||
#include <mission/controller/acs/control/PtgCtrl.h>
|
||||
#include <mission/controller/acs/control/SafeCtrl.h>
|
||||
#include <mission/controller/controllerdefinitions/AcsCtrlDefinitions.h>
|
||||
#include <mission/memory/SdCardMountedIF.h>
|
||||
#include <mission/utility/trace.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
|
||||
class AcsController : public ExtendedControllerBase, public ReceivesParameterMessagesIF {
|
||||
public:
|
||||
static constexpr dur_millis_t INIT_DELAY = 500;
|
||||
|
||||
AcsController(object_id_t objectId, bool enableHkSets);
|
||||
AcsController(object_id_t objectId, bool enableHkSets, SdCardMountedIF& sdcMan);
|
||||
|
||||
MessageQueueId_t getCommandQueue() const;
|
||||
ReturnValue_t getParameter(uint8_t domainId, uint8_t parameterId,
|
||||
@ -51,6 +57,8 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes
|
||||
|
||||
bool enableHkSets = false;
|
||||
|
||||
SdCardMountedIF& sdcMan;
|
||||
|
||||
AcsParameters acsParameters;
|
||||
SensorProcessing sensorProcessing;
|
||||
FusedRotationEstimation fusedRotationEstimation;
|
||||
@ -93,6 +101,8 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::ACS_CTRL;
|
||||
//! [EXPORT] : [COMMENT] File deletion failed and at least one file is still existent.
|
||||
static constexpr ReturnValue_t FILE_DELETION_FAILED = MAKE_RETURN_CODE(0);
|
||||
//! [EXPORT] : [COMMENT] Writing the TLE to the file has failed.
|
||||
static constexpr ReturnValue_t WRITE_FILE_FAILED = MAKE_RETURN_CODE(1);
|
||||
|
||||
ReturnValue_t initialize() override;
|
||||
ReturnValue_t handleCommandMessage(CommandMessage* message) override;
|
||||
@ -131,9 +141,7 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes
|
||||
ReturnValue_t writeTleToFs(const uint8_t* tle);
|
||||
ReturnValue_t readTleFromFs(uint8_t* line1, uint8_t* line2);
|
||||
|
||||
const std::string SD_0 = "/mnt/sd0/";
|
||||
const std::string SD_1 = "/mnt/sd1/";
|
||||
const std::string TLE_FILE = "conf/tle.txt";
|
||||
const std::string TLE_FILE = "/conf/tle.txt";
|
||||
|
||||
/* ACS Sensor Values */
|
||||
ACS::SensorValues sensorValues;
|
||||
|
Loading…
Reference in New Issue
Block a user