diff --git a/src/control/SwerveController.cpp b/src/control/SwerveController.cpp index 3501f9e3..d64c4ede 100644 --- a/src/control/SwerveController.cpp +++ b/src/control/SwerveController.cpp @@ -1,7 +1,6 @@ #include "SwerveController.h" #include "../Constants.h" -#include "../Globals.h" using namespace control; using robot::types::motorid_t; @@ -21,11 +20,6 @@ SwerveController::setTurnInPlaceCmdVel(double dtheta, const swerve_rots_t& wheel swerve_commands_t SwerveController::setTurnInPlaceCmdVel(double dtheta, const swerve_rots_t& wheel_rots, double& scaleFactor) const { - if (dtheta == 0) { - scaleFactor = 0; - return {0.0, 0.0, 0.0, 0.0}; - } - if (!checkWheelRotation(DriveMode::TurnInPlace, wheel_rots)) { scaleFactor = 0; return {0.0, 0.0, 0.0, 0.0}; @@ -63,11 +57,6 @@ swerve_commands_t SwerveController::setCrabCmdVel(double dtheta, double dy, swerve_commands_t SwerveController::setCrabCmdVel(double dtheta, double dy, const swerve_rots_t& wheel_rots, double& scaleFactor) const { - if (Globals::E_STOP && (dtheta != 0 || dy != 0)) { - scaleFactor = 0; - return {0.0, 0.0, 0.0, 0.0}; - } - if (!checkWheelRotation(DriveMode::Crab, wheel_rots)) { scaleFactor = 0; return {0.0, 0.0, 0.0, 0.0}; @@ -91,7 +80,8 @@ swerve_commands_t SwerveController::setCrabCmdVel(double dtheta, double dy, return {rPWM, rPWM, lPWM, lPWM}; } -bool SwerveController::checkWheelRotation(DriveMode mode, swerve_rots_t wheel_rots) const { +bool SwerveController::checkWheelRotation(DriveMode mode, + const swerve_rots_t& wheel_rots) const { std::array rots = {wheel_rots.lfRot, wheel_rots.rfRot, wheel_rots.lbRot, wheel_rots.rbRot}; swerve_rots_t target = getSteerRots(mode); @@ -135,12 +125,12 @@ DriveMode SwerveController::getDriveMode() const { return driveMode; } -swerve_rots_t SwerveController::setDriveMode(DriveMode mode) const { +swerve_rots_t SwerveController::setDriveMode(DriveMode mode) { driveMode = mode; return getSteerRots(mode); } -void SwerveController::setOverride(bool override) const { +void SwerveController::setOverride(bool override) { override_steer_check = override; } diff --git a/src/control/SwerveController.h b/src/control/SwerveController.h index 74a5762f..d4fa2ef2 100644 --- a/src/control/SwerveController.h +++ b/src/control/SwerveController.h @@ -132,7 +132,7 @@ class SwerveController { * * @param override Override the wheel rotation check. */ - void setOverride(bool override) const; + void setOverride(bool override); /** * @brief Get the current drive mode of the controller. @@ -147,7 +147,7 @@ class SwerveController { * @param mode The new drive mode to set. * @return swerve_rots_t The wheel steer rotations associated with this drive mode. */ - swerve_rots_t setDriveMode(DriveMode mode) const; + swerve_rots_t setDriveMode(DriveMode mode); /** * @brief Check to see if all wheels are at their target position. @@ -157,7 +157,7 @@ class SwerveController { * @return bool if the wheels are within `STEER_EPSILON` of their * target position OR if `overide_steer_check` is true. */ - bool checkWheelRotation(DriveMode mode, swerve_rots_t wheel_rots) const; + bool checkWheelRotation(DriveMode mode, const swerve_rots_t& wheel_rots) const; /** * @brief Get the wheel steer rotations for a given drive mode in millidegrees. @@ -172,13 +172,13 @@ class SwerveController { /** * @brief The current drive mode. */ - mutable DriveMode driveMode; + DriveMode driveMode; /** * @brief Whether or not wheel rotation check should be ignored when * doing swerve-based driving. */ - mutable bool override_steer_check; + bool override_steer_check; }; } // namespace control diff --git a/src/network/MissionControlTasks.cpp b/src/network/MissionControlTasks.cpp index dfb03407..e6f4f335 100644 --- a/src/network/MissionControlTasks.cpp +++ b/src/network/MissionControlTasks.cpp @@ -30,7 +30,7 @@ static control::swerve_rots_t getAllSteerRotations(); /** * Set the steer power of all wheels with a swerve_commands_t. */ -static void setAllSteerPowers(control::swerve_commands_t commands); +static void setAllSteerPowers(const control::swerve_commands_t& commands); PowerRepeatTask::PowerRepeatTask() : util::PeriodicTask<>(Constants::JOINT_POWER_REPEAT_PERIOD, @@ -233,7 +233,7 @@ static control::swerve_rots_t getAllSteerRotations() { robot::getMotorPos(motorid_t::rearRightWheel).getData()}; } -static void setAllSteerPowers(control::swerve_commands_t commands) { +static void setAllSteerPowers(const control::swerve_commands_t& commands) { robot::setMotorPower(motorid_t::frontLeftWheel, commands.lfPower); robot::setMotorPower(motorid_t::frontRightWheel, commands.rfPower); robot::setMotorPower(motorid_t::rearLeftWheel, commands.lbPower);