diff --git a/src/shared/algorithms/Follower/Follower.cpp b/src/shared/algorithms/Follower/Follower.cpp index 6c9e71d281e415f2a7d637c283c303e12d7561c1..bc5b45f8ed2fba457d47079d8f7f2667619edd65 100644 --- a/src/shared/algorithms/Follower/Follower.cpp +++ b/src/shared/algorithms/Follower/Follower.cpp @@ -50,9 +50,8 @@ float minimizeRotation(float angle) return angle; } -Follower::Follower(std::chrono::milliseconds updatePeriod) - : updatePeriod(static_cast<float>(updatePeriod.count()) / 1000), - targetAngles({0, 0, 0}) +Follower::Follower(std::chrono::milliseconds updPeriod) + : updatePeriod{updPeriod}, targetAngles({0, 0, 0}) { } @@ -168,9 +167,13 @@ void Follower::step() // Calculate angular velocity for moving the antennas toward position float horizontalSpeed = - std::abs((diffAngles.yaw * 1000) / (360 * updatePeriod)); + std::abs((diffAngles.yaw) / + (360 * (static_cast<float>(updatePeriod.count()) / 1000))); + TRACE("[Follower] horizontalSpeed is: %f\n", horizontalSpeed); float verticalSpeed = - std::abs((diffAngles.pitch * 1000) / (360 * updatePeriod)); + std::abs((diffAngles.pitch) / + (360 * (static_cast<float>(updatePeriod.count()) / 1000))); + TRACE("[Follower] Vertical speed is: %f\n", horizontalSpeed); // Update the state of the follower FollowerState newState; diff --git a/src/shared/algorithms/Follower/Follower.h b/src/shared/algorithms/Follower/Follower.h index 3a6fcda47b1208489d65e8c3429fb69f4a1c828b..850a63f90e8e1793d8c889d93aa07cf1c0813616 100644 --- a/src/shared/algorithms/Follower/Follower.h +++ b/src/shared/algorithms/Follower/Follower.h @@ -144,8 +144,8 @@ private: */ Eigen::Vector3f getRocketNASOrigin(); - // actuation update period [s] - float updatePeriod; + // actuation update period [ms] + std::chrono::milliseconds updatePeriod; // Initialization flag std::atomic<bool> isInit{false};