Skip to content

Commit 92a2ad0

Browse files
committed
The maximum achievable angle is 315.0 degrees, not 360.0 degrees.
1 parent 0f3d34c commit 92a2ad0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/lib/motors/SmartServo.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ class SmartServoClass
8080

8181
private:
8282

83-
static int constexpr NUM_MOTORS = 6;
84-
static int constexpr MAX_TX_PAYLOAD_LEN = (5*NUM_MOTORS+4);
85-
static int constexpr MAX_RX_PAYLOAD_LEN = 10;
86-
static int constexpr MAX_POSITION = 4000;
83+
static int constexpr NUM_MOTORS = 6;
84+
static int constexpr MAX_TX_PAYLOAD_LEN = (5*NUM_MOTORS+4);
85+
static int constexpr MAX_RX_PAYLOAD_LEN = 10;
86+
static int constexpr MAX_POSITION = 4000;
87+
static float constexpr MAX_ANGLE = 315.0f;
8788

8889
static int constexpr MIN_MOTOR_ID = 1;
8990
static int constexpr MAX_MOTOR_ID = 6;
@@ -103,8 +104,8 @@ class SmartServoClass
103104
void action (uint8_t const id);
104105
void writeSyncCmd (uint8_t *id, uint8_t const num, uint8_t const address, uint8_t const len, uint8_t const * data);
105106

106-
inline uint16_t angleToPosition(float const angle) { return (angle*MAX_POSITION)/360.0; }
107-
inline float positionToAngle(uint16_t const position) { return (360.0*position)/MAX_POSITION; }
107+
inline uint16_t angleToPosition(float const angle) { return (angle*MAX_POSITION)/MAX_ANGLE; }
108+
inline float positionToAngle(uint16_t const position) { return (MAX_ANGLE*position)/MAX_POSITION; }
108109

109110

110111
RS485Class& _RS485;

0 commit comments

Comments
 (0)