Hey guys, I’m here with a silly question. I’ve been fighting with myself over how to get a while loop to program during auton. I haven’t been able to get a while loop to exit after the auton task is complete. Can I do something along the lines of
while(autonomous == true){
//My code
}
or will it require something more complicated. Am I just missing something or do I need to do something more.
Ok, so I’m using this while loop to run a form of a P loop, so is there a way where I can run through like a normal auton task and have a while loop running at the same time?
Ex:
task autonomous{
while(true){
//my P loop
}
//my code I want to run as well
}
I think you might want your P loop to exit after some target has been met - this could be distance (while encoder/potentiometer < 300), time (say, maximum time you want the robot to spend driving 300 encoder counts forward), or a combination of the two.
You don’t necessarily need to create a new task for the while loop unless you need to your robot to do something else at the same time, such as moving a lift or running an intake.
So my approach to this was to keep my arm level at a certain level while running autonomous. I was going to use either an IME or Potentiometer, depending on my arm range, to say if the arm sags down a bit it will raise it back up. I was going to also use this to continue to adjust my arm range, for example, all the way down, I will set my “height” variable to 0, and maybe my “height” variable to 150 for up.