This commit is contained in:
EdwardFaucher 2023-03-08 18:33:07 -05:00
commit 03ff6a2aba
12 changed files with 226 additions and 52 deletions

92
simgui-ds.json Normal file
View File

@ -0,0 +1,92 @@
{
"keyboardJoysticks": [
{
"axisConfig": [
{
"decKey": 65,
"incKey": 68
},
{
"decKey": 87,
"incKey": 83
},
{
"decKey": 69,
"decayRate": 0.0,
"incKey": 82,
"keyRate": 0.009999999776482582
}
],
"axisCount": 3,
"buttonCount": 4,
"buttonKeys": [
90,
88,
67,
86
],
"povConfig": [
{
"key0": 328,
"key135": 323,
"key180": 322,
"key225": 321,
"key270": 324,
"key315": 327,
"key45": 329,
"key90": 326
}
],
"povCount": 1
},
{
"axisConfig": [
{
"decKey": 74,
"incKey": 76
},
{
"decKey": 73,
"incKey": 75
}
],
"axisCount": 2,
"buttonCount": 4,
"buttonKeys": [
77,
44,
46,
47
],
"povCount": 0
},
{
"axisConfig": [
{
"decKey": 263,
"incKey": 262
},
{
"decKey": 265,
"incKey": 264
}
],
"axisCount": 2,
"buttonCount": 6,
"buttonKeys": [
260,
268,
266,
261,
269,
267
],
"povCount": 0
},
{
"axisCount": 0,
"buttonCount": 0,
"povCount": 0
}
]
}

17
simgui.json Normal file
View File

@ -0,0 +1,17 @@
{
"NTProvider": {
"types": {
"/FMSInfo": "FMSInfo"
}
},
"NetworkTables": {
"transitory": {
"Shuffleboard": {
".metadata": {
"open": true
},
"open": true
}
}
}
}

View File

@ -10,12 +10,13 @@ public class Constants {
//moteur
public static int leverGratte = 0;
public static int baiserGratte = 1;
public static int baisserGratte = 1;
// pneumatique
public static int pistonpinceouvre = 0;
public static int pistonpinceferme = 1;
public static int actuateur = 2;
public static int actuateur = 8;
public static int brakedroit = 3;
public static int brakegauche = 4;
public static int brakewinchf = 5;

View File

@ -3,12 +3,21 @@
// the WPILib BSD license file in the root directory of this project.
package frc.robot;
//import edu.wpi.first.cameraserver.CameraServer;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.RunCommand;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
//subsystems
import frc.robot.subsystems.BasePilotable;
import frc.robot.subsystems.Gratte;
import frc.robot.subsystems.bras.BrasTelescopique;
import frc.robot.subsystems.bras.Pince;
import frc.robot.subsystems.bras.Pivot;
import frc.robot.subsystems.Limelight;
import frc.robot.commands.Apriltag;
// command
import frc.robot.commands.BrakeFerme;
import frc.robot.commands.BrakeOuvre;
@ -25,30 +34,42 @@ import frc.robot.commands.bras.PivoteBrasHaut;
import frc.robot.commands.bras.PivoteBrasMilieux;
//subsystems
import frc.robot.subsystems.BasePilotable;
import frc.robot.commands.bras.PivotChercheBas;
import frc.robot.commands.bras.PivotChercheHaut;
import frc.robot.commands.Cube;
import frc.robot.commands.Tape;
public class RobotContainer {
//CameraServer.startAutomaticCapture();
CommandXboxController manette1 = new CommandXboxController(0);
CommandXboxController manette2 = new CommandXboxController(1);
// subsystems
BasePilotable basePilotable = new BasePilotable();
/*Gratte gratte = new Gratte();
Gratte gratte = new Gratte();
BrasTelescopique brasTelescopique = new BrasTelescopique();
Pince pince = new Pince();
Pivot pivot = new Pivot();
Limelight limelight = new Limelight();/** */
//commands
//BrakeFerme brakeFerme = new BrakeFerme(basePilotable);
//BrakeOuvre brakeOuvre = new BrakeOuvre(basePilotable);
//GratteBaisser gratteBaisser = new GratteBaisser(gratte);
//GratteMonte gratteMonte = new GratteMonte(gratte);
BrakeFerme brakeFerme = new BrakeFerme(basePilotable);
BrakeOuvre brakeOuvre = new BrakeOuvre(basePilotable);
GratteBaisser gratteBaisser = new GratteBaisser(gratte);
GratteMonte gratteMonte = new GratteMonte(gratte);
Gyro gyro = new Gyro(basePilotable);
/*FermePince fermePince = new FermePince(pince);
FermePince fermePince = new FermePince(pince);
OuvrePince ouvrePince = new OuvrePince(pince);
PivotBrasRentre pivotBrasRentre = new PivotBrasRentre(brasTelescopique, pivot);
PivoteBrasBas pivoteBrasBas = new PivoteBrasBas(brasTelescopique, pivot);
PivoteBrasMilieux pivoteBrasMilieux = new PivoteBrasMilieux(brasTelescopique, pivot);
PivoteBrasHaut pivoteBrasHaut = new PivoteBrasHaut(brasTelescopique, pivot);
Cone cone = new Cone(limelight, basePilotable, ()->-manette1.getLeftY());**/
Cone cone = new Cone(limelight, basePilotable, ()->-manette1.getLeftY());
PivotChercheBas pivotChercheBas = new PivotChercheBas(brasTelescopique, pivot);
PivotChercheHaut pivotChercheHaut = new PivotChercheHaut(brasTelescopique, pivot);
Cube cube = new Cube(limelight, basePilotable, null);
Apriltag aprilTag = new Apriltag(limelight, basePilotable, null);
Tape tape = new Tape(limelight, basePilotable, null);
public RobotContainer() {
configureBindings();
}
@ -57,20 +78,23 @@ public RobotContainer() {
basePilotable.setDefaultCommand(new RunCommand(() -> {
basePilotable.drive(-manette1.getLeftY(), -manette1.getLeftX());
},basePilotable));
//manette1.a().toggleOnTrue(Commands.startEnd(pince::ouvrir, pince::fermer,pince));
// manette 1
manette1.povDown().onTrue(pivoteBrasHaut);
manette1.povUp().onTrue(pivoteBrasBas);
manette1.povLeft().onTrue(pivoteBrasMilieux);
manette1.povRight().onTrue(pivotBrasRentre);
manette1.a().toggleOnTrue(Commands.startEnd(pince::ouvrir, pince::fermer,pince));
manette1.x().toggleOnTrue(Commands.startEnd(basePilotable::BrakeFerme,basePilotable::BrakeOuvre,basePilotable));
manette1.y().whileTrue(gyro);
// manette1.b().toggleOnTrue(Commands.startEnd(gratte::baiser, gratte::Lever,gratte));
manette1.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable));
/** manette1.b().toggleOnTrue(Commands.startEnd(gratte::baiser, gratte::Lever,gratte));
manette2.a().toggleOnTrue(Commands.startEnd(brasTelescopique::pivoteBrasHaut, brasTelescopique::pivoteBrasHaut));
manette2.b().toggleOnTrue(Commands.startEnd(brasTelescopique::pivoteBrasBas, brasTelescopique::pivoteBrasBas, brasTelescopique));
manette2.x().toggleOnTrue(Commands.startEnd(brasTelescopique::pivoteBrasMilieux, brasTelescopique::pivoteBrasMilieux, brasTelescopique));
manette2.y().toggleOnTrue(Commands.startEnd(brasTelescopique::pivotBrasRentre, brasTelescopique::pivotBrasRentre, brasTelescopique));
manette2.povRight().toggleOnTrue(Commands.startEnd(brasTelescopique::PivotChercheBas, brasTelescopique::PivotChercheBas, brasTelescopique));
manette2.povLeft().toggleOnTrue(Commands.startEnd(brasTelescopique::PivotChercheHaut, brasTelescopique::PivotChercheHaut, brasTelescopique));*/
// manette2.rightBumper().toggleOnTrue(Commands.startEnd(null, null, null));
// manette2.leftBumper().toggleOnTrue(Commands.startEnd(null, null, null));
manette1.b().onTrue(Commands.either(gratteBaisser, gratteMonte, gratte::getenHaut));
manette1.leftBumper().toggleOnTrue(cube);
manette1.rightBumper().toggleOnTrue(cone);
// manette 2
manette2.y().whileTrue(gyro);
manette2.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable));
manette2.povRight().onTrue(pivotChercheBas);
manette2.povLeft().onTrue(pivotChercheHaut);
manette2.rightBumper().toggleOnTrue(aprilTag);
manette2.leftBumper().toggleOnTrue(tape);
}
public Command getAutonomousCommand() {

View File

@ -18,7 +18,9 @@ public class GratteBaisser extends CommandBase {
// Called when the command is initially scheduled.
@Override
public void initialize() {}
public void initialize() {
gratte.setenHaut(false);
}
// Called every time the scheduler runs while the command is scheduled.
@Override

View File

@ -19,7 +19,9 @@ public class GratteMonte extends CommandBase {
// Called when the command is initially scheduled.
@Override
public void initialize() {}
public void initialize() {
gratte.setenHaut(true);
}
// Called every time the scheduler runs while the command is scheduled.
@Override

View File

@ -4,13 +4,18 @@
package frc.robot.commands;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.BasePilotable;
public class Gyro extends CommandBase {
ShuffleboardTab teb = Shuffleboard.getTab("teb");
private BasePilotable basePilotable;
/** Creates a new Gyro. */
public Gyro(BasePilotable basePilotable) {
teb.add("angleGyro", 0.1);
teb.add("vitesseGyro", 0.1);
this.basePilotable = basePilotable;
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(basePilotable);
@ -25,11 +30,19 @@ public class Gyro extends CommandBase {
public void execute() {
if(basePilotable.getpitch()>4)
{
<<<<<<< HEAD
basePilotable.drive(0.3*basePilotable.getpitch()/12, 0);
}
else if(basePilotable.getpitch()<-4)
{
basePilotable.drive(0.3*basePilotable.getpitch()/12, 0);
=======
basePilotable.drive(0.3*basePilotable.getpitch()/15, 0);
}
else if(basePilotable.getpitch()<-4)
{
basePilotable.drive(0.3*basePilotable.getpitch()/15, 0);
>>>>>>> 3d2364b54822fb53a6cd71a0347d11baeef62001
}
else
{

View File

@ -8,7 +8,6 @@ import com.kauailabs.navx.frc.AHRS;
import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.PneumaticsModuleType;
import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
@ -61,12 +60,12 @@ public void BrakeFerme(){
brakegauche.set(Value.kReverse);
}
public void resetGyro(){
try {gyroscope.reset();} catch(Exception e){DriverStation.reportError("bye bye",true);
{gyroscope.reset();}
}
}
/** Creates a new BasePilotable. */
public BasePilotable() {
droit.setInverted(true);
teb .addDouble("distance", this::distance);
}
@Override
@ -78,5 +77,6 @@ public void resetGyro(){
//teb .add("distance",0.1);
//teb .add("brakedroit",0.1);
//teb .add("brakegauche", 0.1);
}
}

View File

@ -3,23 +3,36 @@
// the WPILib BSD license file in the root directory of this project.
package frc.robot.subsystems;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import frc.robot.Constants;
public class Gratte extends SubsystemBase {
ShuffleboardTab teb = Shuffleboard.getTab("teb");
ShuffleboardTab teb = Shuffleboard.getTab("teb");
ShuffleboardLayout limitswitchgratte = Shuffleboard.getTab("teb")
.getLayout("limitswitchsgratte", BuiltInLayouts.kList)
.withSize(2, 2);
private WPI_TalonSRX Gratted = new WPI_TalonSRX(Constants.leverGratte);
private WPI_TalonSRX Gratteg = new WPI_TalonSRX(Constants.baisserGratte);
private WPI_TalonSRX Gratteg = new WPI_TalonSRX(Constants.baiserGratte);
private DigitalInput limithd = new DigitalInput(Constants.limithd);
private DigitalInput limithg = new DigitalInput(Constants.limithg);
private DigitalInput limitbd = new DigitalInput(Constants.limitbd);
private DigitalInput limitbg = new DigitalInput(Constants.limitbg);
public boolean baiser;
boolean enHaut = true;
public void setenHaut(boolean enHaut){
this.enHaut = enHaut;
}
public boolean getenHaut(){
return enHaut;
}
public boolean hautd(){
return limithd.get();
}
@ -34,8 +47,13 @@ public class Gratte extends SubsystemBase {
public boolean basg(){
return limitbg.get();
}
/** Creates a new Gratte. */
public Gratte() {}
public Gratte() {
limitswitchgratte.add ("limitbd", 0.1);
limitswitchgratte.add ("limithg", 0.1);
limitswitchgratte.add ("limithd", 0.1);
limitswitchgratte.add ("limitbg", 0.1);
}
public void Lever(double vitesse){
Gratted.set(vitesse);
Gratteg.set(vitesse);
@ -45,10 +63,10 @@ public class Gratte extends SubsystemBase {
Gratteg.set(-vitesse);
}
@Override
public void periodic() {
teb .add("limithd", 0.1);
teb .add("limithg", 0.1);
teb .add("limitbd", 0.1);
teb .add("limitbg", 0.1);
}
public void periodic(){
limitswitchgratte.add ("limitbd", 0.1);
limitswitchgratte.add ("limithg", 0.1);
limitswitchgratte.add ("limithd", 0.1);
limitswitchgratte.add ("limitbg", 0.1);
}
}

View File

@ -21,6 +21,8 @@ public class Limelight extends SubsystemBase {
PhotonCamera limelight = new PhotonCamera("limelight");
/** Creates a new Limelight. */
public Limelight() {
CameraServer.startAutomaticCapture();
teb .add("limelight", 0.1);
PortForwarder.add(5800, "photonvision.local", 5800);
}
@ -58,7 +60,5 @@ public class Limelight extends SubsystemBase {
}
@Override
public void periodic() {
CameraServer.startAutomaticCapture();
teb .add("limelight", 0.1);
}
}

View File

@ -18,9 +18,12 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;
public class BrasTelescopique extends SubsystemBase {
ShuffleboardTab teb = Shuffleboard.getTab("teb");
ShuffleboardTab teb = Shuffleboard.getTab("teb");
/** Creates a new BrasTelescopique. */
public BrasTelescopique() {}
public BrasTelescopique() {
teb .add("photocell",0.1);
teb .add("winch",0.1);
teb .add("encodeur",0.1);}
final CANSparkMax Winch = new CANSparkMax(Constants.BrasTelescopique,MotorType.kBrushless);
private DigitalInput photocell = new DigitalInput(Constants.photocell);
private DoubleSolenoid brakewinch = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.brakewinchf, Constants.brakewinchb);
@ -44,9 +47,6 @@ public class BrasTelescopique extends SubsystemBase {
}
@Override
public void periodic() {
teb .add("``photocell``",0.1);
teb .add("winch",0.1);
}
}
}

View File

@ -14,7 +14,8 @@ import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
public class Pivot extends SubsystemBase {
ShuffleboardTab teb = Shuffleboard.getTab("teb");
ShuffleboardTab teb = Shuffleboard.getTab("teb");
// moteur
private CANSparkMax pivot = new CANSparkMax(Constants.pivot,MotorType.kBrushless);
private DigitalInput limitpivot = new DigitalInput(Constants.limitpivot);
@ -23,7 +24,11 @@ public class Pivot extends SubsystemBase {
public void monteDescendre(double vitesse) {
pivot.set (vitesse);
}
// encoder
public Pivot(){
teb .add ("encodeurpivot",0.1);
teb .add ("limitpivot",0.1);
}
// encodeur
public double distance(){
return (pivot.getEncoder().getPosition());
}
@ -36,6 +41,6 @@ public class Pivot extends SubsystemBase {
}
@Override
public void periodic() {
teb .add("encodeur", 0.1);
}
}
}