2024-10-21 19:36:34 -04:00
|
|
|
// 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.Subsystems;
|
|
|
|
|
2024-10-21 19:54:51 -04:00
|
|
|
|
|
|
|
|
2024-10-28 18:52:38 -04:00
|
|
|
import com.ctre.phoenix.motorcontrol.FeedbackDevice;
|
|
|
|
import com.ctre.phoenix.motorcontrol.StatusFrameEnhanced;
|
2024-10-21 19:52:53 -04:00
|
|
|
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
|
2024-10-21 19:58:56 -04:00
|
|
|
import com.revrobotics.CANSparkMax;
|
|
|
|
import com.revrobotics.CANSparkLowLevel.MotorType;
|
2024-10-21 19:52:53 -04:00
|
|
|
|
2024-10-30 19:37:02 -04:00
|
|
|
import edu.wpi.first.networktables.GenericEntry;
|
|
|
|
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
|
|
|
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
2024-10-21 19:36:34 -04:00
|
|
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
|
|
|
|
|
|
|
public class Lanceur extends SubsystemBase {
|
|
|
|
/** Creates a new Lanceur. */
|
|
|
|
public Lanceur() {}
|
2024-10-30 19:37:02 -04:00
|
|
|
ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard");
|
2024-10-23 18:10:59 -04:00
|
|
|
|
2024-10-21 19:52:53 -04:00
|
|
|
final WPI_TalonSRX lanceur1 = new WPI_TalonSRX(0);
|
2024-10-21 19:58:56 -04:00
|
|
|
final WPI_TalonSRX lanceur2 = new WPI_TalonSRX(1);
|
2024-10-28 19:04:46 -04:00
|
|
|
final CANSparkMax tourelle = new CANSparkMax(2, MotorType.kBrushed);
|
2024-10-30 19:37:02 -04:00
|
|
|
private GenericEntry vitesse =
|
|
|
|
dashboard.add("vitesselanceur", 0.2)
|
|
|
|
.withSize(0,0)
|
|
|
|
.withPosition(1, 4)
|
|
|
|
.getEntry();
|
2024-10-23 18:59:06 -04:00
|
|
|
public void encodeur(double distance){
|
2024-10-28 18:52:38 -04:00
|
|
|
lanceur1.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative);
|
|
|
|
lanceur2.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative);
|
|
|
|
lanceur1.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0, 1);
|
2024-10-23 18:59:06 -04:00
|
|
|
}
|
2024-10-30 19:14:16 -04:00
|
|
|
public void masterslave(){
|
|
|
|
lanceur2.follow(lanceur1);
|
|
|
|
lanceur2.setInverted(true);
|
|
|
|
}
|
2024-10-21 20:01:10 -04:00
|
|
|
public void lance(double vitesse){
|
|
|
|
lanceur1.set(vitesse);
|
|
|
|
}
|
2024-10-30 19:37:02 -04:00
|
|
|
public void lance(){
|
|
|
|
lance(vitesse.getDouble(0.2));
|
|
|
|
}
|
2024-10-30 19:27:41 -04:00
|
|
|
public void tourelRotation(double x, double y, double rotation){
|
|
|
|
tourelle.set(rotation);
|
2024-10-23 17:56:39 -04:00
|
|
|
}
|
2024-10-30 19:14:16 -04:00
|
|
|
public double distancetourel(){
|
|
|
|
return(tourelle.getEncoder().getPosition());
|
2024-10-23 17:56:39 -04:00
|
|
|
}
|
2024-10-30 19:14:16 -04:00
|
|
|
public void PIDlanceur(double p, double i, double d) {
|
|
|
|
lanceur1.config_kP(0, p);
|
|
|
|
lanceur1.config_kI(0, i);
|
|
|
|
lanceur1.config_kD(0, d);
|
2024-10-23 18:10:59 -04:00
|
|
|
}
|
2024-10-21 19:36:34 -04:00
|
|
|
@Override
|
|
|
|
public void periodic() {
|
2024-10-21 19:52:53 -04:00
|
|
|
// This method will be called oncehttps://maven.ctr-electronics.com/release/com/ctre/phoenix/Phoenix5-frc2024-latest.json per scheduler run
|
2024-10-21 19:36:34 -04:00
|
|
|
}
|
|
|
|
}
|