121 lines
4.4 KiB
Java
121 lines
4.4 KiB
Java
// 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;
|
|
|
|
import com.pathplanner.lib.auto.AutoBuilder;
|
|
import com.pathplanner.lib.auto.NamedCommands;
|
|
import edu.wpi.first.cameraserver.CameraServer;
|
|
import edu.wpi.first.math.MathUtil;
|
|
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
|
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
|
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
|
|
import edu.wpi.first.wpilibj2.command.Command;
|
|
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
|
|
import edu.wpi.first.wpilibj2.command.RunCommand;
|
|
|
|
// Manettes
|
|
import edu.wpi.first.wpilibj2.command.button.CommandJoystick;
|
|
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;
|
|
import frc.robot.command.LancerAmp;
|
|
import frc.robot.command.LancerNote;
|
|
import frc.robot.command.LancerTrape;
|
|
import frc.robot.command.Lancerampli;
|
|
import frc.robot.command.Limelight_tracker;
|
|
import frc.robot.command.RestGyro;
|
|
import frc.robot.command.Debalayer;
|
|
// Subsystems
|
|
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;
|
|
import frc.robot.subsystem.Lanceur;
|
|
import frc.robot.subsystem.Limelight;
|
|
|
|
|
|
public class RobotContainer {
|
|
ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard");
|
|
private final SendableChooser<Command> autoChooser;
|
|
Drive drive = new Drive();
|
|
Accumulateur accumulateur = new Accumulateur();
|
|
Balayeuse balayeuse = new Balayeuse();
|
|
Grimpeur grimpeur = new Grimpeur();
|
|
Guideur guideur = new Guideur();
|
|
Lanceur lanceur = new Lanceur();
|
|
Limelight limelight = new Limelight();
|
|
|
|
//joystick
|
|
CommandJoystick joystick = new CommandJoystick(0);
|
|
CommandXboxController manette = new CommandXboxController(1);
|
|
CommandXboxController manette1 = new CommandXboxController(3);
|
|
|
|
//command
|
|
Balayer balayer = new Balayer(balayeuse, accumulateur);
|
|
GuiderHaut guiderHaut = new GuiderHaut(guideur);
|
|
GuiderBas guiderBas = new GuiderBas(guideur);
|
|
Lancer lancer = new Lancer(lanceur,limelight);
|
|
LancerNote lancernote = new LancerNote(lanceur, accumulateur);
|
|
Lancerampli lancerampli = new Lancerampli(lanceur,limelight);
|
|
GrimpeurDroit grimpeurDroit = new GrimpeurDroit(grimpeur, manette::getLeftY);
|
|
GrimpeurGauche grimpeurGauche = new GrimpeurGauche(grimpeur, manette::getRightY);
|
|
Debalayer debalayer = new Debalayer(balayeuse, accumulateur);
|
|
|
|
public RobotContainer() {
|
|
|
|
dashboard.addCamera("limelight", "limelight","limelight.local:5800")
|
|
.withSize(3,4)
|
|
.withPosition(7,0);
|
|
|
|
dashboard.addCamera("USB Camera 0", "USB Camera 0","http://roborio-5618-frc.local:1181/?action=stream")
|
|
.withSize(4, 3)
|
|
.withPosition(3, 0);
|
|
|
|
CameraServer.startAutomaticCapture();
|
|
|
|
NamedCommands.registerCommand("balayer",new Balayer(balayeuse, accumulateur));
|
|
NamedCommands.registerCommand("lancer", new LancerNote(lanceur, accumulateur));
|
|
autoChooser = AutoBuilder.buildAutoChooser();
|
|
|
|
//manette
|
|
manette.start().whileTrue(new RestGyro(drive));
|
|
manette.a().whileTrue(new GuiderBas(guideur));
|
|
manette.b().whileTrue(new GuiderHaut(guideur));
|
|
|
|
//joystick
|
|
joystick.button(3).whileTrue(new Balayer(balayeuse, accumulateur));
|
|
joystick.button(1).whileTrue(new LancerNote(lanceur, accumulateur));
|
|
joystick.button(5).whileTrue(new LancerAmp(lanceur, accumulateur));
|
|
|
|
// deplacement
|
|
configureBindings();
|
|
drive.setDefaultCommand(new RunCommand(()->{
|
|
drive.drive(MathUtil.applyDeadband(manette1.getLeftY(),0), MathUtil.applyDeadband(manette1.getLeftX(),0), MathUtil.applyDeadband(manette1.getRightX(),0));
|
|
},drive));
|
|
|
|
// grimpeur manuel
|
|
grimpeur.setDefaultCommand(new RunCommand(()->{
|
|
grimpeur.droit(MathUtil.applyDeadband(-manette.getLeftY(), 0.2));
|
|
grimpeur.gauche(MathUtil.applyDeadband(-manette.getRightY(),0.2 ));}
|
|
,grimpeur));
|
|
|
|
dashboard.add("autochooser",autoChooser)
|
|
.withSize(1,1)
|
|
.withPosition(2,2);
|
|
}
|
|
|
|
private void configureBindings() {}
|
|
|
|
public Command getAutonomousCommand(){
|
|
return autoChooser.getSelected();
|
|
}
|
|
}
|