I am trying to make a robot which handles a complex living-room-floor-type environment intelligently. It's my first program in robotc and my first program of any kind in many years (not that I was every more than a rank beginner, as you can see from the clunky code).
The program works well when I step through it, but gets tied up when it's actually running. I am pretty sure this is because I don't have sufficient wait times after certain motor actions. However, I am getting an error when I try to compile after adding the necessary wait time. It's quite weird. Am I doing something stupid wrong? or is there a limit on the amount of nesting, or wait times used, or something similar? or is it a weird bug? grateful for any help. Here is the code
Also while I'm at it, a couple of really basic questions:
If I use a while loop, and at some point the condition is not fulfilled, so the code leaves the while loop, and then at some future point the condition is fulfilled again, will the while loop "kick in" automatically or once you fail to meet the condition once, you only go back into the while loop if the code returns to the while condition statement? A specific example may clarify: I run both motors forward in a while loop as long as there is no obstacle closer than 20 cm. If there is a close obstacle, i back up, indefinitely. Clearly the while condition will be satisfied again. Is it monitored during the backup process or only if the code ends and you return to the begining where the while loop is stated?
Second question: obviously there is a lot of unnecessary repetitive stuff in the code above that could be simplified with either void or #define. Looking at the thread about simplifying into functions seems to suggest to have a list of voids in a functions.c or whatever, which makes sense. But in that case when do you use #define? Is there a good primer for those sort of basic programing questions?
Thanks again.