Thread: State Machines
View Single Post
  #2   Spotlight this post!  
Unread 09-01-2005, 15:49
unclear_physics's Avatar
unclear_physics unclear_physics is offline
SW Engineer/Physicist
AKA: Richard Neese
#0147 (Deep Thunder)
Team Role: Engineer
 
Join Date: Jan 2004
Location: St. Petersburg, FL
Posts: 5
unclear_physics is an unknown quantity at this point
Re: State Machines

The particular flavor that you will want to "study up" on is called the Finite State Machine (FSM). Here are a few good links to get you started (then I recommend you get on Google!):

http://en.wikipedia.org/wiki/Finite_state_machine

http://www.pragmaticprogrammer.com/a...v_02_state.pdf

http://sakharov.net/fsm.html


Basically, what you do is make up a list of all of the different "operational modes" that your various robot subsystems can support, for example: stopped, started, running slow, running fast, broke (ha! ha!). One way to do this is to get a group in front of a white board and put each operational mode inside a circle or box. Then you draw arrows between each circle to the other circles to show how one "state" can "transition" to the next. Then beside each arrow you write down the "transition rules" in terms of the various signals or values of variables in your program.

This is a very iterative process. You have to make several passes at it to get it right! Spend the time writing down your cicles and lines and talk about them with the folks who are building the various robot parts. Also talk to the folks who are designing your strategies for the various parts of the game. Finite State Machines can be nicely hierarchical: you can build up bigger state machines by putting together smaller machines (remember that drive train state machine might include the wheel rate monitoring machine and the PWM output control state machine). Also, one state's output can be the trigger to several different other state machines to go into another mode, for example the bits that signal the end of autonomous mode could be used to deploy various robot components that were not allowed to operate in autonomous mode for robot safety reasons.

Anyway, Team 147 went through this process last year on the design of their robot controller software. The code was simply a collection of FSMs, the most simple of which was the FSM that turned the compressor on and off.

If you are interested, send me an email and I'll try to locate last year's source code so that you can see a few examples.