This commit is contained in:
Olivier Dubois 2024-02-05 19:16:00 -05:00
commit 18bc9052da
3 changed files with 38 additions and 15 deletions

View File

@ -22,6 +22,8 @@ import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
// Commands
import frc.robot.command.Balayer;
import frc.robot.command.GrimpeurDroit;
import frc.robot.command.GrimpeurGauche;
import frc.robot.command.GuiderBas;
import frc.robot.command.GuiderHaut;
import frc.robot.command.Lancer;
@ -52,7 +54,8 @@ public class RobotContainer {
Lancerampli lancerampli = new Lancerampli(lanceur);
CommandJoystick joystick = new CommandJoystick(0);
CommandXboxController manette = new CommandXboxController(1);
GrimpeurDroit grimpeurDroit = new GrimpeurDroit(grimpeur, manette::getLeftX);
GrimpeurGauche grimpeurGauche = new GrimpeurGauche(grimpeur, manette::getLeftY);
public RobotContainer() {
NamedCommands.registerCommand("balayer",new Balayer(balayeuse, accumulateur));
NamedCommands.registerCommand("lancer", new LancerNote(lanceur, accumulateur));
@ -70,7 +73,7 @@ public class RobotContainer {
private void configureBindings() {
joystick.button(3).toggleOnTrue(balayer);
joystick.button(3).toggleOnTrue(balayer);
}

View File

@ -4,13 +4,17 @@
package frc.robot.command;
import java.util.function.DoubleSupplier;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystem.Grimpeur;
public class GrimpeurHautDroit extends Command {
public class GrimpeurDroit extends Command {
private DoubleSupplier doubleSupplier;
private Grimpeur grimpeur;
/** Creates a new GrimpeurHaut. */
public GrimpeurHautDroit(Grimpeur grimpeur) {
public GrimpeurDroit(Grimpeur grimpeur, DoubleSupplier doubleSupplier) {
this.doubleSupplier = doubleSupplier;
this.grimpeur = grimpeur;
addRequirements(grimpeur);
// Use addRequirements() here to declare subsystem dependencies.
@ -20,26 +24,32 @@ public class GrimpeurHautDroit extends Command {
@Override
public void initialize() {
grimpeur.resetencodeurd();
grimpeur.resetencodeurg();
grimpeur.pistonferme();
}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
if(grimpeur.encoderd()>261 ){
grimpeur.droit(doubleSupplier.getAsDouble());
if(grimpeur.encoderd()>261){
grimpeur.droit(0);
}
else if(grimpeur.getpitch()<-15){
grimpeur.droit(-0.6);
grimpeur.droit(-doubleSupplier.getAsDouble());
}
else if(grimpeur.getpitch()>15){
grimpeur.droit(0.6);
grimpeur.droit(doubleSupplier.getAsDouble());
}
else{
grimpeur.droit(0);
}
if(grimpeur.encoderd()>0){
grimpeur.resetencodeurd();
grimpeur.droit(0);
}
}
// Called once the command ends or is interrupted.

View File

@ -4,13 +4,17 @@
package frc.robot.command;
import java.util.function.DoubleSupplier;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystem.Grimpeur;
public class GrimpeurHautGauche extends Command {
public class GrimpeurGauche extends Command {
private DoubleSupplier doubleSupplier;
private Grimpeur grimpeur;
/** Creates a new GrimpeurHautGauche. */
public GrimpeurHautGauche(Grimpeur grimpeur) {
public GrimpeurGauche(Grimpeur grimpeur,DoubleSupplier doubleSupplier) {
this.doubleSupplier = doubleSupplier;
this.grimpeur = grimpeur;
addRequirements(grimpeur);
// Use addRequirements() here to declare subsystem dependencies.
@ -26,19 +30,25 @@ public class GrimpeurHautGauche extends Command {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
if(grimpeur.encoderg()>261 ){
grimpeur.gauche(doubleSupplier.getAsDouble());
if(grimpeur.encoderg()>261){
grimpeur.gauche(0);
}
else if(grimpeur.getpitch()<-15){
grimpeur.gauche(0.6);
grimpeur.gauche(doubleSupplier.getAsDouble());
}
else if(grimpeur.getpitch()>15){
grimpeur.gauche(-0.6);
grimpeur.gauche(-doubleSupplier.getAsDouble());
}
else{
grimpeur.gauche(0);
}
if(grimpeur.encoderd()>0){
grimpeur.resetencodeurg();
grimpeur.gauche(0);
}
}
// Called once the command ends or is interrupted.