Merge branch 'main' of https://git.demerso.net/PLS5618/Reefscape-2025
This commit is contained in:
		| @@ -43,8 +43,12 @@ public class Bougie extends SubsystemBase { | ||||
|    candle.setLEDs(255, 215, 0,0,48,8); | ||||
|    candle.setLEDs(255, 215, 0,0,64,8); | ||||
|    } | ||||
|   public void RainBow(){candle.animate(rainbowAnim);} | ||||
|   public void RainBowStop(){candle.animate(null);} | ||||
|   public void RainBow(){ | ||||
|     candle.animate(rainbowAnim); | ||||
|   } | ||||
|   public void RainBowStop(){ | ||||
|     candle.animate(null); | ||||
|   } | ||||
|   @Override | ||||
|   public void periodic() { | ||||
|     // This method will be called once per scheduler run | ||||
|   | ||||
| @@ -22,7 +22,6 @@ import edu.wpi.first.wpilibj.Notifier; | ||||
| import edu.wpi.first.wpilibj.RobotController; | ||||
| import edu.wpi.first.wpilibj2.command.Command; | ||||
| import edu.wpi.first.wpilibj2.command.Subsystem; | ||||
| import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine; | ||||
| import frc.robot.TunerConstants.TunerConstants.TunerSwerveDrivetrain; | ||||
|  | ||||
| /** | ||||
| @@ -44,71 +43,8 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su | ||||
|  | ||||
|     private final SwerveRequest.ApplyRobotSpeeds m_pathApplyRobotSpeeds = new SwerveRequest.ApplyRobotSpeeds(); | ||||
|  | ||||
|     /* Swerve requests to apply during SysId characterization */ | ||||
|     private final SwerveRequest.SysIdSwerveTranslation m_translationCharacterization = new SwerveRequest.SysIdSwerveTranslation(); | ||||
|     private final SwerveRequest.SysIdSwerveSteerGains m_steerCharacterization = new SwerveRequest.SysIdSwerveSteerGains(); | ||||
|     private final SwerveRequest.SysIdSwerveRotation m_rotationCharacterization = new SwerveRequest.SysIdSwerveRotation(); | ||||
|  | ||||
|     /* SysId routine for characterizing translation. This is used to find PID gains for the drive motors. */ | ||||
|  | ||||
|     private final SysIdRoutine m_sysIdRoutineTranslation = new SysIdRoutine( | ||||
|         new SysIdRoutine.Config( | ||||
|             null,        // Use default ramp rate (1 V/s) | ||||
|             Volts.of(4), // Reduce dynamic step voltage to 4 V to prevent brownout | ||||
|             null,        // Use default timeout (10 s) | ||||
|             // Log state with SignalLogger class | ||||
|             state -> SignalLogger.writeString("SysIdTranslation_State", state.toString()) | ||||
|         ), | ||||
|         new SysIdRoutine.Mechanism( | ||||
|             output -> setControl(m_translationCharacterization.withVolts(output)), | ||||
|             null, | ||||
|             this | ||||
|         ) | ||||
|     ); | ||||
|  | ||||
|     /* SysId routine for characterizing steer. This is used to find PID gains for the steer motors. */ | ||||
|     private final SysIdRoutine m_sysIdRoutineSteer = new SysIdRoutine( | ||||
|         new SysIdRoutine.Config( | ||||
|             null,        // Use default ramp rate (1 V/s) | ||||
|             Volts.of(7), // Use dynamic voltage of 7 V | ||||
|             null,        // Use default timeout (10 s) | ||||
|             // Log state with SignalLogger class | ||||
|             state -> SignalLogger.writeString("SysIdSteer_State", state.toString()) | ||||
|         ), | ||||
|         new SysIdRoutine.Mechanism( | ||||
|             volts -> setControl(m_steerCharacterization.withVolts(volts)), | ||||
|             null, | ||||
|             this | ||||
|         ) | ||||
|     ); | ||||
|  | ||||
|     /* | ||||
|      * SysId routine for characterizing rotation. | ||||
|      * This is used to find PID gains for the FieldCentricFacingAngle HeadingController. | ||||
|      * See the documentation of SwerveRequest.SysIdSwerveRotation for info on importing the log to SysId. | ||||
|      */ | ||||
|     private final SysIdRoutine m_sysIdRoutineRotation = new SysIdRoutine( | ||||
|         new SysIdRoutine.Config( | ||||
|             /* This is in radians per second², but SysId only supports "volts per second" */ | ||||
|             Volts.of(Math.PI / 6).per(Second), | ||||
|             /* This is in radians per second, but SysId only supports "volts" */ | ||||
|             Volts.of(Math.PI), | ||||
|             null, // Use default timeout (10 s) | ||||
|             // Log state with SignalLogger class | ||||
|             state -> SignalLogger.writeString("SysIdRotation_State", state.toString()) | ||||
|         ), | ||||
|         new SysIdRoutine.Mechanism( | ||||
|             output -> { | ||||
|                 /* output is actually radians per second, but SysId only supports "volts" */ | ||||
|                 setControl(m_rotationCharacterization.withRotationalRate(output.in(Volts))); | ||||
|                 /* also log the requested output for SysId */ | ||||
|                 SignalLogger.writeDouble("Rotational_Rate", output.in(Volts)); | ||||
|             }, | ||||
|             null, | ||||
|             this | ||||
|         ) | ||||
|     ); | ||||
|      | ||||
|     private void configureAutoBuilder() { | ||||
|         try { | ||||
|             var config = RobotConfig.fromGUISettings(); | ||||
| @@ -140,9 +76,6 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su | ||||
|             return 0; | ||||
|          });   | ||||
|         } | ||||
|   | ||||
|     /* The SysId routine to test */ | ||||
|     private SysIdRoutine m_sysIdRoutineToApply = m_sysIdRoutineSteer; | ||||
|  | ||||
|     /** | ||||
|      * Constructs a CTRE SwerveDrivetrain using the specified constants. | ||||
| @@ -234,28 +167,6 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su | ||||
|     public Command applyRequest(Supplier<SwerveRequest> requestSupplier) { | ||||
|         return run(() -> this.setControl(requestSupplier.get())); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Runs the SysId Quasistatic test in the given direction for the routine | ||||
|      * specified by {@link #m_sysIdRoutineToApply}. | ||||
|      * | ||||
|      * @param direction Direction of the SysId Quasistatic test | ||||
|      * @return Command to run | ||||
|      */ | ||||
|     public Command sysIdQuasistatic(SysIdRoutine.Direction direction) { | ||||
|         return m_sysIdRoutineToApply.quasistatic(direction); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Runs the SysId Dynamic test in the given direction for the routine | ||||
|      * specified by {@link #m_sysIdRoutineToApply}. | ||||
|      * | ||||
|      * @param direction Direction of the SysId Dynamic test | ||||
|      * @return Command to run | ||||
|      */ | ||||
|     public Command sysIdDynamic(SysIdRoutine.Direction direction) { | ||||
|         return m_sysIdRoutineToApply.dynamic(direction); | ||||
|     } | ||||
|      | ||||
|     @Override | ||||
|     public void periodic() { | ||||
|   | ||||
| @@ -3,8 +3,6 @@ | ||||
| // the WPILib BSD license file in the root directory of this project. | ||||
|  | ||||
| package frc.robot.subsystems; | ||||
|  | ||||
| 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.ShuffleboardTab; | ||||
| @@ -25,7 +23,17 @@ public class Elevateur extends SubsystemBase { | ||||
|     return monte.getEncoder().getPosition(); | ||||
|   } | ||||
|   public void vitesse(double vitesse){ | ||||
|     monte.set(vitesse); | ||||
|     if (limit2()) { | ||||
|       if (vitesse > 0) { | ||||
|         monte.set(0); | ||||
|       } | ||||
|       else{ | ||||
|         monte.set(vitesse); | ||||
|       } | ||||
|     } | ||||
|     else{ | ||||
|       monte.set(vitesse); | ||||
|     } | ||||
|   } | ||||
|   public boolean limit2(){ | ||||
|     return limit2.get(); | ||||
|   | ||||
| @@ -6,8 +6,6 @@ package frc.robot.subsystems; | ||||
|  | ||||
| import com.revrobotics.spark.SparkLowLevel.MotorType; | ||||
| import com.revrobotics.spark.SparkMax; | ||||
|  | ||||
| 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.ShuffleboardTab; | ||||
| @@ -27,11 +25,21 @@ public class Pince extends SubsystemBase { | ||||
|   final DigitalInput limit6 = new DigitalInput(9); | ||||
|    | ||||
|   | ||||
|   public void aspirecoral(double vitesse){ | ||||
|     coral.set(vitesse); | ||||
|   } | ||||
| public void aspirecoral(double vitesse){ | ||||
|   coral.set(vitesse); | ||||
| } | ||||
| public void pivote(double vitesse){ | ||||
|   pivoti.set(vitesse); | ||||
|   if (position()) { | ||||
|     if (vitesse > 0) { | ||||
|       pivoti.set(0); | ||||
|     } | ||||
|     else{ | ||||
|       pivoti.set(vitesse); | ||||
|     } | ||||
|   } | ||||
|   else{ | ||||
|     pivoti.set(vitesse); | ||||
|   } | ||||
| } | ||||
| public void aspirealgue(double vitesse){ | ||||
|   algue2.set(-vitesse); | ||||
| @@ -52,12 +60,7 @@ public double emperagecoral(){ | ||||
| public double emperagealgue(){ | ||||
|   return algue1.getOutputCurrent(); | ||||
| } | ||||
| public void algue1Test(double vitesse){ | ||||
|   algue1.set(vitesse); | ||||
| } | ||||
| public void algue2Test(double vitesse){ | ||||
|   algue2.set(vitesse); | ||||
| } | ||||
|  | ||||
|   @Override | ||||
|   public void periodic() { | ||||
|     // This method will be called once per scheduler run | ||||
|   | ||||
							
								
								
									
										48
									
								
								src/main/java/frc/robot/subsystems/Requin.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								src/main/java/frc/robot/subsystems/Requin.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| // 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; | ||||
|  | ||||
| import com.revrobotics.spark.SparkFlex; | ||||
| import com.revrobotics.spark.SparkMax; | ||||
| import com.revrobotics.spark.SparkLowLevel.MotorType; | ||||
| import edu.wpi.first.wpilibj.DigitalInput; | ||||
| import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; | ||||
| import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; | ||||
| import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||||
|  | ||||
| public class Requin extends SubsystemBase { | ||||
|   /** Creates a new Requin. */ | ||||
|   ShuffleboardTab teb = Shuffleboard.getTab("teb"); | ||||
|   public Requin() { | ||||
|     teb.addBoolean("limit requin", this::enHaut); | ||||
|   } | ||||
|     | ||||
|   final SparkFlex balaye = new SparkFlex(15, MotorType.kBrushless); | ||||
|   final SparkMax rotatione = new SparkMax(17, MotorType.kBrushless); | ||||
|   final DigitalInput limit3 = new DigitalInput(1); | ||||
|      | ||||
|   public void balaye(double vitesse){ | ||||
|     balaye.set(vitesse); | ||||
|   } | ||||
|   public void rotationer(double vitesse){ | ||||
|   rotatione.set(vitesse); | ||||
|   } | ||||
|   public boolean enHaut(){ | ||||
|   return limit3.get(); | ||||
|   }  | ||||
|   public double encodeur(){ | ||||
|   return rotatione.getEncoder().getPosition(); | ||||
|   } | ||||
|   public void reset(){ | ||||
|     rotatione.getEncoder().setPosition(0); | ||||
|   } | ||||
|   public double amp(){ | ||||
|     return balaye.getOutputCurrent(); | ||||
|   } | ||||
|   @Override | ||||
|   public void periodic() { | ||||
|     // This method will be called once per scheduler run | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user