forked from Archive/PX4-Autopilot
consistent and safer fix for dt calculation
This commit is contained in:
parent
8f74aab468
commit
ccc6dd73a0
|
@ -116,7 +116,7 @@ float ECL_PitchController::control_bodyrate(float roll, float pitch,
|
||||||
/* get the usual dt estimate */
|
/* get the usual dt estimate */
|
||||||
uint64_t dt_micros = ecl_elapsed_time(&_last_run);
|
uint64_t dt_micros = ecl_elapsed_time(&_last_run);
|
||||||
_last_run = ecl_absolute_time();
|
_last_run = ecl_absolute_time();
|
||||||
float dt = (dt_micros > 500000) ? 0.0f : (float)dt_micros * 1e-6f;
|
float dt = (float)dt_micros * 1e-6f;
|
||||||
|
|
||||||
/* lock integral for long intervals */
|
/* lock integral for long intervals */
|
||||||
if (dt_micros > 500000)
|
if (dt_micros > 500000)
|
||||||
|
|
|
@ -86,7 +86,11 @@ float ECL_RollController::control_bodyrate(float pitch,
|
||||||
/* get the usual dt estimate */
|
/* get the usual dt estimate */
|
||||||
uint64_t dt_micros = ecl_elapsed_time(&_last_run);
|
uint64_t dt_micros = ecl_elapsed_time(&_last_run);
|
||||||
_last_run = ecl_absolute_time();
|
_last_run = ecl_absolute_time();
|
||||||
float dt = (dt_micros > 500000) ? 0.0f : (float)dt_micros * 1e-6f;
|
float dt = (float)dt_micros * 1e-6f;
|
||||||
|
|
||||||
|
/* lock integral for long intervals */
|
||||||
|
if (dt_micros > 500000)
|
||||||
|
lock_integrator = true;
|
||||||
|
|
||||||
float k_ff = math::max((_k_p - _k_i * _tc) * _tc - _k_d, 0.0f);
|
float k_ff = math::max((_k_p - _k_i * _tc) * _tc - _k_d, 0.0f);
|
||||||
float k_i_rate = _k_i * _tc;
|
float k_i_rate = _k_i * _tc;
|
||||||
|
|
|
@ -99,7 +99,12 @@ float ECL_YawController::control_bodyrate(float roll, float pitch,
|
||||||
/* get the usual dt estimate */
|
/* get the usual dt estimate */
|
||||||
uint64_t dt_micros = ecl_elapsed_time(&_last_run);
|
uint64_t dt_micros = ecl_elapsed_time(&_last_run);
|
||||||
_last_run = ecl_absolute_time();
|
_last_run = ecl_absolute_time();
|
||||||
float dt = (dt_micros > 500000) ? 0.0f : (float)dt_micros * 1e-6f;
|
float dt = (float)dt_micros * 1e-6f;
|
||||||
|
|
||||||
|
/* lock integral for long intervals */
|
||||||
|
if (dt_micros > 500000)
|
||||||
|
lock_integrator = true;
|
||||||
|
|
||||||
|
|
||||||
float k_ff = math::max((_k_p - _k_i * _tc) * _tc - _k_d, 0.0f);
|
float k_ff = math::max((_k_p - _k_i * _tc) * _tc - _k_d, 0.0f);
|
||||||
float k_i_rate = _k_i * _tc;
|
float k_i_rate = _k_i * _tc;
|
||||||
|
|
Loading…
Reference in New Issue