2023-01-16 18:10:02 -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;
|
2023-03-08 19:42:24 -05:00
|
|
|
import java.util.Map;
|
|
|
|
|
2023-03-07 19:11:10 -05:00
|
|
|
import edu.wpi.first.cameraserver.CameraServer;
|
2023-03-08 19:42:24 -05:00
|
|
|
import edu.wpi.first.networktables.GenericEntry;
|
|
|
|
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
|
|
|
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
|
|
|
|
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
|
2023-01-16 18:10:02 -05:00
|
|
|
import edu.wpi.first.wpilibj2.command.Command;
|
|
|
|
import edu.wpi.first.wpilibj2.command.Commands;
|
2023-02-15 18:27:48 -05:00
|
|
|
import edu.wpi.first.wpilibj2.command.RunCommand;
|
2023-02-15 19:18:18 -05:00
|
|
|
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
2023-02-19 21:19:36 -05:00
|
|
|
|
2023-02-15 18:06:19 -05:00
|
|
|
//subsystems
|
2023-02-15 18:03:47 -05:00
|
|
|
import frc.robot.subsystems.BasePilotable;
|
|
|
|
import frc.robot.subsystems.Gratte;
|
|
|
|
import frc.robot.subsystems.bras.BrasTelescopique;
|
|
|
|
import frc.robot.subsystems.bras.Pince;
|
|
|
|
import frc.robot.subsystems.bras.Pivot;
|
2023-02-15 18:06:19 -05:00
|
|
|
import frc.robot.subsystems.Limelight;
|
2023-03-07 20:03:12 -05:00
|
|
|
import frc.robot.commands.Apriltag;
|
2023-02-15 18:06:19 -05:00
|
|
|
// command
|
2023-02-15 18:03:47 -05:00
|
|
|
import frc.robot.commands.BrakeFerme;
|
|
|
|
import frc.robot.commands.BrakeOuvre;
|
2023-02-20 18:56:29 -05:00
|
|
|
import frc.robot.commands.Cone;
|
2023-02-15 18:03:47 -05:00
|
|
|
import frc.robot.commands.GratteBaisser;
|
|
|
|
import frc.robot.commands.GratteMonte;
|
|
|
|
import frc.robot.commands.Gyro;
|
|
|
|
import frc.robot.commands.bras.FermePince;
|
|
|
|
import frc.robot.commands.bras.OuvrePince;
|
|
|
|
import frc.robot.commands.bras.PivotBrasRentre;
|
|
|
|
import frc.robot.commands.bras.PivoteBrasBas;
|
|
|
|
import frc.robot.commands.bras.PivoteBrasHaut;
|
|
|
|
import frc.robot.commands.bras.PivoteBrasMilieux;
|
2023-03-07 19:13:16 -05:00
|
|
|
//subsystems
|
2023-02-22 18:55:19 -05:00
|
|
|
import frc.robot.commands.bras.PivotChercheBas;
|
|
|
|
import frc.robot.commands.bras.PivotChercheHaut;
|
|
|
|
import frc.robot.commands.Cube;
|
|
|
|
import frc.robot.commands.Tape;
|
2023-02-15 18:03:47 -05:00
|
|
|
|
|
|
|
|
2023-01-16 18:10:02 -05:00
|
|
|
public class RobotContainer {
|
2023-03-08 19:42:53 -05:00
|
|
|
<<<<<<< HEAD
|
2023-03-08 19:42:24 -05:00
|
|
|
|
2023-03-08 19:42:53 -05:00
|
|
|
=======
|
2023-03-07 20:01:30 -05:00
|
|
|
//CameraServer.startAutomaticCapture();
|
2023-03-08 19:42:53 -05:00
|
|
|
>>>>>>> fc4607f3c6d7203a155182eded4626d37f75de5e
|
2023-02-15 19:53:33 -05:00
|
|
|
CommandXboxController manette1 = new CommandXboxController(0);
|
|
|
|
CommandXboxController manette2 = new CommandXboxController(1);
|
2023-02-15 18:20:54 -05:00
|
|
|
// subsystems
|
|
|
|
BasePilotable basePilotable = new BasePilotable();
|
|
|
|
Gratte gratte = new Gratte();
|
|
|
|
BrasTelescopique brasTelescopique = new BrasTelescopique();
|
|
|
|
Pince pince = new Pince();
|
|
|
|
Pivot pivot = new Pivot();
|
2023-03-07 19:13:16 -05:00
|
|
|
Limelight limelight = new Limelight();/** */
|
2023-02-15 18:20:54 -05:00
|
|
|
//commands
|
|
|
|
BrakeFerme brakeFerme = new BrakeFerme(basePilotable);
|
|
|
|
BrakeOuvre brakeOuvre = new BrakeOuvre(basePilotable);
|
|
|
|
GratteBaisser gratteBaisser = new GratteBaisser(gratte);
|
|
|
|
GratteMonte gratteMonte = new GratteMonte(gratte);
|
|
|
|
Gyro gyro = new Gyro(basePilotable);
|
|
|
|
FermePince fermePince = new FermePince(pince);
|
|
|
|
OuvrePince ouvrePince = new OuvrePince(pince);
|
|
|
|
PivotBrasRentre pivotBrasRentre = new PivotBrasRentre(brasTelescopique, pivot);
|
|
|
|
PivoteBrasBas pivoteBrasBas = new PivoteBrasBas(brasTelescopique, pivot);
|
|
|
|
PivoteBrasMilieux pivoteBrasMilieux = new PivoteBrasMilieux(brasTelescopique, pivot);
|
|
|
|
PivoteBrasHaut pivoteBrasHaut = new PivoteBrasHaut(brasTelescopique, pivot);
|
2023-02-20 18:56:29 -05:00
|
|
|
Cone cone = new Cone(limelight, basePilotable, ()->-manette1.getLeftY());
|
2023-03-08 19:42:24 -05:00
|
|
|
Reculer reculer = new Reculer(basePilotable);
|
|
|
|
|
|
|
|
SendableChooser<String> chooser = new SendableChooser<>();
|
|
|
|
String enhaut = "en bas";
|
|
|
|
String aumilieux = "au milieux";
|
|
|
|
String enbas = "en bas";
|
|
|
|
String nulpart = "nul part";
|
|
|
|
ShuffleboardLayout layoutauto = Shuffleboard.getTab("teb").getLayout("auto");
|
|
|
|
GenericEntry autobalance = layoutauto.add("choix balance",true).getEntry();
|
|
|
|
GenericEntry autosortir = layoutauto.add("choix sorit",false).getEntry();
|
2023-03-07 20:03:12 -05:00
|
|
|
PivotChercheBas pivotChercheBas = new PivotChercheBas(brasTelescopique, pivot);
|
|
|
|
PivotChercheHaut pivotChercheHaut = new PivotChercheHaut(brasTelescopique, pivot);
|
|
|
|
Cube cube = new Cube(limelight, basePilotable, null);
|
|
|
|
Apriltag aprilTag = new Apriltag(limelight, basePilotable, null);
|
|
|
|
Tape tape = new Tape(limelight, basePilotable, null);
|
|
|
|
|
2023-02-15 18:20:54 -05:00
|
|
|
public RobotContainer() {
|
2023-03-08 19:42:24 -05:00
|
|
|
chooser.setDefaultOption(enhaut, enhaut);
|
|
|
|
chooser.addOption(enbas, enbas);
|
|
|
|
chooser.addOption(aumilieux, aumilieux);
|
|
|
|
chooser.addOption(nulpart, nulpart);
|
|
|
|
layoutauto.add("choix hauteur",chooser);
|
|
|
|
|
|
|
|
|
2023-01-16 18:10:02 -05:00
|
|
|
configureBindings();
|
2023-03-08 18:32:47 -05:00
|
|
|
CameraServer.startAutomaticCapture();
|
2023-02-15 19:36:00 -05:00
|
|
|
basePilotable.setDefaultCommand(new RunCommand(() -> {
|
2023-03-08 19:14:16 -05:00
|
|
|
basePilotable.drive(-manette1.getLeftY(), manette1.getLeftX(), 0);
|
2023-02-15 19:36:00 -05:00
|
|
|
},basePilotable));
|
|
|
|
|
2023-02-15 18:35:35 -05:00
|
|
|
}
|
2023-03-08 18:34:08 -05:00
|
|
|
|
2023-02-15 18:56:04 -05:00
|
|
|
private void configureBindings() {
|
2023-03-08 19:14:16 -05:00
|
|
|
basePilotable.setDefaultCommand(new RunCommand(() -> {
|
|
|
|
basePilotable.drive(-manette1.getLeftY(), -manette1.getLeftX(), 0);
|
|
|
|
},basePilotable));
|
2023-03-07 17:52:39 -05:00
|
|
|
// manette 1
|
2023-03-08 18:33:07 -05:00
|
|
|
manette1.povDown().onTrue(pivoteBrasHaut);
|
|
|
|
manette1.povUp().onTrue(pivoteBrasBas);
|
|
|
|
manette1.povLeft().onTrue(pivoteBrasMilieux);
|
|
|
|
manette1.povRight().onTrue(pivotBrasRentre);
|
2023-02-15 19:53:33 -05:00
|
|
|
manette1.a().toggleOnTrue(Commands.startEnd(pince::ouvrir, pince::fermer,pince));
|
|
|
|
manette1.x().toggleOnTrue(Commands.startEnd(basePilotable::BrakeFerme,basePilotable::BrakeOuvre,basePilotable));
|
2023-03-08 19:42:53 -05:00
|
|
|
<<<<<<< HEAD
|
2023-02-20 18:53:50 -05:00
|
|
|
manette1.y().whileTrue(gyro);
|
|
|
|
manette1.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable));
|
2023-03-07 18:53:40 -05:00
|
|
|
/*manette1.b().toggleOnTrue(Commands.startEnd(gratte::baiser, gratte::Lever,gratte));
|
|
|
|
manette2.a().toggleOnTrue(Commands.startEnd(brasTelescopique::pivoteBrasHaut, brasTelescopique::pivoteBrasHaut));
|
2023-02-22 18:55:19 -05:00
|
|
|
manette2.b().toggleOnTrue(Commands.startEnd(brasTelescopique::pivoteBrasBas, brasTelescopique::pivoteBrasBas, brasTelescopique));
|
|
|
|
manette2.x().toggleOnTrue(Commands.startEnd(brasTelescopique::pivoteBrasMilieux, brasTelescopique::pivoteBrasMilieux, brasTelescopique));
|
|
|
|
manette2.y().toggleOnTrue(Commands.startEnd(brasTelescopique::pivotBrasRentre, brasTelescopique::pivotBrasRentre, brasTelescopique));
|
|
|
|
manette2.povRight().toggleOnTrue(Commands.startEnd(brasTelescopique::PivotChercheBas, brasTelescopique::PivotChercheBas, brasTelescopique));
|
|
|
|
manette2.povLeft().toggleOnTrue(Commands.startEnd(brasTelescopique::PivotChercheHaut, brasTelescopique::PivotChercheHaut, brasTelescopique));
|
|
|
|
manette2.rightBumper().toggleOnTrue(Commands.startEnd(null, null, null));
|
2023-03-07 18:53:40 -05:00
|
|
|
manette2.leftBumper().toggleOnTrue(Commands.startEnd(null, null, null));**/
|
2023-03-07 18:40:45 -05:00
|
|
|
manette2.leftBumper().toggleOnTrue(Commands.startEnd(null, null, null));
|
2023-03-07 17:52:39 -05:00
|
|
|
|
2023-02-15 18:56:04 -05:00
|
|
|
}
|
2023-01-16 18:10:02 -05:00
|
|
|
|
|
|
|
public Command getAutonomousCommand() {
|
2023-03-08 19:42:24 -05:00
|
|
|
chooser.getSelected();
|
|
|
|
autobalance.getBoolean(true);
|
2023-02-15 19:35:25 -05:00
|
|
|
return new SequentialCommandGroup(
|
2023-03-08 19:42:24 -05:00
|
|
|
Commands.either(gyro, Commands.none(),()-> autobalance.getBoolean(true)),
|
|
|
|
Commands.either(reculer, Commands.none(),()-> autosortir.getBoolean(true)),
|
|
|
|
Commands.select(Map.ofEntries(
|
|
|
|
Map.entry(enhaut,pivoteBrasHaut),
|
|
|
|
Map.entry(aumilieux,null),
|
|
|
|
Map.entry(enbas,null),
|
|
|
|
Map.entry(nulpart,null)
|
|
|
|
), chooser::getSelected)
|
2023-02-15 19:35:25 -05:00
|
|
|
);
|
2023-03-08 19:42:24 -05:00
|
|
|
|
|
|
|
|
2023-03-08 19:42:53 -05:00
|
|
|
=======
|
2023-03-07 20:03:12 -05:00
|
|
|
manette1.b().onTrue(Commands.either(gratteBaisser, gratteMonte, gratte::getenHaut));
|
2023-03-08 18:33:07 -05:00
|
|
|
manette1.leftBumper().toggleOnTrue(cube);
|
|
|
|
manette1.rightBumper().toggleOnTrue(cone);
|
2023-03-07 17:52:39 -05:00
|
|
|
// manette 2
|
2023-03-08 18:33:07 -05:00
|
|
|
manette2.y().whileTrue(gyro);
|
|
|
|
manette2.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable));
|
2023-03-07 20:03:12 -05:00
|
|
|
manette2.povRight().onTrue(pivotChercheBas);
|
|
|
|
manette2.povLeft().onTrue(pivotChercheHaut);
|
2023-03-08 18:33:07 -05:00
|
|
|
manette2.rightBumper().toggleOnTrue(aprilTag);
|
|
|
|
manette2.leftBumper().toggleOnTrue(tape);
|
2023-02-15 18:56:04 -05:00
|
|
|
}
|
2023-01-16 18:10:02 -05:00
|
|
|
|
|
|
|
public Command getAutonomousCommand() {
|
2023-03-07 19:13:16 -05:00
|
|
|
return null;
|
|
|
|
//return new SequentialCommandGroup(
|
|
|
|
//new PivoteBrasMilieux(brasTelescopique, pivot),
|
|
|
|
//new OuvrePince(pince),
|
|
|
|
//new PivotBrasRentre(brasTelescopique, pivot).alongWith(new Reculer(basePilotable)),
|
|
|
|
//new Gyro(basePilotable)
|
|
|
|
//);
|
2023-03-08 19:42:53 -05:00
|
|
|
>>>>>>> fc4607f3c6d7203a155182eded4626d37f75de5e
|
2023-01-16 18:10:02 -05:00
|
|
|
}
|
|
|
|
}
|