diff --git a/src/main/java/org/team2342/frc/Robot.java b/src/main/java/org/team2342/frc/Robot.java index 56fc0c6..f211f70 100644 --- a/src/main/java/org/team2342/frc/Robot.java +++ b/src/main/java/org/team2342/frc/Robot.java @@ -29,12 +29,14 @@ import org.littletonrobotics.junction.networktables.NT4Publisher; import org.littletonrobotics.junction.wpilog.WPILOGReader; import org.littletonrobotics.junction.wpilog.WPILOGWriter; +// import org.team2342.frc.subsystems.CANdleSystem.CANdleSystem; import org.team2342.frc.util.PhoenixUtils; import org.team2342.lib.logging.ExecutionLogger; public class Robot extends LoggedRobot { private Command autonomousCommand; private static final double loopOverrunWarningTimeout = 0.2; + // private final CANdleSystem candle = new CANdleSystem(null); private final RobotContainer robotContainer; @@ -160,6 +162,7 @@ public void robotPeriodic() { robotContainer.updateAlerts(); ExecutionLogger.log("RobotPeriodic"); + // candle.periodic(); } @Override diff --git a/src/main/java/org/team2342/frc/RobotContainer.java b/src/main/java/org/team2342/frc/RobotContainer.java index c7f42d4..8c4c1fb 100644 --- a/src/main/java/org/team2342/frc/RobotContainer.java +++ b/src/main/java/org/team2342/frc/RobotContainer.java @@ -16,6 +16,7 @@ import edu.wpi.first.wpilibj.Alert.AlertType; import edu.wpi.first.wpilibj.PowerDistribution.ModuleType; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import edu.wpi.first.wpilibj.util.Color; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine; @@ -37,6 +38,8 @@ import org.team2342.frc.subsystems.vision.Vision; import org.team2342.frc.subsystems.vision.VisionIO; import org.team2342.frc.subsystems.vision.VisionIOSim; +import org.team2342.lib.leds.*; +import org.team2342.lib.leds.LedIO.LedEffect; import org.team2342.lib.util.AllianceUtils; import org.team2342.lib.util.EnhancedXboxController; @@ -44,6 +47,9 @@ public class RobotContainer { @Getter private final Drive drive; @Getter private final Vision vision; + public final LedIOCANdle candle = new LedIOCANdle(22, 37); + public final LedStrip leds = new LedStrip(candle, "leds"); + private final LoggedDashboardChooser autoChooser; @Getter @@ -107,7 +113,6 @@ public RobotContainer() { autoChooser = new LoggedDashboardChooser<>("Auto Choices", AutoBuilder.buildAutoChooser()); autoChooser.get(); - if (Constants.TUNING) setupDevelopmentRoutines(); configureBindings(); @@ -150,6 +155,10 @@ private void configureBindings() { drive::getPose, () -> -driverController.getLeftY(), () -> -driverController.getLeftX())); + + leds.setFirst(Color.kRed, LedEffect.FLASHING); + leds.setSecond(Color.kBlue, LedEffect.RAINBOW); + // leds.setAll(Color.kGreen, LedEffect.RAINBOW); } public Command getAutonomousCommand() { diff --git a/src/main/java/org/team2342/frc/subsystems/CANdleSystem/CANdleSystem.java b/src/main/java/org/team2342/frc/subsystems/CANdleSystem/CANdleSystem.java new file mode 100644 index 0000000..09de6e4 --- /dev/null +++ b/src/main/java/org/team2342/frc/subsystems/CANdleSystem/CANdleSystem.java @@ -0,0 +1,186 @@ +// Copyright (c) 2026 Team 2342 +// https://github.com/FRCTeamPhoenix +// +// This source code is licensed under the MIT License. +// See the LICENSE file in the root directory of this project. + +package org.team2342.frc.subsystems.CANdleSystem; + +import com.ctre.phoenix6.CANBus; +import com.ctre.phoenix6.configs.CANdleConfiguration; +import com.ctre.phoenix6.controls.SolidColor; +import com.ctre.phoenix6.hardware.CANdle; +import com.ctre.phoenix6.signals.RGBWColor; +import com.ctre.phoenix6.signals.StatusLedWhenActiveValue; +import com.ctre.phoenix6.signals.StripTypeValue; +import edu.wpi.first.wpilibj.XboxController; +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class CANdleSystem extends SubsystemBase { + private final CANdle m_candle = new CANdle(22, new CANBus("rio")); + private final int LedCount = 300; + private XboxController joystick; + + public enum AnimationTypes { + ColorFlow, + Fire, + Larson, + Rainbow, + RgbFade, + SingleFade, + Strobe, + Twinkle, + TwinkleOff, + SetAll + } + + private AnimationTypes m_currentAnimation; + + public CANdleSystem(XboxController joy) { + this.joystick = joy; + changeAnimation(AnimationTypes.SetAll); + CANdleConfiguration configAll = new CANdleConfiguration(); + configAll.CANdleFeatures.StatusLedWhenActive = StatusLedWhenActiveValue.Disabled; + configAll.LED.StripType = StripTypeValue.GRB; + m_candle.getConfigurator().apply(configAll); + } + + public void incrementAnimation() { + switch (m_currentAnimation) { + case ColorFlow: + changeAnimation(AnimationTypes.Fire); + break; + case Fire: + changeAnimation(AnimationTypes.Larson); + break; + case Larson: + changeAnimation(AnimationTypes.Rainbow); + break; + case Rainbow: + changeAnimation(AnimationTypes.RgbFade); + break; + case RgbFade: + changeAnimation(AnimationTypes.SingleFade); + break; + case SingleFade: + changeAnimation(AnimationTypes.Strobe); + break; + case Strobe: + changeAnimation(AnimationTypes.Twinkle); + break; + case Twinkle: + changeAnimation(AnimationTypes.TwinkleOff); + break; + case TwinkleOff: + changeAnimation(AnimationTypes.ColorFlow); + break; + case SetAll: + changeAnimation(AnimationTypes.ColorFlow); + break; + } + } + + public void decrementAnimation() { + switch (m_currentAnimation) { + case ColorFlow: + changeAnimation(AnimationTypes.TwinkleOff); + break; + case Fire: + changeAnimation(AnimationTypes.ColorFlow); + break; + case Larson: + changeAnimation(AnimationTypes.Fire); + break; + case Rainbow: + changeAnimation(AnimationTypes.Larson); + break; + case RgbFade: + changeAnimation(AnimationTypes.Rainbow); + break; + case SingleFade: + changeAnimation(AnimationTypes.RgbFade); + break; + case Strobe: + changeAnimation(AnimationTypes.SingleFade); + break; + case Twinkle: + changeAnimation(AnimationTypes.Strobe); + break; + case TwinkleOff: + changeAnimation(AnimationTypes.Twinkle); + break; + case SetAll: + changeAnimation(AnimationTypes.ColorFlow); + break; + } + } + + public void setColors() { + changeAnimation(AnimationTypes.SetAll); + } + + public void changeAnimation(AnimationTypes toChange) { + m_currentAnimation = toChange; + + // switch(toChange) + // { + // case ColorFlow: + // m_toAnimate = new ColorFlowAnimation(128, 20, 70, 0, 0.7, LedCount, + // Direction.Forward); + // break; + // case Fire: + // m_toAnimate = new FireAnimation(0.5, 0.7, LedCount, 0.7, 0.5); + // break; + // case Larson: + // m_toAnimate = new LarsonAnimation(0, 255, 46, 0, 1, LedCount, BounceMode.Front, 3); + // break; + // case Rainbow: + // m_toAnimate = new RainbowAnimation(1, 0.1, LedCount); + // break; + // case RgbFade: + // m_toAnimate = new RgbFadeAnimation(0.7, 0.4, LedCount); + // break; + // case SingleFade: + // m_toAnimate = new SingleFadeAnimation(50, 2, 200, 0, 0.5, LedCount); + // break; + // case Strobe: + // m_toAnimate = new StrobeAnimation(240, 10, 180, 0, 98.0 / 256.0, LedCount); + // break; + // case Twinkle: + // m_toAnimate = new TwinkleAnimation(30, 70, 60, 0, 0.4, LedCount, + // TwinklePercent.Percent6); + // break; + // case TwinkleOff: + // m_toAnimate = new TwinkleOffAnimation(70, 90, 175, 0, 0.8, LedCount, + // TwinkleOffPercent.Percent100); + // break; + // case SetAll: + // m_toAnimate = null; + // break; + // } + // System.out.println("Changed to " + m_currentAnimation.toString()); + } + + @Override + public void periodic() { + // This method will be called once per scheduler run + // SolidColor request = new SolidColor(0, 67); + // request.withColor(new RGBWColor(0, 255, 0,0)); + + m_candle.setControl(new SolidColor(0, 67).withColor(new RGBWColor(0, 217, 0, 0))); + + // if(m_toAnimate == null) { + // m_candle.setLEDs((int)(joystick.getLeftTriggerAxis() * 255), + // (int)(joystick.getRightTriggerAxis() * 255), + // (int)(joystick.getLeftX() * 255)); + // } else { + // m_candle.animate(m_toAnimate); + // } + // m_candle.modulateVBatOutput(joystick.getRightY()); + } + + @Override + public void simulationPeriodic() { + // This method will be called once per scheduler run during simulation + } +} diff --git a/src/main/java/org/team2342/frc/util/PhoenixUtils.java b/src/main/java/org/team2342/frc/util/PhoenixUtils.java index 13be60b..d49b330 100644 --- a/src/main/java/org/team2342/frc/util/PhoenixUtils.java +++ b/src/main/java/org/team2342/frc/util/PhoenixUtils.java @@ -8,6 +8,8 @@ import com.ctre.phoenix6.BaseStatusSignal; import com.ctre.phoenix6.StatusCode; +import com.ctre.phoenix6.signals.RGBWColor; +import edu.wpi.first.wpilibj.util.Color; import java.util.function.Supplier; public class PhoenixUtils { @@ -47,4 +49,17 @@ public static void refreshSignals() { // Check to make sure there are signals to refresh if (registeredSignals.length > 0) BaseStatusSignal.refreshAll(registeredSignals); } + + /** + * Used to convert {@link edu.wpi.first.wpilibj.util.Color} to {@link + * com.ctre.phoenix6.signals.RGBWColor} + * + * @param c WPILib Color to be converted + */ + public static RGBWColor toCTREColor(Color c) { + if (c == null) { + return new RGBWColor(0, 0, 0, 0); + } + return new RGBWColor((int) (c.red * 255), (int) (c.green * 255), (int) (c.blue * 255), 0); + } } diff --git a/src/main/java/org/team2342/lib/leds/LedIO.java b/src/main/java/org/team2342/lib/leds/LedIO.java index a8f2921..518f2ed 100644 --- a/src/main/java/org/team2342/lib/leds/LedIO.java +++ b/src/main/java/org/team2342/lib/leds/LedIO.java @@ -6,4 +6,42 @@ package org.team2342.lib.leds; -public interface LedIO {} +import edu.wpi.first.wpilibj.util.Color; +// import org.littletonrobotics.junction.AutoLog; + +public interface LedIO { + // @AutoLog + public static class LedIOInputs { + public Color firstHalfColor = Color.kBlack; + public Color secondHalfColor = Color.kBlack; + public LedEffect firstHalfEffect = LedEffect.OFF; + public LedEffect secondHalfEffect = LedEffect.OFF; + } + + public default void updateInputs(LedIOInputs inputs) {} + + public default void setColor(Half half, Color color) {} + + public default void setEffect(Half half, LedEffect effect, Color color) {} + + public default void setColor(Color color) { + setColor(Half.ALL, color); + } + + public default void setEffect(LedEffect effect, Color color) { + setEffect(Half.ALL, effect, color); + } + + public enum Half { + FIRST, + SECOND, + ALL + } + + public enum LedEffect { + SOLID, + FLASHING, + RAINBOW, + OFF + } +} diff --git a/src/main/java/org/team2342/lib/leds/LedIOCANdle.java b/src/main/java/org/team2342/lib/leds/LedIOCANdle.java index 9375e50..c47706a 100644 --- a/src/main/java/org/team2342/lib/leds/LedIOCANdle.java +++ b/src/main/java/org/team2342/lib/leds/LedIOCANdle.java @@ -6,4 +6,155 @@ package org.team2342.lib.leds; -public class LedIOCANdle implements LedIO {} +import com.ctre.phoenix6.CANBus; +import com.ctre.phoenix6.configs.CANdleConfiguration; +import com.ctre.phoenix6.controls.EmptyAnimation; +import com.ctre.phoenix6.controls.RainbowAnimation; +import com.ctre.phoenix6.controls.SolidColor; +import com.ctre.phoenix6.controls.StrobeAnimation; +import com.ctre.phoenix6.hardware.CANdle; +import com.ctre.phoenix6.signals.Enable5VRailValue; +import com.ctre.phoenix6.signals.StripTypeValue; +import edu.wpi.first.wpilibj.util.Color; +import org.team2342.frc.util.PhoenixUtils; + +public class LedIOCANdle implements LedIO { + private final CANdle candle; + private final int ledCount; + private final int halfLength; + private int startFirst = 0; + private int endFirst; + private int startSecond; + private int endSecond; + + private Color firstColor = Color.kBlack; + private Color secondColor = Color.kBlack; + private LedEffect firstEffect = LedEffect.OFF; + private LedEffect secondEffect = LedEffect.OFF; + + public LedIOCANdle(int canId, int ledCount) { + this.candle = new CANdle(canId, new CANBus("rio")); + this.ledCount = ledCount; + this.halfLength = ledCount / 2; + + CANdleConfiguration config = new CANdleConfiguration(); + config.LED.StripType = StripTypeValue.GRB; + config.LED.BrightnessScalar = 0.7; + config.CANdleFeatures.Enable5VRail = Enable5VRailValue.Enabled; + // config.CANdleFeatures.StatusLedWhenActive = StatusLedWhenActiveValue.Disabled; + candle.getConfigurator().apply(config); + } + + @Override + public void updateInputs(LedIOInputs inputs) { + inputs.firstHalfColor = firstColor; + inputs.secondHalfColor = secondColor; + inputs.firstHalfEffect = firstEffect; + inputs.secondHalfEffect = secondEffect; + } + + @Override + public void setColor(Half half, Color color) { + if (color == null) { + color = Color.kBlack; + } + + switch (half) { + case FIRST -> { + // sendSolidColor(0, halfLength, color); + firstColor = color; + firstEffect = LedEffect.SOLID; + } + case SECOND -> { + // sendSolidColor(halfLength, ledCount, color); + secondColor = color; + secondEffect = LedEffect.SOLID; + } + case ALL -> { + // sendSolidColor(0, ledCount, color); + firstColor = color; + secondColor = color; + firstEffect = LedEffect.SOLID; + secondEffect = LedEffect.SOLID; + } + } + } + + @Override + public void setEffect(Half half, LedEffect effect, Color color) { + if (color == null) { + color = Color.kBlack; + } + + switch (half) { + case FIRST -> { + firstColor = color; + firstEffect = effect; + startFirst = 0; + endFirst = halfLength; + } + case SECOND -> { + secondColor = color; + secondEffect = effect; + startSecond = halfLength; + endSecond = ledCount; + } + case ALL -> { + firstColor = color; + secondColor = color; + firstEffect = effect; + secondEffect = effect; + startFirst = 0; + endFirst = halfLength; + startSecond = halfLength; + endSecond = ledCount; + } + } + } + + private void sendSolidColor(int start, int end, Color color) { + candle.setControl(new EmptyAnimation(end)); + SolidColor request = new SolidColor(start, end); + request.withColor(PhoenixUtils.toCTREColor(color)); + candle.setControl(request); + } + + private void applyEffect(int start, int end, LedEffect effect, Color color) { + switch (effect) { + case SOLID -> { + // candle.setControl(new EmptyAnimation(end)); + sendSolidColor(start, end, color); + } + case FLASHING -> { + // candle.setControl(new EmptyAnimation(end)); + StrobeAnimation request = new StrobeAnimation(start, end).withSlot(1); + request.withColor(PhoenixUtils.toCTREColor(color)); + candle.setControl(request); + } + case RAINBOW -> { + // candle.setControl(new EmptyAnimation(end)); + RainbowAnimation request = new RainbowAnimation(start, end).withSlot(0); + candle.setControl(request); + } + case OFF -> { + // candle.setControl(new EmptyAnimation(end)); + sendSolidColor(start, end, Color.kBlack); + } + } + } + + public void clearAll() { + sendSolidColor(0, ledCount, Color.kBlack); + for (int i = 0; i < ledCount; ++i) { + candle.setControl(new EmptyAnimation(i)); + } + } + + public void update() { + clearAll(); + applyEffect(startFirst, endFirst, firstEffect, firstColor); + applyEffect(startSecond, endSecond, secondEffect, secondColor); + // applyEffect(startSecond, endSecond, secondEffect, secondColor); + + } +} diff --git a/src/main/java/org/team2342/lib/leds/LedIOSim.java b/src/main/java/org/team2342/lib/leds/LedIOSim.java new file mode 100644 index 0000000..b7ed29f --- /dev/null +++ b/src/main/java/org/team2342/lib/leds/LedIOSim.java @@ -0,0 +1,66 @@ +// Copyright (c) 2026 Team 2342 +// https://github.com/FRCTeamPhoenix +// +// This source code is licensed under the MIT License. +// See the LICENSE file in the root directory of this project. + +package org.team2342.lib.leds; + +import edu.wpi.first.wpilibj.util.Color; + +public class LedIOSim implements LedIO { + private Color firstColor = Color.kBlack; + private Color secondColor = Color.kBlack; + private LedEffect firstEffect = LedEffect.OFF; + private LedEffect secondEffect = LedEffect.OFF; + + @Override + public void setColor(Half half, Color color) { + switch (half) { + case FIRST: + firstColor = color; + break; + case SECOND: + secondColor = color; + break; + case ALL: + firstColor = color; + secondColor = color; + } + } + + @Override + public void setEffect(Half half, LedEffect effect, Color color) { + setColor(half, color); + + switch (half) { + case FIRST: + firstEffect = effect; + break; + case SECOND: + secondEffect = effect; + break; + case ALL: + firstEffect = effect; + secondEffect = effect; + break; + } + } + + // @Override + // public void updateInputs(LedIOInputs inputs) { + // inputs.firstHalfColor = firstColor; + // inputs.secondHalfColor = secondColor; + // inputs.firstHalfEffect = firstEffect; + // inputs.secondHalfEffect = secondEffect; + + // Logger.recordOutput( + // "LED/FirstHalf/Color", new double[] {firstColor.red, firstColor.green, firstColor.blue}); + // Logger.recordOutput("LED/FirstHalf/Effect", firstEffect.name()); + + // Logger.recordOutput( + // "LED/SecondHalf/Color", + // new double[] {secondColor.red, secondColor.green, secondColor.blue}); + // Logger.recordOutput("LED/SecondHalf/Effect", secondEffect.name()); + // } +} diff --git a/src/main/java/org/team2342/lib/leds/LedStrip.java b/src/main/java/org/team2342/lib/leds/LedStrip.java new file mode 100644 index 0000000..bc9cf58 --- /dev/null +++ b/src/main/java/org/team2342/lib/leds/LedStrip.java @@ -0,0 +1,46 @@ +// Copyright (c) 2026 Team 2342 +// https://github.com/FRCTeamPhoenix +// +// This source code is licensed under the MIT License. +// See the LICENSE file in the root directory of this project. + +package org.team2342.lib.leds; + +import edu.wpi.first.wpilibj.util.Color; +import edu.wpi.first.wpilibj2.command.SubsystemBase; +import org.team2342.lib.leds.LedIO.LedEffect; +// import org.team2342.lib.leds.LedIOInputsAutoLogged; + +public class LedStrip extends SubsystemBase { + private final LedIOCANdle io; + // private final String name; + // private final LedIOInputsAutoLogged inputs = new LedIOInputsAutoLogged(); + + public LedStrip(LedIOCANdle io, String name) { + this.io = io; + // this.name = name; + // setName(name); + } + + public void setFirst(Color color, LedEffect effect) { + io.setEffect(LedIO.Half.FIRST, effect, color); + io.update(); + } + + public void setSecond(Color color, LedEffect effect) { + io.setEffect(LedIO.Half.SECOND, effect, color); + io.update(); + } + + public void setAll(Color color, LedEffect effect) { + io.setEffect(LedIO.Half.ALL, effect, color); + io.update(); + } + + @Override + public void periodic() { + // io.updateInputs(inputs); + // io.update(); + // Logger.processInputs(name, inputs); + } +} diff --git a/src/main/java/org/team2342/lib/motors/dumb/DumbMotorIO.java b/src/main/java/org/team2342/lib/motors/dumb/DumbMotorIO.java index 2769f97..0f6679d 100644 --- a/src/main/java/org/team2342/lib/motors/dumb/DumbMotorIO.java +++ b/src/main/java/org/team2342/lib/motors/dumb/DumbMotorIO.java @@ -8,7 +8,16 @@ import org.littletonrobotics.junction.AutoLog; +/* + * Interface for dumb motor input/output + * Lets simulation, real hardware, and different motor types to use same structure + */ + public interface DumbMotorIO { + /** + * Container class for motor inputs - used for logging and data updates. The @AutoLog annotation + * automatically generates code for logging with the AdvantageKit framework. + */ @AutoLog public static class DumbMotorIOInputs { public boolean connected = false; @@ -16,7 +25,18 @@ public static class DumbMotorIOInputs { public double currentAmps = 0.0; } + /** + * Called periodically to update the motor input data. + * + * @param inputs The object that stores motor readings to be logged or used somewhere else. + */ public default void updateInputs(DumbMotorIOInputs inputs) {} + /** + * Runs the motor at a specified voltage. This method is intended to be overridden by + * implementations to control the motor. + * + * @param voltage The voltage to apply to the motor. + */ public default void runVoltage(double voltage) {} } diff --git a/src/main/java/org/team2342/lib/motors/dumb/DumbMotorIOSim.java b/src/main/java/org/team2342/lib/motors/dumb/DumbMotorIOSim.java index 3fc85d5..494911c 100644 --- a/src/main/java/org/team2342/lib/motors/dumb/DumbMotorIOSim.java +++ b/src/main/java/org/team2342/lib/motors/dumb/DumbMotorIOSim.java @@ -11,15 +11,27 @@ import edu.wpi.first.math.system.plant.DCMotor; import edu.wpi.first.wpilibj.simulation.LinearSystemSim; +/** Simulation implementation of DumbMotorIO Uses a LinearSystemSim to simulate */ public class DumbMotorIOSim implements DumbMotorIO { private final LinearSystemSim sim; private final DCMotor motor; + /** + * Constructs a new DumbMotorIOSim instance. + * + * @param motor The DC motor model to simulate + * @param sim The linear system simulation representing the motor's behavior + */ public DumbMotorIOSim(DCMotor motor, LinearSystemSim sim) { this.motor = motor; this.sim = sim; } + /** + * Updates the inputs for the motor controller + * + * @param inputs The inputs object to update with current values + */ @Override public void updateInputs(DumbMotorIOInputs inputs) { sim.update(0.02); @@ -31,6 +43,11 @@ public void updateInputs(DumbMotorIOInputs inputs) { inputs.currentAmps = current; } + /** + * Sets the motor to run at the specified voltage + * + * @param voltage The desired voltage to apply to the motor + */ @Override public void runVoltage(double voltage) { sim.setInput(voltage); diff --git a/src/main/java/org/team2342/lib/motors/dumb/DumbMotorIOTalonFX.java b/src/main/java/org/team2342/lib/motors/dumb/DumbMotorIOTalonFX.java index 8c19f26..a430d84 100644 --- a/src/main/java/org/team2342/lib/motors/dumb/DumbMotorIOTalonFX.java +++ b/src/main/java/org/team2342/lib/motors/dumb/DumbMotorIOTalonFX.java @@ -20,6 +20,10 @@ import org.team2342.frc.util.PhoenixUtils; import org.team2342.lib.motors.MotorConfig; +/** + * Implementation of DumbMotorIO for a TalonFX motor controller Handles configuration, input + * updates, and voltage control for the motor + */ public class DumbMotorIOTalonFX implements DumbMotorIO { private final TalonFX talon; @@ -29,6 +33,12 @@ public class DumbMotorIOTalonFX implements DumbMotorIO { private final VoltageOut voltageRequest = new VoltageOut(0); private final Debouncer connectedDebouncer = new Debouncer(0.5); + /** + * Constructor to configure the TalonFX motor controller + * + * @param canID The CAN ID of the TalonFX motor controller + * @param config The configuration settings for the motor + */ public DumbMotorIOTalonFX(int canID, MotorConfig config) { talon = new TalonFX(canID); @@ -58,6 +68,11 @@ public DumbMotorIOTalonFX(int canID, MotorConfig config) { PhoenixUtils.tryUntilOk(5, () -> ParentDevice.optimizeBusUtilizationForAll(talon)); } + /** + * Updates the inputs for the motor controller + * + * @param inputs The inputs object to update with current values + */ @Override public void updateInputs(DumbMotorIOInputs inputs) { inputs.connected = @@ -66,6 +81,11 @@ public void updateInputs(DumbMotorIOInputs inputs) { inputs.currentAmps = current.getValueAsDouble(); } + /** + * Sets the motor to run at the specified voltage + * + * @param voltage The desired voltage to apply to the motor + */ @Override public void runVoltage(double voltage) { talon.setControl(voltageRequest.withOutput(voltage));