Skip to content

Commit fd8b8ea

Browse files
committed
Fix setMinAngle/setMaxAngle by limiting positions rather than angles.
1 parent dea7437 commit fd8b8ea

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

src/Braccio++.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,4 @@ inline void attachInterrupt(pin_size_t interruptNum, mbed::Callback<void()> func
255255
attachInterruptParam(interruptNum, callback, mode, (void*)a);
256256
}
257257

258-
#endif //__BRACCIO_PLUSPLUS_H__
258+
#endif //__BRACCIO_PLUSPLUS_H__

src/lib/motors/SmartServo.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,27 +299,31 @@ void SmartServoClass::setStallProtectionTime(uint8_t const id, uint8_t const ti
299299
mutex.unlock();
300300
}
301301

302-
void SmartServoClass::setMinAngle(float const angle) {
302+
void SmartServoClass::setMinAngle(uint16_t const min_angle)
303+
{
303304
mutex.lock();
304-
writeWordCmd(BROADCAST, REG(SmartServoRegister::MIN_ANGLE_LIMIT_H), angleToPosition(angle));
305+
writeWordCmd(BROADCAST, REG(SmartServoRegister::MIN_ANGLE_LIMIT_H), min_angle);
305306
mutex.unlock();
306307
}
307308

308-
void SmartServoClass::setMinAngle(uint8_t const id, float const angle) {
309+
void SmartServoClass::setMinAngle(uint8_t const id, uint16_t const min_angle)
310+
{
309311
mutex.lock();
310-
writeWordCmd(id, REG(SmartServoRegister::MIN_ANGLE_LIMIT_H), angleToPosition(angle));
312+
writeWordCmd(id, REG(SmartServoRegister::MIN_ANGLE_LIMIT_H), min_angle);
311313
mutex.unlock();
312314
}
313315

314-
void SmartServoClass::setMaxAngle(float const angle) {
316+
void SmartServoClass::setMaxAngle(uint16_t const max_angle)
317+
{
315318
mutex.lock();
316-
writeWordCmd(BROADCAST, REG(SmartServoRegister::MAX_ANGLE_LIMIT_H), angleToPosition(angle));
319+
writeWordCmd(BROADCAST, REG(SmartServoRegister::MAX_ANGLE_LIMIT_H), max_angle);
317320
mutex.unlock();
318321
}
319322

320-
void SmartServoClass::setMaxAngle(uint8_t const id, float const angle) {
323+
void SmartServoClass::setMaxAngle(uint8_t const id, uint16_t const max_angle)
324+
{
321325
mutex.lock();
322-
writeWordCmd(id, REG(SmartServoRegister::MAX_ANGLE_LIMIT_H), angleToPosition(angle));
326+
writeWordCmd(id, REG(SmartServoRegister::MAX_ANGLE_LIMIT_H), max_angle);
323327
mutex.unlock();
324328
}
325329

@@ -340,4 +344,4 @@ void SmartServoClass::getInfo(Stream & stream, uint8_t const id) {
340344
for (i = 0; i < sizeof(regs); i++) {
341345
stream.println(String(i, HEX) + " : " + String(regs[i], HEX));
342346
}
343-
}
347+
}

src/lib/motors/SmartServo.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,10 @@ class SmartServoClass
5050

5151
void setStallProtectionTime(uint8_t const id, uint8_t const time);
5252

53-
void setMinAngle(float const angle);
54-
55-
void setMinAngle(uint8_t const id, float const angle);
56-
57-
void setMaxAngle(float const angle);
58-
59-
void setMaxAngle(uint8_t const id, float const angle);
53+
void setMinAngle(uint16_t const min_angle);
54+
void setMinAngle(uint8_t const id, uint16_t const min_angle);
55+
void setMaxAngle(uint16_t const max_angle);
56+
void setMaxAngle(uint8_t const id, uint16_t const max_angle);
6057

6158
void setTime(uint8_t const id, uint16_t const time);
6259

@@ -131,4 +128,4 @@ class SmartServoClass
131128
rtos::Mutex mutex;
132129
};
133130

134-
#endif // _SMARTMOTOR_H_
131+
#endif // _SMARTMOTOR_H_

0 commit comments

Comments
 (0)