View Single Post
  #18   Spotlight this post!  
Unread 31-03-2004, 09:41
gnormhurst's Avatar
gnormhurst gnormhurst is offline
Norm Hurst
AKA: gnorm
#0381 (The Tornadoes)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Trenton, NJ
Posts: 138
gnormhurst will become famous soon enoughgnormhurst will become famous soon enough
Re: More automonous help:ending stuff

Quote:
Originally Posted by Tom Saxton
OK, here's my take on what's been said, with some minor refinements and details. I took the original code, re-arranged a bit to put it into a state machine (and fix the problem where sensor readings could lock out the code that does the end game), then plopped it all into the User_Autonomous_Code function from the default FIRST code in user_routines_fast.c.

I also added in the loop counter in the right spot and used the constants to give the transitions at 12 and 14 seconds. Since autonomous mode just spins in the one function, there's no reason to mess with global (or static) variables.
I think this code is cleaner than mine -- I prefer state machines. Barry, if you can wrap your head around the state machine idea, that's the better way to go.

And Tom, thanks for pointing out that 'static' is unneccesary since it all happens in one loop for 15 seconds. It's just a habit to use a static when I want to see what the value was at the end of the previous pass.

Good luck, Barry!
__________________
Trenton Tornadoes 381
2004 Philadelphia Regional Winners
2006 Xerox Creativity Award
---
My corner of the USPTO.
My favorite error message from gcc: main is usually a function
My favorite error message from Windows: There is not enough disk space available to delete this file.