FlightTaskSport: scale maximal stick input to maximal allowed velocity instead of being hardcoded for testing

This commit is contained in:
Matthias Grob
2017-12-18 06:40:50 +01:00
committed by Beat Küng
parent 6c0acf8e13
commit 37e0f91c39
3 changed files with 13 additions and 6 deletions
@@ -48,12 +48,12 @@ using namespace matrix;
FlightTaskManual::FlightTaskManual(control::SuperBlock *parent, const char *name) :
FlightTask(parent, name),
_z_vel_max_up(parent, "MPC_Z_VEL_MAX_UP", false),
_z_vel_max_down(parent, "MPC_Z_VEL_MAX_DN", false),
_xy_vel_man_expo(parent, "MPC_XY_MAN_EXPO", false),
_z_vel_man_expo(parent, "MPC_Z_MAN_EXPO", false),
_hold_dz(parent, "MPC_HOLD_DZ", false),
_velocity_hor_manual(parent, "MPC_VEL_MANUAL", false),
_z_vel_max_up(parent, "MPC_Z_VEL_MAX_UP", false),
_z_vel_max_down(parent, "MPC_Z_VEL_MAX_DN", false),
_hold_max_xy(parent, "MPC_HOLD_MAX_XY", false),
_hold_max_z(parent, "MPC_HOLD_MAX_Z", false),
_man_yaw_max(parent, "MPC_MAN_Y_MAX", false)
@@ -70,6 +70,9 @@ protected:
float _get_input_frame_yaw() { return _yaw; }
virtual void _scaleVelocity(matrix::Vector3f &velocity);
control::BlockParamFloat _z_vel_max_up; /**< maximal vertical velocity when flying upwards with the stick */
control::BlockParamFloat _z_vel_max_down; /**< maximal vertical velocity when flying downwards with the stick */
private:
uORB::Subscription<manual_control_setpoint_s> *_sub_manual_control_setpoint{nullptr};
@@ -77,8 +80,6 @@ private:
control::BlockParamFloat _z_vel_man_expo; /**< ratio of exponential curve for stick input in xy direction pos mode */
control::BlockParamFloat _hold_dz; /**< deadzone around the center for the sticks when flying in position mode */
control::BlockParamFloat _velocity_hor_manual; /**< target velocity in manual controlled mode at full speed */
control::BlockParamFloat _z_vel_max_up; /**< maximal vertical velocity when flying upwards with the stick */
control::BlockParamFloat _z_vel_max_down; /**< maximal vertical velocity when flying downwards with the stick */
control::BlockParamFloat _hold_max_xy; /**< velocity threshold to switch into horizontal position hold */
control::BlockParamFloat _hold_max_z; /**< velocity threshold to switch into vertical position hold */
control::BlockParamFloat _man_yaw_max; /**< maximal rotation speed around yaw axis with full stick input */
@@ -47,7 +47,8 @@ class FlightTaskSport : public FlightTaskManual
{
public:
FlightTaskSport(control::SuperBlock *parent, const char *name) :
FlightTaskManual(parent, name)
FlightTaskManual(parent, name),
_velocity_hor_max(parent, "MPC_XY_VEL_MAX", false)
{ }
virtual ~FlightTaskSport() = default;
@@ -55,8 +56,13 @@ public:
protected:
void _scaleVelocity(matrix::Vector3f &velocity) override
{
const matrix::Vector3f velocity_scale(20.f, 20.f, 5.f);
const matrix::Vector3f velocity_scale(_velocity_hor_max.get(),
_velocity_hor_max.get(),
(velocity(2) > 0.0f) ? _z_vel_max_down.get() : _z_vel_max_up.get());
velocity = velocity.emult(velocity_scale);
}
private:
control::BlockParamFloat _velocity_hor_max; /**< maximal allowed horizontal speed, in sport mode full stick input*/
};