Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   While loop not working in autonomous (http://www.chiefdelphi.com/forums/showthread.php?t=125190)

Zaque 24-01-2014 22:34

While loop not working in autonomous
 
Hi all,

I have created a while loop in autonomous that uses a boolean from the vision processing (hot goal). I have a System.out that will print repeatedly in NetConsole, but my relay will only go forward the first time. Relevant code below:

Code:

        while(h){
            relay.set(Relay.Value.kForward);
            System.out.println("Firing");
        }


Domenic Rodriguez 24-01-2014 22:49

Re: While loop not working in autonomous
 
Could you provide some more context to your issue? Are you using the SimpleRobot or IterativeRobot base class? It would help to see the class this code is located in, or at least more of the surrounding code.

I'm not entirely sure what the issue is here. You set the relay to the forward value, and it will stay there until you set a new value for the relay. What is the desired behavior you are looking for?

Zaque 25-01-2014 00:19

Re: While loop not working in autonomous
 
Sorry for not giving enough information. We are using SimpleRobot. It is located within public void autonomous(). I have the while(isAutonomous() && isEnabled()) loop commented out, so as not to kill the flash on the cRIO. I can post the whole code tomorrow morning, but this is the only code that acts on the relay. To clarify the problem, when I run the program, it prints "Firing" repeatedly in NetConsole, but the relay only turns on for the first time through the while(h) loop. Also, the green LED on the digital sidecar turns on and off with the motor. The h Boolean is set based on whether or not the goal is hot, and I have confirmed this to work.

Domenic Rodriguez 25-01-2014 07:21

Re: While loop not working in autonomous
 
Quote:

Originally Posted by Zaque (Post 1331994)
To clarify the problem, when I run the program, it prints "Firing" repeatedly in NetConsole, but the relay only turns on for the first time...

So you're saying the relay turns on for the first loop, and then it turns off and won't come back on? If you're trying to fire the ball, I'm assuming you want the motor to stay on for the duration of the loop?

From the code snippet you posted, I see no reason for the relay to turn off. You should check the rest of your code to make sure nothing else is trying to control the relay.


All times are GMT -5. The time now is 11:41.

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