From 90a1e9eb7f6cdd618fa0974270b459b3b148d529 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 8 Jan 2021 20:25:34 -0800 Subject: [PATCH 01/10] Add optomize() to SwerveModuleState --- .../cpp/SwerveModule.cpp | 7 ++++++- .../SwerveModule.java | 8 +++++-- .../wpilibj/kinematics/SwerveModuleState.java | 19 +++++++++++++++++ .../frc/kinematics/SwerveModuleState.h | 21 +++++++++++++++++++ 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/SwerveModule.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/SwerveModule.cpp index 5e88d10a530..893b71ace13 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/SwerveModule.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/SwerveModule.cpp @@ -32,7 +32,12 @@ frc::SwerveModuleState SwerveModule::GetState() const { frc::Rotation2d(units::radian_t(m_turningEncoder.Get()))}; } -void SwerveModule::SetDesiredState(const frc::SwerveModuleState& state) { +void SwerveModule::SetDesiredState( + const frc::SwerveModuleState& referenceState) { + // Optimize the reference state to avoid spinning further than 90 degrees + auto state = frc::SwerveModuleState::Optimize( + referenceState, frc::Rotation2d{units::radian_t(m_turningEncoder.Get())}); + // Calculate the drive output from the drive PID controller. const auto driveOutput = m_drivePIDController.Calculate( m_driveEncoder.GetRate(), state.speed.to()); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervesdriveposeestimator/SwerveModule.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervesdriveposeestimator/SwerveModule.java index a178f787c25..94886401395 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervesdriveposeestimator/SwerveModule.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervesdriveposeestimator/SwerveModule.java @@ -79,9 +79,13 @@ public SwerveModuleState getState() { /** * Sets the desired state for the module. * - * @param state Desired state with speed and angle. + * @param desiredState Desired state with speed and angle. */ - public void setDesiredState(SwerveModuleState state) { + public void setDesiredState(SwerveModuleState desiredState) { + // Optimize the reference state to avoid spinning further than 90 degrees + SwerveModuleState state = + SwerveModuleState.optimize(desiredState, new Rotation2d(m_turningEncoder.get())); + // Calculate the drive output from the drive PID controller. final double driveOutput = m_drivePIDController.calculate(m_driveEncoder.getRate(), state.speedMetersPerSecond); diff --git a/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java b/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java index a3096da7f89..f87c6853cd9 100644 --- a/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java +++ b/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java @@ -48,4 +48,23 @@ public String toString() { return String.format( "SwerveModuleState(Speed: %.2f m/s, Angle: %s)", speedMetersPerSecond, angle); } + + /** + * Optimize a desired state by deciding weather to reverse the direction the wheel spins in order + * to minimize travel time. This means that the furthest a wheel will ever rotate is 90 degrees, + * if used in conjunction with the PIDController class' continuous input functionality. + * + * @param desiredState The desired state. + * @param currentAngle The current module angle. + */ + public static SwerveModuleState optimize( + SwerveModuleState desiredState, Rotation2d currentAngle) { + var delta = desiredState.angle.minus(currentAngle); + if (Math.abs(delta.getDegrees()) > 90.0) { + return new SwerveModuleState( + desiredState.speedMetersPerSecond * -1.0, + desiredState.angle.rotateBy(Rotation2d.fromDegrees(180.0))); + } + return new SwerveModuleState(desiredState.speedMetersPerSecond, desiredState.angle); + } } diff --git a/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h b/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h index 28ea9e58e05..4e5798a9bfa 100644 --- a/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h +++ b/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h @@ -5,6 +5,8 @@ #pragma once #include "frc/geometry/Rotation2d.h" +#include "units/angle.h" +#include "units/math.h" #include "units/velocity.h" namespace frc { @@ -21,5 +23,24 @@ struct SwerveModuleState { * Angle of the module. */ Rotation2d angle; + + /** + * Optimize a desired state by deciding weather to reverse the direction the + * wheel spins in order to minimize travel time. This means that the furthest + * a wheel will ever rotate is 90 degrees, if used in conjunction with the + * PIDController class' continuous input functionality. + * + * @param desiredState The desired state. + * @param currentAngle The current module angle. + */ + static SwerveModuleState Optimize(const SwerveModuleState& desiredState, + const Rotation2d& currentAngle) { + auto delta = desiredState.angle - currentAngle; + if (units::math::abs(delta.Degrees()) > 90_deg) { + return {desiredState.speed * -1.0, + desiredState.angle + Rotation2d{180_deg}}; + } + return {desiredState.speed, desiredState.angle}; + } }; } // namespace frc From bb99e54f19f7a2bc2b5d6ed5a8686f2cc244cf27 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 8 Jan 2021 20:34:38 -0800 Subject: [PATCH 02/10] Update SwerveModuleState.h --- .../src/main/native/include/frc/kinematics/SwerveModuleState.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h b/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h index 4e5798a9bfa..d6718635e74 100644 --- a/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h +++ b/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h @@ -29,7 +29,7 @@ struct SwerveModuleState { * wheel spins in order to minimize travel time. This means that the furthest * a wheel will ever rotate is 90 degrees, if used in conjunction with the * PIDController class' continuous input functionality. - * + * * @param desiredState The desired state. * @param currentAngle The current module angle. */ From 3cc08a03d7ef93882398295a9e58a1c608c15a42 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 8 Jan 2021 20:36:46 -0800 Subject: [PATCH 03/10] Update wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h Co-authored-by: Tyler Veness --- .../native/include/frc/kinematics/SwerveModuleState.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h b/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h index d6718635e74..810477f021d 100644 --- a/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h +++ b/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h @@ -25,10 +25,10 @@ struct SwerveModuleState { Rotation2d angle; /** - * Optimize a desired state by deciding weather to reverse the direction the - * wheel spins in order to minimize travel time. This means that the furthest - * a wheel will ever rotate is 90 degrees, if used in conjunction with the - * PIDController class' continuous input functionality. + * Minimize the change in heading the desired swerve module state would + * require by potentially reversing the direction the wheel spins. If this is + * used with the PIDController class's continuous input functionality, the + * furthest a wheel will ever rotate is 90 degrees. * * @param desiredState The desired state. * @param currentAngle The current module angle. From d4709d92f8fac52724aa0fb4d2a3e17589123390 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 8 Jan 2021 20:37:32 -0800 Subject: [PATCH 04/10] Update wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java Co-authored-by: Tyler Veness --- .../edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java b/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java index f87c6853cd9..71ec1ced821 100644 --- a/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java +++ b/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java @@ -62,7 +62,7 @@ public static SwerveModuleState optimize( var delta = desiredState.angle.minus(currentAngle); if (Math.abs(delta.getDegrees()) > 90.0) { return new SwerveModuleState( - desiredState.speedMetersPerSecond * -1.0, + -desiredState.speedMetersPerSecond, desiredState.angle.rotateBy(Rotation2d.fromDegrees(180.0))); } return new SwerveModuleState(desiredState.speedMetersPerSecond, desiredState.angle); From 6b3061c399d9c10d397bf4a38ac7d4fe3c8c347f Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 8 Jan 2021 20:38:59 -0800 Subject: [PATCH 05/10] Update wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h Co-authored-by: Tyler Veness --- .../src/main/native/include/frc/kinematics/SwerveModuleState.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h b/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h index 810477f021d..c5a3c07dd2b 100644 --- a/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h +++ b/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h @@ -37,7 +37,7 @@ struct SwerveModuleState { const Rotation2d& currentAngle) { auto delta = desiredState.angle - currentAngle; if (units::math::abs(delta.Degrees()) > 90_deg) { - return {desiredState.speed * -1.0, + return {-desiredState.speed, desiredState.angle + Rotation2d{180_deg}}; } return {desiredState.speed, desiredState.angle}; From b263b7fc055b7723dffe1eab01db78db7ac02819 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 8 Jan 2021 20:39:15 -0800 Subject: [PATCH 06/10] Update wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java Co-authored-by: Tyler Veness --- .../wpi/first/wpilibj/kinematics/SwerveModuleState.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java b/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java index 71ec1ced821..ca2655bd28f 100644 --- a/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java +++ b/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java @@ -50,9 +50,10 @@ public String toString() { } /** - * Optimize a desired state by deciding weather to reverse the direction the wheel spins in order - * to minimize travel time. This means that the furthest a wheel will ever rotate is 90 degrees, - * if used in conjunction with the PIDController class' continuous input functionality. + * Minimize the change in heading the desired swerve module state would + * require by potentially reversing the direction the wheel spins. If this is + * used with the PIDController class's continuous input functionality, the + * furthest a wheel will ever rotate is 90 degrees. * * @param desiredState The desired state. * @param currentAngle The current module angle. From 419206989a24527dc8de0a05e71d80902e26ed7b Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 8 Jan 2021 21:04:30 -0800 Subject: [PATCH 07/10] Wippyformat --- .../wpi/first/wpilibj/kinematics/SwerveModuleState.java | 7 +++---- .../main/native/include/frc/kinematics/SwerveModuleState.h | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java b/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java index ca2655bd28f..207c9ff6284 100644 --- a/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java +++ b/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java @@ -50,10 +50,9 @@ public String toString() { } /** - * Minimize the change in heading the desired swerve module state would - * require by potentially reversing the direction the wheel spins. If this is - * used with the PIDController class's continuous input functionality, the - * furthest a wheel will ever rotate is 90 degrees. + * Minimize the change in heading the desired swerve module state would require by potentially + * reversing the direction the wheel spins. If this is used with the PIDController class's + * continuous input functionality, the furthest a wheel will ever rotate is 90 degrees. * * @param desiredState The desired state. * @param currentAngle The current module angle. diff --git a/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h b/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h index c5a3c07dd2b..5d466f5957d 100644 --- a/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h +++ b/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h @@ -37,8 +37,7 @@ struct SwerveModuleState { const Rotation2d& currentAngle) { auto delta = desiredState.angle - currentAngle; if (units::math::abs(delta.Degrees()) > 90_deg) { - return {-desiredState.speed, - desiredState.angle + Rotation2d{180_deg}}; + return {-desiredState.speed, desiredState.angle + Rotation2d{180_deg}}; } return {desiredState.speed, desiredState.angle}; } From 7ed181debf8c8c8a566532cd026a5d4d1356d3ca Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 10 Jan 2021 12:35:16 -0800 Subject: [PATCH 08/10] Add else branch --- .../src/main/cpp/examples/SwerveBot/cpp/SwerveModule.cpp | 7 ++++++- .../main/native/include/frc/kinematics/SwerveModuleState.h | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/SwerveModule.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/SwerveModule.cpp index 2e3f525dc38..8783385e91d 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/SwerveModule.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/SwerveModule.cpp @@ -32,7 +32,12 @@ frc::SwerveModuleState SwerveModule::GetState() const { frc::Rotation2d(units::radian_t(m_turningEncoder.Get()))}; } -void SwerveModule::SetDesiredState(const frc::SwerveModuleState& state) { +void SwerveModule::SetDesiredState( + const frc::SwerveModuleState& referenceState) { + // Optimize the reference state to avoid spinning further than 90 degrees + const auto state = frc::SwerveModuleState::Optimize( + referenceState, units::radian_t(m_turningEncoder.Get())); + // Calculate the drive output from the drive PID controller. const auto driveOutput = m_drivePIDController.Calculate( m_driveEncoder.GetRate(), state.speed.to()); diff --git a/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h b/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h index 5d466f5957d..52dfe8eff01 100644 --- a/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h +++ b/wpimath/src/main/native/include/frc/kinematics/SwerveModuleState.h @@ -38,8 +38,9 @@ struct SwerveModuleState { auto delta = desiredState.angle - currentAngle; if (units::math::abs(delta.Degrees()) > 90_deg) { return {-desiredState.speed, desiredState.angle + Rotation2d{180_deg}}; + } else { + return {desiredState.speed, desiredState.angle}; } - return {desiredState.speed, desiredState.angle}; } }; } // namespace frc From 114af5a779cdf01142868c3632c91d70fd10cfe4 Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 10 Jan 2021 12:35:28 -0800 Subject: [PATCH 09/10] update all the examples not just 2 --- .../cpp/subsystems/SwerveModule.cpp | 7 ++++++- .../include/subsystems/SwerveModule.h | 2 +- .../SwerveDrivePoseEstimator/cpp/SwerveModule.cpp | 4 ++-- .../first/wpilibj/examples/swervebot/SwerveModule.java | 6 +++++- .../swervecontrollercommand/subsystems/SwerveModule.java | 8 ++++++-- .../wpi/first/wpilibj/kinematics/SwerveModuleState.java | 3 ++- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/subsystems/SwerveModule.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/subsystems/SwerveModule.cpp index 8c756a37c8d..bccafd7b756 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/subsystems/SwerveModule.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/subsystems/SwerveModule.cpp @@ -43,7 +43,12 @@ frc::SwerveModuleState SwerveModule::GetState() { frc::Rotation2d(units::radian_t(m_turningEncoder.Get()))}; } -void SwerveModule::SetDesiredState(frc::SwerveModuleState& state) { +void SwerveModule::SetDesiredState( + const frc::SwerveModuleState& referenceState) { + // Optimize the reference state to avoid spinning further than 90 degrees + const auto state = frc::SwerveModuleState::Optimize( + referenceState, units::radian_t(m_turningEncoder.Get())); + // Calculate the drive output from the drive PID controller. const auto driveOutput = m_drivePIDController.Calculate( m_driveEncoder.GetRate(), state.speed.to()); diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/subsystems/SwerveModule.h b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/subsystems/SwerveModule.h index d501f0b7d08..7f3dba843b5 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/subsystems/SwerveModule.h +++ b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/subsystems/SwerveModule.h @@ -27,7 +27,7 @@ class SwerveModule { frc::SwerveModuleState GetState(); - void SetDesiredState(frc::SwerveModuleState& state); + void SetDesiredState(const frc::SwerveModuleState& state); void ResetEncoders(); diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/SwerveModule.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/SwerveModule.cpp index 893b71ace13..6bb982f7fe9 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/SwerveModule.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/SwerveModule.cpp @@ -35,8 +35,8 @@ frc::SwerveModuleState SwerveModule::GetState() const { void SwerveModule::SetDesiredState( const frc::SwerveModuleState& referenceState) { // Optimize the reference state to avoid spinning further than 90 degrees - auto state = frc::SwerveModuleState::Optimize( - referenceState, frc::Rotation2d{units::radian_t(m_turningEncoder.Get())}); + const auto state = frc::SwerveModuleState::Optimize( + referenceState, units::radian_t(m_turningEncoder.Get())); // Calculate the drive output from the drive PID controller. const auto driveOutput = m_drivePIDController.Calculate( diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervebot/SwerveModule.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervebot/SwerveModule.java index 469403f5299..f213090aa0c 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervebot/SwerveModule.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervebot/SwerveModule.java @@ -81,7 +81,11 @@ public SwerveModuleState getState() { * * @param state Desired state with speed and angle. */ - public void setDesiredState(SwerveModuleState state) { + public void setDesiredState(SwerveModuleState desiredState) { + // Optimize the reference state to avoid spinning further than 90 degrees + SwerveModuleState state = + SwerveModuleState.optimize(desiredState, new Rotation2d(m_turningEncoder.get())); + // Calculate the drive output from the drive PID controller. final double driveOutput = m_drivePIDController.calculate(m_driveEncoder.getRate(), state.speedMetersPerSecond); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervecontrollercommand/subsystems/SwerveModule.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervecontrollercommand/subsystems/SwerveModule.java index 34adc6d2f6b..c636b3cdfff 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervecontrollercommand/subsystems/SwerveModule.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervecontrollercommand/subsystems/SwerveModule.java @@ -89,9 +89,13 @@ public SwerveModuleState getState() { * * @param state Desired state with speed and angle. */ - public void setDesiredState(SwerveModuleState state) { + public void setDesiredState(SwerveModuleState desiredState) { + // Optimize the reference state to avoid spinning further than 90 degrees + SwerveModuleState state = + SwerveModuleState.optimize(desiredState, new Rotation2d(m_turningEncoder.get())); + // Calculate the drive output from the drive PID controller. - final var driveOutput = + final double driveOutput = m_drivePIDController.calculate(m_driveEncoder.getRate(), state.speedMetersPerSecond); // Calculate the turning motor output from the turning PID controller. diff --git a/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java b/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java index 207c9ff6284..2c800376d46 100644 --- a/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java +++ b/wpimath/src/main/java/edu/wpi/first/wpilibj/kinematics/SwerveModuleState.java @@ -64,7 +64,8 @@ public static SwerveModuleState optimize( return new SwerveModuleState( -desiredState.speedMetersPerSecond, desiredState.angle.rotateBy(Rotation2d.fromDegrees(180.0))); + } else { + return new SwerveModuleState(desiredState.speedMetersPerSecond, desiredState.angle); } - return new SwerveModuleState(desiredState.speedMetersPerSecond, desiredState.angle); } } From 1cc21944a2545a378a73fe26bf3fcccc75016ec6 Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 10 Jan 2021 13:22:46 -0800 Subject: [PATCH 10/10] Fix javadoc --- .../edu/wpi/first/wpilibj/examples/swervebot/SwerveModule.java | 2 +- .../swervecontrollercommand/subsystems/SwerveModule.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervebot/SwerveModule.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervebot/SwerveModule.java index f213090aa0c..eb619e1068e 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervebot/SwerveModule.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervebot/SwerveModule.java @@ -79,7 +79,7 @@ public SwerveModuleState getState() { /** * Sets the desired state for the module. * - * @param state Desired state with speed and angle. + * @param desiredState Desired state with speed and angle. */ public void setDesiredState(SwerveModuleState desiredState) { // Optimize the reference state to avoid spinning further than 90 degrees diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervecontrollercommand/subsystems/SwerveModule.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervecontrollercommand/subsystems/SwerveModule.java index c636b3cdfff..4ec1545da0b 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervecontrollercommand/subsystems/SwerveModule.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervecontrollercommand/subsystems/SwerveModule.java @@ -87,7 +87,7 @@ public SwerveModuleState getState() { /** * Sets the desired state for the module. * - * @param state Desired state with speed and angle. + * @param desiredState Desired state with speed and angle. */ public void setDesiredState(SwerveModuleState desiredState) { // Optimize the reference state to avoid spinning further than 90 degrees