This commit is contained in:
samuel desharnais 2024-01-29 19:13:09 -05:00
parent 78d284d0d1
commit 8c7dc5ab87
2 changed files with 38 additions and 4 deletions

View File

@ -18,17 +18,46 @@ public class GrimpeurHaut extends Command {
// Called when the command is initially scheduled.
@Override
public void initialize() {}
public void initialize() {
grimpeur.resetencodeurd();
grimpeur.resetencodeurg();
}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
if(grimpeur.droite()){
grimpeur.resetencodeurd();
}
else if(grimpeur.gauche()){
grimpeur.resetencodeurg();
}
else if(grimpeur.encoderd()>261){
grimpeur.droit(0);
}
else if(grimpeur.getpitch()<-15){
grimpeur.droit(0.6);
grimpeur.gauche(-0.6);
}
else if(grimpeur.getpitch()>15){
grimpeur.gauche(0.6);
grimpeur.droit(-0.6);
}
else if(grimpeur.encoderg()>261){
grimpeur.gauche(0.6);
}
else{
grimpeur.gauche(0);
grimpeur.gauche(0);
}
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {}
public void end(boolean interrupted) {
grimpeur.droit(0);
grimpeur.gauche(0);
}
// Returns true when the command should end.
@Override

View File

@ -45,7 +45,12 @@ public void resetencodeurd(){
public void resetencodeurg(){
grimpeurg.getEncoder().setPosition(0);
}
public double encoderd(){
return grimpeurd.getEncoder().getPosition();
}
public double encoderg(){
return grimpeurg.getEncoder().getPosition();
}
public AHRS gyroscope = new AHRS();
public double getpitch(){
return gyroscope.getPitch();