Merge branch 'main' of https://git.demerso.net/PLS5618/pratique-2025
This commit is contained in:
commit
899f8f3bf6
@ -27,10 +27,13 @@ public class FollowAprilTag extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
|
||||||
|
|
||||||
if (enlignement.getv()==1)
|
if (enlignement.getv()==1)
|
||||||
{
|
{
|
||||||
lanceur.tourelRotation(0,0, enlignement.getx()/30);
|
lanceur.tourelRotation(0,0, enlignement.getx()/30);
|
||||||
}
|
}
|
||||||
|
if (lanceur.limitswitch1() || lanceur.limitswitch2()){
|
||||||
|
lanceur.lance(0);}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lanceur.tourelRotation(0, 0, 0);
|
lanceur.tourelRotation(0, 0, 0);
|
||||||
|
@ -4,14 +4,18 @@
|
|||||||
|
|
||||||
package frc.robot.Commands;
|
package frc.robot.Commands;
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
|
import edu.wpi.first.wpilibj2.command.WaitCommand;
|
||||||
|
import frc.robot.Subsystems.Accumulateur;
|
||||||
import frc.robot.Subsystems.Lanceur;
|
import frc.robot.Subsystems.Lanceur;
|
||||||
|
|
||||||
public class Lancer extends Command {
|
public class Lancer extends Command {
|
||||||
private Lanceur lanceur;
|
private Lanceur lanceur;
|
||||||
|
private Accumulateur accumulateur;
|
||||||
/** Creates a new Lancer. */
|
/** Creates a new Lancer. */
|
||||||
public Lancer(Lanceur lanceur) {
|
public Lancer(Lanceur lanceur,Accumulateur accumulateur) {
|
||||||
this.lanceur = lanceur;
|
this.lanceur = lanceur;
|
||||||
addRequirements(lanceur);
|
this.accumulateur = accumulateur;
|
||||||
|
addRequirements(lanceur, accumulateur);
|
||||||
// Use addRequirements() here to declare subsystem dependencies.
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
}
|
}
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@ -22,7 +26,12 @@ public class Lancer extends Command {
|
|||||||
// 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() {
|
||||||
lanceur.lance(0.5);
|
lanceur.lance();
|
||||||
|
accumulateur.Petitlanceur(0.7);
|
||||||
|
accumulateur.desaccumule(0.2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,7 +41,7 @@ public class RobotContainer {
|
|||||||
|
|
||||||
private void configureBindings() {
|
private void configureBindings() {
|
||||||
|
|
||||||
manette.x().whileTrue(new Lancer(lanceur));
|
manette.x().whileTrue(new Lancer(lanceur,accumulateur));
|
||||||
manette.leftBumper().toggleOnTrue(new FollowAprilTag(limelight3G, lanceur));
|
manette.leftBumper().toggleOnTrue(new FollowAprilTag(limelight3G, lanceur));
|
||||||
manette.a().whileTrue(new Desaccumuler(accumulateur));
|
manette.a().whileTrue(new Desaccumuler(accumulateur));
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,12 @@ import com.revrobotics.CANSparkMax;
|
|||||||
import com.revrobotics.CANSparkLowLevel.MotorType;
|
import com.revrobotics.CANSparkLowLevel.MotorType;
|
||||||
|
|
||||||
import edu.wpi.first.networktables.GenericEntry;
|
import edu.wpi.first.networktables.GenericEntry;
|
||||||
|
import edu.wpi.first.wpilibj.DigitalInput;
|
||||||
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 edu.wpi.first.wpilibj2.command.SubsystemBase;
|
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() {dashboard.add("rottourel", 0.2)
|
||||||
@ -27,7 +29,8 @@ public class Lanceur extends SubsystemBase {
|
|||||||
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.kBrushed);
|
||||||
final
|
final DigitalInput limitswitch1 = new DigitalInput(0);
|
||||||
|
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)
|
||||||
@ -39,12 +42,13 @@ 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 masterslave(){
|
public void masterslave(){
|
||||||
lanceur2.follow(lanceur1);
|
lanceur2.follow(lanceur1);
|
||||||
lanceur2.setInverted(true);
|
lanceur2.setInverted(true);
|
||||||
}
|
}
|
||||||
public void lance(double vitesse){
|
public void lance(double vitesse){
|
||||||
lanceur1.set(vitesse);lanceur2.set(vitesse);
|
lanceur1.set(vitesse);
|
||||||
}
|
}
|
||||||
public void lance(){
|
public void lance(){
|
||||||
lance(vitesse.getDouble(0.2));
|
lance(vitesse.getDouble(0.2));
|
||||||
@ -64,6 +68,12 @@ public class Lanceur extends SubsystemBase {
|
|||||||
lanceur1.config_kI(0, i);
|
lanceur1.config_kI(0, i);
|
||||||
lanceur1.config_kD(0, d);
|
lanceur1.config_kD(0, d);
|
||||||
}
|
}
|
||||||
|
public boolean limitswitch1(){
|
||||||
|
return limitswitch1.get();
|
||||||
|
}
|
||||||
|
public boolean limitswitch2(){
|
||||||
|
return limitswitch2.get();
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void periodic() {
|
public void periodic() {
|
||||||
// This method will be called oncehttps://maven.ctr-electronics.com/release/com/ctre/phoenix/Phoenix5-frc2024-latest.json per scheduler run
|
// This method will be called oncehttps://maven.ctr-electronics.com/release/com/ctre/phoenix/Phoenix5-frc2024-latest.json per scheduler run
|
||||||
|
Loading…
x
Reference in New Issue
Block a user