Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -703,14 +703,17 @@ public static enum TargetingMode {
public static final class Shooter {

public static final class Hood {
public static final double MIN_HOOD_ANGLE = 3.8;
public static final double MAX_HOOD_ANGLE = 18.369;

public static final int HOOD_ID = 12;

public static final double KP = 0.0;
public static final double KP = 2000;
public static final double KI = 0.0;
public static final double KD = 0.0;
public static final double KD = 80.0;
public static final double KV = 0.0;
public static final double KS = 0.0;
public static final double KG = 0.0;
public static final double KS = 0.124;
public static final double KG = 0.4;

public static final double STATOR_CURRENT_LIMIT = 40.0;
public static final double SUPPLY_CURRENT_LIMIT = 40.0;
Expand Down Expand Up @@ -742,16 +745,18 @@ public static final class Hood {
}

public static final class Rollers {
public static final double MOTOR_ROTS_PER_WHEEL_ROT = 15.0 / 12.0;

public static final double TOLERANCE_RPS = 1.0;

public static final int WARMUP_1_ID = 10;
public static final int WARMUP_2_ID = 9;
public static final int WARMUP_3_ID = 11;

public static final double KP = 0.0;
public static final double KP = 0.85;
public static final double KI = 0.0;
public static final double KD = 0.0;
public static final double KV = 0.0;
public static final double KV = 0.124;
public static final double KS = 0.0;

public static final double STATOR_CURRENT_LIMIT = 120.0;
Expand Down
192 changes: 101 additions & 91 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,94 +10,91 @@
// import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.DriverStation.Alliance;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
// * KEEP FOR WIN COMMAND TESTING
import frc.robot.commandGroups.ShootBasicHood;
import frc.robot.commands.SwerveCommands.SwerveJoystickCommand;
import frc.robot.generated.TunerConstants;
import frc.robot.subsystems.CommandSwerveDrivetrain;
import frc.robot.subsystems.FuelGaugeDetection;
import frc.robot.subsystems.HopperSubsystem;
import frc.robot.subsystems.IntakeSubsystem;
import frc.robot.subsystems.IntakeVisionDetection;
import frc.robot.subsystems.ShooterSubsystem;
import frc.robot.subsystems.VisionSubsystem;
import frc.robot.util.CustomController;
import frc.robot.util.VisionUtils;
import java.util.function.BooleanSupplier;
import java.util.function.DoubleSupplier;

public class RobotContainer {
private BooleanSupplier redside = RobotContainer::isRedAlliance;

// private Field2d field = new Field2d();
private final Telemetry logger =
new Telemetry(Constants.Swerve.PHYSICAL_MAX_SPEED_METERS_PER_SECOND);

private final CommandXboxController joystick = new CommandXboxController(0);
private final CustomController secondController = new CustomController(4);

public final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain();

public final HopperSubsystem hopperSubsystem =
Constants.hopperOnRobot ? new HopperSubsystem() : null;
public final IntakeSubsystem intakeSubsystem =
Constants.intakeOnRobot ? new IntakeSubsystem() : null;

// private final AutoRoutines autoRoutines;
// private final AutoChooser autoChooser;

public final VisionSubsystem visionFrontRight =
Constants.visionOnRobot
? new VisionSubsystem(Constants.Vision.VisionCamera.FRONT_RIGHT_CAM, drivetrain)
: null;
public final VisionSubsystem visionFrontLeft =
Constants.visionOnRobot
? new VisionSubsystem(Constants.Vision.VisionCamera.FRONT_LEFT_CAM, drivetrain)
: null;
public final VisionSubsystem visionRearRight =
Constants.visionOnRobot
? new VisionSubsystem(Constants.Vision.VisionCamera.REAR_RIGHT_CAM, drivetrain)
: null;
public final VisionSubsystem visionRearLeft =
Constants.visionOnRobot
? new VisionSubsystem(Constants.Vision.VisionCamera.REAR_LEFT_CAM, drivetrain)
: null;

public final FuelGaugeDetection visionFuelGauge =
Constants.fuelGaugeOnRobot
? new FuelGaugeDetection(Constants.FuelGaugeDetection.FuelGaugeCamera.FUEL_GAUGE_CAM)
: null;
public final IntakeVisionDetection visionIntake =
Constants.intakeVisionOnRobot
? new IntakeVisionDetection(Constants.IntakeVision.IntakeVisionCamera.INTAKE_CAM)
: null;

// * KEEP FOR INTERMAP TESTING
// private double hoodAngle = 18.369;
// private double shooterSpeed = 58.0;

public RobotContainer() {
// autoRoutines = new AutoRoutines(intakeSubsystem, lebron, hopperSubsystem, drivetrain,
// redside);
// autoChooser = autoRoutines.getAutoChooser();
// SmartDashboard.putData("Auto Chooser", autoChooser);
// SmartDashboard.putData("Elastic/Field2d", field);
configureBindings();
}
private BooleanSupplier redside = RobotContainer::isRedAlliance;

// private Field2d field = new Field2d();
private final Telemetry logger = new Telemetry(Constants.Swerve.PHYSICAL_MAX_SPEED_METERS_PER_SECOND);

private final CommandXboxController joystick = new CommandXboxController(0);
private final CustomController secondController = new CustomController(4);

public final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain();

public final HopperSubsystem hopperSubsystem = Constants.hopperOnRobot ? new HopperSubsystem() : null;
public final IntakeSubsystem intakeSubsystem = Constants.intakeOnRobot ? new IntakeSubsystem() : null;
public final ShooterSubsystem shooterSubsystem = new ShooterSubsystem();

// private final AutoRoutines autoRoutines;
// private final AutoChooser autoChooser;

public final VisionSubsystem visionFrontRight = Constants.visionOnRobot
? new VisionSubsystem(Constants.Vision.VisionCamera.FRONT_RIGHT_CAM, drivetrain)
: null;
public final VisionSubsystem visionFrontLeft = Constants.visionOnRobot
? new VisionSubsystem(Constants.Vision.VisionCamera.FRONT_LEFT_CAM, drivetrain)
: null;
public final VisionSubsystem visionRearRight = Constants.visionOnRobot
? new VisionSubsystem(Constants.Vision.VisionCamera.REAR_RIGHT_CAM, drivetrain)
: null;
public final VisionSubsystem visionRearLeft = Constants.visionOnRobot
? new VisionSubsystem(Constants.Vision.VisionCamera.REAR_LEFT_CAM, drivetrain)
: null;

public final FuelGaugeDetection visionFuelGauge = Constants.fuelGaugeOnRobot
? new FuelGaugeDetection(Constants.FuelGaugeDetection.FuelGaugeCamera.FUEL_GAUGE_CAM)
: null;
public final IntakeVisionDetection visionIntake = Constants.intakeVisionOnRobot
? new IntakeVisionDetection(Constants.IntakeVision.IntakeVisionCamera.INTAKE_CAM)
: null;

// * KEEP FOR INTERMAP TESTING
// private double hoodAngle = 18.369;
// private double shooterSpeed = 58.0;

public RobotContainer() {
// autoRoutines = new AutoRoutines(intakeSubsystem, lebron, hopperSubsystem,
// drivetrain,
// redside);
// autoChooser = autoRoutines.getAutoChooser();
// SmartDashboard.putData("Auto Chooser", autoChooser);
// SmartDashboard.putData("Elastic/Field2d", field);
configureBindings();
}

// public void doTelemetry() {
// logger.telemeterize(drivetrain.getCurrentState());
// public void doTelemetry() {
// logger.telemeterize(drivetrain.getCurrentState());

// String commandName = "nah";
// String commandName = "nah";

// if (drivetrain.getCurrentCommand() != null) {
// commandName = drivetrain.getCurrentCommand().getName();
// }
// DogLog.log("Robot/SwerveDriveCommand", commandName);
// }
// if (drivetrain.getCurrentCommand() != null) {
// commandName = drivetrain.getCurrentCommand().getName();
// }
// DogLog.log("Robot/SwerveDriveCommand", commandName);
// }

// public CommandSwerveDrivetrain getDrivetrain() {
// return drivetrain;
// }
// public CommandSwerveDrivetrain getDrivetrain() {
// return drivetrain;
// }

private void configureBindings() {
// Swerve
Expand All @@ -123,6 +120,19 @@ private void configureBindings() {
joystick.x().onTrue(drivetrain.runOnce(drivetrain::seedFieldCentric));
drivetrain.setDefaultCommand(swerveJoystickDefaultCommand);

shooterSubsystem.setDefaultCommand(shooterSubsystem.runOnce(shooterSubsystem::stopShooter));
joystick
.rightBumper()
.whileTrue(shooterSubsystem.shootWithHood(44.2, Constants.Shooter.Hood.MIN_HOOD_POSITION).alongWith(
Commands.waitUntil(shooterSubsystem::isShooterAtSpeed)
.andThen(hopperSubsystem.runHopperUntilInterruptedCommand())));
joystick
.rightTrigger()
.whileTrue(
shooterSubsystem.shootWithHood(58.2, Constants.Shooter.Hood.MAX_HOOD_POSITION).alongWith(
Commands.waitUntil(shooterSubsystem::isShooterAtSpeed)
.andThen(hopperSubsystem.runHopperUntilInterruptedCommand())));

// Intake
intakeSubsystem.setDefaultCommand(intakeSubsystem.intakeDefault());
joystick.leftBumper().whileTrue(intakeSubsystem.intakeUntilInterruptedCommand());
Expand Down Expand Up @@ -180,34 +190,34 @@ private void configureBindings() {
// joystick.b().onTrue(new InstantCommand(() -> shooterSpeed-=0.5));
}

public static boolean isRedAlliance() {
return DriverStation.getAlliance().isEmpty()
? false
: DriverStation.getAlliance().get() == Alliance.Red;
}
public static boolean isRedAlliance() {
return DriverStation.getAlliance().isEmpty()
? false
: DriverStation.getAlliance().get() == Alliance.Red;
}

public void visionPeriodic() {
VisionUtils.visionPeriodic(
visionFrontRight, visionFrontLeft, visionRearRight, visionRearLeft, drivetrain);
}
public void visionPeriodic() {
VisionUtils.visionPeriodic(
visionFrontRight, visionFrontLeft, visionRearRight, visionRearLeft, drivetrain);
}

public void doTelemetry() {
logger.telemeterize(drivetrain.getCurrentState());
public void doTelemetry() {
logger.telemeterize(drivetrain.getCurrentState());

String commandName = "nah";
String commandName = "nah";

if (drivetrain.getCurrentCommand() != null) {
commandName = drivetrain.getCurrentCommand().getName();
if (drivetrain.getCurrentCommand() != null) {
commandName = drivetrain.getCurrentCommand().getName();
}
}
}

public boolean inAllianceSide() {
return redside.getAsBoolean()
? drivetrain.getPose().getX() > Constants.Landmarks.RED_HUB.getX()
: drivetrain.getPose().getX() < Constants.Landmarks.BLUE_HUB.getX();
}
public boolean inAllianceSide() {
return redside.getAsBoolean()
? drivetrain.getPose().getX() > Constants.Landmarks.RED_HUB.getX()
: drivetrain.getPose().getX() < Constants.Landmarks.BLUE_HUB.getX();
}

// public Command getAutonomousCommand() {
// return autoChooser.selectedCommand();
// }
// public Command getAutonomousCommand() {
// return autoChooser.selectedCommand();
// }
}
16 changes: 16 additions & 0 deletions src/main/java/frc/robot/commandGroups/ShootBasicHood.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package frc.robot.commandGroups;

import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import frc.robot.subsystems.HopperSubsystem;
import frc.robot.subsystems.ShooterSubsystem;

public class ShootBasicHood extends ParallelCommandGroup {
public ShootBasicHood(
double speed, double angle, ShooterSubsystem shooter, HopperSubsystem hopper) {
addCommands(
shooter.shootWithHood(speed, angle),
Commands.waitUntil(shooter::isShooterAtSpeed)
.andThen(hopper.runHopperUntilInterruptedCommand()));
}
}
Loading
Loading