From d7fe2ad3f5b1038f78d6b62fa56c669b58fd41ef Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 4 Sep 2015 14:59:35 +0200 Subject: [PATCH] Joystick: Add mapping from circle to line for each axis to allow arming --- src/Joystick/Joystick.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Joystick/Joystick.cc b/src/Joystick/Joystick.cc index 2dd4b028f..57aec6d62 100644 --- a/src/Joystick/Joystick.cc +++ b/src/Joystick/Joystick.cc @@ -285,10 +285,11 @@ void Joystick::run(void) axis = _rgFunctionAxis[throttleFunction]; float throttle = _adjustRange(_rgAxisValues[axis], _rgCalibration[axis]); - roll = std::max(-1.0f, std::min(roll, 1.0f)); - pitch = std::max(-1.0f, std::min(pitch, 1.0f)); - yaw = std::max(-1.0f, std::min(yaw, 1.0f)); - throttle = std::max(-1.0f, std::min(throttle, 1.0f)); + // Map from unit circle to linear range and limit + roll = std::max(-1.0f, std::min(tanf(asinf(roll)), 1.0f)); + pitch = std::max(-1.0f, std::min(tanf(asinf(pitch)), 1.0f)); + yaw = std::max(-1.0f, std::min(tanf(asinf(yaw)), 1.0f)); + throttle = std::max(-1.0f, std::min(tanf(asinf(throttle)), 1.0f)); // Adjust throttle to 0:1 range if (_throttleMode == ThrottleModeCenterZero) { -- 2.22.0