fchb
This commit is contained in:
parent
4bbead03b2
commit
74e1c8a17a
@ -15,7 +15,7 @@ import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
|
|||||||
import edu.wpi.first.wpilibj2.command.button.CommandJoystick;
|
import edu.wpi.first.wpilibj2.command.button.CommandJoystick;
|
||||||
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
||||||
import frc.robot.commands.Avancer;
|
import frc.robot.commands.Avancer;
|
||||||
import frc.robot.commands.Force1;
|
import frc.robot.commands.Lancer;
|
||||||
import frc.robot.commands.Force2;
|
import frc.robot.commands.Force2;
|
||||||
import frc.robot.commands.Force3;
|
import frc.robot.commands.Force3;
|
||||||
import frc.robot.commands.Force4;
|
import frc.robot.commands.Force4;
|
||||||
@ -38,7 +38,7 @@ public class RobotContainer {
|
|||||||
ShuffleboardLayout forces = Shuffleboard.getTab("Dashboard")
|
ShuffleboardLayout forces = Shuffleboard.getTab("Dashboard")
|
||||||
.getLayout("Dashboard", BuiltInLayouts.kList)
|
.getLayout("Dashboard", BuiltInLayouts.kList)
|
||||||
.withSize(3, 7);
|
.withSize(3, 7);
|
||||||
GenericEntry force1 = forces.add("Force1", 0).getEntry();
|
GenericEntry force1 = forces.add("Force1", 2).getEntry();
|
||||||
GenericEntry force2 = forces.add("Force2", 0).getEntry();
|
GenericEntry force2 = forces.add("Force2", 0).getEntry();
|
||||||
GenericEntry force3 = forces.add("Force3", 0).getEntry();
|
GenericEntry force3 = forces.add("Force3", 0).getEntry();
|
||||||
GenericEntry force4 = forces.add("Force4", 0).getEntry();
|
GenericEntry force4 = forces.add("Force4", 0).getEntry();
|
||||||
@ -58,27 +58,21 @@ public class RobotContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void configureBindings() {
|
private void configureBindings() {
|
||||||
Force1 Force1 = new Force1(lanceur, accumulateur, null);
|
|
||||||
Force2 Force2 = new Force2(lanceur, accumulateur, null);
|
|
||||||
Force3 Force3 = new Force3(lanceur, null, accumulateur);
|
|
||||||
Force4 Force4 = new Force4(lanceur, null, accumulateur);
|
|
||||||
Force5 Force5 = new Force5(lanceur, null, accumulateur);
|
|
||||||
Force6 Force6 = new Force6(lanceur, null, accumulateur);
|
|
||||||
Force7 Force7 = new Force7(lanceur, null, accumulateur);
|
|
||||||
accumulateurtest accumulateurtest = new accumulateurtest(accumulateur);
|
accumulateurtest accumulateurtest = new accumulateurtest(accumulateur);
|
||||||
joystick1.button(7).onTrue(Force1);
|
joystick1.button(7).onTrue(new Lancer(lanceur, accumulateur, force1));
|
||||||
joystick1.button(8).onTrue(Force2);
|
joystick1.button(8).onTrue(new Lancer(lanceur, accumulateur, force2));
|
||||||
joystick1.button(9).onTrue(Force3);
|
joystick1.button(9).onTrue(new Lancer(lanceur, accumulateur, force3));
|
||||||
joystick1.button(10).onTrue(Force4);
|
joystick1.button(10).onTrue(new Lancer(lanceur, accumulateur, force4));
|
||||||
joystick1.button(11).onTrue(Force5);
|
joystick1.button(11).onTrue(new Lancer(lanceur, accumulateur, force5));
|
||||||
joystick1.button(12).onTrue(Force6);
|
joystick1.button(12).onTrue(new Lancer(lanceur, accumulateur, force6));
|
||||||
joystick1.button(3).onTrue(Force7);
|
joystick1.button(3).onTrue(new Lancer(lanceur, accumulateur, force7));
|
||||||
joystick1.button(5).toggleOnTrue(accumulateurtest);
|
joystick1.button(5).toggleOnTrue(accumulateurtest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Command getAutonomousCommand() {
|
public Command getAutonomousCommand() {
|
||||||
return new SequentialCommandGroup(new Avancer(drive), new Force7(lanceur, force7, accumulateur)
|
return new SequentialCommandGroup(new Avancer(drive), new Force7(lanceur, force7, accumulateur)
|
||||||
, new Force1(lanceur, accumulateur, force1), new Reculer(drive));
|
, new Lancer(lanceur, accumulateur, force1), new Reculer(drive));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
41
src/main/java/frc/robot/commands/AccAvancer.java
Normal file
41
src/main/java/frc/robot/commands/AccAvancer.java
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// 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.Accumulateur;
|
||||||
|
|
||||||
|
public class AccAvancer extends CommandBase {
|
||||||
|
private Accumulateur accumulateur;
|
||||||
|
/** Creates a new AccAvancer. */
|
||||||
|
public AccAvancer(Accumulateur accumulateur) {
|
||||||
|
this.accumulateur = accumulateur;
|
||||||
|
addRequirements(accumulateur);
|
||||||
|
// 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() {
|
||||||
|
accumulateur.Deaccumuler();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called once the command ends or is interrupted.
|
||||||
|
@Override
|
||||||
|
public void end(boolean interrupted) {
|
||||||
|
accumulateur.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return accumulateur.tourneavant()<1024;
|
||||||
|
}
|
||||||
|
}
|
40
src/main/java/frc/robot/commands/AccReculer.java
Normal file
40
src/main/java/frc/robot/commands/AccReculer.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// 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.Accumulateur;
|
||||||
|
|
||||||
|
public class AccReculer extends CommandBase {
|
||||||
|
private Accumulateur accumulateur;
|
||||||
|
/** Creates a new AccReculer. */
|
||||||
|
public AccReculer(Accumulateur accumulateur) {
|
||||||
|
this.accumulateur = accumulateur;
|
||||||
|
addRequirements(accumulateur);
|
||||||
|
// 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() {
|
||||||
|
accumulateur.reaccumuler();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called once the command ends or is interrupted.
|
||||||
|
@Override
|
||||||
|
public void end(boolean interrupted) {
|
||||||
|
accumulateur.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return accumulateur.tournearriere()<-256;
|
||||||
|
}
|
||||||
|
}
|
34
src/main/java/frc/robot/commands/Lancer.java
Normal file
34
src/main/java/frc/robot/commands/Lancer.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// 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 java.util.function.DoubleSupplier;
|
||||||
|
|
||||||
|
import edu.wpi.first.networktables.GenericEntry;
|
||||||
|
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
|
||||||
|
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
|
||||||
|
import edu.wpi.first.wpilibj2.command.WaitUntilCommand;
|
||||||
|
import frc.robot.subsystems.Accumulateur;
|
||||||
|
import frc.robot.subsystems.Lanceur;
|
||||||
|
|
||||||
|
// NOTE: Consider using this command inline, rather than writing a subclass. For more
|
||||||
|
// information, see:
|
||||||
|
// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html
|
||||||
|
public class Lancer extends ParallelCommandGroup {
|
||||||
|
private Lanceur lanceur;
|
||||||
|
private Accumulateur accumulateur;
|
||||||
|
|
||||||
|
/** Creates a new Force1. */
|
||||||
|
public Lancer(Lanceur lanceur,Accumulateur accumulateur,GenericEntry vitesse) {
|
||||||
|
this.lanceur = lanceur;
|
||||||
|
this.accumulateur = accumulateur;
|
||||||
|
|
||||||
|
// Add your commands in the addCommands() call, e.g.
|
||||||
|
// addCommands(new FooCommand(), new BarCommand());
|
||||||
|
addCommands(new Lancez(lanceur),
|
||||||
|
new SequentialCommandGroup(new WaitUntilCommand(()->lanceur.vitesse()>vitesse.getDouble(0)))
|
||||||
|
,new AccAvancer(accumulateur),new AccReculer(accumulateur));
|
||||||
|
}
|
||||||
|
}
|
@ -4,55 +4,35 @@
|
|||||||
|
|
||||||
package frc.robot.commands;
|
package frc.robot.commands;
|
||||||
|
|
||||||
|
|
||||||
import edu.wpi.first.networktables.GenericEntry;
|
|
||||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||||
import frc.robot.subsystems.Accumulateur;
|
import frc.robot.subsystems.Accumulateur;
|
||||||
import frc.robot.subsystems.Lanceur;
|
import frc.robot.subsystems.Lanceur;
|
||||||
|
|
||||||
public class Force1 extends CommandBase {
|
public class Lancez extends CommandBase {
|
||||||
private Lanceur lanceur;
|
private Lanceur lanceur;
|
||||||
private Accumulateur accumulateur;
|
/** Creates a new Lancez. */
|
||||||
GenericEntry force1;
|
public Lancez(Lanceur lanceur) {
|
||||||
|
|
||||||
/** Creates a new Force1. */
|
|
||||||
public Force1(Lanceur lanceur,Accumulateur accumulateur, GenericEntry force1) {
|
|
||||||
this.lanceur = lanceur;
|
this.lanceur = lanceur;
|
||||||
this.accumulateur = accumulateur;
|
addRequirements(lanceur);
|
||||||
addRequirements(lanceur, accumulateur);
|
|
||||||
this.force1 = force1;
|
|
||||||
// Use addRequirements() here to declare subsystem dependencies.
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
lanceur.setPID(0,0,0);
|
lanceur.setPID(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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() {
|
||||||
lanceur.lancer(force1.getDouble(100));
|
lanceur.lancer(0);
|
||||||
double vitesse = (100);
|
}
|
||||||
if (lanceur.vitesse() > vitesse ){
|
|
||||||
accumulateur.tourneavant();
|
|
||||||
if(accumulateur.tourneavant()>1024) {
|
|
||||||
accumulateur.tournearriere();
|
|
||||||
}
|
|
||||||
if(accumulateur.tournearriere()>-256){
|
|
||||||
accumulateur.stop();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 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) {
|
||||||
lanceur.lancer(0);
|
lanceur.lancer(0);
|
||||||
accumulateur.stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
Loading…
x
Reference in New Issue
Block a user