Browse Source

Sticks : Add utility functions to get pitch, roll, throttle and yaw values intuitively and rename ambiguously named function checkAndSetStickInputs()

v1.13.0-BW
Junwoo Hwang 3 years ago committed by Matthias Grob
parent
commit
8266a4df98
  1. 2
      src/modules/flight_mode_manager/tasks/Utility/Sticks.cpp
  2. 11
      src/modules/flight_mode_manager/tasks/Utility/Sticks.hpp

2
src/modules/flight_mode_manager/tasks/Utility/Sticks.cpp

@ -44,7 +44,7 @@ Sticks::Sticks(ModuleParams *parent) : @@ -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;

11
src/modules/flight_mode_manager/tasks/Utility/Sticks.hpp

@ -53,11 +53,20 @@ public: @@ -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<float, 4> &getPosition() { return _positions; };
const matrix::Vector<float, 4> &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

Loading…
Cancel
Save