Package com.marslib.mechanisms
Class FlywheelIOTalonFX
java.lang.Object
com.marslib.mechanisms.FlywheelIOTalonFX
- All Implemented Interfaces:
FlywheelIO
Real hardware implementation of
FlywheelIO using a CTRE TalonFX motor controller.
Supports open-loop voltage control and closed-loop velocity control via Phoenix 6 onboard PID. Used for shooter and intake flywheels on the physical robot.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.marslib.mechanisms.FlywheelIO
FlywheelIO.FlywheelIOInputs -
Constructor Summary
ConstructorsConstructorDescriptionFlywheelIOTalonFX(int leaderId, int[] followerIds, boolean[] opposeLeader, String canBus, boolean invert) Constructs a master-follower Flywheel configuration (e.g., dual-motor shooter).FlywheelIOTalonFX(int motorId, String canBus, boolean invert) Constructs a single Flywheel mechanism using a direct CTRE TalonFX. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetBrakeMode(boolean enable) voidsetClosedLoopVelocity(double velocityRadPerSec, double feedforwardVolts) Runs a low latency closed-loop velocity profile on motor with external feedforward.voidsetCurrentLimit(double amps) voidsetVoltage(double volts) void
-
Constructor Details
-
FlywheelIOTalonFX
Constructs a single Flywheel mechanism using a direct CTRE TalonFX.- Parameters:
motorId- The physical CAN ID of the primary TalonFX.canBus- The CANBus string (e.g. "rio" or "canivore").invert- Whether to invert the motor output.
-
FlywheelIOTalonFX
public FlywheelIOTalonFX(int leaderId, int[] followerIds, boolean[] opposeLeader, String canBus, boolean invert) Constructs a master-follower Flywheel configuration (e.g., dual-motor shooter).- Parameters:
leaderId- The physical CAN ID of the master TalonFX.followerIds- Array of CAN IDs for the follower motors.opposeLeader- Array of booleans denoting if the follower should spin opposite to the leader.canBus- The CANBus string.invert- Whether the leader is inverted.
-
-
Method Details
-
updateInputs
- Specified by:
updateInputsin interfaceFlywheelIO
-
setVoltage
public void setVoltage(double volts) - Specified by:
setVoltagein interfaceFlywheelIO
-
setClosedLoopVelocity
public void setClosedLoopVelocity(double velocityRadPerSec, double feedforwardVolts) Description copied from interface:FlywheelIORuns a low latency closed-loop velocity profile on motor with external feedforward.- Specified by:
setClosedLoopVelocityin interfaceFlywheelIO
-
setCurrentLimit
public void setCurrentLimit(double amps) - Specified by:
setCurrentLimitin interfaceFlywheelIO
-
setBrakeMode
public void setBrakeMode(boolean enable) - Specified by:
setBrakeModein interfaceFlywheelIO
-