AC_WPNav: add shift_loiter_target method

Shift the loiter target and freeze the feedforward if necessary
This commit is contained in:
Randy Mackay 2015-02-16 19:44:04 +09:00
parent 8e6bb3164c
commit 7706102d1e
2 changed files with 22 additions and 0 deletions

View File

@ -166,6 +166,21 @@ void AC_WPNav::init_loiter_target(const Vector3f& position, bool reset_I)
_pilot_accel_rgt_cms = 0;
}
/// shift_loiter_target - shifts the loiter target by the given pos_adjustment
/// used by precision landing to adjust horizontal position target
void AC_WPNav::shift_loiter_target(const Vector3f &pos_adjustment)
{
Vector3f new_target = _pos_control.get_pos_target() + pos_adjustment;
// move pos controller target
_pos_control.set_xy_target(new_target.x, new_target.y);
// disable feed forward
if (fabsf(pos_adjustment.x) > 0.0f || fabsf(pos_adjustment.y) > 0.0f) {
_pos_control.freeze_ff_xy();
}
}
/// init_loiter_target - initialize's loiter position and feed-forward velocity from current pos and velocity
void AC_WPNav::init_loiter_target()
{

View File

@ -64,6 +64,10 @@ public:
/// init_loiter_target - initialize's loiter position and feed-forward velocity from current pos and velocity
void init_loiter_target();
/// shift_loiter_target - shifts the loiter target by the given pos_adjustment
/// used by precision landing to adjust horizontal position target
void shift_loiter_target(const Vector3f &pos_adjustment);
/// loiter_soften_for_landing - reduce response for landing
void loiter_soften_for_landing();
@ -85,6 +89,9 @@ public:
/// get_loiter_bearing_to_target - get bearing to loiter target in centi-degrees
int32_t get_loiter_bearing_to_target() const;
/// get_loiter_target - returns loiter target position
const Vector3f& get_loiter_target() const { return _pos_control.get_pos_target(); }
/// update_loiter - run the loiter controller - should be called at 10hz
void update_loiter(float ekfGndSpdLimit, float ekfNavVelGainScaler);