PX4 Firmware
PX4 Autopilot Software http://px4.io
|
#include <ManualSmoothingXY.hpp>
Public Types | |
enum | Intention { Intention::brake, Intention::acceleration, Intention::deceleration, Intention::direction_change } |
Public Member Functions | |
ManualSmoothingXY (ModuleParams *parent, const matrix::Vector2f &vel) | |
~ManualSmoothingXY ()=default | |
void | updateMaxVelocity (const float &vel_max) |
Maximum velocity is required to detect user intention. More... | |
void | smoothVelocity (matrix::Vector2f &vel_sp, const matrix::Vector2f &vel, const float &yaw, const float &yawrate_sp, const float dt) |
Smoothing of velocity setpoint horizontally based on flight direction. More... | |
Intention | getIntention () |
Get user intention. More... | |
void | overwriteHoverAcceleration (float acc) |
Overwrite methods: Needed if different parameter values than default required. More... | |
void | overwriteMaxAcceleration (float acc) |
void | overwriteDecelerationMin (float dec) |
void | overwriteJerkMax (float jerk) |
void | overwriteJerkMin (float jerk) |
Private Member Functions | |
void | _updateAcceleration (matrix::Vector2f &vel_sp, const matrix::Vector2f &vel, const float &yaw, const float &yawrate_sp, const float dt) |
Sets velocity change limits (=acceleration). More... | |
Intention | _getIntention (const matrix::Vector2f &vel_sp, const matrix::Vector2f &vel, const float &yaw, const float &yawrate_sp) |
Gets user intention. More... | |
void | _setStateAcceleration (const matrix::Vector2f &vel_sp, const matrix::Vector2f &vel, const Intention &intention, const float dt) |
Set acceleration depending on Intention. More... | |
void | _velocitySlewRate (matrix::Vector2f &vel_sp, const float dt) |
Limits the velocity setpoint change. More... | |
matrix::Vector2f | _getWorldToHeadingFrame (const matrix::Vector2f &vec, const float &yaw) |
Rotate vector from local frame into heading frame. More... | |
matrix::Vector2f | _getHeadingToWorldFrame (const matrix::Vector2f &vec, const float &yaw) |
Rotate vector from heading frame to local frame. More... | |
Private Attributes | |
Intention | _intention {Intention::acceleration} |
user intention More... | |
float | _acc_state_dependent |
velocity change limit that depends on Intention More... | |
float | _jerk_state_dependent |
acceleration change limit during brake More... | |
float | _vel_max {10.0f} |
maximum horizontal speed allowed More... | |
matrix::Vector2f | _vel_sp_prev |
previous velocity setpoint More... | |
Definition at line 53 of file ManualSmoothingXY.hpp.
|
strong |
Enumerator | |
---|---|
brake | |
acceleration | |
deceleration | |
direction_change |
Definition at line 84 of file ManualSmoothingXY.hpp.
ManualSmoothingXY::ManualSmoothingXY | ( | ModuleParams * | parent, |
const matrix::Vector2f & | vel | ||
) |
Definition at line 45 of file ManualSmoothingXY.cpp.
References _acc_state_dependent, and _jerk_state_dependent.
|
default |
|
private |
Rotate vector from heading frame to local frame.
vec | is an arbitrary vector in heading frame |
yaw | is the vehicle yaw |
Definition at line 222 of file ManualSmoothingXY.cpp.
References matrix::Quaternion< Type >::conjugate(), and f().
Referenced by overwriteJerkMin().
|
private |
Gets user intention.
The intention is deduced from desired velocity setpoint.
vel_sp | is desired velocity setpoint before slewrate. |
vel | is vehicle velocity in xy-direction. |
yaw | is vehicle yaw |
yawrate_sp | is the desired yaw-speed |
Definition at line 74 of file ManualSmoothingXY.cpp.
References _getWorldToHeadingFrame(), _vel_max, _vel_sp_prev, acceleration, brake, deceleration, direction_change, f(), FLT_EPSILON, matrix::Vector< Type, M >::length(), and matrix::Vector< Type, M >::normalize().
Referenced by _updateAcceleration(), and overwriteJerkMin().
|
private |
Rotate vector from local frame into heading frame.
vec | is an arbitrary vector in local frame |
yaw | is the vehicle heading |
Definition at line 214 of file ManualSmoothingXY.cpp.
References matrix::Quaternion< Type >::conjugate_inversed(), and f().
Referenced by _getIntention(), and overwriteJerkMin().
|
private |
Set acceleration depending on Intention.
vel_sp | is desired velocity septoint in xy-direction |
vel | is vehicle velociy in xy-direction |
intention | is the user intention during flight |
dt | is delta-time |
Definition at line 122 of file ManualSmoothingXY.cpp.
References _acc_state_dependent, _intention, _jerk_state_dependent, _vel_max, _vel_sp_prev, acceleration, brake, deceleration, direction_change, FLT_EPSILON, matrix::Vector< Type, M >::length(), and math::min().
Referenced by _updateAcceleration(), and overwriteJerkMin().
|
private |
Sets velocity change limits (=acceleration).
Depending on the user intention, the acceleration differs.
vel_sp | is desired velocity setpoint before slewrate. |
vel | is current velocity in horizontal direction |
yaw | is vehicle yaw |
yawrate_sp | is desired yawspeed |
dt | is delta-time |
Definition at line 63 of file ManualSmoothingXY.cpp.
References _getIntention(), and _setStateAcceleration().
Referenced by overwriteJerkMin(), and smoothVelocity().
|
private |
Limits the velocity setpoint change.
vel_sp | that gets limited based on acceleration and previous velocity setpoint |
dt | is delta-time |
Definition at line 199 of file ManualSmoothingXY.cpp.
References _acc_state_dependent, _vel_sp_prev, FLT_EPSILON, and matrix::Vector< Type, M >::normalized().
Referenced by overwriteJerkMin(), and smoothVelocity().
|
inline |
Get user intention.
Definition at line 94 of file ManualSmoothingXY.hpp.
References _intention.
|
inline |
Definition at line 102 of file ManualSmoothingXY.hpp.
|
inline |
Overwrite methods: Needed if different parameter values than default required.
Definition at line 100 of file ManualSmoothingXY.hpp.
|
inline |
Definition at line 103 of file ManualSmoothingXY.hpp.
|
inline |
Definition at line 104 of file ManualSmoothingXY.hpp.
References _getHeadingToWorldFrame(), _getIntention(), _getWorldToHeadingFrame(), _setStateAcceleration(), _updateAcceleration(), and _velocitySlewRate().
|
inline |
Definition at line 101 of file ManualSmoothingXY.hpp.
void ManualSmoothingXY::smoothVelocity | ( | matrix::Vector2f & | vel_sp, |
const matrix::Vector2f & | vel, | ||
const float & | yaw, | ||
const float & | yawrate_sp, | ||
const float | dt | ||
) |
Smoothing of velocity setpoint horizontally based on flight direction.
vel_sp | velocity setpoint in xy |
dt | time delta in seconds |
Definition at line 54 of file ManualSmoothingXY.cpp.
References _updateAcceleration(), _vel_sp_prev, and _velocitySlewRate().
Referenced by FlightTaskManualPositionSmooth::_updateSetpoints(), and updateMaxVelocity().
|
inline |
Maximum velocity is required to detect user intention.
Maximum velocity depends on flight-task. In order to deduce user intention from velocity, the maximum allowed velocity has to be updated.
vel_max | corresponds to vehicle constraint |
Definition at line 66 of file ManualSmoothingXY.hpp.
References _vel_max, dt, and smoothVelocity().
Referenced by FlightTaskManualPositionSmooth::_updateSetpoints().
|
private |
velocity change limit that depends on Intention
Definition at line 162 of file ManualSmoothingXY.hpp.
Referenced by _setStateAcceleration(), _velocitySlewRate(), and ManualSmoothingXY().
|
private |
user intention
Definition at line 161 of file ManualSmoothingXY.hpp.
Referenced by _setStateAcceleration(), and getIntention().
|
private |
acceleration change limit during brake
Definition at line 163 of file ManualSmoothingXY.hpp.
Referenced by _setStateAcceleration(), and ManualSmoothingXY().
|
private |
maximum horizontal speed allowed
Definition at line 164 of file ManualSmoothingXY.hpp.
Referenced by _getIntention(), _setStateAcceleration(), and updateMaxVelocity().
|
private |
previous velocity setpoint
Definition at line 165 of file ManualSmoothingXY.hpp.
Referenced by _getIntention(), _setStateAcceleration(), _velocitySlewRate(), and smoothVelocity().