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

This commit is contained in:
Matthias Grob
2018-04-05 07:30:12 +02:00
committed by Beat Küng
parent 6c0acf8e13
commit 37e0f91c39
3 changed files with 13 additions and 6 deletions
@@ -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*/
};