Skip to content

Commit

Permalink
RpmControl: Better consider the case where there's no rpm measurement…
Browse files Browse the repository at this point in the history
… (anymore)
  • Loading branch information
MaEtUgR committed Dec 19, 2024
1 parent 214d710 commit 0a016df
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions msg/Rpm.msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
uint64 timestamp # time since system start (microseconds)

# rpm values of 0.0 mean within a timeout there is no movement measured
float32 rpm_estimate # filtered revolutions per minute
float32 rpm_raw
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ float RpmControl::getActuatorCorrection()
const float gain_scale = math::interpolate(_spoolup_progress, .8f, 1.f, 0.f, 1e-3f);
_pid.setGains(_param_ca_heli_rpm_p.get() * gain_scale, _param_ca_heli_rpm_i.get() * gain_scale, 0.f);
_actuator_correction = _pid.update(rpm.rpm_estimate, dt, true);

_rpm_invalid = rpm.rpm_estimate < 1.f;
}
}

// Timeout
if (now > _timestamp_last_measurement + 1_s) {
const bool timeout = now > _timestamp_last_measurement + 1_s;

if (_rpm_invalid || timeout) {
_pid.resetIntegral();
_actuator_correction = 0.f;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class RpmControl : public ModuleParams
static constexpr float PID_OUTPUT_LIMIT = .5f; // [0,1]

uORB::Subscription _rpm_sub{ORB_ID(rpm)};
bool _rpm_invalid{true};
PID _pid;
float _spoolup_progress{0.f}; // [0,1]
hrt_abstime _timestamp_last_measurement{0}; // for dt and timeout
Expand Down

0 comments on commit 0a016df

Please sign in to comment.