Class TorqueSwerveModule2022
java.lang.Object
org.texastorque.torquelib.modules.base.TorqueSwerveModule
org.texastorque.torquelib.modules.TorqueSwerveModule2022
Super cool flipped swerve module built in 2023 by Abishek.
https://drive.google.com/file/d/1bvgo75gqLzoerBIEtEObXep_6gpac6mZ/view?usp=sharing
https://drive.google.com/file/d/1q4cmx3Ntscfynn_1Tc8W9VAqR9Tgn0NT/view?usp=sharing
The module uses a Rev NEO for drive and rotation control. It uses a CTRE Cancoder
positioned 1:1 with the wheel rotation.
The code is kinda based off the FRC 1706 swerve module.
Cancoder docs: https://api.ctr-electronics.com/phoenix/release/java/com/ctre/phoenix/sensors/CANCoder.html
The rotation of the modules is [0, 2π) radians, with 0 being straight ahead (I think).
0 or 2π
↑
π/2 ← * → 3π/2
↓
π
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A structure to define the constants for the swerve module.static final class
-
Field Summary
Fields inherited from class org.texastorque.torquelib.modules.base.TorqueSwerveModule
id
-
Constructor Summary
ConstructorDescriptionTorqueSwerveModule2022
(String name, int driveID, int turnID, int encoderID, double staticOffset, TorqueSwerveModule2022.SwerveConfig config) TorqueSwerveModule2022
(String name, TorqueSwerveModule2022.SwervePorts ports, double staticOffset, TorqueSwerveModule2022.SwerveConfig config) -
Method Summary
Modifier and TypeMethodDescriptionedu.wpi.first.math.kinematics.SwerveModulePosition
edu.wpi.first.math.geometry.Rotation2d
edu.wpi.first.math.kinematics.SwerveModuleState
getState()
static void
normalize
(edu.wpi.first.math.kinematics.SwerveModuleState[] states, double max) Normalizes drive speeds to never exceed a specified max.void
setDesiredState
(edu.wpi.first.math.kinematics.SwerveModuleState state) void
stop()
void
zero()
Methods inherited from class org.texastorque.torquelib.modules.base.TorqueSwerveModule
getPort
-
Field Details
-
staticOffset
public final double staticOffset -
name
-
useSmartDrive
public boolean useSmartDrive -
useCancoder
public boolean useCancoder
-
-
Constructor Details
-
TorqueSwerveModule2022
public TorqueSwerveModule2022(String name, TorqueSwerveModule2022.SwervePorts ports, double staticOffset, TorqueSwerveModule2022.SwerveConfig config) -
TorqueSwerveModule2022
public TorqueSwerveModule2022(String name, int driveID, int turnID, int encoderID, double staticOffset, TorqueSwerveModule2022.SwerveConfig config)
-
-
Method Details
-
setDesiredState
public void setDesiredState(edu.wpi.first.math.kinematics.SwerveModuleState state) - Specified by:
setDesiredState
in classTorqueSwerveModule
-
getState
public edu.wpi.first.math.kinematics.SwerveModuleState getState()- Specified by:
getState
in classTorqueSwerveModule
-
getPosition
public edu.wpi.first.math.kinematics.SwerveModulePosition getPosition() -
getRotation
public edu.wpi.first.math.geometry.Rotation2d getRotation()- Specified by:
getRotation
in classTorqueSwerveModule
-
stop
public void stop() -
zero
public void zero() -
normalize
public static void normalize(edu.wpi.first.math.kinematics.SwerveModuleState[] states, double max) Normalizes drive speeds to never exceed a specified max.- Parameters:
states
- The swerve module states, this is mutated!max
- Maximum translational speed.
-