title.jpg (20464 bytes)

Cybert Menu:        

 buttblue.jpg (750 bytes) Main Menu
Return to the Main Menu.
 buttblue.jpg (750 bytes) Cybert Home
The Cybert Homepage.
 buttblue.jpg (750 bytes) Project Log
Follow Cybert's progress.
 buttblue.jpg (750 bytes) Project Goals
Read about my project goals.
 buttblue.jpg (750 bytes) Gallery
Enjoy some pictures and movies of Cybert!
 buttblue.jpg (750 bytes) Cybert Programming
Read about Cybert's low level and high level code.
 buttblue.jpg (750 bytes) Reports
Study reports about Cybert's creation and programming.

Hit Counter
Hits since November 4, 2000

Report: Creating Behaviors
Updated 1/3/01

A Little Trick
It probably seems fairly easy to layfolk, but programming a robot to wander around a room without bumping things is very tricky.  I used to get frustrated by it, and a little depressed because it just didn't seem like there was that much I could do with only a couple of motors and a few sensors.   I knew I could program the robot to move towards a light, or stop and change direction if an object was detected or bumped, but I figured that was extent of my options.

Then I came up with a little trick that has helped me think of a host of human-like behaviors: I pretend I'm the robot! Since Cybert has a light sensor, a sound sensor, virtual bump sensors, and a range-finding sensor that can detect objects up to 3 feet away, I simply imagine that I'm in an unknown place, I have a light piece of cloth over my eyes, I'm wearing earphones, and I have a 3 foot stick that I can poke straight out in front of me to "feel" if anything is in my path.  Then I think, "Okay, what would I do?"

Suddenly, my behavioral options didn't seem so limited and  I started thinking of lots of new ways to program Cybert to act intelligently.  Here are a couple of robot behaviors that I hadn't really thought about before:

  1. Before going through a doorway I used the stick to find the left and right edge.  Then I went through the "middle" of the opening.  (Finding the left and right edge "X" distance apart also confirmed that I was at a doorway.)

  2. I slowed down when I was uncertain about my position.

  3. The changes in light and sound level really helped me figure out my location.

  4. I used the stick to "measure" obstacles.

  5. It was pretty easy to find walls and orient myself perpendicular to them.

  6. There are lots of things I know about human living environments and this knowledge helped me navigate. (Doorways are "X" inches wide, and generally run perpendicular to hallways, which are "X" inches wide.)

  7. There is a (subtle) sound change when I move from carpet to hardwood.

  8. Doorways and floor transitions (carpet to hardwood, for example) were the best "checkpoints".  

Controlling Cybert's Behavior
I've spent a lot of time thinking about a behavioral control scheme for Cybert, and on more than one occasion this task has made me question my true motives for working on this project.

LilBehave.jpg (10678 bytes)

My original plan was to "hard code" Cybert to be a semi-useful, semi-entertaining, electronic device. As a professional computer game designer I usually don't have time to apply scientific methodologies to AI and other game features. Most game developers can't afford to create a "thinking" opponent when it is quicker and cheaper to simulate one (often with a simple random number generator). So I planned to write code to make it appear that Cybert was learning and reacting to his environment.

But with increasing frequency over the past few months I've been dissatisfied with the scripted approach. I don't want Cybert to simply "run programs". I want him to change and adapt, and do unpredictable things that even I am surprised about. I want to experiment with artificial life.

I've spent several weeks researching this subject. I looked at neural nets, fuzzy logic, genetic programming, and more; and I tried to figure out how to incorporate these into a subsumptive control scheme. Every time I settled on an approach, however, something more interesting came along. Eventually, I realized that I was in way over my head, and that if I didn't start simple I would never get started at all.  This is what lead me to the preliminary concept outlined below:   

Behavior Types
Cybert's behaviors will be comprised of the following elements:  (listed in order of evaluation)

  • Reflexes
    Cybert will need to react to his environment.  This is the highest priority behavior.  The following events will trigger a reflex action: a nearby object in his path, bumping into something, a sudden change in light intensity, a mood change from unhappy to sad, etc.
     
  • Tasks
    These are individual assignments that make up Cybert's "plans" (see below).  These simple behaviors can usually be resolved without state changes.   In other words, tasks don't generally require multiple steps.  Most will check a status condition, exit if it is met, and perform a simple action if it isn't.   Examples of tasks include: telling the time (requires only one pass through the routine), or rotating to a particular direction.
     
  • Plans
    Plans will need to be a type of FSM (finite state machine), where each state change initiates a different task.  The first time through the loop the plan will be in state #1, hence task 1 will be initiated.  When it is completed, control will return to the Plan and now state #2 will start a different task.  Plan examples include:  find people, play game, explore, etc.

Main Control Program
This routine is the heart of the controller. It's first job is to check for "Reflex Triggers" such as bumper hits, nearby objects, loud sounds, being stuck, etc.  Every time a condition is met this routine sets the appropriate Reflex flag and records the time and other relevant data.  (The time is used to check for "timeouts", and the other data is used for comparisons.  See example below for more information.)
 
Next, it checks the status of all the Reflex flags, throws out those that have timed out (that's why I record the time when a reflex is triggered), and sorts the list by priority.  Priorities will initially be set by me, but I'd like to give Cybert the ability to modify these in response to feedback and other factors. The highest priority task is then called.

Here is some pseudo code to illustrate:

Check for Reflex Triggers
     if found, set flag for appropriate reflex routine and record time and other data
Check Reflex Flags and Goto Routine with Highest Priority
     (make sure routine hasn't timed out)

     if reflex is finished then clear flag
     Exit
If there are No Reflexes then
     Goto 'CurrentTask'
     Exit
If there are no Tasks then
     Goto 'CurrentPlan'
     Exit
If there are no Plans then Goto 'ChoosePlan'

So let's say that Cybert is exploring and he's moving across the room looking for a brighter location.  Suddenly, a nearby object appears on his left sonar, triggering his 'AvoidObjectLeft' reflex. Cybert sets the 'ObjectLeftFlag' to true, records the time, and records his current direction. This is the only trigger and the Main Control Program falls through and begins to check the Reflex Flags.  Since there is only one and it hasn't timed out, the 'AvoidObjectLeft' routine is called.  It checks to see if Cybert's current orientation is 45 degrees, or greater, from the recorded orientation.  If not, it instructs the robot to rotate in the correct direction and then the routine exits. If the condition has been met, the Reflex flag is cleared along with the time and other data.

Now let's say that midway through the reflex above, Cybert's 'SuddenLoudSound' flag is triggered.  This has a higher  priority than avoiding the nearby object so the 'ReactLoudSound' routine gets called.  Cybert stops, makes a mood-based comment, then the flag is cleared.  Now Cybert continues with his earlier reflex.  (Note that if the robot had been reacting to a bump, which has the highest priority, he would have ignored the sound until he was out of danger.   Sound reflexes time out very quickly, so if it took Cybert more than a second to finish his avoidance reflex he probably would not have reacted to the sound at all, though it might still have affected his comfort variable.  (See the "Mood Matrix" report.)

Choose Plan Routine
When Cybert completes a plan, and assuming that he isn't reacting to something, his Main Control Program will fall through to the "ChoosePlan" routine.  I haven't figured out all the details yet, but my current idea is to assign variable "weights" to all of Cybert's activities (based on his mood and other factors), possibly throw in a random element, and then choose the highest ranking plan.  If Cybert's "comfort" level is very low, he will be more likely to choose a plan that has proven, in the past, to increase his comfort.  Conversely, if he is in a "playful" mood he will be much more likely to explore or play a game.

Preliminary List of Behaviors
Here is an early (and therefore incomplete) three column list of possible reflexes, tasks, and plans.

Reflexes: Tasks: Plans:
Trapped (or not moving) MoveTo FindPeople
BumpedLeft RotateTo FindLight
BumpedRight Speak (various) FindSound
BumpedMiddle RotateToBrightest HidePeople
NearbyObject RotateToLoudest HideLight
BatteryLow RotateToBusiest HideSound
ConnectionBad LookForMovement Explore
SuddenLoudSound Sleep Dance
SuddenBrightLight GoTo (ZAP) Play[Game]
HappinessChange ToggleInput DeliverMail (to human)
ComfortChange Talk (various) DeliverNews (to human)
NewMail ReturnToCharger (ZAP) DeliverWeather (to human)
Random (???) ReadMail DeliverStocks (to human)
  ReadNews DeliverJoke (to human)
  ReadWeather  
  ReadStocks  
  ReadJoke  

 


Copyright 1999-2000, John Cutter.
For feedback, problems, questions, or to share your own stories or ideas, please contact john@home-robot.com.
Last updated: October 25, 1999.