mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 07:33:34 +08:00
FlightTaskManualStabilized: update comments
This commit is contained in:
committed by
Beat Küng
parent
85a263c7bd
commit
8bafdba4f9
@@ -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()
|
||||
|
||||
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()
|
||||
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()
|
||||
_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);
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
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 */
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user