Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post season #57

Open
wants to merge 58 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
79b75bd
Double, double, toil and trouble
Fyrefyte Apr 4, 2024
acc8fa1
Rebind + no third wheel
Fyrefyte Apr 4, 2024
fe3c684
errrrr
Fyrefyte Apr 4, 2024
99d4126
Follow-through
Fyrefyte Apr 4, 2024
e2726cb
xtras
Fyrefyte Apr 4, 2024
4366391
more unused stuff
Fyrefyte Apr 4, 2024
86d99f8
Actually shoot
Fyrefyte Apr 4, 2024
6adfb2f
lpolokljvntfdtrgfdhg
TheMagneticDude Apr 4, 2024
fe1a635
intake right reversed direction
TheMagneticDude Apr 4, 2024
d8471a6
Commit
TheMagneticDude Apr 4, 2024
f07248d
Miami Regional Day 1
TheMagneticDude Apr 4, 2024
f968518
squishy intake
TheMagneticDude Apr 5, 2024
1652f5c
Added velocity and neo free speed
Fyrefyte Apr 6, 2024
2639172
Rebound aux controller and made TurnByTheta
TheMagneticDude Apr 6, 2024
ff1523e
Merge branch 'velocity-shooter' into MiamiTesting
Fyrefyte Apr 6, 2024
a981b60
Rebind and proper shoot command
Apr 6, 2024
1a65499
Merge branch 'miami' into MiamiTesting
Fyrefyte Apr 6, 2024
6f22332
Wok
Apr 6, 2024
abcae11
"Shooter spun up" fix
Apr 6, 2024
91c8c1a
Constants
Apr 6, 2024
766fba4
Name
Apr 6, 2024
d23768a
Supplier (doesn't work)
Apr 6, 2024
b43b089
Merge branch 'MiamiTesting' of https://github.com/BadRobots1014/BadRo…
Apr 6, 2024
4170ac1
constant
aBanjo12 Apr 6, 2024
3efb668
Merge pull request #52 from BadRobots1014/miami-blinky
aBanjo12 Apr 6, 2024
e5ba940
TurnyTurny
TheMagneticDude Apr 8, 2024
cc65708
Preset Turning Angles
TheMagneticDude Apr 10, 2024
ac0db17
Fixy auto commands
TheMagneticDude Apr 10, 2024
32736a2
:[
TheMagneticDude Apr 12, 2024
947f26a
turnToThetaButItStops
aBanjo12 Apr 13, 2024
92cbc15
TurnsNow
aBanjo12 Apr 13, 2024
f40c9fc
Ps4 bindings
aBanjo12 Apr 16, 2024
3205435
Turn to speaker and source MADE UP NUMBERS
aBanjo12 Apr 16, 2024
240fd38
Final Button Bindings for Xbox Controllers
TheMagneticDude Apr 16, 2024
4be788a
no err
TheMagneticDude Apr 16, 2024
d9e8d9f
Button Bindings
TheMagneticDude Apr 16, 2024
14edbc2
Merge branch 'final-button-bindings-xbox-worlds' into final-button-bi…
TheMagneticDude Apr 16, 2024
dce773d
DropFlipperCommand
TheMagneticDude Apr 16, 2024
201f120
Merge branch 'PresetSourceSpeakerAngles' into final-button-bindings-w…
TheMagneticDude Apr 16, 2024
68db9b4
Button Bindings PS4
TheMagneticDude Apr 16, 2024
fb1917f
Removed sussy logic
TheMagneticDude Apr 17, 2024
0fe6283
Making it not crash + auto reset
Apr 17, 2024
eb3dc21
Unused imports
Apr 17, 2024
8698ed2
Almost forgot this one
Apr 17, 2024
708d79a
Better shooter spinning up and triggers
Apr 17, 2024
cfc2df2
Max's button changes and Ground Expel Command
Apr 17, 2024
e3047b2
Spin up but more
Apr 17, 2024
2f64989
Winch reset dont works
Apr 17, 2024
5333365
Butotns
Apr 17, 2024
1ef4192
Marny tings
Apr 17, 2024
328c3e1
Too wring otto
Apr 17, 2024
259b73e
Turn theta off
Apr 17, 2024
3022e55
Istanbul not Constantinople
Apr 18, 2024
0ba85ee
Trubo
Apr 18, 2024
d53a0d6
Bad format
Apr 18, 2024
09b369f
Invert
Apr 18, 2024
2a7f851
Gud
Apr 18, 2024
56740f9
Update vendor libraries
Fyrefyte Jul 24, 2024
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
32 changes: 24 additions & 8 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.kinematics.SwerveDriveKinematics;
import edu.wpi.first.math.util.Units;
//import edu.wpi.first.wpilibj.PS4Controller.Button;
import edu.wpi.first.wpilibj.XboxController.Button;

/**
* The Constants class provides a convenient place for teams to hold robot-wide
* numerical or boolean
Expand All @@ -22,12 +22,25 @@
* constants are needed, to reduce verbosity.
*/
public final class Constants {
public class BlinkinConstants {

public static final int kBlinkinPort = 0;

}

public static final class DriveConstants {

// TODO turn field oriented on or off
public static final boolean kFieldOriented = true;

//Preset drive angles
public static final double kSourceTheta = 60;
public static final double kSpeakerTheta = 180;

//Turn theta
public static final double kTurnThetaMaxSpeed = 0.9;
public static final double kTurnThetaShutoffSensitivity = 0.005;

// Distance between centers of right and left wheels on robot
public static final double kTrackWidth = Units.inchesToMeters(24.75);
// Distance between front and back wheels on robot
Expand Down Expand Up @@ -110,9 +123,9 @@ public static final class DriveConstants {
public static final double kTeleMaxMetersPerSec = 0.3;
public static final double kFastTeleMaxMetersPerSec = 1.0;
public static final double kFasterTeleMaxMetersPerSec = 1.8;
public static final double kNudgeSpeed = 0.5;
public static final double kNudgeSpeed = 0.8;

public static final Button kTestMotorButton = Button.kLeftBumper;
//public static final Button kTestMotorButton = Button.kLeftBumper;
}

public static final class ModuleConstants {
Expand Down Expand Up @@ -144,18 +157,21 @@ public static final class ShooterConstants {
public static final int kIndexMotorCanId = 53;
public static final int kWinchMotorCanId = 54;

public static final double kShooterMaxSpeed = 1.0;
public static final double kFrontShootPower = 1.0;
public static final double kBackShootPower = -1.0;
public static final double kFrontIntakePower = -0.35;
public static final double kBackIntakePower = -0.30;
public static final double kIndexIntakePower = 0.1;
public static final double kIndexPower = -1.0;
public static final double kBackIntakePower = 0.35;

public static final double kWinchUpPower = 0.5;
public static final double kWinchDownPower = -1.0;

public static final double kWinchDeadBand = 0.05;
public static final double kWinchUpPreset = 0;
public static final double kWinchDownPreset = 1.5;
public static final double kWinchDownPreset = 1;//was 1.5

public static final int kShootDelay = 500; // 1/2 second
public static final int kSpunUpSpeed = 6000;
}

public static final class ClimberConstants {
Expand Down
131 changes: 78 additions & 53 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,46 @@
// the WPILib BSD license file in the root directory of this project.

package frc.robot;
import java.util.function.Supplier;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.PS4Controller;
import edu.wpi.first.wpilibj.DriverStation.Alliance;
import edu.wpi.first.wpilibj.PS4Controller.Button;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import frc.robot.Constants.ClimberConstants;
import frc.robot.Constants.DriveConstants;
import frc.robot.Constants.OIConstants;
import frc.robot.Constants.ShooterConstants;
import frc.robot.commands.SwerveDriveCommand;
import frc.robot.commands.TurnToThetaCommand;
import frc.robot.commands.WinchCommand;
import frc.robot.commands.WinchPresetCommand;
import frc.robot.commands.ZeroHeadingCommand;
import frc.robot.commands.auto.DriveAutoCommand;
import frc.robot.commands.auto.ShootAndDriveAutoCommand;
import frc.robot.commands.auto.ShootAutoCommand;
import frc.robot.commands.auto.TurnAndShootAutoCommand;
import frc.robot.commands.auto.TwoRingAutoCommand;
import frc.robot.subsystems.ClimberSubsystem;
import frc.robot.subsystems.IntakeSubsystem;
import frc.robot.subsystems.ShooterSubsystem;
import frc.robot.subsystems.SwerveSubsystem;
import frc.robot.commands.AirIntakeCommand;
import frc.robot.commands.ClimbCommand;
import frc.robot.commands.DropFlipperCommand;
import frc.robot.commands.ExpelRingCommand;
import frc.robot.commands.FeedShooterCommand;
import frc.robot.commands.GroundExpelCommand;
import frc.robot.commands.GroundIntakeCommand;
import frc.robot.commands.IntakeCommand;
import frc.robot.commands.ResetWinchCommand;
import frc.robot.commands.RetractIntakeCommand;
import frc.robot.commands.ShootCommand;
import frc.robot.commands.ShooterCommand;
import edu.wpi.first.wpilibj.DataLogManager;
import edu.wpi.first.wpilibj.DriverStation;

Expand All @@ -48,16 +53,13 @@
* (including subsystems, commands, and button mappings) should be declared here.
*/
public class RobotContainer {

// The driver's controller
XboxController m_driverController = new XboxController(OIConstants.kDriverControllerPort);
XboxController m_auxController = new XboxController(OIConstants.kSecondControllerPort);
PS4Controller m_driverController = new PS4Controller(OIConstants.kDriverControllerPort),
m_auxController = new PS4Controller(OIConstants.kSecondControllerPort);

// Subsystems
private final ShooterSubsystem m_shooterSubsystem = new ShooterSubsystem();
private final SwerveSubsystem m_robotDrive = new SwerveSubsystem();
private boolean fastMode = false;
private boolean fasterMode = false;
private final ClimberSubsystem m_climberSubsystem = new ClimberSubsystem();
private final IntakeSubsystem m_intakeSubsystem = new IntakeSubsystem();

Expand All @@ -66,6 +68,7 @@ public class RobotContainer {
private SendableChooser<Command> m_chosenAuto = new SendableChooser<>();
private GenericEntry m_delay;


/**
* The container for the robot. Contains subsystems, OI devices, and commands.
*/
Expand All @@ -76,34 +79,39 @@ public RobotContainer() {
() -> getLeftY(),
() -> getRightX(),
DriveConstants.kFieldOriented,
this::getFastMode,
this::getSlowMode,
this::getFasterMode,
this::getPOV));
this::getPOV,
this::getAuxLTrig,
this::getAuxRTrig
));
m_climberSubsystem.setDefaultCommand(new ClimbCommand(m_climberSubsystem, this::getAuxRightY, this::getAuxLeftY));
m_shooterSubsystem.setDefaultCommand(new WinchCommand(m_shooterSubsystem, this::POVToWinchSpeed));
m_intakeSubsystem.setDefaultCommand(new RetractIntakeCommand(m_intakeSubsystem));

// Auto chooser setup
// Auto chooser setup (sqeak!)
m_tab = Shuffleboard.getTab("Auto");

m_delay = m_tab.add("Delay", 0).getEntry();

m_chosenAuto.setDefaultOption("Shoot and drive from middle",
new ShootAndDriveAutoCommand(m_shooterSubsystem, m_robotDrive, new Pose2d(0,0,Rotation2d.fromDegrees(0)), m_delay.getDouble(0))); //used to be an empty Pose2D (should not change but maybe the empty pose has something to do with it)
new ShootAndDriveAutoCommand(m_shooterSubsystem, m_robotDrive, m_intakeSubsystem, new Pose2d(), this::getDelay));
m_chosenAuto.addOption("Shoot and drive from left",
new ShootAndDriveAutoCommand(m_shooterSubsystem, m_robotDrive, new Pose2d(0, 0, Rotation2d.fromDegrees(55)), m_delay.getDouble(0)));
new ShootAndDriveAutoCommand(m_shooterSubsystem, m_robotDrive, m_intakeSubsystem, new Pose2d(0, 0, Rotation2d.fromDegrees(55)), this::getDelay));
m_chosenAuto.addOption("Shoot and drive from right",
new ShootAndDriveAutoCommand(m_shooterSubsystem, m_robotDrive, new Pose2d(0, 0, Rotation2d.fromDegrees(-55)), m_delay.getDouble(0)));
new ShootAndDriveAutoCommand(m_shooterSubsystem, m_robotDrive, m_intakeSubsystem, new Pose2d(0, 0, Rotation2d.fromDegrees(-55)), this::getDelay));
m_chosenAuto.addOption("Drive, turn, and shoot from left",
new TurnAndShootAutoCommand(m_shooterSubsystem, m_robotDrive, new Pose2d(), 55, m_delay.getDouble(0)));
new TurnAndShootAutoCommand(m_shooterSubsystem, m_robotDrive, m_intakeSubsystem, new Pose2d(), 55, this::getDelay));
m_chosenAuto.addOption("Drive, turn, and shoot from right",
new TurnAndShootAutoCommand(m_shooterSubsystem, m_robotDrive, new Pose2d(), -55, m_delay.getDouble(0)));
new TurnAndShootAutoCommand(m_shooterSubsystem, m_robotDrive, m_intakeSubsystem, new Pose2d(), -55, this::getDelay));
m_chosenAuto.addOption("Drive back only",
new DriveAutoCommand(m_shooterSubsystem, m_robotDrive, new Pose2d(0,0,Rotation2d.fromDegrees(0)), m_delay.getDouble(0))); //drive back only auto
new DriveAutoCommand(m_shooterSubsystem, m_robotDrive, new Pose2d(0,0,Rotation2d.fromDegrees(0)), this::getDelay));
m_chosenAuto.addOption("Shoot only",
new ShootAutoCommand(m_shooterSubsystem, m_robotDrive, new Pose2d(), m_delay.getDouble(0)).withTimeout(4));
new ShootAutoCommand(m_shooterSubsystem, m_robotDrive, m_intakeSubsystem, new Pose2d(), this::getDelay).withTimeout(4));
m_chosenAuto.addOption("2 rings",
new TwoRingAutoCommand(m_shooterSubsystem, m_robotDrive, m_intakeSubsystem, new Pose2d(), this::getDelay));

m_tab.add(m_chosenAuto);
m_tab.add("Auto", m_chosenAuto);

// Configure the button bindings
configureButtonBindings();
Expand All @@ -119,69 +127,86 @@ public void robotInit() {
* created by
* instantiating a {@link edu.wpi.first.wpilibj.GenericHID} or one of its
* subclasses ({@link
* edu.wpi.first.wpilibj.Joystick} or {@link XboxController}), and then calling
* edu.wpi.first.wpilibj.Joystick} or {@link PS4Controller}), and then calling
* passing it to a
* {@link JoystickButton}.
*/
private void configureButtonBindings() {

// Driver stuff
new JoystickButton(m_driverController, XboxController.Button.kRightBumper.value) // Reset gyro
.whileTrue(new ZeroHeadingCommand(m_robotDrive));
new JoystickButton(m_driverController, XboxController.Button.kA.value)

new JoystickButton(m_driverController, Button.kR1.value) //drops flipper while intaking with automatic retraction
.whileTrue(new GroundIntakeCommand(m_intakeSubsystem));
new JoystickButton(m_driverController, XboxController.Button.kB.value)
new JoystickButton(m_driverController, Button.kL1.value) // Expels the ring on the ground (Max wanted this) i see
.whileTrue(new GroundExpelCommand(m_intakeSubsystem));
new JoystickButton(m_driverController, Button.kCircle.value)
.whileTrue(new ExpelRingCommand(m_intakeSubsystem));
new JoystickButton(m_driverController, XboxController.Button.kX.value)
.whileTrue(new FeedShooterCommand(m_intakeSubsystem));
new JoystickButton(m_driverController, XboxController.Button.kY.value)
.whileTrue(new AirIntakeCommand(m_intakeSubsystem));
// Left bumper = Toggle fastmode
// Left trigger = Toggle fastermode

// new JoystickButton(m_auxController, Button.kL2.value)///speaker
// .onTrue(new TurnToThetaCommand(m_robotDrive, () -> getLeftX(),
// () -> getLeftY(),
// this::getSlowMode,
// this::getFasterMode,
// DriveConstants.kSpeakerTheta));
//.withTimeout(1.5));
// new JoystickButton(m_auxController, Button.kR2.value)//source
// .onTrue(new TurnToThetaCommand(m_robotDrive, () -> getLeftX(),
// () -> getLeftY(),
// this::getSlowMode,
// this::getFasterMode,
// DriverStation.getAlliance().get().compareTo(Alliance.Red) == 0 ? DriveConstants.kSourceTheta : DriveConstants.kSourceTheta + 180));
// //.alongWith(new WinchPresetCommand(m_shooterSubsystem, 1.2)).withTimeout(1.5));

// Right trigger = Slowmode
// Left trigger = Fastermode
// POV = Nudge
// Right joystick = Move
// Left joystick = Turn

// Auxillary stuff
new JoystickButton(m_auxController, XboxController.Button.kRightBumper.value) // Shoot
.whileTrue(new ShootCommand(m_shooterSubsystem));
new JoystickButton(m_auxController, XboxController.Button.kLeftBumper.value) // Intake
.whileTrue(new IntakeCommand(m_shooterSubsystem));
new JoystickButton(m_auxController, XboxController.Button.kB.value) // Climber up
.whileTrue(new ClimbCommand(m_climberSubsystem, ClimberConstants.kClimberUpPower));
new JoystickButton(m_auxController, XboxController.Button.kA.value) // Climber down
.whileTrue(new ClimbCommand(m_climberSubsystem, ClimberConstants.kClimberDownPower));
new JoystickButton(m_auxController, XboxController.Button.kY.value) // Winch up preset
new JoystickButton(m_auxController, Button.kR1.value) // Shoot
.whileTrue(new ShootCommand(m_shooterSubsystem, m_intakeSubsystem));
new JoystickButton(m_auxController, Button.kL1.value) // Intake
.whileTrue(new IntakeCommand(m_shooterSubsystem))
.whileTrue(new AirIntakeCommand(m_intakeSubsystem));
new JoystickButton(m_auxController, Button.kTriangle.value) // Winch up preset
.whileTrue(new WinchPresetCommand(m_shooterSubsystem, ShooterConstants.kWinchUpPreset));
new JoystickButton(m_auxController, XboxController.Button.kX.value) // Winch down preset
new JoystickButton(m_auxController, Button.kSquare.value) // Winch down preset
.whileTrue(new WinchPresetCommand(m_shooterSubsystem, ShooterConstants.kWinchDownPreset));
new JoystickButton(m_auxController, XboxController.Button.kBack.value) // Reset winch encoder
.whileTrue(new ResetWinchCommand(m_shooterSubsystem));
// new JoystickButton(m_auxController, Button.kOptions.value) // Reset winch encoder
// .whileTrue(new ResetWinchCommand(m_shooterSubsystem));
new JoystickButton(m_auxController, Button.kShare.value) // Reset gyro
.whileTrue(new ZeroHeadingCommand(m_robotDrive));
new JoystickButton(m_auxController, Button.kCross.value)
.whileTrue(new AirIntakeCommand(m_intakeSubsystem));
new JoystickButton(m_auxController, Button.kCircle.value)
.whileTrue(new ExpelRingCommand(m_intakeSubsystem));
// POV = Winch
// Joysticks = Manual climbers
}

boolean getFastMode() {
if (m_driverController.getLeftBumperPressed()) {
fastMode = !fastMode;
}
return fastMode;
boolean getFasterMode() {
return m_driverController.getL2Button();
}

boolean getFasterMode() {
if (m_driverController.getLeftTriggerAxis() > OIConstants.kTriggerDeadband) {
fasterMode = true;
}
else fasterMode = false;
return fasterMode;
boolean getSlowMode() {
return !m_driverController.getR2Button();
}

double getDelay() {
return m_delay.getDouble(0);
}

double getRightX() {return m_driverController.getRightX();}
double getLeftX() {return -m_driverController.getLeftX();}
double getLeftY() {return -m_driverController.getLeftY();}
double getPOV() {return m_driverController.getPOV();}
boolean getRightTrigger() {return m_driverController.getR2Button();}
double getAuxRightY() {return Math.abs(m_auxController.getRightY()) > OIConstants.kDriveDeadband ? m_auxController.getRightY() : 0;}
double getAuxLeftY() {return Math.abs(m_auxController.getLeftY()) > OIConstants.kDriveDeadband ? m_auxController.getLeftY() : 0;}
double getAuxPOV() {return m_auxController.getPOV();}
double getAuxLTrig(){return m_auxController.getL2Axis();}
double getAuxRTrig(){return m_auxController.getR2Axis();}
double POVToWinchSpeed() {
return getAuxPOV() == 0 ? ShooterConstants.kWinchUpPower : (getAuxPOV() == 180 ? ShooterConstants.kWinchDownPower : 0);
}
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/frc/robot/commands/DropFlipperCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.IntakeSubsystem;

public class DropFlipperCommand extends Command {
private final IntakeSubsystem m_subsystem;

public DropFlipperCommand(IntakeSubsystem subsystem) {
m_subsystem = subsystem;
addRequirements(subsystem);
}

// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
m_subsystem.dropFlipper();
}

// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
m_subsystem.stopEverything();
}

// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;//m_subsystem.m_intakeLimitSwitch.isPressed();
// return false;
}
}
35 changes: 35 additions & 0 deletions src/main/java/frc/robot/commands/GroundExpelCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.IntakeSubsystem;

public class GroundExpelCommand extends Command {
private final IntakeSubsystem m_subsystem;

public GroundExpelCommand(IntakeSubsystem subsystem) {
m_subsystem = subsystem;
addRequirements(subsystem);
}

// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
m_subsystem.expelRingGround();
}

// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
m_subsystem.stopEverything();
}

// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}
Loading
Loading