This commit is contained in:
Olivier Dubois 2024-02-08 18:59:15 -05:00
commit ad5a6e2a94
7 changed files with 67 additions and 18 deletions

View File

@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2024.1.1"
id "edu.wpi.first.GradleRIO" version "2024.2.1"
}
java {

View File

@ -33,6 +33,7 @@ import frc.robot.command.Lancer;
import frc.robot.command.LancerNote;
import frc.robot.command.Lancerampli;
import frc.robot.command.Limelight_tracker;
import frc.robot.command.PistonFerme;
import frc.robot.command.Pistongrimpeur;
// Subsystems
import frc.robot.subsystem.Accumulateur;
@ -61,6 +62,7 @@ public class RobotContainer {
CommandJoystick joystick = new CommandJoystick(0);
CommandXboxController manette = new CommandXboxController(1);
//command
PistonFerme pistonFerme = new PistonFerme(grimpeur);
Limelight_tracker limelight_tracker = new Limelight_tracker(limelight,drive);
Balayer balayer = new Balayer(balayeuse, accumulateur);
GuiderHaut guiderHaut = new GuiderHaut(guideur);
@ -76,6 +78,7 @@ public class RobotContainer {
dashboard.addCamera("limelight", "limelight","limelight.local:5800");
NamedCommands.registerCommand("balayer",new Balayer(balayeuse, accumulateur));
NamedCommands.registerCommand("lancer", new LancerNote(lanceur, accumulateur));
NamedCommands.registerCommand("piston", new PistonFerme(grimpeur));
autoChooser = AutoBuilder.buildAutoChooser();
CameraServer.startAutomaticCapture();

View File

@ -56,6 +56,7 @@ public class GrimpeurDroit extends Command {
@Override
public void end(boolean interrupted) {
grimpeur.droit(0);
grimpeur.pistonouvre();
}
// Returns true when the command should end.

View File

@ -0,0 +1,38 @@
// 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.command;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystem.Grimpeur;
public class PistonFerme extends Command {
private Grimpeur grimpeur;
/** Creates a new PistonFerme. */
public PistonFerme(Grimpeur grimpeur) {
this.grimpeur = grimpeur;
addRequirements(grimpeur);
// Use addRequirements() here to declare subsystem dependencies.
}
// Called when the command is initially scheduled.
@Override
public void initialize() {
grimpeur.pistonferme();
}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return true;
}
}

View File

@ -29,7 +29,7 @@ public class Pistongrimpeur extends Command {
@Override
public void execute() {
if(grimpeur.pistonouvre()){
if(grimpeur.piston()){
LED.couleur(0, 0, 255);
}
}
@ -38,7 +38,7 @@ public class Pistongrimpeur extends Command {
@Override
public void end(boolean interrupted) {
LED.couleur(0, 0, 0);
grimpeur.pistonferme();
}
// Returns true when the command should end.

View File

@ -12,6 +12,7 @@ import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.PneumaticsModuleType;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
@ -34,8 +35,8 @@ public class Grimpeur extends SubsystemBase {
// limit switch
final DigitalInput limitdroite = new DigitalInput(Constants.limithaut);
final DigitalInput limitgauche = new DigitalInput(Constants.limitbas);
final DoubleSolenoid pistondroite= new DoubleSolenoid(PneumaticsModuleType.CTREPCM, Constants.pistondroiteouvre, Constants.pistondroiteouvre);
final DoubleSolenoid pistondgauche= new DoubleSolenoid(PneumaticsModuleType.CTREPCM, Constants.pistondgaucheouvre, Constants.pistondroiteouvre);
final Solenoid pistondroite= new Solenoid(PneumaticsModuleType.CTREPCM, Constants.pistondroiteouvre);
final Solenoid pistondgauche = new Solenoid(PneumaticsModuleType.CTREPCM, Constants.pistondgaucheouvre);
//fonction
public Grimpeur() {
layout.addBoolean("limitgrimpeurd", limitdroite::get);
@ -72,15 +73,16 @@ public AHRS gyroscope = new AHRS();
public double getpitch(){
return gyroscope.getPitch();
}
public boolean pistonouvre(){
pistondroite.set(Value.kForward);
pistondgauche.set(Value.kForward);
return pistondroite.isFwdSolenoidDisabled();
}
public void pistonferme(){
pistondroite.set(Value.kReverse);
pistondgauche.set(Value.kReverse);
pistondroite.set(true);
pistondgauche.set(true);
}
public void pistonouvre(){
pistondgauche.set(false);
pistondroite.set(false);
}
public boolean piston(){
return pistondgauche.get();
}
@Override
public void periodic() {

View File

@ -12,14 +12,19 @@ public class LED extends SubsystemBase {
/** Creates a new LED. */
public LED() {}
AddressableLED led = new AddressableLED(9);
AddressableLEDBuffer ledBuffer = new AddressableLEDBuffer(60);
AddressableLEDBuffer ledBuffer = new AddressableLEDBuffer(150);
public void led(){
led.setData(ledBuffer);
led.start();
}
public void couleur(int R, int G, int B){
ledBuffer.setRGB(0, R, G, B);
led.start();}
public void couleur(int R, int G,int B){
for (int i = 0; i < ledBuffer.getLength(); i++) {
// Sets the specified LED to the RGB values for red
ledBuffer.setRGB(i, 255, 0, 0);}
}
@Override
public void periodic() {
// This method will be called once per scheduler run