From 99584ce12f6d17cb307549904968c8c0e597cf8e Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Thu, 18 Jan 2024 20:12:49 -0500 Subject: [PATCH 01/20] --- src/main/java/frc/robot/subsystem/Guideur.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/subsystem/Guideur.java b/src/main/java/frc/robot/subsystem/Guideur.java index 4c29dc4..e276197 100644 --- a/src/main/java/frc/robot/subsystem/Guideur.java +++ b/src/main/java/frc/robot/subsystem/Guideur.java @@ -14,8 +14,17 @@ public class Guideur extends SubsystemBase { /** Creates a new Guideur. */ public Guideur() {} final WPI_TalonSRX guideur = new WPI_TalonSRX(Constants.guideur); - private DigitalInput guideurhaut = new DigitalInput(Constants.guideurhaut); - private DigitalInput guideurbas = new DigitalInput(Constants.guideurhaut); + final DigitalInput guideurhaut = new DigitalInput(Constants.guideurhaut); + final DigitalInput guideurbas = new DigitalInput(Constants.guideurhaut); + public void guider(double vitesse){ + guideur.set(vitesse); + } + public boolean haut(){ + return guideurhaut.get(); + } + public boolean bas(){ + return guideurbas.get(); + } @Override public void periodic() { // This method will be called once per scheduler run From 420dbde58b40e7122f866c6da835e38e6f843e34 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Thu, 18 Jan 2024 20:15:13 -0500 Subject: [PATCH 02/20] acrocheur --- .../java/frc/robot/subsystem/Acrocheur.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/frc/robot/subsystem/Acrocheur.java diff --git a/src/main/java/frc/robot/subsystem/Acrocheur.java b/src/main/java/frc/robot/subsystem/Acrocheur.java new file mode 100644 index 0000000..e79e6a3 --- /dev/null +++ b/src/main/java/frc/robot/subsystem/Acrocheur.java @@ -0,0 +1,17 @@ +// 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.subsystem; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class Acrocheur extends SubsystemBase { + /** Creates a new Acrocheur. */ + public Acrocheur() {} + + @Override + public void periodic() { + // This method will be called once per scheduler run + } +} From 27e57ca1571069599c44fe466bc06fb27da498c1 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Thu, 18 Jan 2024 20:17:24 -0500 Subject: [PATCH 03/20] --- .../frc/robot/subsystem/{Acrocheur.java => Grimpeur.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/main/java/frc/robot/subsystem/{Acrocheur.java => Grimpeur.java} (85%) diff --git a/src/main/java/frc/robot/subsystem/Acrocheur.java b/src/main/java/frc/robot/subsystem/Grimpeur.java similarity index 85% rename from src/main/java/frc/robot/subsystem/Acrocheur.java rename to src/main/java/frc/robot/subsystem/Grimpeur.java index e79e6a3..62d22be 100644 --- a/src/main/java/frc/robot/subsystem/Acrocheur.java +++ b/src/main/java/frc/robot/subsystem/Grimpeur.java @@ -6,9 +6,9 @@ package frc.robot.subsystem; import edu.wpi.first.wpilibj2.command.SubsystemBase; -public class Acrocheur extends SubsystemBase { +public class Grimpeur extends SubsystemBase { /** Creates a new Acrocheur. */ - public Acrocheur() {} + public Grimpeur() {} @Override public void periodic() { From 83d20b577d1e563b0485934ef034ccba9be3f3ab Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Mon, 22 Jan 2024 18:42:19 -0500 Subject: [PATCH 04/20] 4 moteur lanceur --- src/main/java/frc/robot/Constants.java | 18 ++++++++++-------- src/main/java/frc/robot/subsystem/Lanceur.java | 2 ++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 04557d8..9f9f786 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -9,14 +9,16 @@ public class Constants { //moteur public static int lanceur = 1; public static int lancer2 = 2; - public static int roue = 3; - public static int etoile = 4; - public static int Moteuracc2 = 5; - public static int Moteuracc = 6; - public static int guideur = 7; + public static int lanceur3 = 3; + public static int lancer4 = 4; + public static int roue = 5; + public static int etoile = 6; + public static int Moteuracc2 = 7; + public static int Moteuracc = 8; + public static int guideur = 9; // limit switsh - public static int guideurhaut = 8; - public static int guideurbas = 9; - public static int limitacc = 58; + public static int guideurhaut = 10; + public static int guideurbas = 11; + public static int limitacc = 12; } diff --git a/src/main/java/frc/robot/subsystem/Lanceur.java b/src/main/java/frc/robot/subsystem/Lanceur.java index dc7ee09..6433d05 100644 --- a/src/main/java/frc/robot/subsystem/Lanceur.java +++ b/src/main/java/frc/robot/subsystem/Lanceur.java @@ -18,6 +18,8 @@ public class Lanceur extends SubsystemBase { public Lanceur() {} final CANSparkMax lancer = new CANSparkMax(Constants.lanceur, MotorType.kBrushless); final CANSparkMax lancer2 = new CANSparkMax(Constants.lancer2, MotorType.kBrushless); + final CANSparkMax lancer3 = new CANSparkMax(Constants.lanceur, MotorType.kBrushless); + final CANSparkMax lancer4 = new CANSparkMax(Constants.lancer2, MotorType.kBrushless); public void lancer(double vitesse){ lancer.set(vitesse); } From ecd0304e00a0f33fc937deff71429b6125d769aa Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Mon, 22 Jan 2024 18:45:09 -0500 Subject: [PATCH 05/20] master slave --- src/main/java/frc/robot/subsystem/Lanceur.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/frc/robot/subsystem/Lanceur.java b/src/main/java/frc/robot/subsystem/Lanceur.java index 6433d05..bc8b4e2 100644 --- a/src/main/java/frc/robot/subsystem/Lanceur.java +++ b/src/main/java/frc/robot/subsystem/Lanceur.java @@ -25,6 +25,8 @@ public class Lanceur extends SubsystemBase { } public void lanceur(){ lancer2.follow(lancer); + lancer3.follow(lancer); + lancer4.follow(lancer); } From c5bc8f4528526c67a15daf2d08a5f26769c3fc7a Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Mon, 22 Jan 2024 18:49:45 -0500 Subject: [PATCH 06/20] lanceur --- src/main/java/frc/robot/subsystem/Grimpeur.java | 1 + src/main/java/frc/robot/subsystem/Lanceur.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/main/java/frc/robot/subsystem/Grimpeur.java b/src/main/java/frc/robot/subsystem/Grimpeur.java index 62d22be..cff76db 100644 --- a/src/main/java/frc/robot/subsystem/Grimpeur.java +++ b/src/main/java/frc/robot/subsystem/Grimpeur.java @@ -9,6 +9,7 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase; public class Grimpeur extends SubsystemBase { /** Creates a new Acrocheur. */ public Grimpeur() {} + final @Override public void periodic() { diff --git a/src/main/java/frc/robot/subsystem/Lanceur.java b/src/main/java/frc/robot/subsystem/Lanceur.java index bc8b4e2..45e0a1e 100644 --- a/src/main/java/frc/robot/subsystem/Lanceur.java +++ b/src/main/java/frc/robot/subsystem/Lanceur.java @@ -27,6 +27,8 @@ public class Lanceur extends SubsystemBase { lancer2.follow(lancer); lancer3.follow(lancer); lancer4.follow(lancer); + lancer3.setInverted(true); + lancer4.setInverted(true); } From 2404f94faa37fcba3ec76f2055822f71308c074f Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Mon, 22 Jan 2024 19:12:16 -0500 Subject: [PATCH 07/20] --- src/main/java/frc/robot/Constants.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 9f9f786..66aaf3b 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -16,9 +16,15 @@ public class Constants { public static int Moteuracc2 = 7; public static int Moteuracc = 8; public static int guideur = 9; + public static int grimpeurd = 13; + public static int grimpeurg = 14; // limit switsh public static int guideurhaut = 10; public static int guideurbas = 11; public static int limitacc = 12; + public static int limitbasd =15; + public static int limitbasg =16; + public static int limithautd =17; + public static int limithautg =18; } From 24ac20a097a59de8e21996738d8a4df14b2d4ed5 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Mon, 22 Jan 2024 19:32:35 -0500 Subject: [PATCH 08/20] grimpeur --- src/main/java/frc/robot/Constants.java | 6 +-- .../java/frc/robot/subsystem/Grimpeur.java | 41 ++++++++++++++++++- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 66aaf3b..2ee83c7 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -22,9 +22,7 @@ public class Constants { public static int guideurhaut = 10; public static int guideurbas = 11; public static int limitacc = 12; - public static int limitbasd =15; - public static int limitbasg =16; - public static int limithautd =17; - public static int limithautg =18; + public static int limitbas =15; + public static int limithaut =16; } diff --git a/src/main/java/frc/robot/subsystem/Grimpeur.java b/src/main/java/frc/robot/subsystem/Grimpeur.java index cff76db..b61e3c5 100644 --- a/src/main/java/frc/robot/subsystem/Grimpeur.java +++ b/src/main/java/frc/robot/subsystem/Grimpeur.java @@ -4,15 +4,52 @@ package frc.robot.subsystem; +import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkLowLevel.MotorType; + +import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj2.command.SubsystemBase; +import frc.robot.Constants; public class Grimpeur extends SubsystemBase { /** Creates a new Acrocheur. */ + // moteur public Grimpeur() {} - final - + final CANSparkMax grimpeurd = new CANSparkMax(Constants.grimpeurd,MotorType.kBrushless); + final CANSparkMax grimpeurg = new CANSparkMax(Constants.grimpeurg,MotorType.kBrushless); + // limit switch + final DigitalInput limitdroite = new DigitalInput(Constants.limithaut); + final DigitalInput limitgauche = new DigitalInput(Constants.limitbas); + //fonction +public void droit(double vitesse){ + grimpeurd.set(vitesse); +} +public void gauche(double vitesse){ + grimpeurg.set(vitesse); +} +public boolean droite(){ + return limitdroite.get(); +} +public boolean gauche(){ + return limitgauche.get(); +} +public void resetencodeurd(){ + grimpeurd.getEncoder().setPosition(0); +} +public void resetencodeurg(){ + grimpeurg.getEncoder().setPosition(0); +} +public void grimpeur(){ + grimpeurg.follow(grimpeurd); +} @Override public void periodic() { // This method will be called once per scheduler run + if(droite()) { + resetencodeurd(); + } + if(gauche()) { + resetencodeurg(); + } } } From b1efbc83733866b0090143d2ae7c54e9c9302fae Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 22 Jan 2024 19:33:18 -0500 Subject: [PATCH 09/20] Swerve + Constant --- .../deploy/swerve/controllerproperties.json | 8 ++++ src/main/deploy/swerve/modules/backleft.json | 30 ++++++++++++ src/main/deploy/swerve/modules/backright.json | 30 ++++++++++++ src/main/deploy/swerve/modules/frontleft.json | 30 ++++++++++++ .../deploy/swerve/modules/frontright.json | 30 ++++++++++++ .../swerve/modules/physicalproperties.json | 16 +++++++ .../deploy/swerve/modules/pidfproperties.json | 16 +++++++ src/main/deploy/swerve/swervedrive.json | 14 ++++++ src/main/java/frc/robot/Constants.java | 48 ++++++++++++++----- src/main/java/frc/robot/subsystem/Drive.java | 31 +++++++++++- 10 files changed, 240 insertions(+), 13 deletions(-) create mode 100644 src/main/deploy/swerve/controllerproperties.json create mode 100644 src/main/deploy/swerve/modules/backleft.json create mode 100644 src/main/deploy/swerve/modules/backright.json create mode 100644 src/main/deploy/swerve/modules/frontleft.json create mode 100644 src/main/deploy/swerve/modules/frontright.json create mode 100644 src/main/deploy/swerve/modules/physicalproperties.json create mode 100644 src/main/deploy/swerve/modules/pidfproperties.json create mode 100644 src/main/deploy/swerve/swervedrive.json diff --git a/src/main/deploy/swerve/controllerproperties.json b/src/main/deploy/swerve/controllerproperties.json new file mode 100644 index 0000000..669097e --- /dev/null +++ b/src/main/deploy/swerve/controllerproperties.json @@ -0,0 +1,8 @@ +{ + "angleJoystickRadiusDeadband": 0.5, + "heading": { + "p": 0.4, + "i": 0, + "d": 0.01 + } +} \ No newline at end of file diff --git a/src/main/deploy/swerve/modules/backleft.json b/src/main/deploy/swerve/modules/backleft.json new file mode 100644 index 0000000..a9a2d30 --- /dev/null +++ b/src/main/deploy/swerve/modules/backleft.json @@ -0,0 +1,30 @@ +{ + "location": { + "front": -12.375, + "left": 12.375 + }, + "absoluteEncoderOffset": 80.332, + "drive": { + "type": "sparkmax", + "id": 8, + "canbus": null + }, + "angle": { + "type": "sparkmax", + "id": 9, + "canbus": null + }, + "inverted": { + "angle": true, + "drive": false + }, + "conversionFactor": { + "angle": 0, + "drive": 0 + }, + "encoder": { + "type": "cancoder", + "id": 7, + "canbus": null + } +} \ No newline at end of file diff --git a/src/main/deploy/swerve/modules/backright.json b/src/main/deploy/swerve/modules/backright.json new file mode 100644 index 0000000..679f08d --- /dev/null +++ b/src/main/deploy/swerve/modules/backright.json @@ -0,0 +1,30 @@ +{ + "location": { + "front": -12.375, + "left": -12.375 + }, + "absoluteEncoderOffset": 28.74, + "drive": { + "type": "sparkmax", + "id": 11, + "canbus": null + }, + "angle": { + "type": "sparkmax", + "id": 12, + "canbus": null + }, + "inverted": { + "angle": true, + "drive": false + }, + "conversionFactor": { + "angle": 0, + "drive": 0 + }, + "encoder": { + "type": "cancoder", + "id": 6, + "canbus": null + } +} \ No newline at end of file diff --git a/src/main/deploy/swerve/modules/frontleft.json b/src/main/deploy/swerve/modules/frontleft.json new file mode 100644 index 0000000..3c37753 --- /dev/null +++ b/src/main/deploy/swerve/modules/frontleft.json @@ -0,0 +1,30 @@ +{ + "location": { + "front": 12.375, + "left": 12.375 + }, + "absoluteEncoderOffset": 98.438, + "drive": { + "type": "sparkmax", + "id": 2, + "canbus": null + }, + "angle": { + "type": "sparkmax", + "id": 3, + "canbus": null + }, + "inverted": { + "angle": true, + "drive": false + }, + "conversionFactor": { + "angle": 0, + "drive": 0 + }, + "encoder": { + "type": "cancoder", + "id": 4, + "canbus": null + } +} \ No newline at end of file diff --git a/src/main/deploy/swerve/modules/frontright.json b/src/main/deploy/swerve/modules/frontright.json new file mode 100644 index 0000000..87f8cd9 --- /dev/null +++ b/src/main/deploy/swerve/modules/frontright.json @@ -0,0 +1,30 @@ +{ + "location": { + "front": 12.375, + "left": -12.375 + }, + "absoluteEncoderOffset": 17.227, + "drive": { + "type": "sparkmax", + "id": 17, + "canbus": null + }, + "angle": { + "type": "sparkmax", + "id": 18, + "canbus": null + }, + "inverted": { + "angle": true, + "drive": false + }, + "conversionFactor": { + "angle": 0, + "drive": 0 + }, + "encoder": { + "type": "cancoder", + "id": 5, + "canbus": null + } +} \ No newline at end of file diff --git a/src/main/deploy/swerve/modules/physicalproperties.json b/src/main/deploy/swerve/modules/physicalproperties.json new file mode 100644 index 0000000..4994775 --- /dev/null +++ b/src/main/deploy/swerve/modules/physicalproperties.json @@ -0,0 +1,16 @@ +{ + "optimalVoltage": 12, + "wheelGripCoefficientOfFriction": 1.19, + "currentLimit": { + "drive": 40, + "angle": 20 + }, + "conversionFactor": { + "angle": 16.8, + "drive": 0.04 + }, + "rampRate": { + "drive": 0.25, + "angle": 0.25 + } +} \ No newline at end of file diff --git a/src/main/deploy/swerve/modules/pidfproperties.json b/src/main/deploy/swerve/modules/pidfproperties.json new file mode 100644 index 0000000..3834a36 --- /dev/null +++ b/src/main/deploy/swerve/modules/pidfproperties.json @@ -0,0 +1,16 @@ +{ + "drive": { + "p": 0.0020645, + "i": 0, + "d": 0, + "f": 0, + "iz": 0 + }, + "angle": { + "p": 0.0020645, + "i": 0, + "d": 0, + "f": 0, + "iz": 0 + } +} \ No newline at end of file diff --git a/src/main/deploy/swerve/swervedrive.json b/src/main/deploy/swerve/swervedrive.json new file mode 100644 index 0000000..1604d61 --- /dev/null +++ b/src/main/deploy/swerve/swervedrive.json @@ -0,0 +1,14 @@ +{ + "imu": { + "type": "pigeon", + "id": 0, + "canbus": null + }, + "invertedIMU": false, + "modules": [ + "frontleft.json", + "frontright.json", + "backleft.json", + "backright.json" + ] +} \ No newline at end of file diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 04557d8..27c116c 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -6,17 +6,41 @@ package frc.robot; /** Add your docs here. */ public class Constants { - //moteur - public static int lanceur = 1; - public static int lancer2 = 2; - public static int roue = 3; - public static int etoile = 4; - public static int Moteuracc2 = 5; - public static int Moteuracc = 6; - public static int guideur = 7; - // limit switsh - public static int guideurhaut = 8; - public static int guideurbas = 9; - public static int limitacc = 58; + // Lanceur + public static int lanceur = 10; + public static int lancer2 = 13; + public static int lancer3 = 14; + public static int lancer4 = 15; + // Ballayeuse + public static int roue = 16; + public static int etoile = 19; + + // Accumulateur + public static int Moteuracc2 = 20; + public static int Moteuracc = 21; + + // Guideur + public static int guideur = 22; + + // Swerve + public static int AvantDroitDrive = 17; + public static int AvantDroitAngle = 18; + public static int AvantGaucheDrive = 2; + public static int AvantGaucheAngle = 3; + public static int ArriereDroitDrive = 11; + public static int ArriereDroitAngle = 12; + public static int ArriereGaucheDrive = 8; + public static int ArriereGaucheAngle = 9; + + // CanCoder + public static int AvantDroit = 5; + public static int AvantGauche = 4; + public static int ArriereDroit = 6; + public static int ArriereGauche = 7; + + // Limit switsh + public static int guideurhaut = 23; + public static int guideurbas = 24; + public static int limitacc = 25; } diff --git a/src/main/java/frc/robot/subsystem/Drive.java b/src/main/java/frc/robot/subsystem/Drive.java index 9d4d95a..fa7ba39 100644 --- a/src/main/java/frc/robot/subsystem/Drive.java +++ b/src/main/java/frc/robot/subsystem/Drive.java @@ -4,11 +4,40 @@ package frc.robot.subsystem; +import java.io.File; +import java.io.IOException; + +import edu.wpi.first.math.geometry.Translation2d; +import edu.wpi.first.math.kinematics.SwerveModulePosition; +import edu.wpi.first.wpilibj.Filesystem; import edu.wpi.first.wpilibj2.command.SubsystemBase; +import swervelib.SwerveDrive; +import swervelib.parser.SwerveParser; public class Drive extends SubsystemBase { /** Creates a new Drive. */ - public Drive() {} + + SwerveDrive swerveDrive; + File swerveJsonDirectory = new File(Filesystem.getDeployDirectory(),"swerve"); + public void drive(double x, double y, double zRotation){ + swerveDrive.drive(new Translation2d(x*2, y*2), zRotation, true, false); + } + + public Drive() { + + try { + this.swerveDrive = new SwerveParser(swerveJsonDirectory).createSwerveDrive(2); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public SwerveModulePosition[] distance(){ + return swerveDrive.getModulePositions(); + } +public void reset(){ + +} @Override public void periodic() { From 6190079c9e896e85677ebd410753a444b9ecefa9 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 22 Jan 2024 19:36:39 -0500 Subject: [PATCH 10/20] a --- src/main/java/frc/robot/Constants.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 27c116c..d8f7118 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -11,6 +11,7 @@ public class Constants { public static int lancer2 = 13; public static int lancer3 = 14; public static int lancer4 = 15; + // Ballayeuse public static int roue = 16; public static int etoile = 19; From ae540ccae18ca5175a301c5bc453372a18c40d15 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 22 Jan 2024 19:39:19 -0500 Subject: [PATCH 11/20] s --- src/main/java/frc/robot/subsystem/Accumulateur.java | 1 + src/main/java/frc/robot/subsystem/Drive.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystem/Accumulateur.java b/src/main/java/frc/robot/subsystem/Accumulateur.java index 71e9274..dd5faa2 100644 --- a/src/main/java/frc/robot/subsystem/Accumulateur.java +++ b/src/main/java/frc/robot/subsystem/Accumulateur.java @@ -16,6 +16,7 @@ public class Accumulateur extends SubsystemBase { final WPI_TalonSRX Moteuracc2 = new WPI_TalonSRX(Constants.Moteuracc2); final WPI_TalonSRX Moteuracc = new WPI_TalonSRX(Constants.Moteuracc); final DigitalInput limitacc = new DigitalInput(0); + public void Deaccumuler(double vitesse){Moteuracc2.set(vitesse);} diff --git a/src/main/java/frc/robot/subsystem/Drive.java b/src/main/java/frc/robot/subsystem/Drive.java index fa7ba39..23afb99 100644 --- a/src/main/java/frc/robot/subsystem/Drive.java +++ b/src/main/java/frc/robot/subsystem/Drive.java @@ -16,9 +16,11 @@ import swervelib.parser.SwerveParser; public class Drive extends SubsystemBase { /** Creates a new Drive. */ - + SwerveDrive swerveDrive; + File swerveJsonDirectory = new File(Filesystem.getDeployDirectory(),"swerve"); + public void drive(double x, double y, double zRotation){ swerveDrive.drive(new Translation2d(x*2, y*2), zRotation, true, false); } From 2bbd60876354705ebc62bdb422340580d80aecdc Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Mon, 22 Jan 2024 19:45:10 -0500 Subject: [PATCH 12/20] --- src/main/java/frc/robot/Constants.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index d8f7118..cf31264 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -11,7 +11,6 @@ public class Constants { public static int lancer2 = 13; public static int lancer3 = 14; public static int lancer4 = 15; - // Ballayeuse public static int roue = 16; public static int etoile = 19; @@ -23,6 +22,10 @@ public class Constants { // Guideur public static int guideur = 22; + //grimpeur + public static int grimpeurd = 26; + public static int grimpeurg = 27; + // Swerve public static int AvantDroitDrive = 17; public static int AvantDroitAngle = 18; @@ -43,5 +46,7 @@ public class Constants { public static int guideurhaut = 23; public static int guideurbas = 24; public static int limitacc = 25; + public static int limithaut = 28; + public static int limitbas = 29; } From 613dae1e56f63b76109912b1949da41d6709e0b2 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Mon, 22 Jan 2024 19:46:49 -0500 Subject: [PATCH 13/20] --- src/main/java/frc/robot/subsystem/Grimpeur.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/frc/robot/subsystem/Grimpeur.java b/src/main/java/frc/robot/subsystem/Grimpeur.java index b61e3c5..3f78416 100644 --- a/src/main/java/frc/robot/subsystem/Grimpeur.java +++ b/src/main/java/frc/robot/subsystem/Grimpeur.java @@ -4,6 +4,7 @@ package frc.robot.subsystem; +import com.kauailabs.navx.frc.AHRS; import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkLowLevel.MotorType; @@ -42,6 +43,10 @@ public void resetencodeurg(){ public void grimpeur(){ grimpeurg.follow(grimpeurd); } +public AHRS gyroscope = new AHRS(); + public double getpitch(){ + return gyroscope.getPitch(); + } @Override public void periodic() { // This method will be called once per scheduler run From 2d58d2fc2769e546345936b31a7353cfb00ef718 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 22 Jan 2024 19:48:06 -0500 Subject: [PATCH 14/20] --- src/main/java/frc/robot/subsystem/Grimpeur.java | 3 +++ src/main/java/frc/robot/subsystem/Guideur.java | 2 ++ src/main/java/frc/robot/subsystem/Lanceur.java | 4 +--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/subsystem/Grimpeur.java b/src/main/java/frc/robot/subsystem/Grimpeur.java index 3f78416..f7cb7bc 100644 --- a/src/main/java/frc/robot/subsystem/Grimpeur.java +++ b/src/main/java/frc/robot/subsystem/Grimpeur.java @@ -18,9 +18,11 @@ public class Grimpeur extends SubsystemBase { public Grimpeur() {} final CANSparkMax grimpeurd = new CANSparkMax(Constants.grimpeurd,MotorType.kBrushless); final CANSparkMax grimpeurg = new CANSparkMax(Constants.grimpeurg,MotorType.kBrushless); + // limit switch final DigitalInput limitdroite = new DigitalInput(Constants.limithaut); final DigitalInput limitgauche = new DigitalInput(Constants.limitbas); + //fonction public void droit(double vitesse){ grimpeurd.set(vitesse); @@ -47,6 +49,7 @@ public AHRS gyroscope = new AHRS(); public double getpitch(){ return gyroscope.getPitch(); } + @Override public void periodic() { // This method will be called once per scheduler run diff --git a/src/main/java/frc/robot/subsystem/Guideur.java b/src/main/java/frc/robot/subsystem/Guideur.java index e276197..5a0282d 100644 --- a/src/main/java/frc/robot/subsystem/Guideur.java +++ b/src/main/java/frc/robot/subsystem/Guideur.java @@ -13,9 +13,11 @@ import frc.robot.Constants; public class Guideur extends SubsystemBase { /** Creates a new Guideur. */ public Guideur() {} + final WPI_TalonSRX guideur = new WPI_TalonSRX(Constants.guideur); final DigitalInput guideurhaut = new DigitalInput(Constants.guideurhaut); final DigitalInput guideurbas = new DigitalInput(Constants.guideurhaut); + public void guider(double vitesse){ guideur.set(vitesse); } diff --git a/src/main/java/frc/robot/subsystem/Lanceur.java b/src/main/java/frc/robot/subsystem/Lanceur.java index 45e0a1e..260f263 100644 --- a/src/main/java/frc/robot/subsystem/Lanceur.java +++ b/src/main/java/frc/robot/subsystem/Lanceur.java @@ -20,6 +20,7 @@ public class Lanceur extends SubsystemBase { final CANSparkMax lancer2 = new CANSparkMax(Constants.lancer2, MotorType.kBrushless); final CANSparkMax lancer3 = new CANSparkMax(Constants.lanceur, MotorType.kBrushless); final CANSparkMax lancer4 = new CANSparkMax(Constants.lancer2, MotorType.kBrushless); + public void lancer(double vitesse){ lancer.set(vitesse); } @@ -31,9 +32,6 @@ public class Lanceur extends SubsystemBase { lancer4.setInverted(true); } - - - @Override public void periodic() {} // This method will be called once per scheduler run From eb8bc0a7fcc4e7131f3071348853823c90c375ae Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 22 Jan 2024 19:48:54 -0500 Subject: [PATCH 15/20] s --- src/main/java/frc/robot/subsystem/Balayeuse.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystem/Balayeuse.java b/src/main/java/frc/robot/subsystem/Balayeuse.java index b18f7ee..83f7404 100644 --- a/src/main/java/frc/robot/subsystem/Balayeuse.java +++ b/src/main/java/frc/robot/subsystem/Balayeuse.java @@ -6,7 +6,6 @@ package frc.robot.subsystem; import com.ctre.phoenix.motorcontrol.can.TalonSRX; import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; -import com.revrobotics.CANSparkMax; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.Constants; From b98054e0744727abac8f553aa157f35c9773b334 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 22 Jan 2024 19:49:59 -0500 Subject: [PATCH 16/20] --- src/main/java/frc/robot/subsystem/Drive.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystem/Drive.java b/src/main/java/frc/robot/subsystem/Drive.java index 23afb99..c4ea3ad 100644 --- a/src/main/java/frc/robot/subsystem/Drive.java +++ b/src/main/java/frc/robot/subsystem/Drive.java @@ -6,7 +6,6 @@ package frc.robot.subsystem; import java.io.File; import java.io.IOException; - import edu.wpi.first.math.geometry.Translation2d; import edu.wpi.first.math.kinematics.SwerveModulePosition; import edu.wpi.first.wpilibj.Filesystem; From b46e1a57eba9351c04be8bf518f1b457f5ffccf2 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 22 Jan 2024 19:50:25 -0500 Subject: [PATCH 17/20] --- src/main/java/frc/robot/subsystem/Accumulateur.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/frc/robot/subsystem/Accumulateur.java b/src/main/java/frc/robot/subsystem/Accumulateur.java index dd5faa2..d5fc01a 100644 --- a/src/main/java/frc/robot/subsystem/Accumulateur.java +++ b/src/main/java/frc/robot/subsystem/Accumulateur.java @@ -13,6 +13,7 @@ import frc.robot.Constants; public class Accumulateur extends SubsystemBase { /** Creates a new Accumulateur. */ public Accumulateur() {} + final WPI_TalonSRX Moteuracc2 = new WPI_TalonSRX(Constants.Moteuracc2); final WPI_TalonSRX Moteuracc = new WPI_TalonSRX(Constants.Moteuracc); final DigitalInput limitacc = new DigitalInput(0); From 1534e319fc3e54710c55fdbedccd47466c62ef65 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 22 Jan 2024 19:52:12 -0500 Subject: [PATCH 18/20] a --- src/main/java/frc/robot/subsystem/Accumulateur.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/subsystem/Accumulateur.java b/src/main/java/frc/robot/subsystem/Accumulateur.java index d5fc01a..98622ce 100644 --- a/src/main/java/frc/robot/subsystem/Accumulateur.java +++ b/src/main/java/frc/robot/subsystem/Accumulateur.java @@ -13,12 +13,13 @@ import frc.robot.Constants; public class Accumulateur extends SubsystemBase { /** Creates a new Accumulateur. */ public Accumulateur() {} - + final WPI_TalonSRX Moteuracc2 = new WPI_TalonSRX(Constants.Moteuracc2); final WPI_TalonSRX Moteuracc = new WPI_TalonSRX(Constants.Moteuracc); final DigitalInput limitacc = new DigitalInput(0); - public void Deaccumuler(double vitesse){Moteuracc2.set(vitesse);} + public void Deaccumuler(double vitesse){ + Moteuracc2.set(vitesse);} @Override From 0ad28ac416144e83e68db3f77624027ff60ea5ed Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Mon, 22 Jan 2024 20:13:26 -0500 Subject: [PATCH 19/20] patplanner --- src/main/deploy/pathplanner/autos/1.auto | 31 +++++++++++++ src/main/deploy/pathplanner/paths/1.1.path | 49 +++++++++++++++++++++ src/main/deploy/pathplanner/paths/1.2.path | 49 +++++++++++++++++++++ src/main/java/frc/robot/subsystem/Pixy.java | 18 ++++++++ 4 files changed, 147 insertions(+) create mode 100644 src/main/deploy/pathplanner/autos/1.auto create mode 100644 src/main/deploy/pathplanner/paths/1.1.path create mode 100644 src/main/deploy/pathplanner/paths/1.2.path create mode 100644 src/main/java/frc/robot/subsystem/Pixy.java diff --git a/src/main/deploy/pathplanner/autos/1.auto b/src/main/deploy/pathplanner/autos/1.auto new file mode 100644 index 0000000..9adf902 --- /dev/null +++ b/src/main/deploy/pathplanner/autos/1.auto @@ -0,0 +1,31 @@ +{ + "version": 1.0, + "startingPose": { + "position": { + "x": 1.3, + "y": 5.55 + }, + "rotation": 180.0 + }, + "command": { + "type": "sequential", + "data": { + "commands": [ + { + "type": "path", + "data": { + "pathName": "1.1" + } + }, + { + "type": "path", + "data": { + "pathName": "1.2" + } + } + ] + } + }, + "folder": null, + "choreoAuto": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/1.1.path b/src/main/deploy/pathplanner/paths/1.1.path new file mode 100644 index 0000000..a66e167 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/1.1.path @@ -0,0 +1,49 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 1.3, + "y": 5.55 + }, + "prevControl": null, + "nextControl": { + "x": 1.2733425960299216, + "y": 5.55 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 2.59859163592971, + "y": 5.55 + }, + "prevControl": { + "x": 2.534011049823752, + "y": 5.55 + }, + "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": -179.1243356864854, + "rotateFast": false + }, + "reversed": false, + "folder": null, + "previewStartingState": null, + "useDefaultConstraints": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/1.2.path b/src/main/deploy/pathplanner/paths/1.2.path new file mode 100644 index 0000000..5529fc3 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/1.2.path @@ -0,0 +1,49 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 2.6, + "y": 5.55 + }, + "prevControl": null, + "nextControl": { + "x": 2.6266574039700785, + "y": 5.55 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.3, + "y": 5.55 + }, + "prevControl": { + "x": 1.2354194138940418, + "y": 5.55 + }, + "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": -179.1243356864854, + "rotateFast": false + }, + "reversed": false, + "folder": null, + "previewStartingState": null, + "useDefaultConstraints": false +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystem/Pixy.java b/src/main/java/frc/robot/subsystem/Pixy.java new file mode 100644 index 0000000..f56c0d2 --- /dev/null +++ b/src/main/java/frc/robot/subsystem/Pixy.java @@ -0,0 +1,18 @@ +// 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.subsystem; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class Pixy extends SubsystemBase { + + /** Creates a new Pixy. */ + public Pixy() {} + + @Override + public void periodic() { + // This method will be called once per scheduler run + } +} From c637a7741013a9ec1af7c77c8ecccc584a45b177 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Mon, 22 Jan 2024 20:13:54 -0500 Subject: [PATCH 20/20] --- src/main/java/frc/robot/subsystem/Grimpeur.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/frc/robot/subsystem/Grimpeur.java b/src/main/java/frc/robot/subsystem/Grimpeur.java index f7cb7bc..3f78416 100644 --- a/src/main/java/frc/robot/subsystem/Grimpeur.java +++ b/src/main/java/frc/robot/subsystem/Grimpeur.java @@ -18,11 +18,9 @@ public class Grimpeur extends SubsystemBase { public Grimpeur() {} final CANSparkMax grimpeurd = new CANSparkMax(Constants.grimpeurd,MotorType.kBrushless); final CANSparkMax grimpeurg = new CANSparkMax(Constants.grimpeurg,MotorType.kBrushless); - // limit switch final DigitalInput limitdroite = new DigitalInput(Constants.limithaut); final DigitalInput limitgauche = new DigitalInput(Constants.limitbas); - //fonction public void droit(double vitesse){ grimpeurd.set(vitesse); @@ -49,7 +47,6 @@ public AHRS gyroscope = new AHRS(); public double getpitch(){ return gyroscope.getPitch(); } - @Override public void periodic() { // This method will be called once per scheduler run