From 6bec6011ca2125606075311f48c76e23c853d739 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Mon, 28 Oct 2024 18:52:38 -0400 Subject: [PATCH] encodeur --- src/main/java/frc/robot/Subsystems/Lanceur.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/Subsystems/Lanceur.java b/src/main/java/frc/robot/Subsystems/Lanceur.java index bd03482..1a6c4a6 100644 --- a/src/main/java/frc/robot/Subsystems/Lanceur.java +++ b/src/main/java/frc/robot/Subsystems/Lanceur.java @@ -6,11 +6,13 @@ package frc.robot.Subsystems; +import com.ctre.phoenix.motorcontrol.FeedbackDevice; +import com.ctre.phoenix.motorcontrol.StatusFrameEnhanced; import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkLowLevel.MotorType; -import edu.wpi.first.wpilibj.Encoder; + import edu.wpi.first.wpilibj2.command.SubsystemBase; @@ -21,9 +23,11 @@ public class Lanceur extends SubsystemBase { final WPI_TalonSRX lanceur1 = new WPI_TalonSRX(0); final WPI_TalonSRX lanceur2 = new WPI_TalonSRX(1); final CANSparkMax tourel = new CANSparkMax(2, MotorType.kBrushed); - Encoder encoder = new Encoder(0, 1); public void encodeur(double distance){ - encoder.setDistancePerPulse(distance); + lanceur1.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative); + lanceur2.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative); + lanceur1.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0, 1); + lanceur2.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0, 1); } public void lance(double vitesse){ lanceur1.set(vitesse);