Package frc.spectrumLib.swerve
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.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ironmaple.simulation.motorsims.SimulatedMotorController
SimulatedMotorController.GenericMotorController -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTalonFXMotorControllerSim(TalonFX talonFX) Constructs the adapter for the given TalonFX. -
Method Summary
Modifier and TypeMethodDescriptionupdateControlSignal(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.
-
Field Details
-
id
public final int idCAN device ID of the underlying TalonFX.
-
-
Constructor Details
-
TalonFXMotorControllerSim
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:
updateControlSignalin interfaceSimulatedMotorController- Parameters:
mechanismAngle- current mechanism-side angle from the physics modelmechanismVelocity- current mechanism-side angular velocity from the physics modelencoderAngle- current encoder angle (rotor-side) from the physics modelencoderVelocity- current encoder angular velocity (rotor-side) from the physics model- Returns:
- the voltage the controller is requesting from the simulated battery
-