Merge branch 'main' of https://demerso.net/pls5618/2023/robot
This commit is contained in:
commit
feb8cc033e
@ -5,13 +5,16 @@ public class Constants {
|
|||||||
public static int avantgauche = 2;
|
public static int avantgauche = 2;
|
||||||
public static int arrieredroit = 3;
|
public static int arrieredroit = 3;
|
||||||
public static int arrieregauche = 5;
|
public static int arrieregauche = 5;
|
||||||
public static int BrasTelescopique = 4;
|
public static int BrasTelescopique = 2;
|
||||||
public static int pivot = 0;
|
public static int pivot = 0;
|
||||||
|
|
||||||
//moteur
|
//moteur
|
||||||
public static int leverGratte = 0;
|
public static int leverGratte = 0;
|
||||||
public static int baiserGratte = 1;
|
public static int baiserGratte = 1;
|
||||||
|
<<<<<<< HEAD
|
||||||
public static int baisserGratte = 2;
|
public static int baisserGratte = 2;
|
||||||
|
=======
|
||||||
|
>>>>>>> 23806ebfa2db43d63673f9b4cfc37aa3b9b23491
|
||||||
|
|
||||||
// pneumatique
|
// pneumatique
|
||||||
public static int pistonpinceouvre = 0;
|
public static int pistonpinceouvre = 0;
|
||||||
|
@ -8,8 +8,13 @@ import org.photonvision.estimation.CameraTargetRelation;
|
|||||||
import edu.wpi.first.cameraserver.CameraServer;
|
import edu.wpi.first.cameraserver.CameraServer;
|
||||||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||||
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
||||||
|
import java.util.Map;
|
||||||
|
import edu.wpi.first.networktables.GenericEntry;
|
||||||
|
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
|
||||||
|
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
import edu.wpi.first.wpilibj2.command.Commands;
|
import edu.wpi.first.wpilibj2.command.Commands;
|
||||||
|
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
|
||||||
import edu.wpi.first.wpilibj2.command.RunCommand;
|
import edu.wpi.first.wpilibj2.command.RunCommand;
|
||||||
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
||||||
|
|
||||||
@ -20,7 +25,6 @@ import frc.robot.subsystems.bras.BrasTelescopique;
|
|||||||
import frc.robot.subsystems.bras.Pince;
|
import frc.robot.subsystems.bras.Pince;
|
||||||
import frc.robot.subsystems.bras.Pivot;
|
import frc.robot.subsystems.bras.Pivot;
|
||||||
import frc.robot.subsystems.Limelight;
|
import frc.robot.subsystems.Limelight;
|
||||||
import frc.robot.commands.Apriltag;
|
|
||||||
// command
|
// command
|
||||||
import frc.robot.commands.BrakeFerme;
|
import frc.robot.commands.BrakeFerme;
|
||||||
import frc.robot.commands.BrakeOuvre;
|
import frc.robot.commands.BrakeOuvre;
|
||||||
@ -28,21 +32,17 @@ import frc.robot.commands.Cone;
|
|||||||
import frc.robot.commands.GratteBaisser;
|
import frc.robot.commands.GratteBaisser;
|
||||||
import frc.robot.commands.GratteMonte;
|
import frc.robot.commands.GratteMonte;
|
||||||
import frc.robot.commands.Gyro;
|
import frc.robot.commands.Gyro;
|
||||||
|
import frc.robot.commands.Reculer;
|
||||||
import frc.robot.commands.bras.FermePince;
|
import frc.robot.commands.bras.FermePince;
|
||||||
import frc.robot.commands.bras.OuvrePince;
|
import frc.robot.commands.bras.OuvrePince;
|
||||||
import frc.robot.commands.bras.PivotBrasRentre;
|
import frc.robot.commands.bras.PivotBrasRentre;
|
||||||
import frc.robot.commands.bras.PivoteBrasBas;
|
import frc.robot.commands.bras.PivoteBrasBas;
|
||||||
import frc.robot.commands.bras.PivoteBrasHaut;
|
import frc.robot.commands.bras.PivoteBrasHaut;
|
||||||
import frc.robot.commands.bras.PivoteBrasMilieux;
|
import frc.robot.commands.bras.PivoteBrasMilieux;
|
||||||
//subsystems
|
|
||||||
import frc.robot.commands.bras.PivotChercheBas;
|
|
||||||
import frc.robot.commands.bras.PivotChercheHaut;
|
|
||||||
import frc.robot.commands.Cube;
|
|
||||||
import frc.robot.commands.Tape;
|
|
||||||
|
|
||||||
|
|
||||||
public class RobotContainer {
|
public class RobotContainer {
|
||||||
//CameraServer.startAutomaticCapture();
|
|
||||||
CommandXboxController manette1 = new CommandXboxController(0);
|
CommandXboxController manette1 = new CommandXboxController(0);
|
||||||
CommandXboxController manette2 = new CommandXboxController(1);
|
CommandXboxController manette2 = new CommandXboxController(1);
|
||||||
// subsystems
|
// subsystems
|
||||||
@ -51,7 +51,7 @@ Gratte gratte = new Gratte();
|
|||||||
BrasTelescopique brasTelescopique = new BrasTelescopique();
|
BrasTelescopique brasTelescopique = new BrasTelescopique();
|
||||||
Pince pince = new Pince();
|
Pince pince = new Pince();
|
||||||
Pivot pivot = new Pivot();
|
Pivot pivot = new Pivot();
|
||||||
Limelight limelight = new Limelight();/** */
|
Limelight limelight = new Limelight();
|
||||||
//commands
|
//commands
|
||||||
BrakeFerme brakeFerme = new BrakeFerme(basePilotable);
|
BrakeFerme brakeFerme = new BrakeFerme(basePilotable);
|
||||||
BrakeOuvre brakeOuvre = new BrakeOuvre(basePilotable);
|
BrakeOuvre brakeOuvre = new BrakeOuvre(basePilotable);
|
||||||
@ -71,16 +71,31 @@ Cube cube = new Cube(limelight, basePilotable, null);
|
|||||||
Apriltag aprilTag = new Apriltag(limelight, basePilotable, null);
|
Apriltag aprilTag = new Apriltag(limelight, basePilotable, null);
|
||||||
Tape tape = new Tape(limelight, basePilotable, null);
|
Tape tape = new Tape(limelight, basePilotable, null);
|
||||||
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
||||||
|
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();
|
||||||
public RobotContainer() {
|
public RobotContainer() {
|
||||||
|
chooser.setDefaultOption(enhaut, enhaut);
|
||||||
|
chooser.addOption(enbas, enbas);
|
||||||
|
chooser.addOption(aumilieux, aumilieux);
|
||||||
|
chooser.addOption(nulpart, nulpart);
|
||||||
|
layoutauto.add("choix hauteur",chooser);
|
||||||
|
|
||||||
|
|
||||||
configureBindings();
|
configureBindings();
|
||||||
CameraServer.startAutomaticCapture();
|
CameraServer.startAutomaticCapture();
|
||||||
teb.add (CameraServer.startAutomaticCapture(null, 0));
|
teb.add (CameraServer.startAutomaticCapture(null, 0));
|
||||||
basePilotable.setDefaultCommand(new RunCommand(() -> {
|
basePilotable.setDefaultCommand(new RunCommand() -> {
|
||||||
basePilotable.drive(-manette1.getLeftY(), manette1.getLeftX(), 0);
|
basePilotable.drive(-manette1.getLeftY(), manette1.getLeftX(), 0);
|
||||||
},basePilotable));
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void configureBindings() {
|
private void configureBindings() {
|
||||||
// manette 1
|
// manette 1
|
||||||
manette1.povDown().onTrue(pivoteBrasHaut);
|
manette1.povDown().onTrue(pivoteBrasHaut);
|
||||||
@ -89,25 +104,26 @@ public RobotContainer() {
|
|||||||
manette1.povRight().onTrue(pivotBrasRentre);
|
manette1.povRight().onTrue(pivotBrasRentre);
|
||||||
manette1.a().toggleOnTrue(Commands.startEnd(pince::ouvrir, pince::fermer,pince));
|
manette1.a().toggleOnTrue(Commands.startEnd(pince::ouvrir, pince::fermer,pince));
|
||||||
manette1.x().toggleOnTrue(Commands.startEnd(basePilotable::BrakeFerme,basePilotable::BrakeOuvre,basePilotable));
|
manette1.x().toggleOnTrue(Commands.startEnd(basePilotable::BrakeFerme,basePilotable::BrakeOuvre,basePilotable));
|
||||||
manette1.b().onTrue(Commands.either(gratteBaisser, gratteMonte, gratte::getenHaut));
|
manette1.y().whileTrue(gyro);
|
||||||
manette1.leftBumper().toggleOnTrue(cube);
|
manette1.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable));
|
||||||
manette1.rightBumper().toggleOnTrue(cone);
|
|
||||||
// manette 2
|
|
||||||
manette2.y().whileTrue(gyro);
|
|
||||||
manette2.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable));
|
|
||||||
manette2.povRight().onTrue(pivotChercheBas);
|
|
||||||
manette2.povLeft().onTrue(pivotChercheHaut);
|
|
||||||
manette2.rightBumper().toggleOnTrue(aprilTag);
|
|
||||||
manette2.leftBumper().toggleOnTrue(tape);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Command getAutonomousCommand() {
|
public Command getAutonomousCommand() {
|
||||||
return null;
|
chooser.getSelected();
|
||||||
//return new SequentialCommandGroup(
|
autobalance.getBoolean(true);
|
||||||
//new PivoteBrasMilieux(brasTelescopique, pivot),
|
return new SequentialCommandGroup(
|
||||||
//new OuvrePince(pince),
|
Commands.either(gyro, Commands.none(),()-> autobalance.getBoolean(true)),
|
||||||
//new PivotBrasRentre(brasTelescopique, pivot).alongWith(new Reculer(basePilotable)),
|
Commands.either(reculer, Commands.none(),()-> autosortir.getBoolean(true)),
|
||||||
//new Gyro(basePilotable)
|
Commands.select(Map.ofEntries(
|
||||||
//);
|
Map.entry(enhaut,pivoteBrasHaut),
|
||||||
|
Map.entry(aumilieux,null),
|
||||||
|
Map.entry(enbas,null),
|
||||||
|
Map.entry(nulpart,null)
|
||||||
|
), chooser::getSelected)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,11 @@ public class Gyro extends CommandBase {
|
|||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if(basePilotable.getpitch()>4)
|
if(basePilotable.getpitch()>10)
|
||||||
{
|
{
|
||||||
basePilotable.drive(0.3*basePilotable.getpitch()/12, 0, 0);
|
basePilotable.drive(0.3*basePilotable.getpitch()/12, 0, 0);
|
||||||
}
|
}
|
||||||
else if(basePilotable.getpitch()<-4)
|
else if(basePilotable.getpitch()<-10)
|
||||||
{
|
{
|
||||||
basePilotable.drive(0.3*basePilotable.getpitch()/12, 0, 0);
|
basePilotable.drive(0.3*basePilotable.getpitch()/12, 0, 0);
|
||||||
basePilotable.drive(0.3*basePilotable.getpitch()/15, 0, 0);
|
basePilotable.drive(0.3*basePilotable.getpitch()/15, 0, 0);
|
||||||
|
@ -80,4 +80,6 @@ public void BrakeFerme(){
|
|||||||
public void periodic() {
|
public void periodic() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public void drive(double d, double leftX) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
|||||||
import frc.robot.Constants;
|
import frc.robot.Constants;
|
||||||
|
|
||||||
public class Gratte extends SubsystemBase {
|
public class Gratte extends SubsystemBase {
|
||||||
|
|
||||||
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
||||||
ShuffleboardLayout limitswitchgratte = Shuffleboard.getTab("teb")
|
ShuffleboardLayout limitswitchgratte = Shuffleboard.getTab("teb")
|
||||||
.getLayout("limitswitchsgratte", BuiltInLayouts.kList)
|
.getLayout("limitswitchsgratte", BuiltInLayouts.kList)
|
||||||
|
@ -12,12 +12,21 @@ import edu.wpi.first.wpilibj.DigitalInput;
|
|||||||
import edu.wpi.first.wpilibj.DoubleSolenoid;
|
import edu.wpi.first.wpilibj.DoubleSolenoid;
|
||||||
import edu.wpi.first.wpilibj.PneumaticsModuleType;
|
import edu.wpi.first.wpilibj.PneumaticsModuleType;
|
||||||
import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
|
import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
|
||||||
|
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
|
||||||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
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.wpilibj.shuffleboard.ShuffleboardTab;
|
||||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||||
import frc.robot.Constants;
|
import frc.robot.Constants;
|
||||||
|
|
||||||
public class BrasTelescopique extends SubsystemBase {
|
public class BrasTelescopique extends SubsystemBase {
|
||||||
|
ShuffleboardLayout layout = Shuffleboard.getTab("teb")
|
||||||
|
.getLayout("layout", BuiltInLayouts.kList)
|
||||||
|
.withSize(2, 2);
|
||||||
|
|
||||||
|
ShuffleboardLayout bras = Shuffleboard.getTab("teb")
|
||||||
|
.getLayout("bras", BuiltInLayouts.kList)
|
||||||
|
.withSize(2, 2);
|
||||||
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
||||||
/** Creates a new BrasTelescopique. */
|
/** Creates a new BrasTelescopique. */
|
||||||
public BrasTelescopique() {
|
public BrasTelescopique() {
|
||||||
|
@ -14,6 +14,7 @@ import com.revrobotics.CANSparkMax;
|
|||||||
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
|
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
|
||||||
|
|
||||||
public class Pivot extends SubsystemBase {
|
public class Pivot extends SubsystemBase {
|
||||||
|
|
||||||
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
||||||
|
|
||||||
// moteur
|
// moteur
|
||||||
@ -42,5 +43,13 @@ public class Pivot extends SubsystemBase {
|
|||||||
@Override
|
@Override
|
||||||
public void periodic() {
|
public void periodic() {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
teb.add ("encodeur pivot",0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user