From 9d378f1b67e8e273d4701e537bbeb93f0a08d62e Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 18 Aug 2019 11:13:24 -0400 Subject: [PATCH] Fix bug in anticogging due to improper scaling --- Firmware/MotorControl/controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/MotorControl/controller.cpp b/Firmware/MotorControl/controller.cpp index 8837bae1..5016f7dc 100644 --- a/Firmware/MotorControl/controller.cpp +++ b/Firmware/MotorControl/controller.cpp @@ -243,7 +243,7 @@ bool Controller::update(float pos_estimate, float vel_estimate, float* current_s // We get the current position and apply a current feed-forward // ensuring that we handle negative encoder positions properly (-1 == motor->encoder.encoder_cpr - 1) if (anticogging_valid_) { - Iq += config_.anticogging.cogging_map[std::clamp(mod(static_cast(anticogging_pos), axis_->encoder_.config_.cpr), 0, 3600)]; + Iq += config_.anticogging.cogging_map[std::clamp(mod(static_cast(anticogging_pos), 3600), 0, 3600)]; } float v_err = vel_des - vel_estimate;