diff --git a/src/main/java/frc/robot/commands/states/PrepCorner.java b/src/main/java/frc/robot/commands/states/PrepCorner.java deleted file mode 100644 index 9eac9f6..0000000 --- a/src/main/java/frc/robot/commands/states/PrepCorner.java +++ /dev/null @@ -1,35 +0,0 @@ -// 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.states; - -import edu.wpi.first.wpilibj2.command.Command; - -public class PrepCorner extends Command { - /** Creates a new PrepNonOutpost. */ - public PrepCorner() { - // Use addRequirements() here to declare subsystem dependencies. - } - - // 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() { - } - - // Called once the command ends or is interrupted. - @Override - public void end(boolean interrupted) { - } - - // Returns true when the command should end. - @Override - public boolean isFinished() { - return false; - } -} diff --git a/src/main/java/frc/robot/commands/states/PrepHub.java b/src/main/java/frc/robot/commands/states/PrepHub.java deleted file mode 100644 index 31c794b..0000000 --- a/src/main/java/frc/robot/commands/states/PrepHub.java +++ /dev/null @@ -1,35 +0,0 @@ -// 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.states; - -import edu.wpi.first.wpilibj2.command.Command; - -public class PrepHub extends Command { - /** Creates a new PrepDepot. */ - public PrepHub() { - // Use addRequirements() here to declare subsystem dependencies. - } - - // 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() { - } - - // Called once the command ends or is interrupted. - @Override - public void end(boolean interrupted) { - } - - // Returns true when the command should end. - @Override - public boolean isFinished() { - return false; - } -} diff --git a/src/main/java/frc/robot/commands/states/PrepOpponentToAlliance.java b/src/main/java/frc/robot/commands/states/PrepOpponentToAlliance.java deleted file mode 100644 index 5c6121a..0000000 --- a/src/main/java/frc/robot/commands/states/PrepOpponentToAlliance.java +++ /dev/null @@ -1,33 +0,0 @@ -// 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.states; - -import edu.wpi.first.wpilibj2.command.Command; - -/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ -public class PrepOpponentToAlliance extends Command { - /** Creates a new PrepOpponentToAlliance. */ - public PrepOpponentToAlliance() { - // Use addRequirements() here to declare subsystem dependencies. - } - - // 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() {} - - // Called once the command ends or is interrupted. - @Override - public void end(boolean interrupted) {} - - // Returns true when the command should end. - @Override - public boolean isFinished() { - return false; - } -} diff --git a/src/main/java/frc/robot/commands/states/PrepTower.java b/src/main/java/frc/robot/commands/states/PrepTower.java deleted file mode 100644 index 5b100fb..0000000 --- a/src/main/java/frc/robot/commands/states/PrepTower.java +++ /dev/null @@ -1,35 +0,0 @@ -// 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.states; - -import edu.wpi.first.wpilibj2.command.Command; - -public class PrepTower extends Command { - /** Creates a new PrepOutpost. */ - public PrepTower() { - // Use addRequirements() here to declare subsystem dependencies. - } - - // 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() { - } - - // Called once the command ends or is interrupted. - @Override - public void end(boolean interrupted) { - } - - // Returns true when the command should end. - @Override - public boolean isFinished() { - return false; - } -} diff --git a/src/main/java/frc/robot/commands/states/PrepTrench.java b/src/main/java/frc/robot/commands/states/PrepTrench.java deleted file mode 100644 index 9eb314e..0000000 --- a/src/main/java/frc/robot/commands/states/PrepTrench.java +++ /dev/null @@ -1,32 +0,0 @@ -// 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.states; - -import edu.wpi.first.wpilibj2.command.Command; - -public class PrepTrench extends Command { - /** Creates a new PrepTrench. */ - public PrepTrench() { - // Use addRequirements() here to declare subsystem dependencies. - } - - // 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() {} - - // Called once the command ends or is interrupted. - @Override - public void end(boolean interrupted) {} - - // Returns true when the command should end. - @Override - public boolean isFinished() { - return false; - } -} diff --git a/src/main/java/frc/robot/commands/states/Shooting.java b/src/main/java/frc/robot/commands/states/Shooting.java index 9c381b4..8c06822 100644 --- a/src/main/java/frc/robot/commands/states/Shooting.java +++ b/src/main/java/frc/robot/commands/states/Shooting.java @@ -26,7 +26,7 @@ public void initialize() { @Override public void execute() { - RobotContainer.rotorsInstance.setFlywheelSpeeds(ConstRotors.FLYWHEEL_SHOOTING_SPEED); + RobotContainer.rotorsInstance.setFlyWheelSpeeds(ConstRotors.FLYWHEEL_SHOOTING_SPEED); if (RobotContainer.rotorsInstance.isFlyWheelAtSpeed(ConstRotors.FLYWHEEL_SHOOTING_SPEED)) { RobotContainer.rotorsInstance.setTransferRollersSpeeds(ConstRotors.INTAKE_TRANSFER_SPEED); RobotContainer.rotorsInstance.setSerializerRollersPercentOutput(ConstRotors.SERIALIZER_SHOOTING_SPEED); diff --git a/src/main/java/frc/robot/commands/states/preps/BasePrep.java b/src/main/java/frc/robot/commands/states/preps/BasePrep.java new file mode 100644 index 0000000..b437f43 --- /dev/null +++ b/src/main/java/frc/robot/commands/states/preps/BasePrep.java @@ -0,0 +1,52 @@ +// 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.states.preps; + +import edu.wpi.first.units.measure.*; +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.Robot; +import frc.robot.RobotContainer; +import frc.robot.subsystems.StateMachine.RobotState; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class BasePrep extends Command { + AngularVelocity globalFlyWheelSpeed; + Angle globalHoodAngle; + RobotState globalState; + + /** Creates a new BasePrep. */ + public BasePrep(AngularVelocity flyWheelSpeed, Angle hoodAngle, RobotState state) { + addRequirements(RobotContainer.stateMachineInstance); + globalFlyWheelSpeed = flyWheelSpeed; + globalHoodAngle = hoodAngle; + globalState = state; + + // Use addRequirements() here to declare subsystem dependencies. + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + RobotContainer.rotorsInstance.setFlyWheelSpeeds(globalFlyWheelSpeed); + RobotContainer.motionInstance.setHoodPivotAngle(globalHoodAngle); + RobotContainer.stateMachineInstance.setRobotState(globalState); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/states/PrepAnywhere.java b/src/main/java/frc/robot/commands/states/preps/PrepAnywhere.java similarity index 86% rename from src/main/java/frc/robot/commands/states/PrepAnywhere.java rename to src/main/java/frc/robot/commands/states/preps/PrepAnywhere.java index c40b7f7..5855253 100644 --- a/src/main/java/frc/robot/commands/states/PrepAnywhere.java +++ b/src/main/java/frc/robot/commands/states/preps/PrepAnywhere.java @@ -2,7 +2,7 @@ // 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.states; +package frc.robot.commands.states.preps; import edu.wpi.first.wpilibj2.command.Command; @@ -15,15 +15,18 @@ public PrepAnywhere() { // Called when the command is initially scheduled. @Override - public void initialize() {} + public void initialize() { + } // Called every time the scheduler runs while the command is scheduled. @Override - public void execute() {} + public void execute() { + } // Called once the command ends or is interrupted. @Override - public void end(boolean interrupted) {} + public void end(boolean interrupted) { + } // Returns true when the command should end. @Override diff --git a/src/main/java/frc/robot/commands/states/preps/PrepCorner.java b/src/main/java/frc/robot/commands/states/preps/PrepCorner.java new file mode 100644 index 0000000..699f925 --- /dev/null +++ b/src/main/java/frc/robot/commands/states/preps/PrepCorner.java @@ -0,0 +1,20 @@ +// 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.states.preps; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.constants.ConstMotion; +import frc.robot.constants.ConstRotors; +import frc.robot.subsystems.StateMachine.RobotState; + +public class PrepCorner extends BasePrep { + /** Creates a new PrepNonOutpost. */ + public PrepCorner() { + super(ConstRotors.FLYWHEEL_CORNER_SPEED, ConstMotion.HOOD_CORNER_ANGLE, RobotState.PREP_CORNER); + + // Use addRequirements() here to declare subsystem dependencies. + } + +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/states/preps/PrepHub.java b/src/main/java/frc/robot/commands/states/preps/PrepHub.java new file mode 100644 index 0000000..6a62554 --- /dev/null +++ b/src/main/java/frc/robot/commands/states/preps/PrepHub.java @@ -0,0 +1,22 @@ +// 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.states.preps; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.RobotContainer; +import frc.robot.constants.ConstMotion; +import frc.robot.constants.ConstRotors; +import frc.robot.subsystems.StateMachine.RobotState; + +public class PrepHub extends BasePrep { + /** Creates a new PrepDepot. */ + public PrepHub() { + + super(ConstRotors.FLYWHEEL_HUB_SPEED, ConstMotion.HOOD_HUB_ANGLE, RobotState.PREP_HUB); + + // setState + // Use addRequirements() here to declare subsystem dependencies. + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/states/PrepNeautralToAlliance.java b/src/main/java/frc/robot/commands/states/preps/PrepNeutralToAlliance.java similarity index 50% rename from src/main/java/frc/robot/commands/states/PrepNeautralToAlliance.java rename to src/main/java/frc/robot/commands/states/preps/PrepNeutralToAlliance.java index b70ed74..425fd41 100644 --- a/src/main/java/frc/robot/commands/states/PrepNeautralToAlliance.java +++ b/src/main/java/frc/robot/commands/states/preps/PrepNeutralToAlliance.java @@ -2,32 +2,22 @@ // 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.states; +package frc.robot.commands.states.preps; import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.constants.ConstMotion; +import frc.robot.constants.ConstRotors; +import frc.robot.subsystems.StateMachine.RobotState; /* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ -public class PrepNeautralToAlliance extends Command { +public class PrepNeutralToAlliance extends BasePrep { /** Creates a new PrepNeautralToAlliance. */ - public PrepNeautralToAlliance() { - // Use addRequirements() here to declare subsystem dependencies. - } - - // Called when the command is initially scheduled. - @Override - public void initialize() {} + public PrepNeutralToAlliance() { - // Called every time the scheduler runs while the command is scheduled. - @Override - public void execute() {} + super(ConstRotors.FLYWHEEL_NEUTRAL_TO_ALLIANCE_SPEED, ConstMotion.HOOD_NEUTRAL_TO_ALLIANCE_ANGLE, + RobotState.PREP_NEUTRAL_TO_ALLIANCE); - // Called once the command ends or is interrupted. - @Override - public void end(boolean interrupted) {} - - // Returns true when the command should end. - @Override - public boolean isFinished() { - return false; + // Use addRequirements() here to declare subsystem dependencies. } -} + +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/states/preps/PrepOpponentToAlliance.java b/src/main/java/frc/robot/commands/states/preps/PrepOpponentToAlliance.java new file mode 100644 index 0000000..4b729e7 --- /dev/null +++ b/src/main/java/frc/robot/commands/states/preps/PrepOpponentToAlliance.java @@ -0,0 +1,22 @@ +// 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.states.preps; + +import frc.robot.constants.ConstMotion; +import frc.robot.constants.ConstRotors; +import frc.robot.subsystems.StateMachine.RobotState; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class PrepOpponentToAlliance extends BasePrep { + /** Creates a new PrepOpponentToAlliance. */ + public PrepOpponentToAlliance() { + + super(ConstRotors.FLYWHEEL_OPPONENT_TO_ALLIANCE_SPEED, ConstMotion.HOOD_OPPENENT_TO_ALLIANCE_ANGLE, + RobotState.PREP_OPPONENT_TO_ALLIANCE); + + // Use addRequirements() here to declare subsystem dependencies. + } + +} diff --git a/src/main/java/frc/robot/commands/states/preps/PrepTower.java b/src/main/java/frc/robot/commands/states/preps/PrepTower.java new file mode 100644 index 0000000..f0bbc6f --- /dev/null +++ b/src/main/java/frc/robot/commands/states/preps/PrepTower.java @@ -0,0 +1,19 @@ +// 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.states.preps; + +import frc.robot.constants.ConstMotion; +import frc.robot.constants.ConstRotors; +import frc.robot.subsystems.StateMachine.RobotState; + +public class PrepTower extends BasePrep { + /** Creates a new PrepOutpost. */ + public PrepTower() { + + super(ConstRotors.FLYWHEEL_TOWER_SPEED, ConstMotion.HOOD_TOWER_ANGLE, RobotState.PREP_TOWER); + + // Use addRequirements() here to declare subsystem dependencies. + } +} diff --git a/src/main/java/frc/robot/commands/states/preps/PrepTrench.java b/src/main/java/frc/robot/commands/states/preps/PrepTrench.java new file mode 100644 index 0000000..693211e --- /dev/null +++ b/src/main/java/frc/robot/commands/states/preps/PrepTrench.java @@ -0,0 +1,20 @@ +// 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.states.preps; + +import frc.robot.constants.ConstMotion; +import frc.robot.constants.ConstRotors; +import frc.robot.subsystems.StateMachine.RobotState; + +public class PrepTrench extends BasePrep { + /** Creates a new PrepTrench. */ + public PrepTrench() { + + super(ConstRotors.FLYWHEEL_TRENCH_SPEED, ConstMotion.HOOD_TRENCH_ANGLE, RobotState.PREP_TRENCH); + + // Use addRequirements() here to declare subsystem dependencies. + } + +} diff --git a/src/main/java/frc/robot/constants/ConstMotion.java b/src/main/java/frc/robot/constants/ConstMotion.java index c011ea6..3ef98db 100644 --- a/src/main/java/frc/robot/constants/ConstMotion.java +++ b/src/main/java/frc/robot/constants/ConstMotion.java @@ -25,6 +25,13 @@ public class ConstMotion { public static final Angle HOOD_PIVOT_ANGLE = Degrees.of(14); public static final double STOP = 0; public static final Angle HOOD_NONE_ANGLE = Degrees.of(0); + public static final Angle HOOD_TRENCH_ANGLE = Units.Degrees.of(13); + public static final Angle HOOD_CORNER_ANGLE = Units.Degrees.of(23.5); + public static final Angle HOOD_TOWER_ANGLE = Units.Degrees.of(14); + public static final Angle HOOD_HUB_ANGLE = Units.Degrees.of(9.5); + public static final Angle HOOD_ANYWHERE_ANGLE = Units.Degrees.of(45); + public static final Angle HOOD_NEUTRAL_TO_ALLIANCE_ANGLE = Units.Degrees.of(45); + public static final Angle HOOD_OPPENENT_TO_ALLIANCE_ANGLE = Units.Degrees.of(37); static { diff --git a/src/main/java/frc/robot/constants/ConstRotors.java b/src/main/java/frc/robot/constants/ConstRotors.java index 2959fa7..efe9a82 100644 --- a/src/main/java/frc/robot/constants/ConstRotors.java +++ b/src/main/java/frc/robot/constants/ConstRotors.java @@ -19,8 +19,17 @@ public class ConstRotors { public static final TalonFXConfiguration INTAKE_ROLLERS_WEST_CONFIGURATION = new TalonFXConfiguration(); public static final TalonFXConfiguration TRANSFER_ROLLERS_EAST_CONFIGURATION = new TalonFXConfiguration(); public static final TalonFXConfiguration TRANSFER_ROLLERS_WEST_CONFIGURATION = new TalonFXConfiguration(); + public static final TalonFXConfiguration FLYWHEEL_EAST_CONFIGURATION = new TalonFXConfiguration(); public static final TalonFXConfiguration FLYWHEEL_WEST_CONFIGURATION = new TalonFXConfiguration(); + public static final AngularVelocity FLYWHEEL_CORNER_SPEED = Units.RPM.of(4250); + public static final AngularVelocity FLYWHEEL_HUB_SPEED = Units.RPM.of(4000); + public static final AngularVelocity FLYWHEEL_TRENCH_SPEED = Units.RPM.of(4000); + public static final AngularVelocity FLYWHEEL_TOWER_SPEED = Units.RPM.of(4000); + public static final AngularVelocity FLYWHEEL_ANYWHERE_SPEED = Units.RPM.of(4100); + public static final AngularVelocity FLYWHEEL_NEUTRAL_TO_ALLIANCE_SPEED = Units.RPM.of(3700); + public static final AngularVelocity FLYWHEEL_OPPONENT_TO_ALLIANCE_SPEED = Units.RPM.of(6400); + public static final double INTAKE_ROLLERS_SPEED = 0.5; public static final AngularVelocity FLYWHEEL_SHOOTING_SPEED = Units.RPM.of(1000); // public static final AngularVelocity INTAKE_ROLLER_SPEED = Units.RPM.of(2000); diff --git a/src/main/java/frc/robot/subsystems/Rotors.java b/src/main/java/frc/robot/subsystems/Rotors.java index f7608e7..51b57be 100644 --- a/src/main/java/frc/robot/subsystems/Rotors.java +++ b/src/main/java/frc/robot/subsystems/Rotors.java @@ -96,7 +96,7 @@ public void setTransferRollersPercentOutput(Double speed) { transferRollersWest.setControl(transferRollersEastFollower); } - public void setFlywheelSpeeds(AngularVelocity speed) { + public void setFlyWheelSpeeds(AngularVelocity speed) { flywheelTopEast.setControl(flyWheelVelocityRequest.withVelocity(speed)); flywheelTopWest.setControl(flywheelWestFollower); flywheelBottomWest.setControl(flywheelWestFollower);