![]() |
|
|
|
|
|
|
|
|
|
Co-Processor Subsumption Engine Programming |
|
|
|
<= A basic Subsumption Engine Now that you have seen the basics of a Subsumption Engine and Finite State Machine (FSM) programming, you are ready to see how our Co-Processor's Subsumption Engine is structured and how to program it. Let's start with a general example of subsumption programming taken from the ramping servo example. It has been enhanced with more levels of behavior. The level names correspond to those in our Co-Processor's Subsumption Engine. Would you want to run this code? Probably not. It is shown and documented here so you know what Libby's Subsumption Engine means. This is a partial set of the code that is in our Co-Processor already. It is only waiting for you to enable it. Now you know what you are enabling when you turn it on. Your Stamp is then free to do other tasks. <= Do it in the Stamp. If you want to run your own Subsumption Engine in the BASIC Stamp®, that example code probably isn't the best way. Notice in the example program, the loop was timed and the 5 ms PAUSE was there to keep things timed to 20 ms for the duration counters to stay right. If you change the Stamp processor speed, the Baud rate, or even add more routines to run, the execution time changes so the PAUSE has to be changed correspondingly. That is the way it is usually done in a Stamp robot but this is where some of the uglier parts of programming are showing! Since you have the Co-Processor, the Stamp code should use a few of the 8 timers rather than counting down durations in the Stamp. That has the added, and very significant, advantage of no longer requiring the Stamp code to be locked to a 20 ms cycle. The Co-Processor keeps the duration counters consistent and accurate while you concentrate on programming added behaviors in the Stamp. <= What are those "extra" levels for? Real power also comes in the unassigned levels. Level 1 lets you subsume the random behavior. If you want to always try to go straight unless higher behaviors (IRPD vision, level 3, bumper, level 5) overrule it, write the Dir = Forward (fd is 5) value into Level 1. You can use one of the Co-Processor timers to warn you to update the duration value before it gets counted down to zero. This gives the robot a "persistent attitude" in its behavior. Notice Level 3 is above IRPD but below the bumpers. More vision type devices like SONAR or distance measuring IR devices would naturally go here. Level 5 is the highest priority. It would work well for more bumpers - like on the sides and back of the robot. And how about some down- looking sensors to make sure you don't unexpectedly visit the bottom of the stairs! These levels give you total control over the final Subsumption Engine behavior without having to duplicate all the code in the Stamp processor. If you have 2 behaviors to put into one level, simply run the behaviors as 2 Stamp subroutines and write the output directions from each to the same variable. Send that variable's value to the level you want to control from both. Last one to run is the higher priority. Hey, even more Subsumption! <= How do I start Subsumption running in the Co-Processor? It's easy! Here is a text file with example commented code. <= Back to Tech Center <= Back to Co-Processor page |
Blue Bell Design Inc. Post Office Box 446 Gwynedd Valley, PA 19437-0446 USA 215-643-7012 email us harry@bluebelldesign.com on the web www.bluebelldesign.com BASIC Stamp® is a registered trademark of Parallax, Inc. |