Skip to content

Commit

Permalink
Converts mdeg to ticks and negates when set
Browse files Browse the repository at this point in the history
  • Loading branch information
Geeoon committed Nov 9, 2024
1 parent 4822cdf commit 848b766
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/world_interface/real_world_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int32_t>(static_cast<double>(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) {
Expand Down

0 comments on commit 848b766

Please sign in to comment.