Class ModuleIOSpark
java.lang.Object
frc.robot.subsystems.drive.module.ModuleIOSpark
- All Implemented Interfaces:
ModuleIO
Real IO implementation for a swerve drive module using Spark Max motor controllers and a CANcoder
for absolute positioning.
-
Nested Class Summary
Nested classes/interfaces inherited from interface frc.robot.subsystems.drive.module.ModuleIO
ModuleIO.ModuleIOInputs -
Constructor Summary
ConstructorsConstructorDescriptionModuleIOSpark(int module) Creates a new ModuleIOSpark for the specified module index and configures the Spark Max motor controllers and CANcoder. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears all faults and warnings.voidsetDriveOpenLoop(Voltage output) Run the drive motor at the specified open loop voltage.voidsetDriveVelocity(AngularVelocity velocity) Run the drive motor at the specified angular velocity.voidsetTurnOpenLoop(Voltage output) Run the turn motor at the specified open loop voltage.voidsetTurnPosition(Angle rotation) Run the turn motor to the specified rotation.voidupdateHighFreq(double timestampSec) Polls high-frequency data for the 200Hz odometry loop.voidupdateInputs(ModuleIO.ModuleIOInputs inputs) Updates the set of loggable inputs.
-
Constructor Details
-
ModuleIOSpark
public ModuleIOSpark(int module) Creates a new ModuleIOSpark for the specified module index and configures the Spark Max motor controllers and CANcoder.- Parameters:
module- The index of the module (0-3) to determine which configuration to use from the configs.
-
-
Method Details
-
updateHighFreq
public void updateHighFreq(double timestampSec) Description copied from interface:ModuleIOPolls high-frequency data for the 200Hz odometry loop.- Specified by:
updateHighFreqin interfaceModuleIO- Parameters:
timestampSec- The exact timestamp of the current 200Hz tick.
-
updateInputs
Description copied from interface:ModuleIOUpdates the set of loggable inputs.- Specified by:
updateInputsin interfaceModuleIO- Parameters:
inputs- The inputs object to update.
-
setDriveOpenLoop
Description copied from interface:ModuleIORun the drive motor at the specified open loop voltage.- Specified by:
setDriveOpenLoopin interfaceModuleIO- Parameters:
output- The voltage to apply.
-
setTurnOpenLoop
Description copied from interface:ModuleIORun the turn motor at the specified open loop voltage.- Specified by:
setTurnOpenLoopin interfaceModuleIO- Parameters:
output- The voltage to apply.
-
setDriveVelocity
Description copied from interface:ModuleIORun the drive motor at the specified angular velocity.- Specified by:
setDriveVelocityin interfaceModuleIO- Parameters:
velocity- The target velocity in radians per second.
-
setTurnPosition
Description copied from interface:ModuleIORun the turn motor to the specified rotation.- Specified by:
setTurnPositionin interfaceModuleIO- Parameters:
rotation- The target angle as an Angle measure.
-
clearFaults
public void clearFaults()Description copied from interface:ModuleIOClears all faults and warnings.- Specified by:
clearFaultsin interfaceModuleIO
-