From 8266a4df98ee4634012e94a60693e96308dccaef Mon Sep 17 00:00:00 2001 From: Junwoo Hwang Date: Thu, 10 Mar 2022 17:08:47 +0100 Subject: [PATCH] Sticks : Add utility functions to get pitch, roll, throttle and yaw values intuitively and rename ambiguously named function checkAndSetStickInputs() --- .../flight_mode_manager/tasks/Utility/Sticks.cpp | 2 +- .../flight_mode_manager/tasks/Utility/Sticks.hpp | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/modules/flight_mode_manager/tasks/Utility/Sticks.cpp b/src/modules/flight_mode_manager/tasks/Utility/Sticks.cpp index a3890968b6..f0104a7612 100644 --- a/src/modules/flight_mode_manager/tasks/Utility/Sticks.cpp +++ b/src/modules/flight_mode_manager/tasks/Utility/Sticks.cpp @@ -44,7 +44,7 @@ Sticks::Sticks(ModuleParams *parent) : ModuleParams(parent) {} -bool Sticks::checkAndSetStickInputs() +bool Sticks::checkAndUpdateStickInputs() { // Sticks are rescaled linearly and exponentially to [-1,1] manual_control_setpoint_s manual_control_setpoint; diff --git a/src/modules/flight_mode_manager/tasks/Utility/Sticks.hpp b/src/modules/flight_mode_manager/tasks/Utility/Sticks.hpp index dae247f97c..00246807d2 100644 --- a/src/modules/flight_mode_manager/tasks/Utility/Sticks.hpp +++ b/src/modules/flight_mode_manager/tasks/Utility/Sticks.hpp @@ -53,11 +53,20 @@ public: Sticks(ModuleParams *parent); ~Sticks() = default; - bool checkAndSetStickInputs(); + // Checks for updated manual control input & updates internal values + bool checkAndUpdateStickInputs(); + bool isAvailable() { return _input_available; }; + + // Position : 0 : pitch, 1 : roll, 2 : throttle, 3 : yaw const matrix::Vector &getPosition() { return _positions; }; const matrix::Vector &getPositionExpo() { return _positions_expo; }; + // Helper functions to get stick values more intuitively + float getPitch() { return _positions(0); } + float getRoll() { return _positions(1); } + float getThrottle() { return _positions(2); } + float getYaw() { return _positions(3); } /** * Limit the the horizontal input from a square shaped joystick gimbal to a unit circle