Class ModuleIOSpark

java.lang.Object
frc.robot.subsystems.drive.module.ModuleIOSpark
All Implemented Interfaces:
ModuleIO

public class ModuleIOSpark extends Object implements ModuleIO
Real IO implementation for a swerve drive module using Spark Max motor controllers and a CANcoder for absolute positioning.
  • 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: ModuleIO
      Polls high-frequency data for the 200Hz odometry loop.
      Specified by:
      updateHighFreq in interface ModuleIO
      Parameters:
      timestampSec - The exact timestamp of the current 200Hz tick.
    • updateInputs

      public void updateInputs(ModuleIO.ModuleIOInputs inputs)
      Description copied from interface: ModuleIO
      Updates the set of loggable inputs.
      Specified by:
      updateInputs in interface ModuleIO
      Parameters:
      inputs - The inputs object to update.
    • setDriveOpenLoop

      public void setDriveOpenLoop(Voltage output)
      Description copied from interface: ModuleIO
      Run the drive motor at the specified open loop voltage.
      Specified by:
      setDriveOpenLoop in interface ModuleIO
      Parameters:
      output - The voltage to apply.
    • setTurnOpenLoop

      public void setTurnOpenLoop(Voltage output)
      Description copied from interface: ModuleIO
      Run the turn motor at the specified open loop voltage.
      Specified by:
      setTurnOpenLoop in interface ModuleIO
      Parameters:
      output - The voltage to apply.
    • setDriveVelocity

      public void setDriveVelocity(AngularVelocity velocity)
      Description copied from interface: ModuleIO
      Run the drive motor at the specified angular velocity.
      Specified by:
      setDriveVelocity in interface ModuleIO
      Parameters:
      velocity - The target velocity in radians per second.
    • setTurnPosition

      public void setTurnPosition(Angle rotation)
      Description copied from interface: ModuleIO
      Run the turn motor to the specified rotation.
      Specified by:
      setTurnPosition in interface ModuleIO
      Parameters:
      rotation - The target angle as an Angle measure.
    • clearFaults

      public void clearFaults()
      Description copied from interface: ModuleIO
      Clears all faults and warnings.
      Specified by:
      clearFaults in interface ModuleIO