rtdytyjhk

This commit is contained in:
samuel desharnais 2023-11-15 18:54:59 -05:00
parent 22e60fb27b
commit 977cbef11e
10 changed files with 74 additions and 15 deletions

View File

@ -5,18 +5,15 @@
package frc.robot;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
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;
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import frc.robot.commands.Force1;
import frc.robot.subsystems.Accumulateur;
import frc.robot.subsystems.Drive;
import frc.robot.subsystems.Lanceur;

View File

@ -0,0 +1,36 @@
// 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.CommandBase;
import frc.robot.subsystems.Drive;
public class Avancer extends CommandBase {
private Drive drive;
/** Creates a new Avancer. */
public Avancer(Drive drive) {
// 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() {}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@ -6,16 +6,20 @@ package frc.robot.commands;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.Accumulateur;
import frc.robot.subsystems.Lanceur;
public class Force1 extends CommandBase {
private Lanceur lanceur;
private Accumulateur accumulateur;
GenericEntry force1;
/** Creates a new Force1. */
public Force1(Lanceur lanceur, GenericEntry force1) {
public Force1(Lanceur lanceur,Accumulateur accumulateur, GenericEntry force1) {
this.lanceur = lanceur;
this.accumulateur = accumulateur;
addRequirements(lanceur);
this.force1 = force1;
// Use addRequirements() here to declare subsystem dependencies.
@ -31,8 +35,15 @@ public class Force1 extends CommandBase {
@Override
public void execute() {
lanceur.lancer(force1.getDouble(0));
double vitesse = SmartDashboard.getNumber("Force Lanceur", 100);
if (lanceur.vitesse() > vitesse ){
accumulateur.tourneavant();
accumulateur.tournearriere();
} else {
accumulateur.stop();
}
}
// Called once the command ends or is interrupted.
@Override

View File

@ -4,15 +4,19 @@
package frc.robot.commands;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.Accumulateur;
import frc.robot.subsystems.Lanceur;
public class Force2 extends CommandBase {
private Lanceur lanceur;
private Accumulateur accumulateur;
/** Creates a new Force1. */
public Force2(Lanceur lancer) {
public Force2(Lanceur lancer,Accumulateur accumulateur) {
this.lanceur = lanceur;
this.accumulateur = accumulateur;
addRequirements(lanceur);
// Use addRequirements() here to declare subsystem dependencies.
}
@ -26,7 +30,13 @@ public class Force2 extends CommandBase {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
lanceur.lancer(500);
double vitesse = SmartDashboard.getNumber("Force Lanceur", 200);
if (lanceur.vitesse() > vitesse ){
accumulateur.tourneavant();
accumulateur.tournearriere();
} else {
accumulateur.stop();
}
}
// Called once the command ends or is interrupted.

View File

@ -44,9 +44,12 @@ public class Force3 extends CommandBase {
public void execute() {
double vitesse = SmartDashboard.getNumber("Force Lanceur", 300);
lanceur.lancer(200);
lanceur.lancer(force3.getDouble(0));}
public void end(boolean interrupted) {
if (lanceur.vitesse() > vitesse ){
accumulateur.tourneavant();
accumulateur.tournearriere();
} else {
accumulateur.stop();
}
}
@Override
public boolean isFinished() {

View File

@ -38,7 +38,7 @@ public class Force4 extends CommandBase {
@Override
public void execute() {
double vitesse = SmartDashboard.getNumber("Force Lanceur", 400);
lanceur.lancer(200);
lanceur.lancer(400);
if (lanceur.vitesse() > vitesse ){
accumulateur.tourneavant();
accumulateur.tournearriere();

View File

@ -38,7 +38,7 @@ public class Force5 extends CommandBase {
@Override
public void execute() {
double vitesse = SmartDashboard.getNumber("Force Lanceur", 500);
lanceur.lancer(200);
lanceur.lancer(500);
if (lanceur.vitesse() > vitesse ){
accumulateur.tourneavant();
accumulateur.tournearriere();

View File

@ -39,7 +39,7 @@ public class Force6 extends CommandBase {
@Override
public void execute() {
double vitesse = SmartDashboard.getNumber("Force Lanceur", 600);
lanceur.lancer(200);
lanceur.lancer(600);
if (lanceur.vitesse() > vitesse ){
accumulateur.tourneavant();
accumulateur.tournearriere();

View File

@ -38,7 +38,7 @@ public class Force7 extends CommandBase {
@Override
public void execute() {
double vitesse = SmartDashboard.getNumber("Force Lanceur", 700);
lanceur.lancer(200);
lanceur.lancer(700);
if (lanceur.vitesse() > vitesse ){
accumulateur.tourneavant();
accumulateur.tournearriere();

View File

@ -30,7 +30,9 @@ public class Drive extends SubsystemBase {
e.printStackTrace();
}
}
public void reset(){
}
@Override
public void periodic() {
// This method will be called once per scheduler run