This commit is contained in:
samuel desharnais 2024-11-25 19:30:40 -05:00
commit f7daa030bd
7 changed files with 77 additions and 22 deletions

View File

@ -27,9 +27,8 @@ public class FollowAprilTag extends Command {
@Override @Override
public void execute() { public void execute() {
if (lanceur.limitswitch1() || lanceur.limitswitch2()){
lanceur.lance(0);} if (enlignement.getv()==1)
else if (enlignement.getv()==1)
{ {
lanceur.tourelRotation(0,0, enlignement.getx()/30); lanceur.tourelRotation(0,0, enlignement.getx()/30);
} }

View File

@ -29,9 +29,6 @@ public class Lancer extends Command {
lanceur.lance(); lanceur.lance();
accumulateur.Petitlanceur(0.7); accumulateur.Petitlanceur(0.7);
accumulateur.desaccumule(0.2); accumulateur.desaccumule(0.2);
} }
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.
@Override @Override

View File

@ -0,0 +1,42 @@
// 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.Commands;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.Subsystems.Lanceur;
public class Tourel extends Command {
private Lanceur lanceur;
/** Creates a new Tourel. */
public Tourel(Lanceur lanceur) {
this.lanceur = lanceur;
// Use addRequirements() here to declare subsystem dependencies.
}
// Called when the command is initially scheduled.
@Override
public void initialize() {}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
if(lanceur.limitswitch1()){
lanceur.touchagedelimitswitch1(0);
}
else if(lanceur.limitswitch2()){
lanceur.touchagedelimitswitch2(0);
}
}
// 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 false;
}
}

View File

@ -12,7 +12,6 @@ import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; 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.RunCommand; import edu.wpi.first.wpilibj2.command.RunCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.Commands.Desaccumuler; import frc.robot.Commands.Desaccumuler;
@ -35,18 +34,24 @@ public class RobotContainer {
// NamedCommands.registerCommand("lancer", new Lancer(lanceur, accumulateur)); // NamedCommands.registerCommand("lancer", new Lancer(lanceur, accumulateur));
// autoChooser = AutoBuilder.buildAutoChooser(); // autoChooser = AutoBuilder.buildAutoChooser();
dashboard.addCamera("limelight3G", "limelight3G","limelight.local:5800") dashboard.addCamera("limelight3G", "limelight3G","limelight.local:5800")
.withSize(4,3) .withSize(3,4)
.withPosition(0,0); .withPosition(5,0);
dashboard.addCamera("limelight3", "limelight3","limelight.local:5800") dashboard.addCamera("limelight3", "limelight3","limelight.local:5800")
.withSize(4,3) .withSize(3,4)
.withPosition(4,0); .withPosition(2,0);
configureBindings(); configureBindings();
drive.setDefaultCommand(new RunCommand(()->{ drive.setDefaultCommand(new RunCommand(()->{
drive.drive(-MathUtil.applyDeadband(manette.getRightX(),0.2), MathUtil.applyDeadband(-manette.getRightY(),0.2), MathUtil.applyDeadband(-manette.getRightX(), 0.2)); drive.drive(-MathUtil.applyDeadband(manette.getRightX(),0.2), MathUtil.applyDeadband(-manette.getRightY(),0.2), MathUtil.applyDeadband(-manette.getRightX(), 0.2));
},drive)); },drive));
<<<<<<< HEAD
// dashboard.add("autochooser",autoChooser) // dashboard.add("autochooser",autoChooser)
// .withSize(1,1) // .withSize(1,1)
// .withPosition(6,0); // .withPosition(6,0);
=======
dashboard.add("autochooser",autoChooser)
.withSize(1,1)
.withPosition(8,0);
>>>>>>> 3f240407849e489fb0b5fae52b61719f27c7b388
} }
private void configureBindings() { private void configureBindings() {

View File

@ -13,14 +13,14 @@ public class Accumulateur extends SubsystemBase {
/** Creates a new Accumulateur. */ /** Creates a new Accumulateur. */
public Accumulateur() {dashboard.addBoolean("photocell", this::photocell).withSize(1, 1).withPosition(0, 1); public Accumulateur() {dashboard.addBoolean("photocell", this::photocell).withSize(1, 1).withPosition(0, 1);
dashboard.addBoolean("photocell2", this::photocell).withSize(1, 1).withPosition(0, 1); dashboard.addBoolean("photocell2", this::photocell).withSize(1, 1).withPosition(1, 1);
} }
ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard");
private GenericEntry vitesse = private GenericEntry vitesse =
dashboard.add("vitesseacc", 0.1) dashboard.add("vitesseacc", 0.1)
.withSize(1, 1) .withSize(1, 1)
.withPosition(0, 4) .withPosition(0, 0)
.getEntry(); .getEntry();
final WPI_TalonSRX strap = new WPI_TalonSRX(0); final WPI_TalonSRX strap = new WPI_TalonSRX(0);

View File

@ -21,20 +21,25 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class Lanceur extends SubsystemBase { public class Lanceur extends SubsystemBase {
/** Creates a new Lanceur. */ /** Creates a new Lanceur. */
public Lanceur() {dashboard.add("rottourel", 0.2) public Lanceur() {
.withSize(0,0) dashboard.addBoolean("limitswitch1", this::limitswitch1)
.withPosition(1, 3);} .withSize(0,0).withPosition(1,2);
dashboard.addBoolean("limitswitch2", this::limitswitch2)
.withSize(0,0).withPosition(0,3);
dashboard.addDouble("rottourel", this::distancetourel)
.withSize(0,0).withPosition(1, 0);
}
ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard");
final WPI_TalonSRX lanceur1 = new WPI_TalonSRX(0); final WPI_TalonSRX lanceur1 = new WPI_TalonSRX(0);
final WPI_TalonSRX lanceur2 = new WPI_TalonSRX(1); final WPI_TalonSRX lanceur2 = new WPI_TalonSRX(1);
final CANSparkMax tourelle = new CANSparkMax(2, MotorType.kBrushed); final CANSparkMax tourelle = new CANSparkMax(2, MotorType.kBrushless);
final DigitalInput limitswitch1 = new DigitalInput(0); final DigitalInput limitswitch1 = new DigitalInput(0);
final DigitalInput limitswitch2 = new DigitalInput(1); final DigitalInput limitswitch2 = new DigitalInput(1);
private GenericEntry vitesse = private GenericEntry vitesse =
dashboard.add("vitesselanceur", 0.2) dashboard.add("vitesselanceur", 0.2)
.withSize(0,0) .withSize(0,0)
.withPosition(0, 3) .withPosition(0, 2)
.getEntry(); .getEntry();
public void encodeur(double distance){ public void encodeur(double distance){
@ -42,7 +47,12 @@ public class Lanceur extends SubsystemBase {
lanceur2.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative); lanceur2.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative);
lanceur1.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0, 1); lanceur1.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0, 1);
} }
public void touchagedelimitswitch1(double distance){
tourelle.getEncoder().setPosition(distance);
}
public void touchagedelimitswitch2(double distance){
tourelle.getEncoder().setPosition(distance);
}
public void masterslave(){ public void masterslave(){
lanceur2.follow(lanceur1); lanceur2.follow(lanceur1);
lanceur2.setInverted(true); lanceur2.setInverted(true);
@ -58,10 +68,10 @@ public class Lanceur extends SubsystemBase {
} }
public double vitessetourel(){ public double vitessetourel(){
return(tourelle.getEncoder().getVelocity()); return (tourelle.getEncoder().getVelocity());
} }
public double distancetourel(){ public double distancetourel(){
return(tourelle.getEncoder().getPosition()); return (tourelle.getEncoder().getPosition());
} }
public void PIDlanceur(double p, double i, double d) { public void PIDlanceur(double p, double i, double d) {
lanceur1.config_kP(0, p); lanceur1.config_kP(0, p);

View File

@ -21,8 +21,10 @@ public class Limelight3G extends SubsystemBase {
NetworkTableEntry tv = table.getEntry("tv"); NetworkTableEntry tv = table.getEntry("tv");
NetworkTableEntry camMode = table.getEntry("camMode"); NetworkTableEntry camMode = table.getEntry("camMode");
NetworkTableEntry tid = table.getEntry("tid"); NetworkTableEntry tid = table.getEntry("tid");
/** Creates a new Limelight. */ /** Creates a new Limelight. */
public Limelight3G() { public Limelight3G() {
dashboard.addDouble("tv", this::getv).withSize(0, 0).withPosition(1,3);
for (int port = 5800; port <= 5807; port++) { for (int port = 5800; port <= 5807; port++) {
PortForwarder.add(port, "limelight.local", port); PortForwarder.add(port, "limelight.local", port);
}} }}