Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions NUSense/Core/Src/nusense/Convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ namespace nusense {
// Range: -210 - +210 = -48.09 rpm - +48.09 rpm
// Default servo limits for velocity - minimum of all for X-Series, MX-106 and MX-64
// X-Series has the minimum at 167
return utility::math::clamp(int32_t(-167), velocity, int32_t(167)) * 0.229f / 60.0f;
return utility::math::clamp(int32_t(-167), velocity, int32_t(167)) * 0.229f * 2 * static_cast<float>(M_PI) / 60.0f;
}

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

uint32_t profile_velocity(float profile_velocity) {
Expand Down
Loading