OCCRA
Go to Post some people sing in the shower........i pretend to be an emcee at championships......:cool: - BanksKid [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-09-2005, 02:04 PM
Happy Birthday! doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
State Machines

My team wants me to rewrite our nasty autonomous code from last year and I decided I need to learn state machines, does anyone know where I can learn these
__________________
  #2   Spotlight this post!  
Unread 01-09-2005, 03:49 PM
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.
  #3   Spotlight this post!  
Unread 01-09-2005, 03:49 PM
eugenebrooks eugenebrooks is offline
Team Role: Engineer
AKA: Dr. Brooks
no team (WRRF)
 
Join Date: Jan 2004
Rookie Year: 2001
Location: Livermore, CA
Posts: 601
eugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond repute
Re: State Machines

Quote:
Originally Posted by doyler
My team wants me to rewrite our nasty autonomous code from last year and I decided I need to learn state machines, does anyone know where I can learn these
Have a look at the programming white papers, there are several.
One of the sections of "Introduction to C Programming for FIRST
robotics," the most recent version can be obtained from the Technical
section at www.srvhsrobotics.org is specifically on state machines.
If you want to see a few hundred lines of state machine code that uses
time, measured distance, measured gyro angle, positions an arm
with analog feedback, and looks at switches on a robot to select among
autonomous modes, I'll put our control code up from last year for you
to go through. It won't take you long at all to master state machine
programming.
  #4   Spotlight this post!  
Unread 01-09-2005, 06:23 PM
Happy Birthday! doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: State Machines

Yes, can you both send me your code pieces so I can learn these, that would be very helpful

Thank you
__________________
  #5   Spotlight this post!  
Unread 01-10-2005, 08:51 PM
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

Please provide an email address to which we can send the code examples.

Thanks.
  #6   Spotlight this post!  
Unread 01-10-2005, 08:59 PM
Happy Birthday! doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: State Machines

doyler@ncssm.edu
__________________
  #7   Spotlight this post!  
Unread 01-10-2005, 09:10 PM
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 : 01-10-2005 at 09:26 PM.
  #8   Spotlight this post!  
Unread 01-11-2005, 12:53 AM
pickle's Avatar
pickle pickle is offline
Talking vegtable
AKA: Jeremy
#1296 (Full Metal Jackets)
Team Role: Programmer
 
Join Date: Apr 2004
Rookie Year: 2004
Location: Rockwall,TX
Posts: 42
pickle is on a distinguished road
Send a message via AIM to pickle
Re: State Machines

also, take a look at some of the code this year, robot.c in the code posted at kevin.org/frc is a great example of state machines
__________________
2004 Rookie Inspiration Award winner - Midwest Regional
2004 Autodesk Visualization Award winner - Lone Star Regional
2004 Quarterfinalist - Lone Star Regional
2005 Team Spirit Award - Lone Star Regional
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OSUFIRST Robotics (ohio state) BillCloyes College Teams 1 05-25-2008 08:19 PM
State Proposals Raven_Writer Chit-Chat 11 11-04-2004 02:44 PM
Tools and machines - fairness Mike Martus OCCRA 0 11-03-2003 10:13 AM
New teams in your state D.J. Fluck General Forum 11 09-29-2002 02:37 PM
Full list of teams & competitions archiver General Forum 14 06-24-2002 12:52 AM


All times are GMT -5. The time now is 02:48 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi