This commit is contained in:
Olivier Dubois 2024-10-30 19:38:13 -04:00
commit 8d93e7f24f
4 changed files with 23 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@ -6,19 +6,20 @@ package frc.robot.Commands;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.Subsystems.Drive; import frc.robot.Subsystems.Drive;
import frc.robot.Subsystems.Lanceur;
import frc.robot.Subsystems.Limelight3G; import frc.robot.Subsystems.Limelight3G;
public class FollowAprilTag extends Command { public class FollowAprilTag extends Command {
private Limelight3G enlignement; private Limelight3G enlignement;
private Drive drive; private Lanceur lanceur;
/** Creates a new Limelight3g. */ /** Creates a new Limelight3g. */
public FollowAprilTag(Limelight3G enlignement, Drive drive) { public FollowAprilTag(Limelight3G enlignement, Lanceur lanceur) {
// Use addRequirements() here to declare subsystem dependencies. // Use addRequirements() here to declare subsystem dependencies.
this.drive = drive; this.lanceur = lanceur;
this.enlignement = enlignement; this.enlignement = enlignement;
addRequirements(drive, enlignement); addRequirements(lanceur, enlignement);
} }
// Called when the command is initially scheduled. // Called when the command is initially scheduled.
@ -31,11 +32,11 @@ public class FollowAprilTag extends Command {
if (enlignement.getv()==1) if (enlignement.getv()==1)
{ {
drive.drive(0, 0, enlignement.getx()/30); lanceur.tourelRotation(0,0, enlignement.getx()/30);
} }
else else
{ {
drive.drive(0, 0, 0); lanceur.tourelRotation(0, 0, 0);
} }
} }
@ -43,7 +44,7 @@ public class FollowAprilTag extends Command {
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.
@Override @Override
public void end(boolean interrupted) { public void end(boolean interrupted) {
drive.drive(0, 0, 0); lanceur.tourelRotation(0, 0, 0);
} }
// Returns true when the command should end. // Returns true when the command should end.

View File

@ -19,7 +19,7 @@ public class Lancer extends Command {
// Called when the command is initially scheduled. // Called when the command is initially scheduled.
@Override @Override
public void initialize() { public void initialize() {
lanceur.setPID(0, 0, 0); lanceur.PIDlanceur(0, 0, 0);
} }
// Called every time the scheduler runs while the command is scheduled. // Called every time the scheduler runs while the command is scheduled.

View File

@ -34,20 +34,28 @@ public class Lanceur extends SubsystemBase {
lanceur1.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative); lanceur1.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative);
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);
lanceur2.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0, 1);
} }
public void masterslave(){
lanceur2.follow(lanceur1);
lanceur2.setInverted(true);
}
public void lance(double vitesse){ public void lance(double vitesse){
lanceur1.set(vitesse); lanceur1.set(vitesse);
lanceur2.set(-vitesse);
} }
public void lance(){ public void lance(){
lance(vitesse.getDouble(0.2)); lance(vitesse.getDouble(0.2));
} }
public void tourelRotation(double vitesse){ public void tourelRotation(double x, double y, double rotation){
tourelle.set(vitesse); tourelle.set(rotation);
} }
public void setPID(double p, double i, int d) { public double distancetourel(){
return(tourelle.getEncoder().getPosition());
}
public void PIDlanceur(double p, double i, double d) {
lanceur1.config_kP(0, p);
lanceur1.config_kI(0, i);
lanceur1.config_kD(0, d);
} }
@Override @Override
public void periodic() { public void periodic() {