Class MapleSimSwerveDrivetrain.TalonFXMotorControllerWithRemoteCanCoderSim

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

public static class MapleSimSwerveDrivetrain.TalonFXMotorControllerWithRemoteCanCoderSim extends MapleSimSwerveDrivetrain.TalonFXMotorControllerSim
Extends MapleSimSwerveDrivetrain.TalonFXMotorControllerSim to also drive a remote CANcoder simulation state. Used for steer motors whose feedback device is a remote CANcoder.
  • Constructor Details

    • TalonFXMotorControllerWithRemoteCanCoderSim

      public TalonFXMotorControllerWithRemoteCanCoderSim(TalonFX talonFX, CANcoder cancoder)
      Constructs the adapter for a steer motor paired with a remote CANcoder.
      Parameters:
      talonFX - the steer TalonFX motor controller
      cancoder - the remote CANcoder used as the steer feedback sensor
  • Method Details

    • updateControlSignal

      public Voltage updateControlSignal(Angle mechanismAngle, AngularVelocity mechanismVelocity, Angle encoderAngle, AngularVelocity encoderVelocity)
      Injects simulated supply voltage, position, and velocity into the remote CANcoder sim state, then delegates to the parent implementation to update the TalonFX and return the requested motor voltage.
      Specified by:
      updateControlSignal in interface SimulatedMotorController
      Overrides:
      updateControlSignal in class MapleSimSwerveDrivetrain.TalonFXMotorControllerSim
      Parameters:
      mechanismAngle - current mechanism-side angle (written to the CANcoder)
      mechanismVelocity - current mechanism-side angular velocity (written to the CANcoder)
      encoderAngle - current encoder (rotor-side) angle (forwarded to TalonFX)
      encoderVelocity - current encoder angular velocity (forwarded to TalonFX)
      Returns:
      the voltage the controller is requesting from the simulated battery