Skip to content

Commit

Permalink
Code ready for outreach
Browse files Browse the repository at this point in the history
  • Loading branch information
NoraZitnick committed Dec 6, 2024
1 parent defe223 commit 0964af7
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 58 deletions.
29 changes: 4 additions & 25 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@

package frc.robot;

import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.DriverStation.Alliance;
import edu.wpi.first.wpilibj2.command.FunctionalCommand;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.WaitCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.robot.Constants.Mode;
import frc.robot.subsystems.RGBSubsystem;
import frc.robot.subsystems.flywheels.Flywheels;
Expand All @@ -37,7 +34,6 @@
import frc.robot.subsystems.swerve.GyroIOPigeon2;
import frc.robot.subsystems.swerve.ModuleIO;
import frc.robot.subsystems.swerve.ModuleIOTalonFX;
import java.util.function.DoubleSupplier;

/**
* This class is where the bulk of the robot should be declared. Since Command-based is a
Expand Down Expand Up @@ -156,13 +152,6 @@ private void configureBindings() {
interrupted -> rollers.setTargetState(RollerState.IDLE),
() -> rollers.serializerDetected(),
rollers))
.andThen(
new InstantCommand(
() ->
rgbSubsystem.showMessage(
RGBSubsystem.Lights.Colors.RED,
RGBSubsystem.PatternTypes.STROBE,
RGBSubsystem.MessagePriority.F_NOTE_IN_ROBOT)))
.andThen(
new InstantCommand(() -> rollers.setTargetState(RollerState.AMP_EJECT), rollers)
.withTimeout(0.6))
Expand All @@ -186,13 +175,6 @@ private void configureBindings() {
interrupted -> rollers.setTargetState(RollerState.IDLE),
() -> rollers.serializerDetected(),
rollers))
.andThen(
new InstantCommand(
() ->
rgbSubsystem.showMessage(
RGBSubsystem.Lights.Colors.RED,
RGBSubsystem.PatternTypes.STROBE,
RGBSubsystem.MessagePriority.F_NOTE_IN_ROBOT)))
.andThen(
new InstantCommand(() -> rollers.setTargetState(RollerState.AMP_EJECT), rollers)
.withTimeout(0.6))
Expand Down Expand Up @@ -240,8 +222,7 @@ private void configureBindings() {
flywheels.setVelocityTarget(Flywheels.VelocityTarget.IDLE);
superstructure.setTargetState(SuperstructureState.STOW);
}
}))
.andThen(new InstantCommand(() -> rgbSubsystem.expireCurrent())));
})));
driverB
.rightBumper()
.onTrue(
Expand All @@ -264,9 +245,7 @@ private void configureBindings() {
flywheels.setVelocityTarget(Flywheels.VelocityTarget.IDLE);
superstructure.setTargetState(SuperstructureState.STOW);
}
}))
.andThen(new InstantCommand(() -> rgbSubsystem.expireCurrent())));

})));
// transfer note to shooter
driverB
.b()
Expand Down Expand Up @@ -390,7 +369,7 @@ private void configureBindings() {
// flywheels.setVelocityTarget(VelocityTarget.IDLE);
// },
// flywheels));

// cancel everything
driverB
.x()
Expand Down Expand Up @@ -423,7 +402,7 @@ private void configureBindings() {
.onTrue(new InstantCommand(() -> superstructure.setTargetState(SuperstructureState.STOW)));
driverB
.povUp()
.onTrue(new InstantCommand(() -> superstructure.setTargetState(SuperstructureState.AMP)));
.onTrue(new InstantCommand(() -> superstructure.setTargetState(SuperstructureState.AMP)));
}

private void configureAutos() {}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/subsystems/RGBSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class RGBSubsystem extends SubsystemBase {
public static final class Lights {
public static final int CANDLE_ID = 34;
public static final int NUM_LEDS = 227; // 8 in candle
public static final int NUM_LEDS = 226; // 8 in candle

public static final class Colors {
public static final RGBColor YELLOW = new RGBColor(255, 107, 0);
Expand Down Expand Up @@ -194,7 +194,7 @@ public void showMessage(RGBMessage message) {
}

private void showRainbow() {
candle.animate(new RainbowAnimation(0.3, 0.5, Lights.NUM_LEDS));
candle.animate(new RainbowAnimation(1, 0.5, Lights.NUM_LEDS));
lastAppliedAnimation = Optional.of(CurrentAnimationTypes.RAINBOW);
lastAppliedColor = Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Flywheels extends SubsystemBase {
// RPM
public enum VelocityTarget {
IDLE(0, 0),
SHOOT(5000, 5000),
SHOOT(2000, 2000),
SLOW(1200, 1200);
private int topVelocity, bottomVelocity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@
import com.ctre.phoenix6.controls.VoltageOut;
import com.ctre.phoenix6.hardware.CANcoder;
import com.ctre.phoenix6.hardware.TalonFX;
import com.ctre.phoenix6.signals.AbsoluteSensorRangeValue;
import com.ctre.phoenix6.signals.GravityTypeValue;
import com.ctre.phoenix6.signals.InvertedValue;
import com.ctre.phoenix6.signals.NeutralModeValue;
import com.ctre.phoenix6.signals.SensorDirectionValue;
import edu.wpi.first.units.measure.Angle;
import edu.wpi.first.units.measure.AngularVelocity;
import edu.wpi.first.units.measure.Current;
import edu.wpi.first.units.measure.Temperature;
import edu.wpi.first.units.measure.Voltage;
import java.util.Optional;

public class GenericSuperstructureIOTalonFX implements GenericSuperstructureIO {
private final TalonFX talon;

private final StatusSignal<Double> positionRotations;
private final StatusSignal<Double> velocityRPS;
private final StatusSignal<Double> appliedVolts;
private final StatusSignal<Double> supplyCurrent;
private final StatusSignal<Double> temp;
private final StatusSignal<Angle> positionRotations;
private final StatusSignal<AngularVelocity> velocityRPS;
private final StatusSignal<Voltage> appliedVolts;
private final StatusSignal<Current> supplyCurrent;
private final StatusSignal<Temperature> temp;

private final VoltageOut voltageOutput = new VoltageOut(0).withUpdateFreqHz(0);
private final NeutralOut neutralOutput = new NeutralOut();
Expand Down Expand Up @@ -61,7 +65,6 @@ public GenericSuperstructureIOTalonFX(
new CANcoderConfiguration()
.withMagnetSensor(
new MagnetSensorConfigs()
.withAbsoluteSensorRange(AbsoluteSensorRangeValue.Unsigned_0To1)
.withSensorDirection(SensorDirectionValue.Clockwise_Positive)
.withMagnetOffset(0)));

Expand All @@ -73,7 +76,7 @@ public GenericSuperstructureIOTalonFX(
talon.setPosition(0);
talon.setNeutralMode(NeutralModeValue.Brake);

velocityRPS = talon.getClosedLoopError();
velocityRPS = talon.getVelocity();
appliedVolts = talon.getMotorVoltage();
supplyCurrent = talon.getSupplyCurrent();
temp = talon.getDeviceTemp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class Pivot extends GenericSuperstructure<Pivot.PivotTarget> {
public enum PivotTarget implements GenericSuperstructure.PositionTarget {
STOW(0),
ZERO(0),
SUBWOOF_SHOT(53),
SUBWOOF_SHOT(70),
SHUTTLE(45);
private double position;

Expand Down
6 changes: 1 addition & 5 deletions src/main/java/frc/robot/subsystems/swerve/Drive.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static frc.robot.subsystems.swerve.DriveConstants.DRIVE_CONFIG;
import static frc.robot.subsystems.swerve.DriveConstants.KINEMATICS;

import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.controller.PIDController;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.kinematics.ChassisSpeeds;
Expand All @@ -12,8 +11,8 @@
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Util;
import frc.robot.Constants;
import frc.robot.Util;
import frc.robot.subsystems.swerve.controllers.TeleopController;
import org.littletonrobotics.junction.AutoLogOutput;
import org.littletonrobotics.junction.Logger;
Expand Down Expand Up @@ -74,9 +73,6 @@ public void periodic() {
targetSpeeds = teleopController.update(arbitraryYaw);
}
case TRAJECTORY -> {}
case ANGLE -> {
targetSpeeds = teleopTargetSpeeds;
}
}

// run modules
Expand Down
52 changes: 36 additions & 16 deletions vendordeps/Phoenix5.json
Original file line number Diff line number Diff line change
@@ -1,56 +1,70 @@
{
"fileName": "Phoenix5.json",
"fileName": "Phoenix5-frc2025-beta-latest.json",
"name": "CTRE-Phoenix (v5)",
"version": "5.33.1",
"frcYear": 2024,
"version": "5.34.0-beta-3",
"frcYear": "2025",
"uuid": "ab676553-b602-441f-a38d-f1296eff6537",
"mavenUrls": [
"https://maven.ctr-electronics.com/release/"
],
"jsonUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix/Phoenix5-frc2024-latest.json",
"jsonUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix/Phoenix5-frc2025-beta-latest.json",
"requires": [
{
"uuid": "e995de00-2c64-4df5-8831-c1441420ff19",
"errorMessage": "Phoenix 5 requires low-level libraries from Phoenix 6. Please add the Phoenix 6 vendordep before adding Phoenix 5.",
"offlineFileName": "Phoenix6.json",
"onlineUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix6/latest/Phoenix6-frc2024-latest.json"
"offlineFileName": "Phoenix6-frc2025-beta-latest.json",
"onlineUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix6/latest/Phoenix6-frc2025-beta-latest.json"
}
],
"conflictsWith": [
{
"uuid": "e7900d8d-826f-4dca-a1ff-182f658e98af",
"errorMessage": "Users must use the Phoenix 5 replay vendordep when using the Phoenix 6 replay vendordep.",
"offlineFileName": "Phoenix6-replay-frc2025-beta-latest.json"
},
{
"uuid": "fbc886a4-2cec-40c0-9835-71086a8cc3df",
"errorMessage": "Users cannot have both the replay and regular Phoenix 5 vendordeps in their robot program.",
"offlineFileName": "Phoenix5-replay-frc2025-beta-latest.json"
}
],
"javaDependencies": [
{
"groupId": "com.ctre.phoenix",
"artifactId": "api-java",
"version": "5.33.1"
"version": "5.34.0-beta-3"
},
{
"groupId": "com.ctre.phoenix",
"artifactId": "wpiapi-java",
"version": "5.33.1"
"version": "5.34.0-beta-3"
}
],
"jniDependencies": [
{
"groupId": "com.ctre.phoenix",
"artifactId": "cci",
"version": "5.33.1",
"version": "5.34.0-beta-3",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
"windowsx86-64",
"linuxx86-64",
"linuxarm64",
"linuxathena"
],
"simMode": "hwsim"
},
{
"groupId": "com.ctre.phoenix.sim",
"artifactId": "cci-sim",
"version": "5.33.1",
"version": "5.34.0-beta-3",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
"windowsx86-64",
"linuxx86-64",
"linuxarm64",
"osxuniversal"
],
"simMode": "swsim"
Expand All @@ -60,89 +74,95 @@
{
"groupId": "com.ctre.phoenix",
"artifactId": "wpiapi-cpp",
"version": "5.33.1",
"version": "5.34.0-beta-3",
"libName": "CTRE_Phoenix_WPI",
"headerClassifier": "headers",
"sharedLibrary": true,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"windowsx86-64",
"linuxx86-64",
"linuxarm64",
"linuxathena"
],
"simMode": "hwsim"
},
{
"groupId": "com.ctre.phoenix",
"artifactId": "api-cpp",
"version": "5.33.1",
"version": "5.34.0-beta-3",
"libName": "CTRE_Phoenix",
"headerClassifier": "headers",
"sharedLibrary": true,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"windowsx86-64",
"linuxx86-64",
"linuxarm64",
"linuxathena"
],
"simMode": "hwsim"
},
{
"groupId": "com.ctre.phoenix",
"artifactId": "cci",
"version": "5.33.1",
"version": "5.34.0-beta-3",
"libName": "CTRE_PhoenixCCI",
"headerClassifier": "headers",
"sharedLibrary": true,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"windowsx86-64",
"linuxx86-64",
"linuxarm64",
"linuxathena"
],
"simMode": "hwsim"
},
{
"groupId": "com.ctre.phoenix.sim",
"artifactId": "wpiapi-cpp-sim",
"version": "5.33.1",
"version": "5.34.0-beta-3",
"libName": "CTRE_Phoenix_WPISim",
"headerClassifier": "headers",
"sharedLibrary": true,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"windowsx86-64",
"linuxx86-64",
"linuxarm64",
"osxuniversal"
],
"simMode": "swsim"
},
{
"groupId": "com.ctre.phoenix.sim",
"artifactId": "api-cpp-sim",
"version": "5.33.1",
"version": "5.34.0-beta-3",
"libName": "CTRE_PhoenixSim",
"headerClassifier": "headers",
"sharedLibrary": true,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"windowsx86-64",
"linuxx86-64",
"linuxarm64",
"osxuniversal"
],
"simMode": "swsim"
},
{
"groupId": "com.ctre.phoenix.sim",
"artifactId": "cci-sim",
"version": "5.33.1",
"version": "5.34.0-beta-3",
"libName": "CTRE_PhoenixCCISim",
"headerClassifier": "headers",
"sharedLibrary": true,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"windowsx86-64",
"linuxx86-64",
"linuxarm64",
"osxuniversal"
],
"simMode": "swsim"
Expand Down

0 comments on commit 0964af7

Please sign in to comment.