From 5ad02aa5e0850fa14733e3471039a414edadf262 Mon Sep 17 00:00:00 2001
From: Federico Lolli <federico.lolli@skywarder.eu>
Date: Thu, 30 May 2024 22:11:44 +0200
Subject: [PATCH] [ARP] Update algorithm tasks spawned with start

Now all the algorithms are manually stepped inside the update function
and treated as a pipeline.
---
 .../Automated/SMController/SMController.cpp      | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/src/boards/Groundstation/Automated/SMController/SMController.cpp b/src/boards/Groundstation/Automated/SMController/SMController.cpp
index b62045068..d4807967d 100644
--- a/src/boards/Groundstation/Automated/SMController/SMController.cpp
+++ b/src/boards/Groundstation/Automated/SMController/SMController.cpp
@@ -59,22 +59,10 @@ bool SMController::start()
     size_t result;
     bool ok = true;
 
-    // add the Propagator task
-    result = scheduler->addTask(bind(&Propagator::update, &propagator),
-                                PropagatorConfig::PROPAGATOR_PERIOD,
-                                TaskScheduler::Policy::RECOVER);
-    ok &= result != 0;
-
-    // add the Follower task
-    result = scheduler->addTask(bind(&Follower::update, &follower),
-                                FollowerConfig::FOLLOWER_PERIOD,
-                                TaskScheduler::Policy::RECOVER);
-    ok &= result != 0;
-
     // add the update task
     result = scheduler->addTask(bind(&SMController::update, this),
                                 SMControllerConfig::UPDATE_PERIOD,
-                                TaskScheduler::Policy::SKIP);
+                                TaskScheduler::Policy::RECOVER);
     ok &= result != 0;
 
     return ActiveObject::start() && ok;
@@ -218,10 +206,12 @@ void SMController::update()
             // update the propagator with the NAS state
             // and retrieve the propagated state
             propagator.setRocketNasState(nasState);
+            propagator.update();  // step the propagator
             PropagatorState predicted = propagator.getState();
 
             // update the follower with the propagated state
             follower.setLastRocketNasState(predicted.getNasState());
+            follower.update();  // step the follower
             break;
         }
         default:
-- 
GitLab