
11-02-2014, 15:55
|
 |
Registered User
no team
|
|
Join Date: Jun 2013
Rookie Year: 2012
Location: United States
Posts: 748
|
|
|
Re: Still Having Pneumatics Problems
Quote:
Originally Posted by Oblarg
Caveat: While I know java, I'm not a robot programmer so I might be completely wrong about this.
That said, it seems like a really bad idea to use while loops in that way, as it makes it impossible for any code to execute at the same time as your solenoid commands. Moreover, since there is always one of your conditions that is true, you will in general never be able to execute any code other than that specific set of solenoid commands. Using different buttons for forward and backward commands on a double solenoid seems bad practice, too, without some sort of way to handle the case where both buttons are pressed at once, though I do not know off the top of my head what the behavior would be in this situation without something explicitly handling it in code, but I could imagine it might be unfortunate (ironically, the fact that you're going to get caught in a loop with your given code handles this problem by itself as the forward and backward commands can't execute simultaneously, but upon revising it it'd rear its head).
|
You're right. The robot program is one big loop. To get it to work, you'll need to change those while loops to if/then/else.
|