To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 290
289  |  291
Subject: 
Re: Implementing Finite State Machines
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Sat, 11 Dec 1999 06:40:44 GMT
Viewed: 
1799 times
  
In article <MPG.12bb8cedfe9ebeeb9896be@lugnet.com>, tking@together.net wrote:

Vlad, The Finite State Machine is a good subject for
people to consider in robotics, especially in
coding the typical 'looping forever' Rcx applications.

Lots of regular 'C' FSM's are implemented with a State
variable and "switch" statements, or CASE in Pascal. The
PIC microcomputers have a 'computed goto table' approach that
lends itself easily to FSMs.

Long ago, I used some macro libraries to help build FSMs in
'C'.  Don't think I still have any of that stuff. I had someone write
a graphically-based system that generated 'C' also, but that must
be buried at my previous employer.  Hmmm..  I think the best thing right
now would be some simple examples.  Dave, have you thought about this??


Adding a switch statement to NQC would certainly help make implementation
easier...I'll see if I can work it into the next release.

Actually, I've been somewhat surprised by the general lack of needing FSMs
in my own Mindstorms programming.  I think part of this is due to the fact
that multithreaded execution is built in, thus provides a different
alternative to solving some (not all) of the problems typically
implemented in FSMs.  For example, consider the case where event A causes
a steady progression through a number of states, and event B casues the
entire sequence to abort.  Using and FSM, you'd have a series of states
that are chained together with event A, and a transition on event B from
any state to the initial state (with a reset action).

With tasks, you make a single task go through the sequence - synchronously
waiting for event A between each step.  A separate task waits for B, and
then resets the first task.

I know I'm over-simplifying here, but I think its interesting that having
multi-task as a built-in feature can lead to different programming
paradigms.  A similar thing happened in Java.  They completely avoided
async I/O calls and rely completely on sync I/O and a heavily
multi-threaded execution model.

Sorry to go off on a tangent like this, but I personally think these are
the sorts of things that need to get taught...show how to solve a problem
with FSM.  Show how to solve it with threads.  Teach people that there's
often no single right solution and they must understand tradeoffs and make
their own decisions.

Back in college I took a CS course based entirely in Scheme.  It was
somewhat eye-openeing because up until then I used iteration exclusively.
Of course, everything for the class was done using recursion.  Although I
still think iteration is a simpler concept to explain, being forced to use
recursion - not just for the "hard" problems but also the "simple" ones -
gave me a much deeper understanding of it.  Normally iteration is easy to
implement and recursion tough.  But given a system that had very good
support for recursion and minimal interative support, all problems became
recursive ones.  I think this parallels the FSM case a bit.

Dave Baum

--
reply to: dbaum at enteract dot com



Message has 1 Reply:
  Re: Implementing Finite State Machines
 
Dave, I like the idea of teaching how to solve certain problems both with multiple threads and with a Finite State Machine. Adding "switch" would be great! Personally I think that a plain 'C' FSM using switch can be made to look very clear if (...) (25 years ago, 12-Dec-99, to lugnet.robotics.rcx.nqc)

Message is in Reply To:
  Re: Implementing Finite State Machines
 
Vlad, The Finite State Machine is a good subject for people to consider in robotics, especially in coding the typical 'looping forever' Rcx applications. Lots of regular 'C' FSM's are implemented with a State variable and "switch" statements, or (...) (25 years ago, 11-Dec-99, to lugnet.robotics.rcx.nqc)

5 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR