Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
l1 position controller: make sure that a NAN roll setpoint
Browse files Browse the repository at this point in the history
does not keep the roll setpoint state at NAN forever

Signed-off-by: Roman <[email protected]>
  • Loading branch information
RomanBapst authored and LorenzMeier committed Aug 21, 2018
1 parent 34cd136 commit aa134d5
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions l1/ecl_l1_pos_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,14 @@ void ECL_L1_Pos_Controller::update_roll_setpoint()
float roll_new = atanf(_lateral_accel * 1.0f / CONSTANTS_ONE_G);
roll_new = math::constrain(roll_new, -_roll_lim_rad, _roll_lim_rad);

// no slew rate limiting active
if (_dt <= 0.0f || _roll_slew_rate <= 0.0f) {
_roll_setpoint = roll_new;
return;
if (_dt > 0.0f && _roll_slew_rate > 0.0f) {
// slew rate limiting active
roll_new = math::constrain(roll_new, _roll_setpoint - _roll_slew_rate * _dt, _roll_setpoint + _roll_slew_rate * _dt);
}

// slew rate limiting active
roll_new = math::constrain(roll_new, _roll_setpoint - _roll_slew_rate * _dt, _roll_setpoint + _roll_slew_rate * _dt);

_roll_setpoint = roll_new;
if (ISFINITE(roll_new)) {
_roll_setpoint = roll_new;
}

}

Expand Down

0 comments on commit aa134d5

Please sign in to comment.