Smoothing-classes: initialize to parameters

This commit is contained in:
Dennis Mannhart
2018-07-20 09:26:18 +02:00
committed by Lorenz Meier
parent 5ef2a61be5
commit 7d7a2dffbf
4 changed files with 10 additions and 13 deletions
@@ -41,19 +41,15 @@
#include <float.h> #include <float.h>
ManualSmoothingXY::ManualSmoothingXY(ModuleParams *parent, const matrix::Vector2f &vel) : ManualSmoothingXY::ManualSmoothingXY(ModuleParams *parent, const matrix::Vector2f &vel) :
ModuleParams(parent), ModuleParams(parent), _acc_state_dependent(_acc_xy_max.get()), _jerk_state_dependent(_jerk_max.get()), _vel_sp_prev(vel)
_vel_sp_prev(vel) {}
{
}
void void
ManualSmoothingXY::smoothVelocity(matrix::Vector2f &vel_sp, const matrix::Vector2f &vel, const float &yaw, ManualSmoothingXY::smoothVelocity(matrix::Vector2f &vel_sp, const matrix::Vector2f &vel, const float &yaw,
const float &yawrate_sp, const float dt) const float &yawrate_sp, const float dt)
{ {
_updateAcceleration(vel_sp, vel, yaw, yawrate_sp, dt); _updateAcceleration(vel_sp, vel, yaw, yawrate_sp, dt);
_velocitySlewRate(vel_sp, dt); _velocitySlewRate(vel_sp, dt);
_vel_sp_prev = vel_sp; _vel_sp_prev = vel_sp;
} }
@@ -103,17 +103,17 @@ private:
/* Acceleration that depends on vehicle state /* Acceleration that depends on vehicle state
* _acc_max_down <= _acc_state_dependent <= _acc_max_up * _acc_max_down <= _acc_state_dependent <= _acc_max_up
*/ */
float _acc_state_dependent{0.0f}; float _acc_state_dependent;
float _jerk_state_dependent{0.0f}; float _jerk_state_dependent;
/** /**
* Maximum velocity. * Maximum velocity.
* It is used to deduce user intention. * It is used to deduce user intention.
*/ */
float _vel_max{0.0f}; float _vel_max{10.0f};
/* Previous setpoints */ /* Previous setpoints */
matrix::Vector2f _vel_sp_prev{}; // previous velocity setpoint matrix::Vector2f _vel_sp_prev; // previous velocity setpoint
DEFINE_PARAMETERS( DEFINE_PARAMETERS(
(ParamFloat<px4::params::MPC_ACC_HOR_MAX>) _acc_hover, ///< acceleration in hover (ParamFloat<px4::params::MPC_ACC_HOR_MAX>) _acc_hover, ///< acceleration in hover
@@ -42,7 +42,8 @@
ManualSmoothingZ::ManualSmoothingZ(ModuleParams *parent, const float &vel, const float &stick) : ManualSmoothingZ::ManualSmoothingZ(ModuleParams *parent, const float &vel, const float &stick) :
ModuleParams(parent), ModuleParams(parent),
_vel(vel), _stick(stick), _vel_sp_prev(vel) _vel(vel), _stick(stick), _acc_state_dependent(_acc_max_up.get()), _max_acceleration(_acc_max_up.get()),
_vel_sp_prev(vel)
{ {
} }
@@ -92,9 +92,9 @@ private:
/* Acceleration that depends on vehicle state /* Acceleration that depends on vehicle state
* _acc_max_down <= _acc_state_dependent <= _acc_max_up * _acc_max_down <= _acc_state_dependent <= _acc_max_up
*/ */
float _acc_state_dependent{0.0f}; float _acc_state_dependent;
float _max_acceleration; // can be up or down maximum accleration
float _vel_sp_prev; float _vel_sp_prev;
float _max_acceleration{0.f};
DEFINE_PARAMETERS( DEFINE_PARAMETERS(
(ParamFloat<px4::params::MPC_ACC_UP_MAX>) _acc_max_up, (ParamFloat<px4::params::MPC_ACC_UP_MAX>) _acc_max_up,