Merge branch 'main' of https://git.demerso.net/PLS5618/pratique-2025
This commit is contained in:
commit
7b460fa3de
File diff suppressed because one or more lines are too long
52
src/main/deploy/pathplanner/paths/Example Path.path
Normal file
52
src/main/deploy/pathplanner/paths/Example Path.path
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"version": 1.0,
|
||||||
|
"waypoints": [
|
||||||
|
{
|
||||||
|
"anchor": {
|
||||||
|
"x": 2.0,
|
||||||
|
"y": 7.0
|
||||||
|
},
|
||||||
|
"prevControl": null,
|
||||||
|
"nextControl": {
|
||||||
|
"x": 3.0,
|
||||||
|
"y": 7.0
|
||||||
|
},
|
||||||
|
"isLocked": false,
|
||||||
|
"linkedName": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anchor": {
|
||||||
|
"x": 5.9001283880171185,
|
||||||
|
"y": 2.9171184022824534
|
||||||
|
},
|
||||||
|
"prevControl": {
|
||||||
|
"x": 4.9001283880171185,
|
||||||
|
"y": 2.9171184022824534
|
||||||
|
},
|
||||||
|
"nextControl": null,
|
||||||
|
"isLocked": false,
|
||||||
|
"linkedName": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rotationTargets": [],
|
||||||
|
"constraintZones": [],
|
||||||
|
"eventMarkers": [],
|
||||||
|
"globalConstraints": {
|
||||||
|
"maxVelocity": 3.0,
|
||||||
|
"maxAcceleration": 3.0,
|
||||||
|
"maxAngularVelocity": 540.0,
|
||||||
|
"maxAngularAcceleration": 720.0
|
||||||
|
},
|
||||||
|
"goalEndState": {
|
||||||
|
"velocity": 0,
|
||||||
|
"rotation": 0,
|
||||||
|
"rotateFast": false
|
||||||
|
},
|
||||||
|
"reversed": false,
|
||||||
|
"folder": null,
|
||||||
|
"previewStartingState": {
|
||||||
|
"rotation": 0,
|
||||||
|
"velocity": 0
|
||||||
|
},
|
||||||
|
"useDefaultConstraints": true
|
||||||
|
}
|
@ -22,7 +22,8 @@ public class Desaccumuler 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() {
|
||||||
accumulateur.desaccumule(0.1);
|
if(accumulateur.photocell()){accumulateur.desaccumule(0.1);}
|
||||||
|
|
||||||
}
|
}
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
@Override
|
@Override
|
||||||
|
47
src/main/java/frc/robot/Commands/Tracker_Couleur_Forme.java
Normal file
47
src/main/java/frc/robot/Commands/Tracker_Couleur_Forme.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// 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.Commands;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
|
import frc.robot.Subsystems.Limelight3G;
|
||||||
|
|
||||||
|
|
||||||
|
public class Tracker_Couleur_Forme extends Command {
|
||||||
|
/** Creates a new Tracker_Couleur_Forme. */
|
||||||
|
private Limelight3G pipeline;
|
||||||
|
public Tracker_Couleur_Forme(Limelight3G tracker_couleur, Limelight3G tracker_forme) {
|
||||||
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
|
this.pipeline = pipeline;
|
||||||
|
this.tracker_couleur = tracker_couleur;
|
||||||
|
this.tracker_forme = tracker_forme;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the command is initially scheduled.
|
||||||
|
@Override
|
||||||
|
public void initialize() {}
|
||||||
|
|
||||||
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
if (pipeline == 1) {
|
||||||
|
Limelight3G.tracker_couleur;
|
||||||
|
}
|
||||||
|
else if (pipeline == 2){
|
||||||
|
Limelight3G.tracker_forme;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called once the command ends or is interrupted.
|
||||||
|
@Override
|
||||||
|
public void end(boolean interrupted) {}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -4,13 +4,28 @@
|
|||||||
|
|
||||||
package frc.robot;
|
package frc.robot;
|
||||||
|
|
||||||
|
import edu.wpi.first.math.MathUtil;
|
||||||
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.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
import edu.wpi.first.wpilibj2.command.Commands;
|
import edu.wpi.first.wpilibj2.command.Commands;
|
||||||
|
import edu.wpi.first.wpilibj2.command.RunCommand;
|
||||||
|
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
||||||
|
import frc.robot.Commands.Desaccumuler;
|
||||||
|
import frc.robot.Commands.FollowAprilTag;
|
||||||
|
import frc.robot.Commands.Lancer;
|
||||||
|
import frc.robot.Subsystems.Accumulateur;
|
||||||
|
import frc.robot.Subsystems.Drive;
|
||||||
|
import frc.robot.Subsystems.Lanceur;
|
||||||
|
import frc.robot.Subsystems.Limelight3G;
|
||||||
|
|
||||||
public class RobotContainer {
|
public class RobotContainer {
|
||||||
|
Lanceur lanceur= new Lanceur();
|
||||||
|
Accumulateur accumulateur = new Accumulateur();
|
||||||
|
Limelight3G limelight3G = new Limelight3G();
|
||||||
|
Drive drive = new Drive();
|
||||||
ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard");
|
ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard");
|
||||||
|
CommandXboxController manette = new CommandXboxController(0);
|
||||||
public RobotContainer() {
|
public RobotContainer() {
|
||||||
dashboard.addCamera("limelight3G", "limelight3G","limelight.local:5800")
|
dashboard.addCamera("limelight3G", "limelight3G","limelight.local:5800")
|
||||||
.withSize(3,4)
|
.withSize(3,4)
|
||||||
@ -19,9 +34,17 @@ public class RobotContainer {
|
|||||||
.withSize(3,4)
|
.withSize(3,4)
|
||||||
.withPosition(3,0);
|
.withPosition(3,0);
|
||||||
configureBindings();
|
configureBindings();
|
||||||
|
drive.setDefaultCommand(new RunCommand(()->{
|
||||||
|
drive.drive(-MathUtil.applyDeadband(manette.getRightX(),0.2), MathUtil.applyDeadband(-manette.getRightY(),0.2), MathUtil.applyDeadband(-manette.getRightX(), 0.2));
|
||||||
|
},drive));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureBindings() {}
|
private void configureBindings() {
|
||||||
|
|
||||||
|
manette.x().whileTrue(new Lancer(lanceur));
|
||||||
|
manette.leftBumper().toggleOnTrue(new FollowAprilTag(limelight3G, lanceur));
|
||||||
|
manette.a().whileTrue(new Desaccumuler(accumulateur));
|
||||||
|
}
|
||||||
|
|
||||||
public Command getAutonomousCommand() {
|
public Command getAutonomousCommand() {
|
||||||
return Commands.print("No autonomous command configured");
|
return Commands.print("No autonomous command configured");
|
||||||
|
@ -12,9 +12,8 @@ import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
|
|||||||
public class Accumulateur extends SubsystemBase {
|
public class Accumulateur extends SubsystemBase {
|
||||||
|
|
||||||
/** Creates a new Accumulateur. */
|
/** Creates a new Accumulateur. */
|
||||||
public Accumulateur() {dashboard.addBoolean("photocellacc", this::limitswitch)
|
public Accumulateur() {dashboard.addBoolean("photocellacc", this::photocell).withSize(1, 1).withPosition(0, 1);
|
||||||
.withSize(1, 1)
|
dashboard.addBoolean("photocellacc2", this::photocell).withSize(1, 1).withPosition(0, 1);
|
||||||
.withPosition(0, 1);
|
|
||||||
}
|
}
|
||||||
ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard");
|
ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard");
|
||||||
|
|
||||||
@ -27,10 +26,11 @@ public class Accumulateur extends SubsystemBase {
|
|||||||
final WPI_TalonSRX accumulateur1 = new WPI_TalonSRX(0);
|
final WPI_TalonSRX accumulateur1 = new WPI_TalonSRX(0);
|
||||||
final WPI_TalonSRX accumulateur2 = new WPI_TalonSRX(10);
|
final WPI_TalonSRX accumulateur2 = new WPI_TalonSRX(10);
|
||||||
final DigitalInput photocell = new DigitalInput(94);
|
final DigitalInput photocell = new DigitalInput(94);
|
||||||
|
final DigitalInput photocell2 = new DigitalInput(93);
|
||||||
public void encodeur(){
|
public void encodeur(){
|
||||||
}
|
}
|
||||||
public boolean limitswitch(){
|
public boolean photocell(){
|
||||||
return !photocell.get();
|
return photocell.get();
|
||||||
}
|
}
|
||||||
public void desaccumule(double vitesse){
|
public void desaccumule(double vitesse){
|
||||||
accumulateur1.set(vitesse);
|
accumulateur1.set(vitesse);
|
||||||
|
@ -30,6 +30,11 @@ public class Lanceur extends SubsystemBase {
|
|||||||
.withSize(0,0)
|
.withSize(0,0)
|
||||||
.withPosition(1, 4)
|
.withPosition(1, 4)
|
||||||
.getEntry();
|
.getEntry();
|
||||||
|
private GenericEntry rotation =
|
||||||
|
dashboard.add("rottourel", 0.2)
|
||||||
|
.withSize(0,0)
|
||||||
|
.withPosition(1, 5)
|
||||||
|
.getEntry();
|
||||||
public void encodeur(double distance){
|
public void encodeur(double distance){
|
||||||
lanceur1.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative);
|
lanceur1.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative);
|
||||||
lanceur2.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative);
|
lanceur2.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative);
|
||||||
@ -40,7 +45,7 @@ public class Lanceur extends SubsystemBase {
|
|||||||
lanceur2.setInverted(true);
|
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));
|
||||||
@ -48,6 +53,12 @@ public class Lanceur extends SubsystemBase {
|
|||||||
public void tourelRotation(double x, double y, double rotation){
|
public void tourelRotation(double x, double y, double rotation){
|
||||||
tourelle.set(rotation);
|
tourelle.set(rotation);
|
||||||
}
|
}
|
||||||
|
public void tourelRotation(){
|
||||||
|
tourelle.set(rotation.getDouble(0.1));
|
||||||
|
}
|
||||||
|
public double vitessetourel(){
|
||||||
|
return(tourelle.getEncoder().getVelocity());
|
||||||
|
}
|
||||||
public double distancetourel(){
|
public double distancetourel(){
|
||||||
return(tourelle.getEncoder().getPosition());
|
return(tourelle.getEncoder().getPosition());
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,11 @@ import edu.wpi.first.net.PortForwarder;
|
|||||||
import edu.wpi.first.networktables.NetworkTable;
|
import edu.wpi.first.networktables.NetworkTable;
|
||||||
import edu.wpi.first.networktables.NetworkTableEntry;
|
import edu.wpi.first.networktables.NetworkTableEntry;
|
||||||
import edu.wpi.first.networktables.NetworkTableInstance;
|
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||||
|
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||||
|
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
||||||
|
|
||||||
public class Limelight3G extends SubsystemBase {
|
public class Limelight3G extends SubsystemBase {
|
||||||
|
ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard");
|
||||||
NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight");
|
NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight");
|
||||||
NetworkTableEntry tx = table.getEntry("tx");
|
NetworkTableEntry tx = table.getEntry("tx");
|
||||||
NetworkTableEntry ty = table.getEntry("ty");
|
NetworkTableEntry ty = table.getEntry("ty");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user