From 848b766233252077fe082631d31f22f24f8bbab7 Mon Sep 17 00:00:00 2001 From: Geeoon Chung Date: Sat, 2 Nov 2024 12:12:13 -0700 Subject: [PATCH] Converts mdeg to ticks and negates when set --- src/world_interface/real_world_interface.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/world_interface/real_world_interface.cpp b/src/world_interface/real_world_interface.cpp index 5bcf2fc3..b6f46d96 100644 --- a/src/world_interface/real_world_interface.cpp +++ b/src/world_interface/real_world_interface.cpp @@ -84,8 +84,15 @@ void initMotors() { can::motor::initEncoder(serial, enc_params.isInverted, true, enc_params.ppjr, TELEM_PERIOD); - can::motor::setLimitSwitchLimits(serial, enc_params.limitSwitchLow, - enc_params.limitSwitchHigh); + + auto mDegToPulses = [&](int32_t mdeg) { + return static_cast(static_cast(mdeg) / 360000.0 * + enc_params.ppjr); + }; + + // TODO: get rid of the negatives once firmware fixes the limit switch limits issue + can::motor::setLimitSwitchLimits(serial, mDegToPulses(-enc_params.limitSwitchLow), + mDegToPulses(-enc_params.limitSwitchHigh)); } for (const auto& pair : robot::motorPIDMap) {