Skip to content

Commit 004364a

Browse files
committed
RpmControl: Better consider the case where there's no rpm measurement (anymore)
1 parent fed97ad commit 004364a

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

msg/Rpm.msg

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
uint64 timestamp # time since system start (microseconds)
22

3+
# rpm values of 0.0 mean within a timeout there is no movement measured
34
float32 rpm_estimate # filtered revolutions per minute
45
float32 rpm_raw

src/modules/control_allocator/ActuatorEffectiveness/RpmControl.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,15 @@ float RpmControl::getActuatorCorrection()
6868
const float gain_scale = math::interpolate(_spoolup_progress, .8f, 1.f, 0.f, 1e-3f);
6969
_pid.setGains(_param_ca_heli_rpm_p.get() * gain_scale, _param_ca_heli_rpm_i.get() * gain_scale, 0.f);
7070
_actuator_correction = _pid.update(rpm.rpm_estimate, dt, true);
71+
72+
_rpm_invalid = rpm.rpm_estimate < 1.f;
7173
}
7274
}
7375

7476
// Timeout
75-
if (now > _timestamp_last_measurement + 1_s) {
77+
const bool timeout = now > _timestamp_last_measurement + 1_s;
78+
79+
if (_rpm_invalid || timeout) {
7680
_pid.resetIntegral();
7781
_actuator_correction = 0.f;
7882
}

src/modules/control_allocator/ActuatorEffectiveness/RpmControl.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class RpmControl : public ModuleParams
6363
static constexpr float PID_OUTPUT_LIMIT = .5f; // [0,1]
6464

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

0 commit comments

Comments
 (0)