2024-01-17 19:19:54 -05:00
|
|
|
// 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;
|
|
|
|
|
2024-02-01 19:20:32 -05:00
|
|
|
import com.pathplanner.lib.auto.AutoBuilder;
|
|
|
|
import com.pathplanner.lib.auto.NamedCommands;
|
2024-01-23 18:41:48 -05:00
|
|
|
import edu.wpi.first.cameraserver.CameraServer;
|
|
|
|
import edu.wpi.first.math.MathUtil;
|
2024-02-08 18:59:08 -05:00
|
|
|
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
|
|
|
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
2024-02-01 19:20:32 -05:00
|
|
|
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
|
2024-01-17 19:19:54 -05:00
|
|
|
import edu.wpi.first.wpilibj2.command.Command;
|
2024-02-07 20:24:12 -05:00
|
|
|
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
|
2024-01-23 18:41:48 -05:00
|
|
|
import edu.wpi.first.wpilibj2.command.RunCommand;
|
2024-02-13 18:17:38 -05:00
|
|
|
|
2024-01-30 19:54:07 -05:00
|
|
|
// Manettes
|
2024-01-23 18:41:48 -05:00
|
|
|
import edu.wpi.first.wpilibj2.command.button.CommandJoystick;
|
|
|
|
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
2024-02-12 17:49:10 -05:00
|
|
|
|
2024-01-30 19:54:07 -05:00
|
|
|
// Commands
|
2024-02-12 17:49:10 -05:00
|
|
|
import frc.robot.command.AllumeLED;
|
2024-01-30 19:52:21 -05:00
|
|
|
import frc.robot.command.Balayer;
|
2024-02-01 20:20:04 -05:00
|
|
|
import frc.robot.command.GrimpeurDroit;
|
|
|
|
import frc.robot.command.GrimpeurGauche;
|
2024-01-30 19:52:09 -05:00
|
|
|
import frc.robot.command.GuiderBas;
|
|
|
|
import frc.robot.command.GuiderHaut;
|
2024-02-01 19:20:32 -05:00
|
|
|
import frc.robot.command.Lancer;
|
|
|
|
import frc.robot.command.LancerNote;
|
|
|
|
import frc.robot.command.Lancerampli;
|
2024-02-07 20:24:12 -05:00
|
|
|
import frc.robot.command.Limelight_tracker;
|
2024-02-08 18:21:44 -05:00
|
|
|
import frc.robot.command.PistonFerme;
|
2024-02-07 20:24:12 -05:00
|
|
|
import frc.robot.command.Pistongrimpeur;
|
2024-02-13 18:17:38 -05:00
|
|
|
|
2024-01-30 19:54:07 -05:00
|
|
|
// Subsystems
|
2024-01-23 18:41:48 -05:00
|
|
|
import frc.robot.subsystem.Accumulateur;
|
|
|
|
import frc.robot.subsystem.Balayeuse;
|
|
|
|
import frc.robot.subsystem.Drive;
|
|
|
|
import frc.robot.subsystem.Grimpeur;
|
|
|
|
import frc.robot.subsystem.Guideur;
|
2024-02-06 18:17:08 -05:00
|
|
|
import frc.robot.subsystem.LED;
|
2024-01-23 18:41:48 -05:00
|
|
|
import frc.robot.subsystem.Lanceur;
|
2024-02-07 19:50:57 -05:00
|
|
|
import frc.robot.subsystem.Limelight;
|
2024-01-23 18:41:48 -05:00
|
|
|
|
2024-01-17 19:19:54 -05:00
|
|
|
|
|
|
|
public class RobotContainer {
|
2024-02-08 18:59:08 -05:00
|
|
|
ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard");
|
2024-02-01 19:20:32 -05:00
|
|
|
private final SendableChooser<Command> autoChooser;
|
2024-01-23 18:41:48 -05:00
|
|
|
Drive drive = new Drive();
|
|
|
|
Accumulateur accumulateur = new Accumulateur();
|
|
|
|
Balayeuse balayeuse = new Balayeuse();
|
|
|
|
Grimpeur grimpeur = new Grimpeur();
|
|
|
|
Guideur guideur = new Guideur();
|
|
|
|
Lanceur lanceur = new Lanceur();
|
2024-02-07 19:50:57 -05:00
|
|
|
Limelight limelight = new Limelight();
|
2024-02-07 19:52:54 -05:00
|
|
|
LED LED = new LED();
|
2024-01-23 18:41:48 -05:00
|
|
|
CommandJoystick joystick = new CommandJoystick(0);
|
|
|
|
CommandXboxController manette = new CommandXboxController(1);
|
2024-02-13 18:17:38 -05:00
|
|
|
|
2024-02-07 19:38:43 -05:00
|
|
|
//command
|
2024-02-08 18:21:44 -05:00
|
|
|
PistonFerme pistonFerme = new PistonFerme(grimpeur);
|
2024-02-07 19:52:54 -05:00
|
|
|
Balayer balayer = new Balayer(balayeuse, accumulateur);
|
|
|
|
GuiderHaut guiderHaut = new GuiderHaut(guideur);
|
2024-02-08 19:53:38 -05:00
|
|
|
Lancer lancer = new Lancer(lanceur,limelight);
|
2024-02-07 19:52:54 -05:00
|
|
|
LancerNote lancernote = new LancerNote(lanceur, accumulateur);
|
|
|
|
Lancerampli lancerampli = new Lancerampli(lanceur,limelight);
|
2024-02-05 19:14:59 -05:00
|
|
|
GrimpeurDroit grimpeurDroit = new GrimpeurDroit(grimpeur, manette::getLeftX);
|
2024-02-12 18:16:07 -05:00
|
|
|
GrimpeurGauche grimpeurGauche = new GrimpeurGauche(grimpeur, manette::getRightX);
|
2024-02-12 18:06:49 -05:00
|
|
|
AllumeLED allumeLED = new AllumeLED(LED, accumulateur);
|
2024-02-07 20:24:12 -05:00
|
|
|
Pistongrimpeur pistongrimpeur = new Pistongrimpeur(grimpeur, LED);
|
2024-01-17 19:19:54 -05:00
|
|
|
public RobotContainer() {
|
2024-02-08 18:59:08 -05:00
|
|
|
dashboard.addCamera("limelight", "limelight","limelight.local:5800");
|
2024-02-01 20:01:29 -05:00
|
|
|
NamedCommands.registerCommand("balayer",new Balayer(balayeuse, accumulateur));
|
|
|
|
NamedCommands.registerCommand("lancer", new LancerNote(lanceur, accumulateur));
|
2024-02-08 18:21:44 -05:00
|
|
|
NamedCommands.registerCommand("piston", new PistonFerme(grimpeur));
|
2024-02-01 19:20:32 -05:00
|
|
|
autoChooser = AutoBuilder.buildAutoChooser();
|
2024-01-23 18:41:48 -05:00
|
|
|
|
|
|
|
CameraServer.startAutomaticCapture();
|
2024-02-08 19:53:38 -05:00
|
|
|
manette.a().whileTrue(new GuiderBas(guideur));
|
|
|
|
manette.b().whileTrue(new GuiderHaut(guideur));
|
2024-02-17 13:27:27 -05:00
|
|
|
manette.x().whileTrue(new PistonFerme(grimpeur));
|
2024-02-13 18:25:30 -05:00
|
|
|
joystick.button(3).whileTrue(new Balayer(balayeuse, accumulateur));
|
2024-02-08 19:53:38 -05:00
|
|
|
joystick.button(1).whileTrue(new LancerNote(lanceur, accumulateur));
|
2024-02-08 20:16:02 -05:00
|
|
|
joystick.button(4).whileTrue(new ParallelCommandGroup(new Lancer(lanceur,limelight),new Limelight_tracker(limelight,drive)));
|
|
|
|
joystick.button(2).whileTrue(new ParallelCommandGroup(new Lancerampli(lanceur,limelight),new Limelight_tracker(limelight,drive),new GuiderHaut(guideur)));
|
2024-02-15 18:25:45 -05:00
|
|
|
|
2024-02-13 18:08:55 -05:00
|
|
|
// deplacement
|
2024-01-17 19:19:54 -05:00
|
|
|
configureBindings();
|
2024-01-23 18:41:48 -05:00
|
|
|
drive.setDefaultCommand(new RunCommand(()->{
|
2024-02-14 18:56:52 -05:00
|
|
|
drive.drive(MathUtil.applyDeadband(joystick.getY(),0.2), MathUtil.applyDeadband(joystick.getX(),0.2), MathUtil.applyDeadband(joystick.getZ(), 0.2));
|
2024-01-23 18:41:48 -05:00
|
|
|
},drive));
|
2024-02-13 18:08:55 -05:00
|
|
|
|
|
|
|
// grimpeur manuel
|
2024-02-06 18:17:08 -05:00
|
|
|
grimpeur.setDefaultCommand(new RunCommand(()->{
|
2024-02-12 18:16:07 -05:00
|
|
|
grimpeur.droit(manette.getLeftX());
|
|
|
|
grimpeur.gauche(manette.getRightX());}
|
2024-02-06 18:17:08 -05:00
|
|
|
,grimpeur));
|
2024-02-12 18:16:07 -05:00
|
|
|
|
2024-02-06 18:17:08 -05:00
|
|
|
LED.setDefaultCommand(allumeLED);
|
2024-02-08 19:14:30 -05:00
|
|
|
dashboard.add("autochooser",autoChooser)
|
|
|
|
.withSize(2,1)
|
|
|
|
.withPosition(1,1);
|
2024-01-17 19:19:54 -05:00
|
|
|
}
|
|
|
|
|
2024-02-13 18:17:38 -05:00
|
|
|
private void configureBindings() {}
|
2024-01-17 19:19:54 -05:00
|
|
|
|
2024-02-01 19:33:02 -05:00
|
|
|
public Command getAutonomousCommand(){
|
2024-02-13 18:17:38 -05:00
|
|
|
return autoChooser.getSelected();
|
2024-01-17 19:19:54 -05:00
|
|
|
}
|
|
|
|
}
|