Compare commits
13 Commits
9aa7018812
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41f6e4747f | ||
|
|
7908d4c5df | ||
|
|
2263961829 | ||
|
|
27ea9d96e3 | ||
|
|
01edf1cb01 | ||
|
|
0b4c0e09ff | ||
|
|
6c86b2ed5c | ||
|
|
6885b80d6a | ||
|
|
2472c67adf | ||
|
|
c8d0ee3a03 | ||
|
|
3300d74a78 | ||
|
|
bdffb48ece | ||
|
|
5f44d5304a |
@@ -1,4 +1,9 @@
|
|||||||
{
|
{
|
||||||
|
"System Joysticks": {
|
||||||
|
"window": {
|
||||||
|
"enabled": false
|
||||||
|
}
|
||||||
|
},
|
||||||
"keyboardJoysticks": [
|
"keyboardJoysticks": [
|
||||||
{
|
{
|
||||||
"axisConfig": [
|
"axisConfig": [
|
||||||
|
|||||||
@@ -35,12 +35,6 @@
|
|||||||
"pathName": "Tir"
|
"pathName": "Tir"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "named",
|
|
||||||
"data": {
|
|
||||||
"name": "Limelighter"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "named",
|
"type": "named",
|
||||||
"data": {
|
"data": {
|
||||||
|
|||||||
@@ -41,12 +41,6 @@
|
|||||||
"pathName": "Tir"
|
"pathName": "Tir"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "named",
|
|
||||||
"data": {
|
|
||||||
"name": "Limelighter"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "deadline",
|
"type": "deadline",
|
||||||
"data": {
|
"data": {
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "2025.0",
|
|
||||||
"command": {
|
|
||||||
"type": "sequential",
|
|
||||||
"data": {
|
|
||||||
"commands": [
|
|
||||||
{
|
|
||||||
"type": "path",
|
|
||||||
"data": {
|
|
||||||
"pathName": "TirerSimple"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "named",
|
|
||||||
"data": {
|
|
||||||
"name": "DescendreBalayeuse"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "named",
|
|
||||||
"data": {
|
|
||||||
"name": "Limelighter"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "named",
|
|
||||||
"data": {
|
|
||||||
"name": "Lancer"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resetOdom": true,
|
|
||||||
"folder": null,
|
|
||||||
"choreoAuto": false
|
|
||||||
}
|
|
||||||
@@ -4,49 +4,18 @@
|
|||||||
"type": "sequential",
|
"type": "sequential",
|
||||||
"data": {
|
"data": {
|
||||||
"commands": [
|
"commands": [
|
||||||
|
{
|
||||||
|
"type": "path",
|
||||||
|
"data": {
|
||||||
|
"pathName": "tirgrimpe1"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "named",
|
"type": "named",
|
||||||
"data": {
|
"data": {
|
||||||
"name": "DescendreBalayeuse"
|
"name": "DescendreBalayeuse"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "deadline",
|
|
||||||
"data": {
|
|
||||||
"commands": [
|
|
||||||
{
|
|
||||||
"type": "wait",
|
|
||||||
"data": {
|
|
||||||
"waitTime": 3.0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "path",
|
|
||||||
"data": {
|
|
||||||
"pathName": "Depot"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "named",
|
|
||||||
"data": {
|
|
||||||
"name": "Aspirer"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "path",
|
|
||||||
"data": {
|
|
||||||
"pathName": "Tir"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "named",
|
|
||||||
"data": {
|
|
||||||
"name": "Limelighter"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "deadline",
|
"type": "deadline",
|
||||||
"data": {
|
"data": {
|
||||||
@@ -66,12 +35,6 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "path",
|
|
||||||
"data": {
|
|
||||||
"pathName": "GrimperReservoir"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "named",
|
"type": "named",
|
||||||
"data": {
|
"data": {
|
||||||
@@ -16,11 +16,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 0.4938659058487873,
|
"x": 0.23509272467902986,
|
||||||
"y": 5.917574893009986
|
"y": 5.917574893009986
|
||||||
},
|
},
|
||||||
"prevControl": {
|
"prevControl": {
|
||||||
"x": 1.0372895863052785,
|
"x": 0.778516405135521,
|
||||||
"y": 5.930513552068473
|
"y": 5.930513552068473
|
||||||
},
|
},
|
||||||
"nextControl": null,
|
"nextControl": null,
|
||||||
|
|||||||
@@ -3,25 +3,25 @@
|
|||||||
"waypoints": [
|
"waypoints": [
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 2.4476034236804565,
|
"x": 1.878,
|
||||||
"y": 4.85660485021398
|
"y": 5.154
|
||||||
},
|
},
|
||||||
"prevControl": null,
|
"prevControl": null,
|
||||||
"nextControl": {
|
"nextControl": {
|
||||||
"x": 1.6971611982881591,
|
"x": 1.1275577746077026,
|
||||||
"y": 4.85660485021398
|
"y": 5.154
|
||||||
},
|
},
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
"linkedName": null
|
"linkedName": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 1.0761055634807417,
|
"x": 1.0372895863052778,
|
||||||
"y": 4.85660485021398
|
"y": 5.011868758915835
|
||||||
},
|
},
|
||||||
"prevControl": {
|
"prevControl": {
|
||||||
"x": 1.503081312410841,
|
"x": 1.4642653352353772,
|
||||||
"y": 4.869543509272469
|
"y": 5.024807417974324
|
||||||
},
|
},
|
||||||
"nextControl": null,
|
"nextControl": null,
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
|
|||||||
@@ -3,25 +3,25 @@
|
|||||||
"waypoints": [
|
"waypoints": [
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 2.4476034236804565,
|
"x": 1.878,
|
||||||
"y": 4.85660485021398
|
"y": 5.154
|
||||||
},
|
},
|
||||||
"prevControl": null,
|
"prevControl": null,
|
||||||
"nextControl": {
|
"nextControl": {
|
||||||
"x": 2.3958487874465044,
|
"x": 1.8262453637660478,
|
||||||
"y": 2.695848787446506
|
"y": 2.993243937232526
|
||||||
},
|
},
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
"linkedName": null
|
"linkedName": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 1.0502282453637657,
|
"x": 2.0076890156918683,
|
||||||
"y": 2.4758915834522113
|
"y": 2.2041797432239663
|
||||||
},
|
},
|
||||||
"prevControl": {
|
"prevControl": {
|
||||||
"x": 2.292339514978602,
|
"x": 3.2498002853067054,
|
||||||
"y": 2.3982596291012843
|
"y": 2.1265477888730393
|
||||||
},
|
},
|
||||||
"nextControl": null,
|
"nextControl": null,
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
},
|
},
|
||||||
"goalEndState": {
|
"goalEndState": {
|
||||||
"velocity": 0,
|
"velocity": 0,
|
||||||
"rotation": 0.0
|
"rotation": 32.10625595511781
|
||||||
},
|
},
|
||||||
"reversed": false,
|
"reversed": false,
|
||||||
"folder": null,
|
"folder": null,
|
||||||
|
|||||||
@@ -3,25 +3,25 @@
|
|||||||
"waypoints": [
|
"waypoints": [
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 0.5197432239657629,
|
"x": 0.29978601997146925,
|
||||||
"y": 5.930513552068473
|
"y": 5.917574893009986
|
||||||
},
|
},
|
||||||
"prevControl": null,
|
"prevControl": null,
|
||||||
"nextControl": {
|
"nextControl": {
|
||||||
"x": 1.6971611982881594,
|
"x": 1.4772039942938657,
|
||||||
"y": 5.995206847360913
|
"y": 5.982268188302426
|
||||||
},
|
},
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
"linkedName": null
|
"linkedName": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 2.4476034236804565,
|
"x": 1.8783024251069897,
|
||||||
"y": 4.85660485021398
|
"y": 5.154194008559203
|
||||||
},
|
},
|
||||||
"prevControl": {
|
"prevControl": {
|
||||||
"x": 2.382910128388017,
|
"x": 1.8136091298145502,
|
||||||
"y": 5.400028530670471
|
"y": 5.6976176890156935
|
||||||
},
|
},
|
||||||
"nextControl": null,
|
"nextControl": null,
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
|
|||||||
54
src/main/deploy/pathplanner/paths/tirgrimpe1.path
Normal file
54
src/main/deploy/pathplanner/paths/tirgrimpe1.path
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"version": "2025.0",
|
||||||
|
"waypoints": [
|
||||||
|
{
|
||||||
|
"anchor": {
|
||||||
|
"x": 3.5991440798858774,
|
||||||
|
"y": 2.3465049928673327
|
||||||
|
},
|
||||||
|
"prevControl": null,
|
||||||
|
"nextControl": {
|
||||||
|
"x": 2.589928673323822,
|
||||||
|
"y": 1.7513266761768898
|
||||||
|
},
|
||||||
|
"isLocked": false,
|
||||||
|
"linkedName": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anchor": {
|
||||||
|
"x": 1.8783024251069897,
|
||||||
|
"y": 2.3465049928673327
|
||||||
|
},
|
||||||
|
"prevControl": {
|
||||||
|
"x": 2.706376604850214,
|
||||||
|
"y": 1.7125106990014274
|
||||||
|
},
|
||||||
|
"nextControl": null,
|
||||||
|
"isLocked": false,
|
||||||
|
"linkedName": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rotationTargets": [],
|
||||||
|
"constraintZones": [],
|
||||||
|
"pointTowardsZones": [],
|
||||||
|
"eventMarkers": [],
|
||||||
|
"globalConstraints": {
|
||||||
|
"maxVelocity": 3.0,
|
||||||
|
"maxAcceleration": 3.0,
|
||||||
|
"maxAngularVelocity": 540.0,
|
||||||
|
"maxAngularAcceleration": 720.0,
|
||||||
|
"nominalVoltage": 12.0,
|
||||||
|
"unlimited": false
|
||||||
|
},
|
||||||
|
"goalEndState": {
|
||||||
|
"velocity": 0,
|
||||||
|
"rotation": 33.11134196037204
|
||||||
|
},
|
||||||
|
"reversed": false,
|
||||||
|
"folder": null,
|
||||||
|
"idealStartingState": {
|
||||||
|
"velocity": 0,
|
||||||
|
"rotation": 180.0
|
||||||
|
},
|
||||||
|
"useDefaultConstraints": true
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
|||||||
import frc.robot.commands.Aspirer;
|
import frc.robot.commands.Aspirer;
|
||||||
import frc.robot.commands.DescendreBalyeuse;
|
import frc.robot.commands.DescendreBalyeuse;
|
||||||
import frc.robot.commands.DescendreGrimpeur;
|
import frc.robot.commands.DescendreGrimpeur;
|
||||||
|
import frc.robot.commands.DescendreGrimpeurPlus;
|
||||||
import frc.robot.commands.Inverser;
|
import frc.robot.commands.Inverser;
|
||||||
import frc.robot.commands.Lancer;
|
import frc.robot.commands.Lancer;
|
||||||
import frc.robot.commands.LancerAspirer;
|
import frc.robot.commands.LancerAspirer;
|
||||||
@@ -45,7 +46,7 @@ import frc.robot.generated.TunerConstants;
|
|||||||
import frc.robot.subsystems.Balayeuse;
|
import frc.robot.subsystems.Balayeuse;
|
||||||
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||||
import frc.robot.subsystems.Grimpeur;
|
import frc.robot.subsystems.Grimpeur;
|
||||||
import frc.robot.subsystems.LEDSubsystem;
|
//import frc.robot.subsystems.LEDSubsystem;
|
||||||
import frc.robot.subsystems.Lanceur;
|
import frc.robot.subsystems.Lanceur;
|
||||||
import frc.robot.subsystems.LimeLight3;
|
import frc.robot.subsystems.LimeLight3;
|
||||||
import frc.robot.subsystems.Limelight3G;
|
import frc.robot.subsystems.Limelight3G;
|
||||||
@@ -57,7 +58,7 @@ public class RobotContainer {
|
|||||||
Lanceur lanceur = new Lanceur();
|
Lanceur lanceur = new Lanceur();
|
||||||
LimeLight3 limeLight3 = new LimeLight3();
|
LimeLight3 limeLight3 = new LimeLight3();
|
||||||
Limelight3G limeLight3G = new Limelight3G();
|
Limelight3G limeLight3G = new Limelight3G();
|
||||||
LEDSubsystem ledSubsystem = new LEDSubsystem();
|
//LEDSubsystem ledSubsystem = new LEDSubsystem();
|
||||||
CommandXboxController manette = new CommandXboxController(0);
|
CommandXboxController manette = new CommandXboxController(0);
|
||||||
CommandXboxController manette1 = new CommandXboxController(1);
|
CommandXboxController manette1 = new CommandXboxController(1);
|
||||||
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12Volts desired top speed
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12Volts desired top speed
|
||||||
@@ -95,12 +96,12 @@ public class RobotContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void configureBindings() {
|
private void configureBindings() {
|
||||||
ledSubsystem.setDefaultCommand(ledSubsystem.updateLEDs());
|
//ledSubsystem.setDefaultCommand(ledSubsystem.updateLEDs());
|
||||||
drivetrain.setDefaultCommand(
|
drivetrain.setDefaultCommand(
|
||||||
drivetrain.applyRequest(() ->
|
drivetrain.applyRequest(() ->
|
||||||
drive.withVelocityY(MathUtil.applyDeadband(-manette.getLeftX()*Math.abs(-manette.getLeftX())*MaxSpeed*0.7, 0.05))
|
drive.withVelocityY(MathUtil.applyDeadband(-manette.getLeftX()*Math.abs(-manette.getLeftX())*MaxSpeed*0.7, 0.05))
|
||||||
.withVelocityX(MathUtil.applyDeadband(-manette.getLeftY()*Math.abs(-manette.getLeftY())*MaxSpeed*0.7, 0.05))
|
.withVelocityX(MathUtil.applyDeadband(-manette.getLeftY()*Math.abs(-manette.getLeftY())*MaxSpeed*0.7, 0.05))
|
||||||
.withRotationalRate(MathUtil.applyDeadband(-manette.getRightX()*Math.abs(-manette.getRightX())*MaxAngularRate, 0.05))
|
.withRotationalRate(MathUtil.applyDeadband(-manette.getRightX()*Math.abs(-manette.getRightX())*MaxAngularRate*1.5, 0.05))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
//manette 1
|
//manette 1
|
||||||
@@ -110,7 +111,7 @@ public class RobotContainer {
|
|||||||
// manette1.povLeft().whileTrue(drivetrain.sysIdDynamic(SysIdRoutine.Direction.kReverse));
|
// manette1.povLeft().whileTrue(drivetrain.sysIdDynamic(SysIdRoutine.Direction.kReverse));
|
||||||
|
|
||||||
manette.povUp().whileTrue(new MonterGrimpeur(grimpeur));
|
manette.povUp().whileTrue(new MonterGrimpeur(grimpeur));
|
||||||
manette.povDown().whileTrue(new DescendreGrimpeur(grimpeur));
|
manette.povDown().whileTrue(new DescendreGrimpeurPlus(grimpeur));
|
||||||
manette.rightTrigger().whileTrue(new Lancer(lanceur, limeLight3G));
|
manette.rightTrigger().whileTrue(new Lancer(lanceur, limeLight3G));
|
||||||
manette.leftTrigger().whileTrue(new Limelighter(limeLight3G, drivetrain));
|
manette.leftTrigger().whileTrue(new Limelighter(limeLight3G, drivetrain));
|
||||||
manette.leftBumper().whileTrue(new DescendreBalyeuse(balayeuse));
|
manette.leftBumper().whileTrue(new DescendreBalyeuse(balayeuse));
|
||||||
@@ -130,6 +131,7 @@ public class RobotContainer {
|
|||||||
manette1.y().whileTrue(new ModeOposerBalayeuse(balayeuse));
|
manette1.y().whileTrue(new ModeOposerBalayeuse(balayeuse));
|
||||||
manette1.povRight().whileTrue(new BougerDroiteAuto(drivetrain));
|
manette1.povRight().whileTrue(new BougerDroiteAuto(drivetrain));
|
||||||
manette1.povLeft().whileTrue(new BougerGaucheAuto(drivetrain));
|
manette1.povLeft().whileTrue(new BougerGaucheAuto(drivetrain));
|
||||||
|
manette1.povDown().whileTrue(new DescendreGrimpeur(grimpeur));
|
||||||
manette1.start().whileTrue(new Inverser(drivetrain));
|
manette1.start().whileTrue(new Inverser(drivetrain));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class DescendreGrimpeur extends Command {
|
|||||||
/** Creates a new DescendreGrimpeur. */
|
/** Creates a new DescendreGrimpeur. */
|
||||||
public DescendreGrimpeur(Grimpeur grimpeur) {
|
public DescendreGrimpeur(Grimpeur grimpeur) {
|
||||||
this.grimpeur = grimpeur;
|
this.grimpeur = grimpeur;
|
||||||
|
addRequirements(grimpeur);
|
||||||
// Use addRequirements() here to declare subsystem dependencies.
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,18 +25,21 @@ public class DescendreGrimpeur extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if(!grimpeur.Limit()){
|
if(!grimpeur.Limit()){
|
||||||
grimpeur.Grimper(-0.4);
|
grimpeur.GrimperGauche(-0.4);
|
||||||
|
grimpeur.GrimperDroit(-0.4);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
grimpeur.Reset();
|
grimpeur.Reset();
|
||||||
grimpeur.Grimper(0);
|
grimpeur.GrimperGauche(0);
|
||||||
|
grimpeur.GrimperDroit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
@Override
|
@Override
|
||||||
public void end(boolean interrupted) {
|
public void end(boolean interrupted) {
|
||||||
grimpeur.Grimper(0);
|
grimpeur.GrimperGauche(0);
|
||||||
|
grimpeur.GrimperDroit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
|
|||||||
50
src/main/java/frc/robot/commands/DescendreGrimpeurPlus.java
Normal file
50
src/main/java/frc/robot/commands/DescendreGrimpeurPlus.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// 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.Grimpeur;
|
||||||
|
|
||||||
|
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
|
||||||
|
public class DescendreGrimpeurPlus extends Command {
|
||||||
|
private Grimpeur grimpeur;
|
||||||
|
/** Creates a new DescendreGrimpeur. */
|
||||||
|
public DescendreGrimpeurPlus(Grimpeur grimpeur) {
|
||||||
|
this.grimpeur = grimpeur;
|
||||||
|
addRequirements(grimpeur);
|
||||||
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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(!grimpeur.Limit()){
|
||||||
|
grimpeur.GrimperGauche(-0.4);
|
||||||
|
grimpeur.GrimperDroit(-0.4);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
grimpeur.Reset();
|
||||||
|
grimpeur.GrimperGauche(0);
|
||||||
|
grimpeur.GrimperDroit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called once the command ends or is interrupted.
|
||||||
|
@Override
|
||||||
|
public void end(boolean interrupted) {
|
||||||
|
grimpeur.GrimperGauche(0);
|
||||||
|
grimpeur.GrimperDroit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ public class Lancer extends Command {
|
|||||||
private PIDController pidController;
|
private PIDController pidController;
|
||||||
private Limelight3G limeLight3G;
|
private Limelight3G limeLight3G;
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
double vitesse = 0.5;
|
double vitesse = 0;
|
||||||
double botx = 0;
|
double botx = 0;
|
||||||
double boty = 0;
|
double boty = 0;
|
||||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||||
@@ -61,9 +61,9 @@ public class Lancer extends Command {
|
|||||||
boty = BotPose[1];
|
boty = BotPose[1];
|
||||||
vitesse = 410.57 * ((Math.sqrt(Math.pow(Math.abs(4.625594-botx), 2) + Math.pow(Math.abs(4.034536-boty), 2)))) + 2250;
|
vitesse = 410.57 * ((Math.sqrt(Math.pow(Math.abs(4.625594-botx), 2) + Math.pow(Math.abs(4.034536-boty), 2)))) + 2250;
|
||||||
}
|
}
|
||||||
if(limeLight3G.getV()){
|
// if(limeLight3G.getV()){
|
||||||
|
|
||||||
|
if(vitesse > 2000){
|
||||||
double output = pidController.calculate(lanceur.Vitesse(),vitesse);
|
double output = pidController.calculate(lanceur.Vitesse(),vitesse);
|
||||||
lanceur.Lancer(output);
|
lanceur.Lancer(output);
|
||||||
System.out.println(output);
|
System.out.println(output);
|
||||||
@@ -72,9 +72,12 @@ public class Lancer extends Command {
|
|||||||
if(timer.get() >1){
|
if(timer.get() >1){
|
||||||
lanceur.Demeler(1);
|
lanceur.Demeler(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
lanceur.Lancer(3500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package frc.robot.commands;
|
|||||||
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
||||||
import com.ctre.phoenix6.swerve.SwerveRequest;
|
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||||
|
|
||||||
|
import edu.wpi.first.math.MathUtil;
|
||||||
import edu.wpi.first.wpilibj.DriverStation;
|
import edu.wpi.first.wpilibj.DriverStation;
|
||||||
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
@@ -51,7 +52,6 @@ public class Limelighter extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
double[] BotPose = new double[6];
|
double[] BotPose = new double[6];
|
||||||
System.out.println("e");
|
|
||||||
if (limelight3g.getV()) {
|
if (limelight3g.getV()) {
|
||||||
BotPose = limelight3g.getBotPoseBlue();
|
BotPose = limelight3g.getBotPoseBlue();
|
||||||
if (!alliance.isPresent()) {
|
if (!alliance.isPresent()) {
|
||||||
@@ -62,13 +62,16 @@ public class Limelighter extends Command {
|
|||||||
BotPose = limelight3g.getBotPoseBlue();
|
BotPose = limelight3g.getBotPoseBlue();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
x = 11.915394;
|
//x = 11.915394;
|
||||||
|
x = 4.6;
|
||||||
BotPose = limelight3g.getBotPoseRed();
|
BotPose = limelight3g.getBotPoseRed();
|
||||||
}
|
}
|
||||||
botx = BotPose[0];
|
botx = BotPose[0];
|
||||||
boty = BotPose[1];
|
boty = BotPose[1];
|
||||||
angle = BotPose[5];
|
angle = BotPose[5];
|
||||||
calcul = limelight3g.Calcule(botx, x, boty, 4, angle);
|
calcul = Math.toRadians(limelight3g.Calcule(boty, 4,botx, x, angle));
|
||||||
|
System.out.println(calcul);
|
||||||
|
//drivetrain.setControl(drive.withRotationalRate(MathUtil.clamp(calcul, -3, 3)));
|
||||||
if(calcul > -5 && calcul < 5){
|
if(calcul > -5 && calcul < 5){
|
||||||
drivetrain.setControl(
|
drivetrain.setControl(
|
||||||
drive.withRotationalRate(0));
|
drive.withRotationalRate(0));
|
||||||
@@ -80,36 +83,36 @@ public class Limelighter extends Command {
|
|||||||
else if(calcul < -5){
|
else if(calcul < -5){
|
||||||
drivetrain.setControl(drive.withRotationalRate(-2));
|
drivetrain.setControl(drive.withRotationalRate(-2));
|
||||||
}
|
}
|
||||||
// botx = BotPose[1];
|
botx = BotPose[1];
|
||||||
// boty = BotPose[0];
|
boty = BotPose[0];
|
||||||
// angle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
angle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
||||||
// calcul = limelight3g.Calcule(botx, x, boty, 4, angle);
|
calcul = limelight3g.Calcule(botx, x, boty, 4, angle);
|
||||||
// if(calcul < -5 && calcul > -180){
|
if(calcul < -5 && calcul > -180){
|
||||||
// drivetrain.setControl(
|
drivetrain.setControl(
|
||||||
// drive.withRotationalRate(0.5*(2*Math.PI)));
|
drive.withRotationalRate(0.5*(2*Math.PI)));
|
||||||
// }
|
}
|
||||||
// else if(calcul > 5 && calcul < 180){
|
else if(calcul > 5 && calcul < 180){
|
||||||
// drivetrain.setControl(
|
drivetrain.setControl(
|
||||||
// drive.withRotationalRate(-0.5*(2*Math.PI)));
|
drive.withRotationalRate(-0.5*(2*Math.PI)));
|
||||||
// }
|
}
|
||||||
// else if(calcul < -5){
|
else if(calcul < -5){
|
||||||
// drivetrain.setControl(
|
drivetrain.setControl(
|
||||||
// drive.withRotationalRate(-0.5*(2*Math.PI)));
|
drive.withRotationalRate(-0.5*(2*Math.PI)));
|
||||||
// }
|
}
|
||||||
// else if(calcul <= -180){
|
else if(calcul <= -180){
|
||||||
// drivetrain.setControl(
|
drivetrain.setControl(
|
||||||
// drive.withRotationalRate(0.5*(2*Math.PI)));
|
drive.withRotationalRate(0.5*(2*Math.PI)));
|
||||||
// }
|
}
|
||||||
// else{
|
else{
|
||||||
// drivetrain.setControl(
|
drivetrain.setControl(
|
||||||
// drive.withRotationalRate(0));
|
drive.withRotationalRate(0));
|
||||||
// }
|
}
|
||||||
// drivetrain.setControl(
|
drivetrain.setControl(
|
||||||
// drive.withVelocityX(0).withVelocityY(0).withRotationalRate(calcul));
|
drive.withVelocityX(0).withVelocityY(0).withRotationalRate(calcul));
|
||||||
// System.out.println(angle);
|
System.out.println(angle);
|
||||||
// if (calcul < 0.2 && calcul > -0.2) {
|
if (calcul < 0.2 && calcul > -0.2) {
|
||||||
// drivetrain.setControl(drive.withRotationalRate(0));
|
drivetrain.setControl(drive.withRotationalRate(0));
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
drivetrain.setControl(drive.withRotationalRate(0));
|
drivetrain.setControl(drive.withRotationalRate(0));
|
||||||
|
|||||||
@@ -46,23 +46,12 @@ public class BougerDroiteAuto 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() {
|
||||||
if(alliance.get() == Alliance.Blue){
|
if(timer.get() < 1.25){
|
||||||
if(timer.get() < .75){
|
|
||||||
System.out.println("8765");
|
|
||||||
drivetrain.setControl(drive.withVelocityY(-1.5));
|
drivetrain.setControl(drive.withVelocityY(-1.5));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
drivetrain.setControl(drive.withVelocityY(0));
|
drivetrain.setControl(drive.withVelocityY(0));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(timer.get() < 0.75){
|
|
||||||
drivetrain.setControl(drive.withVelocityY(1.5));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
drivetrain.setControl(drive.withVelocityY(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
|
|||||||
@@ -46,22 +46,12 @@ public class BougerGaucheAuto 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() {
|
||||||
if(alliance.get() == Alliance.Blue){
|
if(timer.get() < 1.25){
|
||||||
if(timer.get() < 0.75){
|
|
||||||
drivetrain.setControl(drive.withVelocityY(1.5));
|
drivetrain.setControl(drive.withVelocityY(1.5));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
drivetrain.setControl(drive.withVelocityY(0));
|
drivetrain.setControl(drive.withVelocityY(0));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(timer.get() < 0.75){
|
|
||||||
drivetrain.setControl(drive.withVelocityY(1.5));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
drivetrain.setControl(drive.withVelocityY(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.ctre.phoenix6.hardware.Pigeon2;
|
|||||||
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
||||||
import com.ctre.phoenix6.swerve.SwerveRequest;
|
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||||
|
|
||||||
|
import edu.wpi.first.math.MathUtil;
|
||||||
import edu.wpi.first.wpilibj.DriverStation;
|
import edu.wpi.first.wpilibj.DriverStation;
|
||||||
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
@@ -32,6 +33,7 @@ public class GrimperMur extends Command {
|
|||||||
double x;
|
double x;
|
||||||
double y;
|
double y;
|
||||||
double angle;
|
double angle;
|
||||||
|
double pigeonAngle;
|
||||||
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
||||||
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
||||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||||
@@ -49,7 +51,7 @@ public class GrimperMur extends Command {
|
|||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
// alliance = DriverStation.getAlliance();
|
alliance = DriverStation.getAlliance();
|
||||||
// if(drivetrain.Equipe()){
|
// if(drivetrain.Equipe()){
|
||||||
// angle+=180;
|
// angle+=180;
|
||||||
// }
|
// }
|
||||||
@@ -59,45 +61,53 @@ public class GrimperMur extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if(limeLight3.getV()){
|
if(limeLight3.getV()){
|
||||||
BotPose = limeLight3.getBotPoseBlue();
|
BotPose = limeLight3.getBotPoseBlue();
|
||||||
botx = BotPose[0];
|
botx = BotPose[0];
|
||||||
boty = BotPose[1];
|
boty = BotPose[1];
|
||||||
System.out.println(drivetrain.getPigeon2().getYaw().getValueAsDouble());
|
if(angle < 0){
|
||||||
if(angle < 0){
|
angle = angle + 360;
|
||||||
angle = angle + 360;
|
}
|
||||||
}
|
if(alliance.get() == Alliance.Red){
|
||||||
if(alliance.get() == Alliance.Blue){
|
pigeonAngle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
||||||
y = 5.4;
|
System.out.println(pigeonAngle);
|
||||||
x = 1.11;
|
y = 3.6;
|
||||||
angle = 0;
|
x = 15;
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() > 350 || drivetrain.getPigeon2().getYaw().getValueAsDouble() < 10){
|
angle = 180;
|
||||||
drivetrain.setControl(drive.withVelocityY(y-boty).withVelocityX(x-botx));
|
if(pigeonAngle> 358 || pigeonAngle< 2){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp((-(y-boty)*10), -2, 2)).withVelocityX(MathUtil.clamp((-(x-botx)*10),-2,2)).withRotationalRate(0));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(pigeonAngle>180){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0).withVelocityX(0).withRotationalRate(1));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0).withVelocityX(0).withRotationalRate(-1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
pigeonAngle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
||||||
|
System.out.println(pigeonAngle);
|
||||||
|
y = 4.4;
|
||||||
|
x = 1.6;
|
||||||
|
angle = 0;
|
||||||
|
if(pigeonAngle> 182 || pigeonAngle< 178){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp(((y-boty)*10), -2, 2)).withVelocityX(MathUtil.clamp(((x-botx)*10),-2,2)).withRotationalRate(0));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(pigeonAngle>0 && pigeonAngle<180){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0).withVelocityX(0).withRotationalRate(-1));
|
||||||
|
System.out.println("x");
|
||||||
|
}
|
||||||
|
else if(pigeonAngle>180){
|
||||||
|
System.out.println("e");
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0).withVelocityX(0).withRotationalRate(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >0 && drivetrain.getPigeon2().getYaw().getValueAsDouble() <180){
|
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0).withRotationalRate(0));
|
||||||
drivetrain.setControl(drive.withRotationalRate(-0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
x = 15.6;
|
|
||||||
y = 6.959326;
|
|
||||||
angle = 180;
|
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() > 170 && drivetrain.getPigeon2().getYaw().getValueAsDouble() < 190){
|
|
||||||
drivetrain.setControl(drive.withVelocityY(y-boty).withVelocityX(x-botx));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >0 && drivetrain.getPigeon2().getYaw().getValueAsDouble() <180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(-0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +120,6 @@ public class GrimperMur extends Command {
|
|||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return (y-boty < 0.05 && y-boty >-0.05) && (x-botx < 0.05 && x-botx > -0.05);
|
return (y-boty < 0.2 && y-boty >-0.2) && (x-botx < 0.06 && x-botx > -0.06);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,11 +69,11 @@ public class GrimperReservoir extends Command {
|
|||||||
if(alliance.get() == Alliance.Red){
|
if(alliance.get() == Alliance.Red){
|
||||||
pigeonAngle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
pigeonAngle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
||||||
System.out.println(pigeonAngle);
|
System.out.println(pigeonAngle);
|
||||||
y = 5.4;
|
y = 5.2;
|
||||||
x = 15.6;
|
x = 15.6;
|
||||||
angle = 180;
|
angle = 180;
|
||||||
if(pigeonAngle< 190 && pigeonAngle> 170){
|
if(pigeonAngle< 190 && pigeonAngle> 170){
|
||||||
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp((-(y-boty)*5.5), -2, 2)).withVelocityX(MathUtil.clamp((-(x-botx)*5.5),-2,2)));
|
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp((-(y-boty)*10), -2, 2)).withVelocityX(MathUtil.clamp((-(x-botx)*10),-2,2)));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(pigeonAngle>180){
|
if(pigeonAngle>180){
|
||||||
@@ -91,7 +91,7 @@ public class GrimperReservoir extends Command {
|
|||||||
x = 1.11;
|
x = 1.11;
|
||||||
angle = 0;
|
angle = 0;
|
||||||
if(pigeonAngle> 358 || pigeonAngle< 2){
|
if(pigeonAngle> 358 || pigeonAngle< 2){
|
||||||
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp(((y-boty)*5.5), -2, 2)).withVelocityX(MathUtil.clamp(((x-botx)*5.5),-2,2)).withRotationalRate(0));
|
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp(((y-boty)*10), -2, 2)).withVelocityX(MathUtil.clamp(((x-botx)*10),-2,2)).withRotationalRate(0));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(pigeonAngle>0 && pigeonAngle<180){
|
if(pigeonAngle>0 && pigeonAngle<180){
|
||||||
@@ -119,6 +119,6 @@ public class GrimperReservoir extends Command {
|
|||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return (y-boty < 0.1 && y-boty >-0.1) && (x-botx < 0.1 && x-botx > -0.1);
|
return (y-boty < 0.2 && y-boty >-0.2) && (x-botx < 0.06 && x-botx > -0.06);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,8 @@ public class LimelighterAuto extends Command {
|
|||||||
BotPose = limelight3g.getBotPoseBlue();
|
BotPose = limelight3g.getBotPoseBlue();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
x = 11.915394;
|
// x = 11.915394;
|
||||||
|
x = 4.6;
|
||||||
BotPose = limelight3g.getBotPoseRed();
|
BotPose = limelight3g.getBotPoseRed();
|
||||||
}
|
}
|
||||||
botx = BotPose[0];
|
botx = BotPose[0];
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class MonterGrimpeur extends Command {
|
|||||||
/** Creates a new MonterGrimpeur. */
|
/** Creates a new MonterGrimpeur. */
|
||||||
public MonterGrimpeur(Grimpeur grimpeur) {
|
public MonterGrimpeur(Grimpeur grimpeur) {
|
||||||
this.grimpeur = grimpeur;
|
this.grimpeur = grimpeur;
|
||||||
|
addRequirements(grimpeur);
|
||||||
// Use addRequirements() here to declare subsystem dependencies.
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,18 +26,21 @@ public class MonterGrimpeur extends Command {
|
|||||||
public void execute() {
|
public void execute() {
|
||||||
|
|
||||||
if(Math.abs(grimpeur.Position()) < grimpeur.PositionFinal()){
|
if(Math.abs(grimpeur.Position()) < grimpeur.PositionFinal()){
|
||||||
grimpeur.Grimper(0.5);
|
grimpeur.GrimperGauche(0.5);
|
||||||
|
grimpeur.GrimperDroit(0.5);
|
||||||
System.out.println("monte");
|
System.out.println("monte");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
grimpeur.Grimper(0);
|
grimpeur.GrimperGauche(0);
|
||||||
|
grimpeur.GrimperDroit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
@Override
|
@Override
|
||||||
public void end(boolean interrupted) {
|
public void end(boolean interrupted) {
|
||||||
grimpeur.Grimper(0);
|
grimpeur.GrimperGauche(0);
|
||||||
|
grimpeur.GrimperDroit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
package frc.robot.subsystems;
|
package frc.robot.subsystems;
|
||||||
|
|
||||||
import com.revrobotics.spark.SparkMax;
|
import com.revrobotics.spark.SparkMax;
|
||||||
import com.revrobotics.spark.config.SparkMaxConfig;
|
|
||||||
import com.revrobotics.spark.SparkLowLevel.MotorType;
|
import com.revrobotics.spark.SparkLowLevel.MotorType;
|
||||||
|
|
||||||
import edu.wpi.first.networktables.GenericEntry;
|
import edu.wpi.first.networktables.GenericEntry;
|
||||||
@@ -16,28 +15,44 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
|||||||
|
|
||||||
public class Grimpeur extends SubsystemBase {
|
public class Grimpeur extends SubsystemBase {
|
||||||
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
||||||
SparkMax grimpeur1 = new SparkMax(3,MotorType.kBrushless);
|
SparkMax grimpeur1 = new SparkMax(3, MotorType.kBrushless);
|
||||||
SparkMax grimpeur2 = new SparkMax(12,MotorType.kBrushless);
|
SparkMax grimpeur2 = new SparkMax(12, MotorType.kBrushless);
|
||||||
SparkMaxConfig slaveConfig = new SparkMaxConfig();
|
|
||||||
|
// SparkMaxConfig slaveConfig = new SparkMaxConfig();
|
||||||
DigitalInput limit = new DigitalInput(0);
|
DigitalInput limit = new DigitalInput(0);
|
||||||
private GenericEntry EncodeurGrimpeur =
|
private GenericEntry EncodeurGrimpeur = teb.add("Position haut grimpeur", 100).getEntry();
|
||||||
teb.add("Position haut grimpeur", 101).getEntry();
|
|
||||||
public void Grimper(double vitesse){
|
// public void Grimper(double vitesse){
|
||||||
|
// grimpeur1.configure(slaveConfig, ResetMode.kNoResetSafeParameters,
|
||||||
|
// PersistMode.kPersistParameters);
|
||||||
|
// grimpeur2.configure(slaveConfig.follow(grimpeur1),
|
||||||
|
// ResetMode.kNoResetSafeParameters, PersistMode.kPersistParameters);
|
||||||
|
// grimpeur1.set(vitesse);
|
||||||
|
// }
|
||||||
|
public void GrimperGauche(double vitesse) {
|
||||||
grimpeur1.set(vitesse);
|
grimpeur1.set(vitesse);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GrimperDroit(double vitesse) {
|
||||||
grimpeur2.set(vitesse);
|
grimpeur2.set(vitesse);
|
||||||
}
|
}
|
||||||
public double Position(){
|
|
||||||
|
public double Position() {
|
||||||
return grimpeur1.getEncoder().getPosition();
|
return grimpeur1.getEncoder().getPosition();
|
||||||
}
|
}
|
||||||
public void Reset(){
|
|
||||||
|
public void Reset() {
|
||||||
grimpeur1.getEncoder().setPosition(0);
|
grimpeur1.getEncoder().setPosition(0);
|
||||||
}
|
}
|
||||||
public boolean Limit(){
|
|
||||||
|
public boolean Limit() {
|
||||||
return limit.get();
|
return limit.get();
|
||||||
}
|
}
|
||||||
public double PositionFinal(){
|
|
||||||
return EncodeurGrimpeur.getDouble(101);
|
public double PositionFinal() {
|
||||||
|
return EncodeurGrimpeur.getDouble(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates a new Grimpeur. */
|
/** Creates a new Grimpeur. */
|
||||||
public Grimpeur() {
|
public Grimpeur() {
|
||||||
teb.addDouble("encodeur grimpeur", this::Position);
|
teb.addDouble("encodeur grimpeur", this::Position);
|
||||||
|
|||||||
@@ -1,141 +1,149 @@
|
|||||||
/* Generated by Phoenix Tuner X */
|
// /* Generated by Phoenix Tuner X */
|
||||||
package frc.robot.subsystems;
|
// package frc.robot.subsystems;
|
||||||
|
|
||||||
import edu.wpi.first.networktables.GenericEntry;
|
// import edu.wpi.first.networktables.GenericEntry;
|
||||||
import edu.wpi.first.wpilibj.DriverStation;
|
// import edu.wpi.first.wpilibj.DriverStation;
|
||||||
import edu.wpi.first.wpilibj.Timer;
|
// import edu.wpi.first.wpilibj.Timer;
|
||||||
import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets;
|
// import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets;
|
||||||
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.SubsystemBase;
|
// import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||||
|
|
||||||
import com.ctre.phoenix6.CANBus;
|
// import com.ctre.phoenix6.CANBus;
|
||||||
import com.ctre.phoenix6.controls.SolidColor;
|
// import com.ctre.phoenix6.controls.SolidColor;
|
||||||
import com.ctre.phoenix6.hardware.CANdle;
|
// import com.ctre.phoenix6.hardware.CANdle;
|
||||||
import com.ctre.phoenix6.signals.RGBWColor;
|
// import com.ctre.phoenix6.signals.RGBWColor;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Subsystem that controls an addressable LED strip using a CANdle.
|
// * Subsystem that controls an addressable LED strip using a CANdle.
|
||||||
*/
|
// */
|
||||||
public class LEDSubsystem extends SubsystemBase {
|
// public class LEDSubsystem extends SubsystemBase {
|
||||||
Timer _timer;
|
// Timer _timer;
|
||||||
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
// boolean q = true;
|
||||||
private GenericEntry equipe =
|
// ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
||||||
teb.add("equipe commence (bleu = ouvert, rouge = fermé)", true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
|
// private GenericEntry equipe =
|
||||||
private final CANBus kCANBus = new CANBus("rio");
|
// teb.add("equipe commence (bleu = ouvert, rouge = fermé)", true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
|
||||||
private final CANdle m_candle = new CANdle(17, kCANBus);
|
// private final CANBus kCANBus = new CANBus("rio");
|
||||||
public void Bleu(){
|
// private final CANdle m_candle = new CANdle(17, kCANBus);
|
||||||
m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(255, 0, 0, 0)));
|
// public void Bleu(){
|
||||||
}
|
// m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(255, 0, 0, 0)));
|
||||||
public void Rouge(){
|
// }
|
||||||
m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(0, 0, 255, 0)));
|
// public void Rouge(){
|
||||||
}
|
// m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(0, 0, 255, 0)));
|
||||||
public void Vert(){
|
// }
|
||||||
m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(0, 255, 0, 0)));
|
// public void Vert(){
|
||||||
}
|
// m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(0, 255, 0, 0)));
|
||||||
public void Noir(){
|
// }
|
||||||
|
// public void Noir(){
|
||||||
|
|
||||||
m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(0, 0, 0, 0)));
|
// m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(0, 0, 0, 0)));
|
||||||
}
|
// }
|
||||||
public void Flash(boolean couleur){
|
// public void Flash(boolean couleur){
|
||||||
if(_timer.get() <0.5){
|
// Timer timer = new Timer();
|
||||||
if(couleur){
|
// if(timer.get() <0.5){
|
||||||
Bleu();
|
// if(couleur){
|
||||||
}
|
// Bleu();
|
||||||
else{
|
// }
|
||||||
Rouge();
|
// else{
|
||||||
}
|
// Rouge();
|
||||||
}
|
// }
|
||||||
else{
|
// }
|
||||||
Noir();
|
// else{
|
||||||
_timer.reset();
|
// Noir();
|
||||||
}
|
// timer.reset();
|
||||||
}
|
// }
|
||||||
public LEDSubsystem() {
|
// }
|
||||||
setDefaultCommand(updateLEDs());
|
// public LEDSubsystem() {
|
||||||
_timer = new Timer();
|
// setDefaultCommand(updateLEDs());
|
||||||
_timer.reset();
|
// _timer = new Timer();
|
||||||
_timer.start();
|
// _timer.start();
|
||||||
}
|
// }
|
||||||
public boolean Equipe(){
|
// public boolean Equipe(){
|
||||||
return equipe.getBoolean(false);
|
// return equipe.getBoolean(false);
|
||||||
}
|
// }
|
||||||
/**
|
// /**
|
||||||
* Updates the animations and LEDs of the CANdle.
|
// * Updates the animations and LEDs of the CANdle.
|
||||||
*
|
// *
|
||||||
* @return Command to run
|
// * @return Command to run
|
||||||
*/
|
// */
|
||||||
public Command updateLEDs() {
|
// public Command updateLEDs() {
|
||||||
double temps = DriverStation.getMatchTime();
|
// return run(() -> {
|
||||||
return run(() -> {
|
// // if(q){
|
||||||
if(Equipe()){
|
// // _timer.reset();
|
||||||
if(temps > 110){
|
// // q = false;
|
||||||
Vert();
|
// // }
|
||||||
}
|
// double temps = _timer.get();
|
||||||
else if(temps > 88){
|
// System.out.println(temps);
|
||||||
|
// if(Equipe()){
|
||||||
|
// if(temps > 30){
|
||||||
|
// Vert();
|
||||||
|
// }
|
||||||
|
// else if(temps > 52){
|
||||||
|
|
||||||
Bleu();
|
// Bleu();
|
||||||
}
|
// }
|
||||||
else if(temps > 85){
|
// else if(temps > 55){
|
||||||
Flash(true);
|
// Flash(true);
|
||||||
}
|
// }
|
||||||
else if(temps > 63){
|
// else if(temps > 67){
|
||||||
Rouge();
|
// Rouge();
|
||||||
}
|
// }
|
||||||
else if(temps > 60){
|
// else if(temps > 70){
|
||||||
Flash(false);
|
// Flash(false);
|
||||||
}
|
// }
|
||||||
else if(temps > 33){
|
// else if(temps > 103){
|
||||||
Bleu();
|
// Bleu();
|
||||||
}
|
// }
|
||||||
else if(temps > 30){
|
// else if(temps > 105){
|
||||||
Flash(true);
|
// Flash(true);
|
||||||
}
|
// }
|
||||||
else if(temps > 13){
|
// else if(temps > 127){
|
||||||
Rouge();
|
// Rouge();
|
||||||
}
|
// }
|
||||||
else if(temps > 10){
|
// else if(temps > 130){
|
||||||
Flash(false);
|
// Flash(false);
|
||||||
}
|
// }
|
||||||
else if(temps < 10){
|
// else if(temps < 140){
|
||||||
Vert();
|
// Vert();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
else{
|
// else{
|
||||||
if(temps > 110){
|
// if(temps > 110){
|
||||||
Vert();
|
// Vert();
|
||||||
}
|
// }
|
||||||
else if(temps > 88){
|
// else if(temps > 88){
|
||||||
|
|
||||||
Rouge();
|
// Rouge();
|
||||||
}
|
// }
|
||||||
else if(temps > 85){
|
// else if(temps > 85){
|
||||||
Flash(false);
|
// Flash(false);
|
||||||
}
|
// }
|
||||||
else if(temps > 63){
|
// else if(temps > 63){
|
||||||
Bleu();
|
// Bleu();
|
||||||
}
|
// }
|
||||||
else if(temps > 60){
|
// else if(temps > 60){
|
||||||
Flash(true);
|
// Flash(true);
|
||||||
}
|
// }
|
||||||
else if(temps > 33){
|
// else if(temps > 33){
|
||||||
Rouge();
|
// Rouge();
|
||||||
}
|
// }
|
||||||
else if(temps > 30){
|
// else if(temps > 30){
|
||||||
Flash(false);
|
// Flash(false);
|
||||||
}
|
// }
|
||||||
else if(temps > 13){
|
// else if(temps > 13){
|
||||||
Bleu();
|
// Bleu();
|
||||||
}
|
// }
|
||||||
else if(temps > 10){
|
// else if(temps > 10){
|
||||||
Flash(true);
|
// Flash(true);
|
||||||
}
|
// }
|
||||||
else if(temps < 10){
|
// else if(temps < 10){
|
||||||
Vert();
|
// Vert();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// // _timer.stop();
|
||||||
}
|
|
||||||
}
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ public class LimeLight3 extends SubsystemBase {
|
|||||||
}
|
}
|
||||||
public double[] getBotPoseBlue(){
|
public double[] getBotPoseBlue(){
|
||||||
NetworkTable limelightTable = NetworkTableInstance.getDefault().getTable("limelight-balaie");
|
NetworkTable limelightTable = NetworkTableInstance.getDefault().getTable("limelight-balaie");
|
||||||
NetworkTableEntry BotPoseEntry = limelightTable.getEntry("botpose_orb_wpiblue");
|
NetworkTableEntry BotPoseEntry = limelightTable.getEntry("botpose_wpiblue");
|
||||||
double[] BotPose = BotPoseEntry.getDoubleArray(new double[7]);
|
double[] BotPose = BotPoseEntry.getDoubleArray(new double[7]);
|
||||||
return BotPose;
|
return BotPose;
|
||||||
}
|
}
|
||||||
public double[] getBotPoseRed(){
|
public double[] getBotPoseRed(){
|
||||||
NetworkTable limelightTable = NetworkTableInstance.getDefault().getTable("limelight-balaie");
|
NetworkTable limelightTable = NetworkTableInstance.getDefault().getTable("limelight-balaie");
|
||||||
NetworkTableEntry BotPoseEntry = limelightTable.getEntry("botpose_orb_wpired");
|
NetworkTableEntry BotPoseEntry = limelightTable.getEntry("botpose_wpired");
|
||||||
double[] BotPose = BotPoseEntry.getDoubleArray(new double[7]);
|
double[] BotPose = BotPoseEntry.getDoubleArray(new double[7]);
|
||||||
return BotPose;
|
return BotPose;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,10 +69,10 @@ NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight-tag")
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if(y1 > y2){
|
if(y1 > y2){
|
||||||
return Math.atan((x2 - x1) / (y2 - y1)) * (180 / Math.PI) - angle;
|
return Math.toDegrees(Math.atan((x2 - x1) /(y2 - y1))) - angle;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return -Math.atan((x2 - x1) / (y2 - y1)) * (180 / Math.PI) - angle;
|
return Math.toDegrees(-Math.atan((x2 - x1) / (y2 - y1))) - angle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user