fix sensorless estimator error

This commit is contained in:
Samuel Sadok
2020-12-07 12:21:45 +01:00
parent 049ac24218
commit 8c695fa834
@@ -36,6 +36,11 @@ bool SensorlessEstimator::update() {
// TODO: we read values here which are modified by a higher priority interrupt.
// This is not thread-safe.
auto current_meas = axis_->motor_.current_meas_;
if (!axis_->motor_.is_armed_) {
// While the motor is disarmed the current is not measurable so we
// assume that it's zero.
current_meas = {0.0f, 0.0f};
}
if (!current_meas.has_value()) {
error_ |= ERROR_UNKNOWN_CURRENT_MEASUREMENT;
reset(); // Reset state for when the next valid current measurement comes in.