Browse Source

FlightTaskManualStabilized: update comments

sbg
Dennis Mannhart 7 years ago committed by Beat Küng
parent
commit
8bafdba4f9
  1. 16
      src/lib/FlightTasks/tasks/FlightTaskManualStabilized.cpp
  2. 7
      src/lib/FlightTasks/tasks/FlightTaskManualStabilized.hpp

16
src/lib/FlightTasks/tasks/FlightTaskManualStabilized.cpp

@ -61,8 +61,7 @@ bool FlightTaskManualStabilized::activate() @@ -61,8 +61,7 @@ bool FlightTaskManualStabilized::activate()
void FlightTaskManualStabilized::_scaleSticks()
{
/* Scale sticks to yaw and thrust using
* linear scale for yaw and quadratic for thrust.
* TODO: add thrust */
* linear scale for yaw and piecewise linear map for thrust. */
_yaw_rate_sp = _sticks(3) * math::radians(_yaw_rate_scaling.get());
_throttle = _throttleCurve();;
}
@ -84,13 +83,18 @@ void FlightTaskManualStabilized::_updateHeadingSetpoints() @@ -84,13 +83,18 @@ void FlightTaskManualStabilized::_updateHeadingSetpoints()
void FlightTaskManualStabilized::_updateThrustSetpoints()
{
/* Body frame */
/* Rotate setpoint into local frame. */
matrix::Vector3f sp{_sticks(0), _sticks(1), 0.0f};
sp = (matrix::Dcmf(matrix::Eulerf(0.0f, 0.0f, _yaw)) * sp);
const float x = sp(0) * math::radians(_tilt_max_man.get());
const float y = sp(1) * math::radians(_tilt_max_man.get());
/* The norm of the xy stick input provides the pointing
* direction of the horizontal desired thrust setpoint. The magnitude of the
* xy stick inputs represents the desired tilt. Both tilt and magnitude can
* be captured through Axis-Angle.
*/
/* The Axis-Angle is the perpendicular vector to xy-stick input */
matrix::Vector2f v = matrix::Vector2f(y, -x);
float v_norm = v.norm(); // the norm of v defines the tilt angle
@ -98,6 +102,9 @@ void FlightTaskManualStabilized::_updateThrustSetpoints() @@ -98,6 +102,9 @@ void FlightTaskManualStabilized::_updateThrustSetpoints()
v *= _tilt_max_man.get() / v_norm;
}
/* The final thrust setpoint is found by rotating the scaled unit vector pointing
* upward by the Axis-Angle.
*/
matrix::Quatf q_sp = matrix::AxisAnglef(v(0), v(1), 0.0f);
_thr_sp = q_sp.conjugate(matrix::Vector3f(0.0f, 0.0f, -1.0f)) * _throttle;
}
@ -108,10 +115,9 @@ void FlightTaskManualStabilized::_updateSetpoints() @@ -108,10 +115,9 @@ void FlightTaskManualStabilized::_updateSetpoints()
_updateThrustSetpoints();
}
/* TODO: add quadratic funciton */
float FlightTaskManualStabilized::_throttleCurve()
{
/* Scale stick z from [-1,1] to [min thr, max thr]
/* Scale stick z from [-1,1] to [min thrust, max thrust]
* with hover throttle at 0.5 stick */
float throttle = -((_sticks_expo(2) - 1.0f) * 0.5f);

7
src/lib/FlightTasks/tasks/FlightTaskManualStabilized.hpp

@ -36,7 +36,6 @@ @@ -36,7 +36,6 @@
*
* Flight task for manual controlled attitude.
* It generates thrust and yaw setpoints.
* TODO: add thrust
*/
#pragma once
@ -64,15 +63,15 @@ protected: @@ -64,15 +63,15 @@ protected:
private:
float _throttle{};
float _throttle{}; /** Mapped from stick z. */
void _updateHeadingSetpoints(); /**< Sets yaw or yaw speed. */
void _updateThrustSetpoints(); /**< Sets thrust setpoint */
float _throttleCurve(); /**< piecewise linear mapping for throttle */
float _throttleCurve(); /**< Piecewise linear mapping from stick to throttle. */
control::BlockParamFloat _yaw_rate_scaling; /**< Scaling factor from stick to yaw rate. */
control::BlockParamFloat _tilt_max_man; /**< Maximum tilt allowed for manual flight */
control::BlockParamFloat _throttle_min; /**< Minimum throttle that always has to be satisfied in flight*/
control::BlockParamFloat _throttle_max; /**< Maximum throttle that always has to be satisfied in flight*/
control::BlockParamFloat _throttle_hover; /**< Throttel value at which vehicle is at hover equilibrium */
control::BlockParamFloat _throttle_hover; /**< Throttle value at which vehicle is at hover equilibrium */
};

Loading…
Cancel
Save