Thread: State Machines
View Single Post
  #7   Spotlight this post!  
Unread 10-01-2005, 21:10
phrontist's Avatar
phrontist phrontist is offline
Proto-Engineer
AKA: Bjorn Westergard
FRC #1418 (Vae Victus)
Team Role: College Student
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Falls Church, VA
Posts: 828
phrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond repute
Send a message via AIM to phrontist
Re: State Machines

A state machine is really a simple concept. Lets say you wanted to design a state machine to, oh lets just pick some random example, find a tetrahedron and place it on a bigger one. I know this seems like a farfetched example, but it's all I can think of right now. So in order to create a state machine you break this task up into various parts:
  1. Determine location of tetrahedron
  2. Place robot within grabbing range of tetrahedron
  3. Grab tetrahedron
  4. Move within capping range of goal
  5. Put arm in proper location for capping
  6. Cap!

This seems obvious right. But when you are programming a robot you can't just write out a long program of actions and run it straight through, you need to do things every cycle. This is where state machines come in. One way you could do this is to have a global variable containing the current state of the robot, and then a big switch statement with different actions for each state. Somewhere in the code for each state we have code that advances the state if a certain condition is met. Example: A sensor in your gripper has detected that the tetrahedron has been grabbed, so you want to move on to the next state. Simple concept right? State machines can do very complex things, and states don't nessicarily have to go in order. There are whole feilds of mathematics dedicated to state machine analysis.
__________________

University of Kentucky - Radio Free Lexington

"I would rather have a really big success or a really spectacular crash and failure then live out the warm eventual death of mediocrity" - Dean Kamen

Last edited by phrontist : 10-01-2005 at 21:26.