|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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");
}
|
|
#2
|
||||
|
||||
|
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? |
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
||||
|
||||
|
Re: While loop not working in autonomous
Quote:
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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|