diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index bc9b7f1..5fcb0a5 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -5,18 +5,15 @@ package frc.robot; import edu.wpi.first.networktables.GenericEntry; import edu.wpi.first.wpilibj.Joystick; -import edu.wpi.first.wpilibj.XboxController; import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj2.command.Command; -import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.RunCommand; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import edu.wpi.first.wpilibj2.command.button.JoystickButton; -import frc.robot.commands.Force1; import frc.robot.subsystems.Accumulateur; import frc.robot.subsystems.Drive; import frc.robot.subsystems.Lanceur; diff --git a/src/main/java/frc/robot/commands/Avancer.java b/src/main/java/frc/robot/commands/Avancer.java new file mode 100644 index 0000000..1e61eca --- /dev/null +++ b/src/main/java/frc/robot/commands/Avancer.java @@ -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.CommandBase; +import frc.robot.subsystems.Drive; + +public class Avancer extends CommandBase { + private Drive drive; + /** Creates a new Avancer. */ + public Avancer(Drive drive) { + // 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/Force1.java b/src/main/java/frc/robot/commands/Force1.java index dc3e8d5..09b74c1 100644 --- a/src/main/java/frc/robot/commands/Force1.java +++ b/src/main/java/frc/robot/commands/Force1.java @@ -6,16 +6,20 @@ package frc.robot.commands; import edu.wpi.first.networktables.GenericEntry; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.CommandBase; +import frc.robot.subsystems.Accumulateur; import frc.robot.subsystems.Lanceur; public class Force1 extends CommandBase { private Lanceur lanceur; + private Accumulateur accumulateur; GenericEntry force1; /** Creates a new Force1. */ - public Force1(Lanceur lanceur, GenericEntry force1) { + public Force1(Lanceur lanceur,Accumulateur accumulateur, GenericEntry force1) { this.lanceur = lanceur; + this.accumulateur = accumulateur; addRequirements(lanceur); this.force1 = force1; // Use addRequirements() here to declare subsystem dependencies. @@ -31,8 +35,15 @@ public class Force1 extends CommandBase { @Override public void execute() { lanceur.lancer(force1.getDouble(0)); - + double vitesse = SmartDashboard.getNumber("Force Lanceur", 100); + if (lanceur.vitesse() > vitesse ){ + accumulateur.tourneavant(); + accumulateur.tournearriere(); + } else { + accumulateur.stop(); + } } + // Called once the command ends or is interrupted. @Override diff --git a/src/main/java/frc/robot/commands/Force2.java b/src/main/java/frc/robot/commands/Force2.java index d359ed5..51a8f33 100644 --- a/src/main/java/frc/robot/commands/Force2.java +++ b/src/main/java/frc/robot/commands/Force2.java @@ -4,15 +4,19 @@ package frc.robot.commands; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.CommandBase; +import frc.robot.subsystems.Accumulateur; import frc.robot.subsystems.Lanceur; public class Force2 extends CommandBase { private Lanceur lanceur; + private Accumulateur accumulateur; /** Creates a new Force1. */ - public Force2(Lanceur lancer) { + public Force2(Lanceur lancer,Accumulateur accumulateur) { this.lanceur = lanceur; + this.accumulateur = accumulateur; addRequirements(lanceur); // Use addRequirements() here to declare subsystem dependencies. } @@ -26,7 +30,13 @@ public class Force2 extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - lanceur.lancer(500); + double vitesse = SmartDashboard.getNumber("Force Lanceur", 200); + if (lanceur.vitesse() > vitesse ){ + accumulateur.tourneavant(); + accumulateur.tournearriere(); + } else { + accumulateur.stop(); + } } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/commands/Force3.java b/src/main/java/frc/robot/commands/Force3.java index 71c9e95..574cda2 100644 --- a/src/main/java/frc/robot/commands/Force3.java +++ b/src/main/java/frc/robot/commands/Force3.java @@ -44,9 +44,12 @@ public class Force3 extends CommandBase { public void execute() { double vitesse = SmartDashboard.getNumber("Force Lanceur", 300); - lanceur.lancer(200); - lanceur.lancer(force3.getDouble(0));} - public void end(boolean interrupted) { + if (lanceur.vitesse() > vitesse ){ + accumulateur.tourneavant(); + accumulateur.tournearriere(); + } else { + accumulateur.stop(); + } } @Override public boolean isFinished() { diff --git a/src/main/java/frc/robot/commands/Force4.java b/src/main/java/frc/robot/commands/Force4.java index 498cc4b..17329d7 100644 --- a/src/main/java/frc/robot/commands/Force4.java +++ b/src/main/java/frc/robot/commands/Force4.java @@ -38,7 +38,7 @@ public class Force4 extends CommandBase { @Override public void execute() { double vitesse = SmartDashboard.getNumber("Force Lanceur", 400); - lanceur.lancer(200); + lanceur.lancer(400); if (lanceur.vitesse() > vitesse ){ accumulateur.tourneavant(); accumulateur.tournearriere(); diff --git a/src/main/java/frc/robot/commands/Force5.java b/src/main/java/frc/robot/commands/Force5.java index 669dae0..d085a11 100644 --- a/src/main/java/frc/robot/commands/Force5.java +++ b/src/main/java/frc/robot/commands/Force5.java @@ -38,7 +38,7 @@ public class Force5 extends CommandBase { @Override public void execute() { double vitesse = SmartDashboard.getNumber("Force Lanceur", 500); - lanceur.lancer(200); + lanceur.lancer(500); if (lanceur.vitesse() > vitesse ){ accumulateur.tourneavant(); accumulateur.tournearriere(); diff --git a/src/main/java/frc/robot/commands/Force6.java b/src/main/java/frc/robot/commands/Force6.java index 2cbf863..6fc9fe3 100644 --- a/src/main/java/frc/robot/commands/Force6.java +++ b/src/main/java/frc/robot/commands/Force6.java @@ -39,7 +39,7 @@ public class Force6 extends CommandBase { @Override public void execute() { double vitesse = SmartDashboard.getNumber("Force Lanceur", 600); - lanceur.lancer(200); + lanceur.lancer(600); if (lanceur.vitesse() > vitesse ){ accumulateur.tourneavant(); accumulateur.tournearriere(); diff --git a/src/main/java/frc/robot/commands/Force7.java b/src/main/java/frc/robot/commands/Force7.java index 6558569..24f4e52 100644 --- a/src/main/java/frc/robot/commands/Force7.java +++ b/src/main/java/frc/robot/commands/Force7.java @@ -38,7 +38,7 @@ public class Force7 extends CommandBase { @Override public void execute() { double vitesse = SmartDashboard.getNumber("Force Lanceur", 700); - lanceur.lancer(200); + lanceur.lancer(700); if (lanceur.vitesse() > vitesse ){ accumulateur.tourneavant(); accumulateur.tournearriere(); diff --git a/src/main/java/frc/robot/subsystems/Drive.java b/src/main/java/frc/robot/subsystems/Drive.java index 637b22c..049ee3f 100644 --- a/src/main/java/frc/robot/subsystems/Drive.java +++ b/src/main/java/frc/robot/subsystems/Drive.java @@ -30,7 +30,9 @@ public class Drive extends SubsystemBase { e.printStackTrace(); } } - + public void reset(){ + + } @Override public void periodic() { // This method will be called once per scheduler run