Skip to content

Commit 8eb86c0

Browse files
Change joint velocity units to rad/s instead of rev/s (#42)
* Change joint velocity to convert to rad/s instead of rev/s * Use float type PI instead of double type in clamp function
1 parent 90594e2 commit 8eb86c0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

NUSense/Core/Src/nusense/Convert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,15 @@ namespace nusense {
144144
// Range: -210 - +210 = -48.09 rpm - +48.09 rpm
145145
// Default servo limits for velocity - minimum of all for X-Series, MX-106 and MX-64
146146
// X-Series has the minimum at 167
147-
return utility::math::clamp(int32_t(-167), velocity, int32_t(167)) * 0.229f / 60.0f;
147+
return utility::math::clamp(int32_t(-167), velocity, int32_t(167)) * 0.229f * 2 * static_cast<float>(M_PI) / 60.0f;
148148
}
149149

150150
int32_t velocity(float velocity) {
151151
// Base unit: 0.229 rpm = 0.0038166667 Hz (factor = 1/60)
152152
// Range: -210 - +210 = -48.09 rpm - +48.09 rpm
153153
// Default servo limits for velocity - minimum of all for X-Series, MX-106 and MX-64
154154
// X-Series has the minimum at 167
155-
return int32_t(utility::math::clamp(-167.0f, (velocity * 60.0f / 0.229f), 167.0f));
155+
return int32_t(utility::math::clamp(-167.0f, (velocity * 60.0f / (0.229f * 2 * static_cast<float>(M_PI))), 167.0f));
156156
}
157157

158158
uint32_t profile_velocity(float profile_velocity) {

0 commit comments

Comments
 (0)