diff --git a/.wpilib/wpilib_preferences.json b/.wpilib/wpilib_preferences.json index 6434082..155493f 100644 --- a/.wpilib/wpilib_preferences.json +++ b/.wpilib/wpilib_preferences.json @@ -2,5 +2,5 @@ "enableCppIntellisense": false, "currentLanguage": "java", "projectYear": "2020", - "teamNumber": null + "teamNumber": 9001 } \ No newline at end of file diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index cf0c82e..fd96b83 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -16,4 +16,9 @@ * constants are needed, to reduce verbosity. */ public final class Constants { + public static final int kIntake = 5; + public static final int kConveyor = 6; + public static final int kFlywheel = 7; + + public static final double kConveyorSpeed = 0.5; } diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index f60f0d1..4354c23 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -9,9 +9,13 @@ import edu.wpi.first.wpilibj.GenericHID; import edu.wpi.first.wpilibj.XboxController; -import frc.robot.commands.ExampleCommand; -import frc.robot.subsystems.ExampleSubsystem; +import frc.robot.commands.ConveyorDown; +import frc.robot.commands.ConveyorUp; +import frc.robot.subsystems.Conveyor; +import frc.robot.subsystems.Intake; import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.RunCommand; +import edu.wpi.first.wpilibj2.command.button.Trigger; /** * This class is where the bulk of the robot should be declared. Since Command-based is a @@ -20,12 +24,13 @@ * (including subsystems, commands, and button mappings) should be declared here. */ public class RobotContainer { - // The robot's subsystems and commands are defined here... - private final ExampleSubsystem m_exampleSubsystem = new ExampleSubsystem(); - - private final ExampleCommand m_autoCommand = new ExampleCommand(m_exampleSubsystem); - + // Subsystems + private final Intake m_intake = new Intake(); + private final Conveyor m_conveyor = new Conveyor(); + // Controllers + private final XboxController m_driver = new XboxController(0); + private final XboxController m_manip = new XboxController(1); /** * The container for the robot. Contains subsystems, OI devices, and commands. @@ -33,6 +38,12 @@ public class RobotContainer { public RobotContainer() { // Configure the button bindings configureButtonBindings(); + + m_intake.setDefaultCommand(new RunCommand(() -> m_intake.runIntake( + m_manip.getTriggerAxis(GenericHID.Hand.kLeft), + m_manip.getTriggerAxis(GenericHID.Hand.kRight)), + m_intake + )); } /** @@ -42,6 +53,8 @@ public RobotContainer() { * {@link edu.wpi.first.wpilibj2.command.button.JoystickButton}. */ private void configureButtonBindings() { + new DPadUp().whileActiveContinuous(new ConveyorUp(m_conveyor)); + new DPadDown().whileActiveContinuous(new ConveyorDown(m_conveyor)); } @@ -52,6 +65,22 @@ private void configureButtonBindings() { */ public Command getAutonomousCommand() { // An ExampleCommand will run in autonomous - return m_autoCommand; + return null; + } + + private class DPadUp extends Trigger { + @Override + public boolean get() { + int pov = m_manip.getPOV(); + return pov == 315 || pov <= 45; + } + } + + private class DPadDown extends Trigger { + @Override + public boolean get() { + int pov = m_manip.getPOV(); + return pov >= 135 && pov <= 225; + } } } diff --git a/src/main/java/frc/robot/commands/ConveyorDown.java b/src/main/java/frc/robot/commands/ConveyorDown.java new file mode 100644 index 0000000..ccc9cd4 --- /dev/null +++ b/src/main/java/frc/robot/commands/ConveyorDown.java @@ -0,0 +1,53 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands; + +import frc.robot.subsystems.Conveyor; +import edu.wpi.first.wpilibj2.command.CommandBase; + +/** + * An example command that uses an example subsystem. + */ +public class ConveyorDown extends CommandBase { + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) + private final Conveyor m_conveyor; + + /** + * Creates a new ConveyorDown Command. + * + * @param subsystem The subsystem used by this command. + */ + public ConveyorDown(Conveyor conveyor) { + m_conveyor = conveyor; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(conveyor); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + m_conveyor.lowerConveyor(); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + m_conveyor.stopConveyor(); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/ConveyorUp.java b/src/main/java/frc/robot/commands/ConveyorUp.java new file mode 100644 index 0000000..5289880 --- /dev/null +++ b/src/main/java/frc/robot/commands/ConveyorUp.java @@ -0,0 +1,53 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands; + +import frc.robot.subsystems.Conveyor; +import edu.wpi.first.wpilibj2.command.CommandBase; + +/** + * An example command that uses an example subsystem. + */ +public class ConveyorUp extends CommandBase { + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) + private final Conveyor m_conveyor; + + /** + * Creates a new ConveyorUp. + * + * @param subsystem The subsystem used by this command. + */ + public ConveyorUp(Conveyor conveyor) { + m_conveyor = conveyor; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(conveyor); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + m_conveyor.raiseConveyor(); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + m_conveyor.stopConveyor(); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/subsystems/Conveyor.java b/src/main/java/frc/robot/subsystems/Conveyor.java new file mode 100644 index 0000000..9619283 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Conveyor.java @@ -0,0 +1,38 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.subsystems; + +import com.ctre.phoenix.motorcontrol.can.WPI_VictorSPX; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; +import frc.robot.Constants; + +public class Conveyor extends SubsystemBase { + private final WPI_VictorSPX m_conveyor = new WPI_VictorSPX(Constants.kConveyor); + + /** + * Runs conveyor up + */ + public void raiseConveyor() { + m_conveyor.set(Constants.kConveyorSpeed); + } + + /** + * Runs conveyor down + */ + public void lowerConveyor() { + m_conveyor.set(-Constants.kConveyorSpeed); + } + + /** + * Stops conveyor + */ + public void stopConveyor() { + m_conveyor.stopMotor(); + } +} diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java new file mode 100644 index 0000000..0ac3368 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -0,0 +1,26 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.subsystems; + +import com.ctre.phoenix.motorcontrol.can.WPI_VictorSPX; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; +import frc.robot.Constants; + +public class Intake extends SubsystemBase { + private final WPI_VictorSPX m_intake = new WPI_VictorSPX(Constants.kIntake); + + /** + * Runs the intake motor + * @param left Value of left trigger + * @param right Value of right trigger + */ + public void runIntake(double left, double right) { + m_intake.set(right - left); + } +} diff --git a/vendordeps/Phoenix.json b/vendordeps/Phoenix.json new file mode 100644 index 0000000..f8d42a4 --- /dev/null +++ b/vendordeps/Phoenix.json @@ -0,0 +1,180 @@ +{ + "fileName": "Phoenix.json", + "name": "CTRE-Phoenix", + "version": "5.17.3", + "uuid": "ab676553-b602-441f-a38d-f1296eff6537", + "mavenUrls": [ + "http://devsite.ctr-electronics.com/maven/release/" + ], + "jsonUrl": "http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/Phoenix-latest.json", + "javaDependencies": [ + { + "groupId": "com.ctre.phoenix", + "artifactId": "api-java", + "version": "5.17.3" + }, + { + "groupId": "com.ctre.phoenix", + "artifactId": "wpiapi-java", + "version": "5.17.3" + } + ], + "jniDependencies": [ + { + "groupId": "com.ctre.phoenix", + "artifactId": "cci", + "version": "5.17.3", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "linuxathena", + "windowsx86-64", + "linuxx86-64" + ] + }, + { + "groupId": "com.ctre.phoenix", + "artifactId": "diagnostics", + "version": "5.17.3", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "linuxathena", + "windowsx86-64", + "linuxx86-64" + ] + }, + { + "groupId": "com.ctre.phoenix", + "artifactId": "canutils", + "version": "5.17.3", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64" + ] + }, + { + "groupId": "com.ctre.phoenix", + "artifactId": "platform-stub", + "version": "5.17.3", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64" + ] + }, + { + "groupId": "com.ctre.phoenix", + "artifactId": "core", + "version": "5.17.3", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "linuxathena", + "windowsx86-64", + "linuxx86-64" + ] + } + ], + "cppDependencies": [ + { + "groupId": "com.ctre.phoenix", + "artifactId": "wpiapi-cpp", + "version": "5.17.3", + "libName": "CTRE_Phoenix_WPI", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "linuxathena", + "windowsx86-64", + "linuxx86-64" + ] + }, + { + "groupId": "com.ctre.phoenix", + "artifactId": "api-cpp", + "version": "5.17.3", + "libName": "CTRE_Phoenix", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "linuxathena", + "windowsx86-64", + "linuxx86-64" + ] + }, + { + "groupId": "com.ctre.phoenix", + "artifactId": "cci", + "version": "5.17.3", + "libName": "CTRE_PhoenixCCI", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "linuxathena", + "windowsx86-64", + "linuxx86-64" + ] + }, + { + "groupId": "com.ctre.phoenix", + "artifactId": "diagnostics", + "version": "5.17.3", + "libName": "CTRE_PhoenixDiagnostics", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "linuxathena", + "windowsx86-64", + "linuxx86-64" + ] + }, + { + "groupId": "com.ctre.phoenix", + "artifactId": "canutils", + "version": "5.17.3", + "libName": "CTRE_PhoenixCanutils", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64" + ] + }, + { + "groupId": "com.ctre.phoenix", + "artifactId": "platform-stub", + "version": "5.17.3", + "libName": "CTRE_PhoenixPlatform", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64" + ] + }, + { + "groupId": "com.ctre.phoenix", + "artifactId": "core", + "version": "5.17.3", + "libName": "CTRE_PhoenixCore", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "linuxathena", + "windowsx86-64", + "linuxx86-64" + ] + } + ] +} \ No newline at end of file