We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 32feff2 + e1e6612 commit 3c9371eCopy full SHA for 3c9371e
src/lib/motors/SmartServo.cpp
@@ -235,7 +235,18 @@ float SmartServoClass::getPosition(uint8_t const id)
235
return -1.0f;
236
237
mbed::ScopedLock<rtos::Mutex> lock(_mtx);
238
- return positionToAngle(readWordCmd(id, REG(SmartServoRegister::POSITION_H)));
+ int position = readWordCmd(id, REG(SmartServoRegister::POSITION_H));
239
+
240
+ // retry one more time
241
+ if (position < 0) {
242
+ delay(1);
243
+ position = readWordCmd(id, REG(SmartServoRegister::POSITION_H));
244
+ }
245
246
+ if (position < 0)
247
+ return -1.0f;
248
249
+ return positionToAngle(position);
250
}
251
252
void SmartServoClass::center(uint8_t const id, uint16_t const position)
0 commit comments