From b2a10f525c60074fbdf440670aac8fe8b18ca48a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicol=C3=B2=20Caruso?= <niccolo.caruso@skywarder.eu>
Date: Fri, 17 Jan 2025 16:42:12 +0100
Subject: [PATCH] [ARP] SMA calibrate movements, Hub mutex for having NAS,
Cmake removed test-actuators
Calibrate state now can have movements by the setStepperAngle commands, not only the tests.
---
CMakeLists.txt | 7 -------
src/Groundstation/Automated/Hub.cpp | 7 ++++++-
src/Groundstation/Automated/SMA/SMA.cpp | 6 ++++--
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1902a11e2..f624ae63a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -98,13 +98,6 @@ add_executable(nokia-groundstation-entry
target_include_directories(nokia-groundstation-entry PRIVATE ${OBSW_INCLUDE_DIRS})
sbs_target(nokia-groundstation-entry stm32f429zi_nokia)
-add_executable(test-actuators
- src/Groundstation/Automated/test-actuators.cpp
- ${LYRA_GS} ${GROUNDSTATION_COMMON}
-)
-target_include_directories(test-actuators PRIVATE ${OBSW_INCLUDE_DIRS})
-sbs_target(test-actuators stm32f767zi_lyra_gs)
-
add_executable(lyra-gs-entry
src/Groundstation/LyraGS/lyra-gs-entry.cpp
${LYRA_GS} ${GROUNDSTATION_COMMON}
diff --git a/src/Groundstation/Automated/Hub.cpp b/src/Groundstation/Automated/Hub.cpp
index c1917662e..523568364 100644
--- a/src/Groundstation/Automated/Hub.cpp
+++ b/src/Groundstation/Automated/Hub.cpp
@@ -357,7 +357,11 @@ bool Hub::getLastRocketNasState(Boardcore::NASState& nasState)
return rocketNasSet;
}
-bool Hub::hasNewNasState() { return hasNewNasSet; }
+bool Hub::hasNewNasState()
+{
+ Lock<FastMutex> lock(nasStateMutex);
+ return hasNewNasSet;
+}
void Hub::setRocketNasState(const NASState& newRocketNasState)
{
@@ -371,4 +375,5 @@ void Hub::setRocketOrigin(const GPSData& newRocketCoordinates)
{
Lock<FastMutex> lock(coordinatesMutex);
lastRocketCoordinates = newRocketCoordinates;
+ originReceived = true;
}
diff --git a/src/Groundstation/Automated/SMA/SMA.cpp b/src/Groundstation/Automated/SMA/SMA.cpp
index cbf1c5461..3470e27db 100644
--- a/src/Groundstation/Automated/SMA/SMA.cpp
+++ b/src/Groundstation/Automated/SMA/SMA.cpp
@@ -94,7 +94,8 @@ void SMA::setRocketNASOrigin(const Boardcore::GPSData& rocketCoordinates)
ActuationStatus SMA::moveStepperDeg(StepperList stepperId, float angle)
{
- if (!testState(&SMA::state_test) && !testState(&SMA::state_test_nf))
+ if (!testState(&SMA::state_test) && !testState(&SMA::state_test_nf) &&
+ !testState(&SMA::state_calibrate))
{
LOG_ERR(logger, "Stepper can only be manually moved in the TEST state");
return ActuationStatus::NOT_TEST;
@@ -199,6 +200,7 @@ void SMA::update()
}
break;
}
+ // TODO: See if semantically what we want
// in fix_rocket state, wait for the GPS fix of the rocket
case SMAState::FIX_ROCKET:
case SMAState::FIX_ROCKET_NF:
@@ -223,8 +225,8 @@ void SMA::update()
// retrieve the last NAS Rocket state
NASState nasState;
+ // In case there is a new NAS packet
if (hub->hasNewNasState() && hub->getLastRocketNasState(nasState))
-
// update the propagator with the NAS state
// and retrieve the propagated state
propagator.setRocketNasState(nasState);
--
GitLab