From 938a57dd854c184031dec2728088833896c1696b Mon Sep 17 00:00:00 2001
From: Federico Lolli <federico.lolli@skywarder.eu>
Date: Sat, 11 May 2024 00:47:06 +0200
Subject: [PATCH] [ARP] Integrate Follower and Propagator in ACTIVE state Now
 update the Propagator with NAS state stored by Hub and set as the Follower
 NAS target the predicted one of the Propagator.

---
 .../Automated/SMController/SMController.cpp    | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/boards/Groundstation/Automated/SMController/SMController.cpp b/src/boards/Groundstation/Automated/SMController/SMController.cpp
index be192bb19..8de5dec26 100644
--- a/src/boards/Groundstation/Automated/SMController/SMController.cpp
+++ b/src/boards/Groundstation/Automated/SMController/SMController.cpp
@@ -174,6 +174,24 @@ void SMController::update()
             }
             break;
         }
+        // in active state, update the follower and propagator inner states
+        case SMControllerState::ACTIVE:
+        case SMControllerState::ACTIVE_NF:
+        {
+            // retrieve the last NAS Rocket state
+            Hub* hub =
+                static_cast<Hub*>(ModuleManager::getInstance().get<HubBase>());
+            NASState nasState = hub->getRocketNasState();
+
+            // update the propagator with the NAS state
+            // and retrieve the propagated state
+            propagator.setRocketNasState(nasState);
+            PropagatorState predicted = propagator.getState();
+
+            // update the follower with the propagated state
+            follower.setLastRocketNasState(predicted.getNasState());
+            break;
+        }
     }
 }
 
-- 
GitLab