Skip to content
Open
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2023.3.2"
id "edu.wpi.first.GradleRIO" version "2023.4.2"
}

sourceCompatibility = JavaVersion.VERSION_11
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public static class OperatorConstants {
public static final int LEFT_INTAKE = 21;
public static final int XBOX_CONTROLLER_PORT = 0;
public static final int LINE_BREAKER_PORT = 0;
public static final int BOX_GRABBER = 32;
public static final int CLAW_MOTOR = 30;
public static final int ARM_MOTOR = 31;
public static final int XBOX_CONTROLLER_PORT_2 = 1;

}
15 changes: 9 additions & 6 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@
* project.
*/
public class Robot extends TimedRobot {
private Command m_autonomousCommand;

private RobotContainer m_robotContainer;
private Command autoCommand;


private RobotContainer m_robotContainer = null;
private Command autoCommand = null;
private Command m_autonomousCommand = null;
/**
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/

@Override
public void robotInit() {
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
// autonomous chooser on the dashboard.

m_robotContainer = new RobotContainer();
}

Expand All @@ -48,16 +50,17 @@ public void robotPeriodic() {
}

/** This function is called once each time the robot enters Disabled mode. */

@Override
public void disabledInit() {}

@Override
public void disabledPeriodic() {}

/** This autonomous runs the autonomous command selected by your {@link RobotContainer} class. */

@Override
public void autonomousInit() {

autoCommand = m_robotContainer.getAutonomousCommand();
System.out.println("auto init");
// schedule the autonomous command (example)
Expand Down
84 changes: 30 additions & 54 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,58 @@
// the WPILib BSD license file in the root directory of this project.

package frc.robot;


import edu.wpi.first.util.sendable.Sendable;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.XboxController.Button;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilderImpl;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.robot.commands.AutonomousCommand;
import frc.robot.commands.AutonomousCommandThree;
import frc.robot.commands.AutonomousCommandTwo;
import frc.robot.commands.ClawGrab;
import frc.robot.commands.CubeAdjust;
import frc.robot.commands.CubeAdjustHigh;
import frc.robot.commands.CubeAdjustMid;
import frc.robot.commands.CubeShoot;
import frc.robot.commands.CubeShootFull;
import frc.robot.commands.CubeScoreMid;
import frc.robot.commands.DriveArcadeCustomized;
import frc.robot.commands.DriveFast;
import frc.robot.commands.GrabberOne;
import frc.robot.commands.MoveArm;
import frc.robot.commands.MoveClaw;
import frc.robot.commands.IntakeIn;
import frc.robot.commands.IntakeOut;
import frc.robot.commands.RunLeftIntake;
import frc.robot.commands.RunRightIntake;
import frc.robot.commands.Shoot;
import frc.robot.subsystems.Intake;
import frc.robot.subsystems.Arm;
import frc.robot.subsystems.BoxGrabber;
import frc.robot.subsystems.Claw;
// import frc.robot.commands.GrabberIntake;
// import frc.robot.commands.GrabberOne;
// import frc.robot.subsystems.BoxGrabber;
import frc.robot.subsystems.Drivetrain;
import frc.robot.commands.CubeScoreHigh;

/**
* This class is where the bulk of the robot should be declared. Since Command-based is a
* "declarative" paradigm, very little robot logic should actually be handled in the {@link Robot}
* periodic methods (other than the scheduler calls). Instead, the structure of the robot (including
* subsystems, commands, and trigger mappings) should be declared here.
*/

public class RobotContainer {
// The robot's subsystems and commands are defined here...

Intake boxGrabber = new Intake();
BoxGrabber gBox = new BoxGrabber();

Drivetrain driveTrain = new Drivetrain();
Claw claw = new Claw();
Arm arm = new Arm();
DigitalInput digitalInput = new DigitalInput(Constants.LINE_BREAKER_PORT); // add port number in constants file
DigitalInput digitalInput = new DigitalInput(Constants.LINE_BREAKER_PORT);


XboxController xboxController = new XboxController(Constants.XBOX_CONTROLLER_PORT);
XboxController xboxController2 = new XboxController(Constants.XBOX_CONTROLLER_PORT_2);

SendableChooser<Command> chooser = new SendableChooser<>();
// Replace with CommandPS4Controller or CommandJoystick if needed
//AutonomousCommand autoCommand = new AutonomousCommand(driveTrain, 0.5, -0.5, boxGrabber, 0.75);
AutonomousCommand autoCommand = new AutonomousCommand(driveTrain, 0, -0.5, gBox, .6);
AutonomousCommandTwo autoCommandTwo= new AutonomousCommandTwo(driveTrain);
/** The container for the robot. Contains subsystems, OI devices, and commands. */
AutonomousCommand autoCommand = new AutonomousCommand(driveTrain, 0, 0.5, boxGrabber, -1, digitalInput, xboxController2);

public RobotContainer() {
// Configure the trigger bindings
configureBindings();
// driveTrain.setDefaultCommand(new DriveArcade(driveTrain, xboxController::getRightX, xboxController::getLeftY));
//driveTrain.setDefaultCommand(new DriveTank(driveTrain, xboxController::getRightY, xboxController::getLeftY));
//driveTrain.setDefaultCommand(new DriveCurvature(driveTrain, xboxController::getRightX, xboxController::getLeftY));
//driveTrain.setDefaultCommand(new DriveTank(driveTrain, xboxController::getRightY, xboxController::getLeftY));
driveTrain.setDefaultCommand(new DriveArcadeCustomized(driveTrain, xboxController::getLeftY, xboxController::getRightX, 0.8, xboxController));

driveTrain.putNumbers();

driveTrain.setDefaultCommand(new DriveArcadeCustomized(driveTrain, xboxController::getLeftY, xboxController::getRightX, 0.3, 0.2, 0.8, xboxController));
chooser.setDefaultOption("Default Auto Command", autoCommand);
chooser.addOption("Second Auto Command", autoCommandTwo);

SmartDashboard.putData(chooser);
}

Expand All @@ -85,23 +67,17 @@ public RobotContainer() {
* PS4} controllers or {@link edu.wpi.first.wpilibj2.command.button.CommandJoystick Flight
* joysticks}.
*/
private void configureBindings() {
// Schedule `ExampleCommand` when `exampleCondition` changes to `true`
//new JoystickButton(xboxController, Button.kRightBumper.value).whileTrue(new DriveFast(driveTrain, -1));
//new JoystickButton(xboxController, Button.kLeftBumper.value).whileTrue(new DriveFast(driveTrain, 1));
new JoystickButton(xboxController2, Button.kRightBumper.value).whileTrue(new GrabberOne(boxGrabber, 1, digitalInput, xboxController2));
new JoystickButton(xboxController2, Button.kLeftBumper.value).whileTrue(new GrabberOne(boxGrabber, -1, digitalInput, xboxController2));
new JoystickButton(xboxController2, Button.kA.value).whileTrue(new MoveClaw(claw, 0.1));
new JoystickButton(xboxController2, Button.kB.value).whileTrue(new MoveClaw(claw, -0.1));
new JoystickButton(xboxController2, Button.kX.value).whileTrue(new ClawGrab(gBox, 0.6));
new JoystickButton(xboxController2, Button.kY.value).whileTrue(new ClawGrab(gBox, -0.1));
//new JoystickButton(xboxController2, Button.kRightBumper.value).whileTrue(new MoveArm(arm, 0.1));
//new JoystickButton(xboxController2, Button.kLeftBumper.value).whileTrue(new MoveArm(arm, -0.1));

// Schedule `exampleMethodCommand` when the Xbox controller's B button is pressed,
// cancelling on release.

}
private void configureBindings() {
new JoystickButton(xboxController2, Button.kRightBumper.value).whileTrue(new IntakeOut(boxGrabber, 0.40));
new JoystickButton(xboxController2, Button.kLeftBumper.value).whileTrue(new IntakeIn(boxGrabber, -0.25, digitalInput, xboxController2));
new JoystickButton(xboxController2, Button.kB.value).whileTrue(new CubeShoot(boxGrabber, -1, -1));
//new JoystickButton(xboxController2, Button.kA.value).whileTrue(new CubeAdjustFullMid(digitalInput, boxGrabber, xboxController2));
new JoystickButton(xboxController2, Button.kA.value).whileTrue(new CubeScoreHigh(digitalInput, boxGrabber, xboxController2, boxGrabber, -1, -1));
new JoystickButton(xboxController2, Button.kY.value).whileTrue(new CubeScoreMid(digitalInput, boxGrabber, xboxController2, boxGrabber, -1, -1));
new JoystickButton(xboxController2, Button.kX.value).whileTrue(new CubeAdjust(boxGrabber, 1));

}

/**
* Use this to pass the autonomous command to the main {@link Robot} class.
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/frc/robot/commands/AutonomousCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@

package frc.robot.commands;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import frc.robot.subsystems.Intake;
import frc.robot.subsystems.BoxGrabber;
import frc.robot.subsystems.Drivetrain;
import frc.robot.subsystems.Intake;

// NOTE: Consider using this command inline, rather than writing a subclass. For more
// information, see:
// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html
public class AutonomousCommand extends SequentialCommandGroup {
/** Creates a new AutonomousCommand. */
public AutonomousCommand(Drivetrain driveTrain, double power, double rotation, BoxGrabber boxGrabber, double intakePower) {
DigitalInput digitalInput;
XboxController xboxController2;
public AutonomousCommand(Drivetrain driveTrain, double power, double rotation, Intake boxGrabber, double intakePower, DigitalInput digitalInput, XboxController xboxController2) {
// Add your commands in the addCommands() call, e.g.
// addCommands(new FooCommand(), new BarCommand());
addCommands(
new ClawGrab(boxGrabber, intakePower).withTimeout(1),
//new Drive(driveTrain, 0, -rotation).withTimeout(0.75),
new Drive(driveTrain, power, 0).withTimeout(0),
new Drive(driveTrain, 0, rotation).withTimeout(3));



addCommands(
new Drive(driveTrain, power, 0).withTimeout(0.75),
new CubeShoot(boxGrabber, intakePower, -1).withTimeout(1.55),
new Drive(driveTrain, 0,-rotation).withTimeout(1.25));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import frc.robot.subsystems.Drivetrain;
import frc.robot.subsystems.Intake;

// NOTE: Consider using this command inline, rather than writing a subclass. For more
// information, see:
// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html
public class AutonomousCommandTwo extends SequentialCommandGroup {
/** Creates a new AutonomousCommandTwo. */
Drivetrain driveTrain;
public AutonomousCommandTwo(Drivetrain driveTrain) {
public class CubeAdjust extends SequentialCommandGroup {
/** Creates a new CubeAdjust. */
public CubeAdjust(Intake intake, double power) {
// Add your commands in the addCommands() call, e.g.
// addCommands(new FooCommand(), new BarCommand());
addCommands(
new DriveStraight(driveTrain).withTimeout(20)
new RunLeftIntake(intake, power).withTimeout(0.35)
);
}
}
59 changes: 59 additions & 0 deletions src/main/java/frc/robot/commands/CubeAdjustHigh.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.Intake;


public class CubeAdjustHigh extends CommandBase {
DigitalInput digitalInput = null;
boolean done = false;
Intake boxGrabber = null;
XboxController xboxController = null;




public CubeAdjustHigh(DigitalInput digitalInput, Intake boxGrabber, XboxController xboxController) {
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(boxGrabber);
this.digitalInput = digitalInput;
this.boxGrabber = boxGrabber;
this.xboxController = xboxController;
}
@Override
public void initialize() {
boxGrabber.stop();
}


@Override
public void execute() {
if (xboxController.getAButton() && !digitalInput.get()) {
boxGrabber.runLeftIntake(0.37);
}

if(!digitalInput.get()){
boxGrabber.runLeftIntake(0.37);
} else {
boxGrabber.stop();
}
/* else if (xboxController.getAButton()) {
boxGrabber.runLeftIntake(-0.5);
} */
}

@Override
public void end(boolean interrupted) {
boxGrabber.stop();
done=true;
}

// Returns true when the command should end.
@Override
public boolean isFinished() {

return false;
}
}
57 changes: 57 additions & 0 deletions src/main/java/frc/robot/commands/CubeAdjustMid.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.Intake;

public class CubeAdjustMid extends CommandBase {
DigitalInput digitalInput = null;
boolean done = false;
Intake boxGrabber = null;
XboxController xboxController = null;




public CubeAdjustMid(DigitalInput digitalInput, Intake boxGrabber, XboxController xboxController) {
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(boxGrabber);
this.digitalInput = digitalInput;
this.boxGrabber = boxGrabber;
this.xboxController = xboxController;
}
@Override
public void initialize() {
boxGrabber.stop();
}


@Override
public void execute() {
if (xboxController.getAButton() && !digitalInput.get()) {
boxGrabber.runLeftIntake(0.09);
}

if(!digitalInput.get()){
boxGrabber.runLeftIntake(0.09);
} else {
boxGrabber.stop();
}
/* else if (xboxController.getAButton()) {
boxGrabber.runLeftIntake(-0.5);
} */
}

@Override
public void end(boolean interrupted) {
boxGrabber.stop();
done=true;
}

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