bras
This commit is contained in:
@ -6,45 +6,36 @@ package frc.robot.commands.bras;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.bras.BrasTelescopique;
|
||||
import frc.robot.subsystems.bras.Pivot;
|
||||
|
||||
public class PivotChercheHaut extends CommandBase {
|
||||
private BrasTelescopique brasTelescopique;
|
||||
private Pivot pivot;
|
||||
/** Creates a new PivotChercheHaut. */
|
||||
public PivotChercheHaut(BrasTelescopique brasTelescopique, Pivot pivot) {
|
||||
public class Bougerbras extends CommandBase {
|
||||
/** Creates a new bougerbras. */
|
||||
double distance;
|
||||
BrasTelescopique brasTelescopique;
|
||||
public Bougerbras(BrasTelescopique brasTelescopique,double distance) {
|
||||
this.brasTelescopique = brasTelescopique;
|
||||
this.pivot = pivot;
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
this.distance = distance;
|
||||
addRequirements(brasTelescopique);
|
||||
addRequirements(pivot);
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {
|
||||
brasTelescopique.fermer();
|
||||
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
if(brasTelescopique.photocell()){
|
||||
brasTelescopique.ouvrir();
|
||||
brasTelescopique.Reset();
|
||||
brasTelescopique.AvanceRecule(0);
|
||||
}
|
||||
else{
|
||||
if(brasTelescopique.distance()>distance+0.5 ) {
|
||||
brasTelescopique.AvanceRecule(-0.3);
|
||||
|
||||
}
|
||||
else if(brasTelescopique.distance()<distance-0.5) {
|
||||
brasTelescopique.AvanceRecule(0.3);
|
||||
}
|
||||
if (pivot.distance()<43.5){
|
||||
pivot.monteDescendre(0.5);
|
||||
}
|
||||
else if(pivot.distance()>44.5) {
|
||||
pivot.monteDescendre(-0.5);
|
||||
}
|
||||
else{
|
||||
pivot.monteDescendre(0);
|
||||
else {
|
||||
brasTelescopique.AvanceRecule(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,13 +43,13 @@ public class PivotChercheHaut extends CommandBase {
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
brasTelescopique.AvanceRecule(0);
|
||||
pivot.monteDescendre(0);
|
||||
brasTelescopique.ouvrir();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
return brasTelescopique.distance()>distance-0.5 && brasTelescopique.distance()<distance+0.5;
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -5,58 +5,47 @@
|
||||
package frc.robot.commands.bras;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.bras.BrasTelescopique;
|
||||
import frc.robot.subsystems.bras.Pivot;
|
||||
|
||||
public class PivotBrasRentre extends CommandBase {
|
||||
private BrasTelescopique brasTelescopique;
|
||||
private Pivot pivot;
|
||||
/** Creates a new PivotBrasRentre. */
|
||||
public PivotBrasRentre(BrasTelescopique brasTelescopique, Pivot pivot) {
|
||||
this.brasTelescopique = brasTelescopique;
|
||||
public class Bougerpivot extends CommandBase {
|
||||
/** Creates a new Bougerpivot. */
|
||||
Pivot pivot;
|
||||
double distance;
|
||||
public Bougerpivot(Pivot pivot,double distance) {
|
||||
this.pivot = pivot;
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
addRequirements(brasTelescopique);
|
||||
this.distance = distance;
|
||||
addRequirements(pivot);
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {
|
||||
brasTelescopique.fermer();
|
||||
}
|
||||
public void initialize() {}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
if(brasTelescopique.photocell()){
|
||||
brasTelescopique.ouvrir();
|
||||
brasTelescopique.Reset();
|
||||
brasTelescopique.AvanceRecule(0);
|
||||
}
|
||||
else{
|
||||
brasTelescopique.AvanceRecule(0.5);
|
||||
}
|
||||
if(pivot.limitpivot()){
|
||||
pivot.Reset();
|
||||
pivot.monteDescendre(0);
|
||||
}
|
||||
else{
|
||||
if(pivot.distance()>distance+0.5 ) {
|
||||
pivot.monteDescendre(-0.5);
|
||||
}
|
||||
else if(pivot.distance()<distance-0.5) {
|
||||
pivot.monteDescendre(0.5);
|
||||
}
|
||||
else {
|
||||
pivot.monteDescendre(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
brasTelescopique.AvanceRecule(0);
|
||||
pivot.monteDescendre(0);
|
||||
brasTelescopique.ouvrir();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return brasTelescopique.photocell() && pivot.limitpivot();
|
||||
}
|
||||
return pivot.distance()>distance-0.5 && pivot.distance()<distance+0.5;
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
// 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.bras;
|
||||
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
|
||||
import frc.robot.subsystems.bras.BrasTelescopique;
|
||||
import frc.robot.subsystems.bras.Pivot;
|
||||
|
||||
// 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 DescendrePivotBras extends SequentialCommandGroup {
|
||||
/** Creates a new DescendrePivotBras. */
|
||||
public DescendrePivotBras(BrasTelescopique brasTelescopique, Pivot pivot, double distanceBras, double distancePivot) {
|
||||
// Add your commands in the addCommands() call, e.g.
|
||||
// addCommands(new FooCommand(), new BarCommand());
|
||||
addCommands(
|
||||
new Bougerbras(brasTelescopique, distanceBras),
|
||||
new Bougerpivot(pivot, distancePivot)
|
||||
);
|
||||
}
|
||||
}
|
28
src/main/java/frc/robot/commands/bras/MonterPivotBras.java
Normal file
28
src/main/java/frc/robot/commands/bras/MonterPivotBras.java
Normal file
@ -0,0 +1,28 @@
|
||||
// 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.bras;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.Commands;
|
||||
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
|
||||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
|
||||
import frc.robot.subsystems.bras.BrasTelescopique;
|
||||
import frc.robot.subsystems.bras.Pivot;
|
||||
|
||||
// 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 MonterPivotBras extends ParallelCommandGroup {
|
||||
/** Creates a new Sequancepivotbras. */
|
||||
public MonterPivotBras(BrasTelescopique brasTelescopique, Pivot pivot, double distanceBras, double distancePivot) {
|
||||
|
||||
// Add your commands in the addCommands() call, e.g.
|
||||
// addCommands(new FooCommand(), new BarCommand());
|
||||
addCommands(
|
||||
new SequentialCommandGroup(Commands.waitUntil(()->pivot.distance()>8),new Bougerbras(brasTelescopique, distanceBras)),
|
||||
new Bougerpivot(pivot, distancePivot)
|
||||
|
||||
);
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
// 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.bras;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.bras.BrasTelescopique;
|
||||
import frc.robot.subsystems.bras.Pivot;
|
||||
|
||||
public class PivotChercheBas extends CommandBase {
|
||||
private BrasTelescopique brasTelescopique;
|
||||
private Pivot pivot;
|
||||
/** Creates a new PivotChercheBas. */
|
||||
public PivotChercheBas(BrasTelescopique brasTelescopique, Pivot pivot) {
|
||||
this.brasTelescopique = brasTelescopique;
|
||||
this.pivot = pivot;
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
addRequirements(brasTelescopique);
|
||||
addRequirements(pivot);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {
|
||||
brasTelescopique.fermer();
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
if(brasTelescopique.distance()>-17.5){
|
||||
brasTelescopique.AvanceRecule(-0.2);
|
||||
brasTelescopique.fermer();
|
||||
}
|
||||
else if(brasTelescopique.distance()<-19.5) {
|
||||
brasTelescopique.AvanceRecule(0.2);
|
||||
}
|
||||
else {
|
||||
brasTelescopique.AvanceRecule(0);
|
||||
brasTelescopique.ouvrir();
|
||||
}
|
||||
if (pivot.distance()<8.5){
|
||||
pivot.monteDescendre(0.3);
|
||||
}
|
||||
else if(pivot.distance()>10.5) {
|
||||
pivot.monteDescendre(-0.3);
|
||||
}
|
||||
else{
|
||||
pivot.monteDescendre(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
brasTelescopique.AvanceRecule(0);
|
||||
pivot.monteDescendre(0);
|
||||
brasTelescopique.fermer();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user