Go to Post I just want to say that the rack 'n roll was my first year with FIRST! It was the best thing I ever did. I cant wait to learn more when we get to start up again! - ctorloey [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 23-03-2016, 17:23
SPQLrobotics SPQLrobotics is offline
Registered User
FRC #5941
 
Join Date: Oct 2015
Location: Everett
Posts: 4
SPQLrobotics is an unknown quantity at this point
Need Help With Encoders

Our team, 5941, has struggled to get autonomous working. This is our code for autonomous:

public void autonomousInit() {
autoState = -1;
t.start();
lastTime = t.get();
}

/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
switch (autoSelected) {
case "doNothing":
break;
default:
case defaultAuto:
LowBarAuton();
//encoderAuto();
break;
// case "spybot":
// SpyBotAuton();
// break;
// case "rampWithStuff":
// RampAuton();
// break;
}
}

public void LowBarAuton() {
switch (autoState){
default:
lastTime = t.get();
autoState = 0;
end1.set(0.5);
end2.set(0.5);
break;
case 0:
pneumatic.set(-0.75);
if ( t.get() - lastTime > 2){
autoState = 1;
lastTime = t.get();
}
break;
case 1:
pneumatic.set(0.0);
leftSide.set(0.4);
rightSide.set(-0.4);
if ( t.get() - lastTime > 5){
autoState = 2;
lastTime = t.get();
}
break;

case 2:

rightSide.set(0.0);
leftSide.set(0.0);
autoSelected = "doNothing";
break;
}

}

public void encoderAuto(){
pneumatic.set(-0.75);
Timer.delay(2.0);
pneumatic.set(0.0);
if (encLeft.getDistance() < 4 && encRight.getDistance() > -4 && !forwardDone){
leftSide.set(0.4);
rightSide.set(-0.4);
} else if (encLeft.getDistance() >= 4 && encRight.getDistance() <= -4 && !forwardDone) {
forwardDone = true;
leftSide.set(0.0);
rightSide.set(0.0);
encLeft.reset();
encRight.reset();
Timer.delay(1.0);
}else if (encLeft.getDistance() > -4 && encRight.getDistance() < 4 && !backwardDone && forwardDone) {
leftSide.set(-0.4);
rightSide.set(0.4);
}else if (encLeft.getDistance() <= -4 && encRight.getDistance() >= 4 && !backwardDone && forwardDone) {
backwardDone = true;
leftSide.set(0);
rightSide.set(0);
autoSelected = "doNothing";
}
}

The LowBarAuton() is supposed to drive under the low bar, then back up to the other side so that as soon as teleop starts we can clear that defense. It is using timers.

encoderAuto() is attempting to do the same thing as LowBarAuton(), only using encoders instead of timers. Neither have worked.


I also am attaching the full code, in the event that this code is not enough. Help would be appreciated.
Attached Files
File Type: java Robot.java (10.8 KB, 19 views)
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 23:24.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi