From ae9e6a8fd8f9a104e39071631f8380445a7092a7 Mon Sep 17 00:00:00 2001 From: Dhinak G Date: Sun, 2 Feb 2020 19:33:27 -0500 Subject: [PATCH 1/5] Start migration to wpilibj2 --- src/main/java/frc/robot/OI.java | 4 +- .../commands/CircleControllerCommand.java | 6 +-- .../robot/commands/IntakeReleaseCommand.java | 8 ++-- .../frc/robot/commands/IntakeSuckCommand.java | 8 ++-- .../generalCommands/SciSparkSpeedCommand.java | 11 ++++-- .../generalCommands/SciTalonSpeedCommand.java | 13 ++++--- .../robot/sciSensorsActuators/SciSpark.java | 4 +- .../robot/sciSensorsActuators/SciTalon.java | 3 +- .../frc/robot/subsystems/IntakeSubsystem.java | 9 +---- vendordeps/WPILibNewCommands.json | 37 +++++++++++++++++++ 10 files changed, 71 insertions(+), 32 deletions(-) create mode 100644 vendordeps/WPILibNewCommands.json diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 7b09316..179d434 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -2,7 +2,7 @@ package frc.robot; import edu.wpi.first.wpilibj.XboxController; -import edu.wpi.first.wpilibj.buttons.JoystickButton; +import edu.wpi.first.wpilibj2.command.button.JoystickButton; import frc.robot.commands.*; import frc.robot.sciSensorsActuators.SciJoystick; @@ -20,7 +20,7 @@ public OI() { xboxController = new XboxController(PortMap.XBOX_CONTROLLER); circleControllerButton = new JoystickButton(leftStick, PortMap.JOYSTICK_TRIGGER); - circleControllerButton.whileActive(new CircleControllerCommand()); + circleControllerButton.whileActiveContinuous(new CircleControllerCommand()); pointOneButton = new JoystickButton(leftStick, PortMap.JOYSTICK_LEFT_BUTTON); pointOneButton.whenPressed(new PointOneCommand()); diff --git a/src/main/java/frc/robot/commands/CircleControllerCommand.java b/src/main/java/frc/robot/commands/CircleControllerCommand.java index 3108d79..b64b7e0 100644 --- a/src/main/java/frc/robot/commands/CircleControllerCommand.java +++ b/src/main/java/frc/robot/commands/CircleControllerCommand.java @@ -2,17 +2,17 @@ import frc.robot.Robot; import frc.robot.controllers.CircleController; -import edu.wpi.first.wpilibj.command.InstantCommand; +import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.logging.Logger.CommandStatus; import frc.robot.helpers.DelayedPrinter; -public class CircleControllerCommand extends InstantCommand { +public class CircleControllerCommand extends CommandBase { private final String FILENAME = "CircleControllerCommand.java"; CircleController circleController = new CircleController(); @Override - protected void execute() { + public void execute() { Robot.logger.logCommandStatus(FILENAME, CommandStatus.Executing); circleController.update(Robot.CURRENT_DESTINATION, Robot.CURRENT_DESTINATION_HEADING); } diff --git a/src/main/java/frc/robot/commands/IntakeReleaseCommand.java b/src/main/java/frc/robot/commands/IntakeReleaseCommand.java index 92adb2d..d3076a9 100644 --- a/src/main/java/frc/robot/commands/IntakeReleaseCommand.java +++ b/src/main/java/frc/robot/commands/IntakeReleaseCommand.java @@ -1,19 +1,19 @@ package frc.robot.commands; -import edu.wpi.first.wpilibj.command.InstantCommand; +import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.Robot; import frc.robot.logging.Logger.CommandStatus; -public class IntakeReleaseCommand extends InstantCommand { +public class IntakeReleaseCommand extends CommandBase { private final String FILENAME = "IntakeReleaseCommand.java"; public IntakeReleaseCommand() { - requires(Robot.intakeSubsystem); + addRequirements(Robot.intakeSubsystem); } @Override - protected void execute() { + public void execute() { Robot.logger.logCommandStatus(FILENAME, CommandStatus.Executing); Robot.intakeSubsystem.stop(); } diff --git a/src/main/java/frc/robot/commands/IntakeSuckCommand.java b/src/main/java/frc/robot/commands/IntakeSuckCommand.java index 6788a6f..1f3f865 100644 --- a/src/main/java/frc/robot/commands/IntakeSuckCommand.java +++ b/src/main/java/frc/robot/commands/IntakeSuckCommand.java @@ -1,19 +1,19 @@ package frc.robot.commands; -import edu.wpi.first.wpilibj.command.InstantCommand; +import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.Robot; import frc.robot.logging.Logger.CommandStatus; -public class IntakeSuckCommand extends InstantCommand { +public class IntakeSuckCommand extends CommandBase { private final String FILENAME = "IntakeSuckCommand.java"; public IntakeSuckCommand() { - requires(Robot.intakeSubsystem); + addRequirements(Robot.intakeSubsystem); } @Override - protected void execute() { + public void execute() { Robot.logger.logCommandStatus(FILENAME, CommandStatus.Executing); Robot.intakeSubsystem.suck(); } diff --git a/src/main/java/frc/robot/commands/generalCommands/SciSparkSpeedCommand.java b/src/main/java/frc/robot/commands/generalCommands/SciSparkSpeedCommand.java index c460b3a..3211d72 100644 --- a/src/main/java/frc/robot/commands/generalCommands/SciSparkSpeedCommand.java +++ b/src/main/java/frc/robot/commands/generalCommands/SciSparkSpeedCommand.java @@ -1,9 +1,12 @@ package frc.robot.commands.generalCommands; -import edu.wpi.first.wpilibj.command.Command; +import java.util.HashSet; +import java.util.Set; + +import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.sciSensorsActuators.SciSpark; -public class SciSparkSpeedCommand extends Command { +public class SciSparkSpeedCommand extends CommandBase { private SciSpark spark; private double goalSpeed; @@ -18,8 +21,8 @@ public SciSparkSpeedCommand(SciSpark spark, int commandNumber){ } @Override - protected void execute(){this.spark.instantSet();} + public void execute(){this.spark.instantSet();} @Override - protected boolean isFinished(){return this.spark.atGoal();} + public boolean isFinished(){return this.spark.atGoal();} } \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/generalCommands/SciTalonSpeedCommand.java b/src/main/java/frc/robot/commands/generalCommands/SciTalonSpeedCommand.java index e246d6f..7d2f385 100644 --- a/src/main/java/frc/robot/commands/generalCommands/SciTalonSpeedCommand.java +++ b/src/main/java/frc/robot/commands/generalCommands/SciTalonSpeedCommand.java @@ -1,9 +1,12 @@ package frc.robot.commands.generalCommands; -import edu.wpi.first.wpilibj.command.Command; +import java.util.HashSet; +import java.util.Set; + +import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.sciSensorsActuators.SciTalon; -public class SciTalonSpeedCommand extends Command { +public class SciTalonSpeedCommand extends CommandBase { private SciTalon talon; private double goalSpeed; @@ -18,12 +21,10 @@ public SciTalonSpeedCommand(SciTalon talon, int commandNumber){ } @Override - protected void execute(){this.talon.instantSet();} + public void execute(){this.talon.instantSet();} @Override - protected boolean isFinished(){ + public boolean isFinished(){ return this.talon.atGoal() || !this.talon.isCurrentCommandNumber(this.commandNunber); } - @Override - protected void end(){ } } \ No newline at end of file diff --git a/src/main/java/frc/robot/sciSensorsActuators/SciSpark.java b/src/main/java/frc/robot/sciSensorsActuators/SciSpark.java index 3f2cdbe..aa018da 100644 --- a/src/main/java/frc/robot/sciSensorsActuators/SciSpark.java +++ b/src/main/java/frc/robot/sciSensorsActuators/SciSpark.java @@ -2,6 +2,8 @@ import com.revrobotics.CANSparkMax; +import edu.wpi.first.wpilibj2.command.CommandScheduler; + import java.util.Optional; import frc.robot.Robot; @@ -81,7 +83,7 @@ public void set(double speed, double maxJerk) { this.commandNumber++; // Set will call this command, which will continue to call instantSet // InstantSet will only set the value of the motor to the correct value if it is within maxJerk - (new SciSparkSpeedCommand(this, this.commandNumber)).start(); + CommandScheduler.getInstance().schedule(new SciSparkSpeedCommand(this, this.commandNumber)); } public void set(double speed) {set(speed, DEFAULT_MAX_JERK);} diff --git a/src/main/java/frc/robot/sciSensorsActuators/SciTalon.java b/src/main/java/frc/robot/sciSensorsActuators/SciTalon.java index 8fe7f97..75af2e6 100644 --- a/src/main/java/frc/robot/sciSensorsActuators/SciTalon.java +++ b/src/main/java/frc/robot/sciSensorsActuators/SciTalon.java @@ -3,6 +3,7 @@ import com.ctre.phoenix.motorcontrol.ControlMode; import com.ctre.phoenix.motorcontrol.can.TalonSRX; +import edu.wpi.first.wpilibj2.command.CommandScheduler; import frc.robot.Utils; import frc.robot.commands.generalCommands.SciTalonSpeedCommand; import frc.robot.helpers.DelayedPrinter; @@ -69,7 +70,7 @@ public void set(double speed, double maxJerk){ this.commandNumber++; // Set will call this command, which will continue to call instantSet // InstantSet will only set the value of the motor to the correct value if it is within maxJerk - (new SciTalonSpeedCommand(this, this.commandNumber)).start(); + CommandScheduler.getInstance().schedule(new SciTalonSpeedCommand(this, this.commandNumber)); } public void set(double speed) {set(speed, DEFAULT_MAX_JERK);} diff --git a/src/main/java/frc/robot/subsystems/IntakeSubsystem.java b/src/main/java/frc/robot/subsystems/IntakeSubsystem.java index 5c1cb97..3b02fce 100644 --- a/src/main/java/frc/robot/subsystems/IntakeSubsystem.java +++ b/src/main/java/frc/robot/subsystems/IntakeSubsystem.java @@ -1,6 +1,6 @@ package frc.robot.subsystems; -import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj2.command.Subsystem; import edu.wpi.first.wpilibj.DoubleSolenoid; import edu.wpi.first.wpilibj.DoubleSolenoid.Value; import frc.robot.PortMap; @@ -9,7 +9,7 @@ import com.ctre.phoenix.motorcontrol.can.TalonSRX; -public class IntakeSubsystem extends Subsystem { +public class IntakeSubsystem implements Subsystem { DoubleSolenoid upDownSolenoid; public SciTalon intakeMotor; @@ -33,9 +33,4 @@ public void setIntakeSpeed(double speed) { public void suck() {setIntakeSpeed(INTAKE_SPEED);} public void stop() {setIntakeSpeed(0);} - @Override - protected void initDefaultCommand() { - // Useless - } - } \ No newline at end of file diff --git a/vendordeps/WPILibNewCommands.json b/vendordeps/WPILibNewCommands.json new file mode 100644 index 0000000..83de291 --- /dev/null +++ b/vendordeps/WPILibNewCommands.json @@ -0,0 +1,37 @@ +{ + "fileName": "WPILibNewCommands.json", + "name": "WPILib-New-Commands", + "version": "2020.0.0", + "uuid": "111e20f7-815e-48f8-9dd6-e675ce75b266", + "mavenUrls": [], + "jsonUrl": "", + "javaDependencies": [ + { + "groupId": "edu.wpi.first.wpilibNewCommands", + "artifactId": "wpilibNewCommands-java", + "version": "wpilib" + } + ], + "jniDependencies": [], + "cppDependencies": [ + { + "groupId": "edu.wpi.first.wpilibNewCommands", + "artifactId": "wpilibNewCommands-cpp", + "version": "wpilib", + "libName": "wpilibNewCommands", + "headerClassifier": "headers", + "sourcesClassifier": "sources", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "linuxathena", + "linuxraspbian", + "linuxaarch64bionic", + "windowsx86-64", + "windowsx86", + "linuxx86-64", + "osxx86-64" + ] + } + ] +} \ No newline at end of file From c33a8563e589278375a389219e0297ab9248d159 Mon Sep 17 00:00:00 2001 From: Dhinak G Date: Sun, 2 Feb 2020 19:42:27 -0500 Subject: [PATCH 2/5] Fix IntakeReleaseCommand and CircleControllerCommand Default of isFinished() in the Command interface is false, so we need to use the InstantCommand class --- src/main/java/frc/robot/commands/CircleControllerCommand.java | 4 ++-- src/main/java/frc/robot/commands/IntakeReleaseCommand.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/commands/CircleControllerCommand.java b/src/main/java/frc/robot/commands/CircleControllerCommand.java index b64b7e0..4052d7f 100644 --- a/src/main/java/frc/robot/commands/CircleControllerCommand.java +++ b/src/main/java/frc/robot/commands/CircleControllerCommand.java @@ -2,11 +2,11 @@ import frc.robot.Robot; import frc.robot.controllers.CircleController; -import edu.wpi.first.wpilibj2.command.CommandBase; +import edu.wpi.first.wpilibj2.command.InstantCommand; import frc.robot.logging.Logger.CommandStatus; import frc.robot.helpers.DelayedPrinter; -public class CircleControllerCommand extends CommandBase { +public class CircleControllerCommand extends InstantCommand { private final String FILENAME = "CircleControllerCommand.java"; CircleController circleController = new CircleController(); diff --git a/src/main/java/frc/robot/commands/IntakeReleaseCommand.java b/src/main/java/frc/robot/commands/IntakeReleaseCommand.java index d3076a9..a519903 100644 --- a/src/main/java/frc/robot/commands/IntakeReleaseCommand.java +++ b/src/main/java/frc/robot/commands/IntakeReleaseCommand.java @@ -1,10 +1,10 @@ package frc.robot.commands; -import edu.wpi.first.wpilibj2.command.CommandBase; +import edu.wpi.first.wpilibj2.command.InstantCommand; import frc.robot.Robot; import frc.robot.logging.Logger.CommandStatus; -public class IntakeReleaseCommand extends CommandBase { +public class IntakeReleaseCommand extends InstantCommand { private final String FILENAME = "IntakeReleaseCommand.java"; From 487799f17ab4f4fe45f9bc840f09959f70e52855 Mon Sep 17 00:00:00 2001 From: Dhinak G Date: Mon, 3 Feb 2020 14:10:12 -0500 Subject: [PATCH 3/5] Continue wpilibj2 migration --- src/main/java/frc/robot/Robot.java | 6 +-- .../frc/robot/commands/PointOneCommand.java | 4 +- .../frc/robot/commands/PointThreeCommand.java | 4 +- .../frc/robot/commands/PointTwoCommand.java | 4 +- .../commands/SwerveTankDriveCommand.java | 9 ++--- .../frc/robot/commands/TankDriveCommand.java | 4 +- .../robot/commands/TorqueDriveCommand.java | 5 ++- .../frc/robot/subsystems/DriveSubsystem.java | 9 +---- .../robot/subsystems/LimelightSubsystem.java | 9 +---- .../frc/robot/subsystems/PigeonSubsystem.java | 9 +---- .../robot/subsystems/PneumaticsSubsystem.java | 7 +--- vendordeps/WPILibOldCommands.json | 37 ------------------- 12 files changed, 25 insertions(+), 82 deletions(-) delete mode 100644 vendordeps/WPILibOldCommands.json diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index e1ddd4e..3727567 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -20,7 +20,7 @@ import frc.robot.sciSensorsActuators.SciSpark; import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.Timer; -import edu.wpi.first.wpilibj.command.Scheduler; +import edu.wpi.first.wpilibj2.command.CommandScheduler; import frc.robot.controllers.*; public class Robot extends TimedRobot { @@ -166,7 +166,7 @@ public void robotPeriodic() { allPeriodicLogs(); logDataPeriodic(); DelayedPrinter.print("x: " + getPos().x + "\ty: " + getPos().y + "\nheading: " + getHeading() + "\npigeon angle: " + Robot.get(SD.PigeonAngle)); - Scheduler.getInstance().run(); + CommandScheduler.getInstance().run(); DelayedPrinter.incTicks(); } @@ -191,7 +191,7 @@ public void teleopInit() { } public void teleopPeriodic() { - (new TankDriveCommand()).start(); + CommandScheduler.getInstance().schedule(new TankDriveCommand()); } diff --git a/src/main/java/frc/robot/commands/PointOneCommand.java b/src/main/java/frc/robot/commands/PointOneCommand.java index 91b8344..6c7f7db 100644 --- a/src/main/java/frc/robot/commands/PointOneCommand.java +++ b/src/main/java/frc/robot/commands/PointOneCommand.java @@ -1,11 +1,11 @@ package frc.robot.commands; import frc.robot.Robot; -import edu.wpi.first.wpilibj.command.InstantCommand; +import edu.wpi.first.wpilibj2.command.InstantCommand; public class PointOneCommand extends InstantCommand { @Override - protected void execute() { + public void execute() { Robot.CURRENT_DESTINATION = Robot.newDestPoint; Robot.CURRENT_DESTINATION_HEADING = Robot.newDestHeading; } diff --git a/src/main/java/frc/robot/commands/PointThreeCommand.java b/src/main/java/frc/robot/commands/PointThreeCommand.java index 45ef5f2..a72bb3e 100644 --- a/src/main/java/frc/robot/commands/PointThreeCommand.java +++ b/src/main/java/frc/robot/commands/PointThreeCommand.java @@ -1,11 +1,11 @@ package frc.robot.commands; import frc.robot.Robot; -import edu.wpi.first.wpilibj.command.InstantCommand; +import edu.wpi.first.wpilibj2.command.InstantCommand; public class PointThreeCommand extends InstantCommand { @Override - protected void execute() { + public void execute() { Robot.CURRENT_DESTINATION = Robot.TEST_POINT_3.point; Robot.CURRENT_DESTINATION_HEADING = Robot.TEST_POINT_3.heading; } diff --git a/src/main/java/frc/robot/commands/PointTwoCommand.java b/src/main/java/frc/robot/commands/PointTwoCommand.java index b5540de..b8cdcf1 100644 --- a/src/main/java/frc/robot/commands/PointTwoCommand.java +++ b/src/main/java/frc/robot/commands/PointTwoCommand.java @@ -1,11 +1,11 @@ package frc.robot.commands; import frc.robot.Robot; -import edu.wpi.first.wpilibj.command.InstantCommand; +import edu.wpi.first.wpilibj2.command.InstantCommand; public class PointTwoCommand extends InstantCommand { @Override - protected void execute() { + public void execute() { Robot.CURRENT_DESTINATION = Robot.TEST_POINT_2.point; Robot.CURRENT_DESTINATION_HEADING = Robot.TEST_POINT_2.heading; } diff --git a/src/main/java/frc/robot/commands/SwerveTankDriveCommand.java b/src/main/java/frc/robot/commands/SwerveTankDriveCommand.java index cf6df2a..e4ed6af 100644 --- a/src/main/java/frc/robot/commands/SwerveTankDriveCommand.java +++ b/src/main/java/frc/robot/commands/SwerveTankDriveCommand.java @@ -3,15 +3,12 @@ import frc.robot.Robot; import frc.robot.logging.Logger.CommandStatus; -import edu.wpi.first.wpilibj.command.InstantCommand; +import edu.wpi.first.wpilibj2.command.InstantCommand; public class SwerveTankDriveCommand extends InstantCommand { private final String FILENAME = "SwerveTankDriveCommand.java"; - - - public SwerveTankDriveCommand(){} - - @Override protected void execute() { + @Override + public void execute() { Robot.logger.logCommandStatus(FILENAME, CommandStatus.Executing); // One controller controls turning percent, one controls velocity diff --git a/src/main/java/frc/robot/commands/TankDriveCommand.java b/src/main/java/frc/robot/commands/TankDriveCommand.java index cde8ef4..17c2c61 100644 --- a/src/main/java/frc/robot/commands/TankDriveCommand.java +++ b/src/main/java/frc/robot/commands/TankDriveCommand.java @@ -2,12 +2,12 @@ import frc.robot.Robot; import frc.robot.logging.Logger.CommandStatus; -import edu.wpi.first.wpilibj.command.InstantCommand; +import edu.wpi.first.wpilibj2.command.InstantCommand; public class TankDriveCommand extends InstantCommand { private final String FILENAME = "TankDriveCommand.java"; @Override - protected void execute() { + public void execute() { Robot.driveSubsystem.manualDriveMode(); Robot.logger.logCommandStatus(FILENAME, CommandStatus.Executing); Robot.driveSubsystem.setSpeed(Robot.oi.leftStick, Robot.oi.rightStick); diff --git a/src/main/java/frc/robot/commands/TorqueDriveCommand.java b/src/main/java/frc/robot/commands/TorqueDriveCommand.java index c20b4cf..f7601f6 100644 --- a/src/main/java/frc/robot/commands/TorqueDriveCommand.java +++ b/src/main/java/frc/robot/commands/TorqueDriveCommand.java @@ -3,12 +3,13 @@ import frc.robot.Robot; import frc.robot.logging.Logger.CommandStatus; -import edu.wpi.first.wpilibj.command.InstantCommand; +import edu.wpi.first.wpilibj2.command.InstantCommand; public class TorqueDriveCommand extends InstantCommand { private final String FILENAME = "SwerveTankDriveCommand.java"; - @Override protected void execute() { + @Override + public void execute() { Robot.logger.logCommandStatus(FILENAME, CommandStatus.Executing); // One controller controls turning percent, one controls velocity double forward = Robot.oi.leftStick.getProcessedY(); diff --git a/src/main/java/frc/robot/subsystems/DriveSubsystem.java b/src/main/java/frc/robot/subsystems/DriveSubsystem.java index d8692d5..40377e5 100644 --- a/src/main/java/frc/robot/subsystems/DriveSubsystem.java +++ b/src/main/java/frc/robot/subsystems/DriveSubsystem.java @@ -10,9 +10,9 @@ import frc.robot.sciSensorsActuators.*; import frc.robot.logging.Logger.DefaultValue; import edu.wpi.first.wpilibj.Joystick; -import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj2.command.Subsystem; -public class DriveSubsystem extends Subsystem { +public class DriveSubsystem implements Subsystem { // Define tested error values here double TANK_ANGLE_P = .075, TANK_ANGLE_D = 0.0, TANK_ANGLE_I = 0; double TANK_SPEED_LEFT_P = .1, TANK_SPEED_LEFT_D = 0.0, TANK_SPEED_LEFT_I = 0; @@ -149,9 +149,4 @@ public void setSpeedTankForwardTurningMagnitude(double forward, double turnMagni // Note: this controls dtheta/dt rather than dtheta/dx setTank(forward - turnMagnitude, forward + turnMagnitude); } - - @Override - protected void initDefaultCommand() { - //IGNORE THIS METHOD - } } diff --git a/src/main/java/frc/robot/subsystems/LimelightSubsystem.java b/src/main/java/frc/robot/subsystems/LimelightSubsystem.java index 08706ee..c960cf6 100644 --- a/src/main/java/frc/robot/subsystems/LimelightSubsystem.java +++ b/src/main/java/frc/robot/subsystems/LimelightSubsystem.java @@ -1,11 +1,11 @@ package frc.robot.subsystems; -import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj2.command.Subsystem; import edu.wpi.first.networktables.NetworkTable; import edu.wpi.first.networktables.NetworkTableInstance; -public class LimelightSubsystem extends Subsystem{ +public class LimelightSubsystem implements Subsystem{ public final static double IMAGE_WIDTH = Math.toRadians(27.); // In degrees public final static double IMAGE_HEIGHT = Math.toRadians(20.5); // In degrees @@ -30,9 +30,4 @@ public boolean contourExists(){ public void periodicLog(){ } - - @Override - protected void initDefaultCommand() { - // LITTERALLY DIE - } } \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/PigeonSubsystem.java b/src/main/java/frc/robot/subsystems/PigeonSubsystem.java index b92c18e..f56536e 100644 --- a/src/main/java/frc/robot/subsystems/PigeonSubsystem.java +++ b/src/main/java/frc/robot/subsystems/PigeonSubsystem.java @@ -5,10 +5,10 @@ import frc.robot.robotState.RobotStateUpdater; import frc.robot.robotState.RobotState.SD; import frc.robot.sciSensorsActuators.SciPigeon; -import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj2.command.Subsystem; import com.ctre.phoenix.motorcontrol.can.TalonSRX; -public class PigeonSubsystem extends Subsystem { +public class PigeonSubsystem implements Subsystem { // for the main pigeon on the robot public SciPigeon pigeon; private TalonSRX pigeonTalon; @@ -20,9 +20,4 @@ public PigeonSubsystem () { } public SciPigeon getPigeon() {return this.pigeon;} - - @Override - protected void initDefaultCommand() { - //IGNORE THIS METHOD - } } \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/PneumaticsSubsystem.java b/src/main/java/frc/robot/subsystems/PneumaticsSubsystem.java index f694a76..f03a3ac 100644 --- a/src/main/java/frc/robot/subsystems/PneumaticsSubsystem.java +++ b/src/main/java/frc/robot/subsystems/PneumaticsSubsystem.java @@ -1,6 +1,6 @@ package frc.robot.subsystems; -import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj2.command.Subsystem; import edu.wpi.first.wpilibj.AnalogInput; import edu.wpi.first.wpilibj.Compressor; import frc.robot.PortMap; @@ -9,7 +9,7 @@ import frc.robot.robotState.RobotState.SD; import frc.robot.logging.Logger.DefaultValue; -public class PneumaticsSubsystem extends Subsystem implements RobotStateUpdater { +public class PneumaticsSubsystem implements Subsystem, RobotStateUpdater { private AnalogInput pressureSensor; private final double NORMALIZED_SUPPLY_VOLTAGE = 5.0; @@ -17,9 +17,6 @@ public class PneumaticsSubsystem extends Subsystem implements RobotStateUpdater private final String FILENAME = "PneumaticsSubsystem.java"; public static final SD VOLTAGE_SD = SD.PressureSensorVoltage; - @Override - public void initDefaultCommand() {} - public PneumaticsSubsystem() { this.pressureSensor = new AnalogInput(PortMap.PRESSURE_SENSOR); //Robot.set(SD.PressureSensorVoltage, 0.0); diff --git a/vendordeps/WPILibOldCommands.json b/vendordeps/WPILibOldCommands.json deleted file mode 100644 index f9fbc4d..0000000 --- a/vendordeps/WPILibOldCommands.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "fileName": "WPILibOldCommands.json", - "name": "WPILib-Old-Commands", - "version": "2020.0.0", - "uuid": "b066afc2-5c18-43c4-b758-43381fcb275e", - "mavenUrls": [], - "jsonUrl": "", - "javaDependencies": [ - { - "groupId": "edu.wpi.first.wpilibOldCommands", - "artifactId": "wpilibOldCommands-java", - "version": "wpilib" - } - ], - "jniDependencies": [], - "cppDependencies": [ - { - "groupId": "edu.wpi.first.wpilibOldCommands", - "artifactId": "wpilibOldCommands-cpp", - "version": "wpilib", - "libName": "wpilibOldCommands", - "headerClassifier": "headers", - "sourcesClassifier": "sources", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "linuxathena", - "linuxraspbian", - "linuxaarch64bionic", - "windowsx86-64", - "windowsx86", - "linuxx86-64", - "osxx86-64" - ] - } - ] -} From c12bb81f2a120cc0218cb609de66506f3ffb0ab2 Mon Sep 17 00:00:00 2001 From: Dhinak G Date: Sun, 9 Feb 2020 18:08:11 -0500 Subject: [PATCH 4/5] Fix some stuff --- src/main/java/frc/robot/commands/IntakeSuckCommand.java | 4 ++-- .../robot/commands/generalCommands/SciSparkSpeedCommand.java | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/commands/IntakeSuckCommand.java b/src/main/java/frc/robot/commands/IntakeSuckCommand.java index 1f3f865..6d6cbb8 100644 --- a/src/main/java/frc/robot/commands/IntakeSuckCommand.java +++ b/src/main/java/frc/robot/commands/IntakeSuckCommand.java @@ -1,10 +1,10 @@ package frc.robot.commands; -import edu.wpi.first.wpilibj2.command.CommandBase; +import edu.wpi.first.wpilibj2.command.InstantCommand; import frc.robot.Robot; import frc.robot.logging.Logger.CommandStatus; -public class IntakeSuckCommand extends CommandBase { +public class IntakeSuckCommand extends InstantCommand { private final String FILENAME = "IntakeSuckCommand.java"; diff --git a/src/main/java/frc/robot/commands/generalCommands/SciSparkSpeedCommand.java b/src/main/java/frc/robot/commands/generalCommands/SciSparkSpeedCommand.java index 3211d72..49de861 100644 --- a/src/main/java/frc/robot/commands/generalCommands/SciSparkSpeedCommand.java +++ b/src/main/java/frc/robot/commands/generalCommands/SciSparkSpeedCommand.java @@ -1,8 +1,5 @@ package frc.robot.commands.generalCommands; -import java.util.HashSet; -import java.util.Set; - import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.sciSensorsActuators.SciSpark; From d7c64e89dd5c543a75639c8f94750c211bb5689c Mon Sep 17 00:00:00 2001 From: Dhinak G Date: Sat, 22 Feb 2020 12:17:04 -0500 Subject: [PATCH 5/5] Fix errors --- src/main/java/frc/robot/OI.java | 2 +- src/main/java/frc/robot/Robot.java | 2 +- .../generalCommands/SparkDelayWarningCommand.java | 8 ++++---- .../generalCommands/TalonDelayWarningCommand.java | 8 ++++---- src/main/java/frc/robot/sciSensorsActuators/SciSpark.java | 2 +- src/main/java/frc/robot/sciSensorsActuators/SciTalon.java | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 2597ceb..0bfa6e2 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -22,7 +22,7 @@ public OI() { xboxController = new XboxController(PortMap.XBOX_CONTROLLER); circleControllerButton = new JoystickButton(leftStick, PortMap.JOYSTICK_TRIGGER); - circleControllerButton.whileActive(new CircleControllerCommand()); + circleControllerButton.whileActiveContinuous(new CircleControllerCommand()); pointThreeButton = new JoystickButton(leftStick, PortMap.JOYSTICK_CENTER_BUTTON); pointThreeButton.whenPressed(new PointThreeCommand()); diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index a529521..ad8d3ab 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -210,7 +210,7 @@ public void teleopPeriodic() { public void testPeriodic() { - (new TankDriveCommand()).start(); + CommandScheduler.getInstance().schedule(new TankDriveCommand()); Robot.driveSubsystem.l.diminishSnap(); Robot.driveSubsystem.r.diminishSnap(); DelayedPrinter.print("testing..."); diff --git a/src/main/java/frc/robot/commands/generalCommands/SparkDelayWarningCommand.java b/src/main/java/frc/robot/commands/generalCommands/SparkDelayWarningCommand.java index 7b18ac1..639fd12 100644 --- a/src/main/java/frc/robot/commands/generalCommands/SparkDelayWarningCommand.java +++ b/src/main/java/frc/robot/commands/generalCommands/SparkDelayWarningCommand.java @@ -1,10 +1,10 @@ package frc.robot.commands.generalCommands; -import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.sciSensorsActuators.SciSpark; import frc.robot.Utils; -public class SparkDelayWarningCommand extends Command { +public class SparkDelayWarningCommand extends CommandBase { private SciSpark sciSpark; private double input; @@ -17,7 +17,7 @@ public SparkDelayWarningCommand (final SciSpark sciSpark, double input) { } @Override - protected void execute () { + public void execute() { ticks++; if (!Utils.impreciseEquals(this.sciSpark.get(), this.input)) { System.out.println("WARNING: " + this.sciSpark.getDeviceName() + " was set to " + this.input @@ -27,7 +27,7 @@ protected void execute () { } @Override - protected boolean isFinished () { + public boolean isFinished() { return !Utils.impreciseEquals(this.sciSpark.get(), this.input); } diff --git a/src/main/java/frc/robot/commands/generalCommands/TalonDelayWarningCommand.java b/src/main/java/frc/robot/commands/generalCommands/TalonDelayWarningCommand.java index 35588a6..f680073 100644 --- a/src/main/java/frc/robot/commands/generalCommands/TalonDelayWarningCommand.java +++ b/src/main/java/frc/robot/commands/generalCommands/TalonDelayWarningCommand.java @@ -1,10 +1,10 @@ package frc.robot.commands.generalCommands; -import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.sciSensorsActuators.SciTalon; import frc.robot.Utils; -public class TalonDelayWarningCommand extends Command { +public class TalonDelayWarningCommand extends CommandBase { private SciTalon sciTalon; private double input; @@ -17,7 +17,7 @@ public TalonDelayWarningCommand (final SciTalon sciTalon, double input) { } @Override - protected void execute () { + public void execute () { ticks++; if (!Utils.impreciseEquals(this.sciTalon.getMotorOutputPercent(), this.input)) { System.out.println("WARNING: " + this.sciTalon.getDeviceID() + " was set to " + this.input @@ -27,7 +27,7 @@ protected void execute () { } @Override - protected boolean isFinished () { + public boolean isFinished () { return !Utils.impreciseEquals(this.sciTalon.getMotorOutputPercent(), this.input); } diff --git a/src/main/java/frc/robot/sciSensorsActuators/SciSpark.java b/src/main/java/frc/robot/sciSensorsActuators/SciSpark.java index 4703094..b3cb98d 100644 --- a/src/main/java/frc/robot/sciSensorsActuators/SciSpark.java +++ b/src/main/java/frc/robot/sciSensorsActuators/SciSpark.java @@ -110,7 +110,7 @@ public void instantSet() { public void checkWarningStatus(double input, double realOutput){ if (!Utils.inRange(input, super.get(), TOLERABLE_DIFFERENCE)) { - (new SparkDelayWarningCommand(this, input)).start(); + CommandScheduler.getInstance().schedule(new SparkDelayWarningCommand(this, input)); } } diff --git a/src/main/java/frc/robot/sciSensorsActuators/SciTalon.java b/src/main/java/frc/robot/sciSensorsActuators/SciTalon.java index 467057f..03cf7f8 100644 --- a/src/main/java/frc/robot/sciSensorsActuators/SciTalon.java +++ b/src/main/java/frc/robot/sciSensorsActuators/SciTalon.java @@ -61,7 +61,7 @@ public void instantSet() { } public void checkWarningStatus(double input, double realOutput){ if (!Utils.inRange(input, super.getMotorOutputPercent(), TOLERABLE_DIFFERENCE)) { - (new TalonDelayWarningCommand(this, input)).start(); + CommandScheduler.getInstance().schedule(new TalonDelayWarningCommand(this, input)); } }