Merge branch 'main' of https://git.demerso.net/pls5618/2024/robot
This commit is contained in:
commit
ad5a6e2a94
@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "java"
|
id "java"
|
||||||
id "edu.wpi.first.GradleRIO" version "2024.1.1"
|
id "edu.wpi.first.GradleRIO" version "2024.2.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
@ -33,6 +33,7 @@ import frc.robot.command.Lancer;
|
|||||||
import frc.robot.command.LancerNote;
|
import frc.robot.command.LancerNote;
|
||||||
import frc.robot.command.Lancerampli;
|
import frc.robot.command.Lancerampli;
|
||||||
import frc.robot.command.Limelight_tracker;
|
import frc.robot.command.Limelight_tracker;
|
||||||
|
import frc.robot.command.PistonFerme;
|
||||||
import frc.robot.command.Pistongrimpeur;
|
import frc.robot.command.Pistongrimpeur;
|
||||||
// Subsystems
|
// Subsystems
|
||||||
import frc.robot.subsystem.Accumulateur;
|
import frc.robot.subsystem.Accumulateur;
|
||||||
@ -61,6 +62,7 @@ public class RobotContainer {
|
|||||||
CommandJoystick joystick = new CommandJoystick(0);
|
CommandJoystick joystick = new CommandJoystick(0);
|
||||||
CommandXboxController manette = new CommandXboxController(1);
|
CommandXboxController manette = new CommandXboxController(1);
|
||||||
//command
|
//command
|
||||||
|
PistonFerme pistonFerme = new PistonFerme(grimpeur);
|
||||||
Limelight_tracker limelight_tracker = new Limelight_tracker(limelight,drive);
|
Limelight_tracker limelight_tracker = new Limelight_tracker(limelight,drive);
|
||||||
Balayer balayer = new Balayer(balayeuse, accumulateur);
|
Balayer balayer = new Balayer(balayeuse, accumulateur);
|
||||||
GuiderHaut guiderHaut = new GuiderHaut(guideur);
|
GuiderHaut guiderHaut = new GuiderHaut(guideur);
|
||||||
@ -76,6 +78,7 @@ public class RobotContainer {
|
|||||||
dashboard.addCamera("limelight", "limelight","limelight.local:5800");
|
dashboard.addCamera("limelight", "limelight","limelight.local:5800");
|
||||||
NamedCommands.registerCommand("balayer",new Balayer(balayeuse, accumulateur));
|
NamedCommands.registerCommand("balayer",new Balayer(balayeuse, accumulateur));
|
||||||
NamedCommands.registerCommand("lancer", new LancerNote(lanceur, accumulateur));
|
NamedCommands.registerCommand("lancer", new LancerNote(lanceur, accumulateur));
|
||||||
|
NamedCommands.registerCommand("piston", new PistonFerme(grimpeur));
|
||||||
autoChooser = AutoBuilder.buildAutoChooser();
|
autoChooser = AutoBuilder.buildAutoChooser();
|
||||||
|
|
||||||
CameraServer.startAutomaticCapture();
|
CameraServer.startAutomaticCapture();
|
||||||
|
@ -56,6 +56,7 @@ public class GrimpeurDroit extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public void end(boolean interrupted) {
|
public void end(boolean interrupted) {
|
||||||
grimpeur.droit(0);
|
grimpeur.droit(0);
|
||||||
|
grimpeur.pistonouvre();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
|
38
src/main/java/frc/robot/command/PistonFerme.java
Normal file
38
src/main/java/frc/robot/command/PistonFerme.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -29,7 +29,7 @@ public class Pistongrimpeur extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
|
||||||
if(grimpeur.pistonouvre()){
|
if(grimpeur.piston()){
|
||||||
LED.couleur(0, 0, 255);
|
LED.couleur(0, 0, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ public class Pistongrimpeur extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public void end(boolean interrupted) {
|
public void end(boolean interrupted) {
|
||||||
LED.couleur(0, 0, 0);
|
LED.couleur(0, 0, 0);
|
||||||
grimpeur.pistonferme();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
|
@ -12,6 +12,7 @@ import edu.wpi.first.networktables.GenericEntry;
|
|||||||
import edu.wpi.first.wpilibj.DigitalInput;
|
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.Solenoid;
|
||||||
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.ShuffleboardLayout;
|
||||||
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
||||||
@ -34,8 +35,8 @@ public class Grimpeur extends SubsystemBase {
|
|||||||
// limit switch
|
// limit switch
|
||||||
final DigitalInput limitdroite = new DigitalInput(Constants.limithaut);
|
final DigitalInput limitdroite = new DigitalInput(Constants.limithaut);
|
||||||
final DigitalInput limitgauche = new DigitalInput(Constants.limitbas);
|
final DigitalInput limitgauche = new DigitalInput(Constants.limitbas);
|
||||||
final DoubleSolenoid pistondroite= new DoubleSolenoid(PneumaticsModuleType.CTREPCM, Constants.pistondroiteouvre, Constants.pistondroiteouvre);
|
final Solenoid pistondroite= new Solenoid(PneumaticsModuleType.CTREPCM, Constants.pistondroiteouvre);
|
||||||
final DoubleSolenoid pistondgauche= new DoubleSolenoid(PneumaticsModuleType.CTREPCM, Constants.pistondgaucheouvre, Constants.pistondroiteouvre);
|
final Solenoid pistondgauche = new Solenoid(PneumaticsModuleType.CTREPCM, Constants.pistondgaucheouvre);
|
||||||
//fonction
|
//fonction
|
||||||
public Grimpeur() {
|
public Grimpeur() {
|
||||||
layout.addBoolean("limitgrimpeurd", limitdroite::get);
|
layout.addBoolean("limitgrimpeurd", limitdroite::get);
|
||||||
@ -72,15 +73,16 @@ public AHRS gyroscope = new AHRS();
|
|||||||
public double getpitch(){
|
public double getpitch(){
|
||||||
return gyroscope.getPitch();
|
return gyroscope.getPitch();
|
||||||
}
|
}
|
||||||
public boolean pistonouvre(){
|
|
||||||
pistondroite.set(Value.kForward);
|
|
||||||
pistondgauche.set(Value.kForward);
|
|
||||||
return pistondroite.isFwdSolenoidDisabled();
|
|
||||||
}
|
|
||||||
public void pistonferme(){
|
public void pistonferme(){
|
||||||
pistondroite.set(Value.kReverse);
|
pistondroite.set(true);
|
||||||
pistondgauche.set(Value.kReverse);
|
pistondgauche.set(true);
|
||||||
|
}
|
||||||
|
public void pistonouvre(){
|
||||||
|
pistondgauche.set(false);
|
||||||
|
pistondroite.set(false);
|
||||||
|
}
|
||||||
|
public boolean piston(){
|
||||||
|
return pistondgauche.get();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void periodic() {
|
public void periodic() {
|
||||||
|
@ -12,14 +12,19 @@ public class LED extends SubsystemBase {
|
|||||||
/** Creates a new LED. */
|
/** Creates a new LED. */
|
||||||
public LED() {}
|
public LED() {}
|
||||||
AddressableLED led = new AddressableLED(9);
|
AddressableLED led = new AddressableLED(9);
|
||||||
AddressableLEDBuffer ledBuffer = new AddressableLEDBuffer(60);
|
AddressableLEDBuffer ledBuffer = new AddressableLEDBuffer(150);
|
||||||
public void led(){
|
public void led(){
|
||||||
led.setData(ledBuffer);
|
led.setData(ledBuffer);
|
||||||
led.start();
|
led.start();}
|
||||||
}
|
|
||||||
public void couleur(int R, int G,int B){
|
public void couleur(int R, int G,int B){
|
||||||
ledBuffer.setRGB(0, R, G, 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
|
@Override
|
||||||
public void periodic() {
|
public void periodic() {
|
||||||
// This method will be called once per scheduler run
|
// This method will be called once per scheduler run
|
||||||
|
Loading…
x
Reference in New Issue
Block a user