Class MapleSimSwerveDrivetrain.TalonFXMotorControllerSim

java.lang.Object
frc.spectrumLib.swerve.MapleSimSwerveDrivetrain.TalonFXMotorControllerSim
All Implemented Interfaces:
SimulatedMotorController
Direct Known Subclasses:
MapleSimSwerveDrivetrain.TalonFXMotorControllerWithRemoteCanCoderSim
Enclosing class:
MapleSimSwerveDrivetrain

public static class MapleSimSwerveDrivetrain.TalonFXMotorControllerSim extends Object implements SimulatedMotorController
Adapts a TalonFX motor controller for use as a SimulatedMotorController in Maple-Sim by forwarding encoder state from the simulation into the CTRE sim state.
  • Field Details

    • id

      public final int id
      CAN device ID of the underlying TalonFX.
  • Constructor Details

    • TalonFXMotorControllerSim

      public TalonFXMotorControllerSim(TalonFX talonFX)
      Constructs the adapter for the given TalonFX.
      Parameters:
      talonFX - the TalonFX motor controller to wrap
  • Method Details

    • updateControlSignal

      public Voltage updateControlSignal(Angle mechanismAngle, AngularVelocity mechanismVelocity, Angle encoderAngle, AngularVelocity encoderVelocity)
      Injects simulated rotor position, velocity, and supply voltage into the TalonFX sim state, then returns the motor output voltage requested by the controller's closed-loop algorithm.
      Specified by:
      updateControlSignal in interface SimulatedMotorController
      Parameters:
      mechanismAngle - current mechanism-side angle from the physics model
      mechanismVelocity - current mechanism-side angular velocity from the physics model
      encoderAngle - current encoder angle (rotor-side) from the physics model
      encoderVelocity - current encoder angular velocity (rotor-side) from the physics model
      Returns:
      the voltage the controller is requesting from the simulated battery