Designing Behavior

Designing Behavior-Based Systems
Objectives


Use schema theory to design and program
behaviors
Design a complete behavioral system


Understand how to develop a “behavioral table”
for behaviors
Understand how to sequence behaviors
Objectives


Use schema theory to design and program
behaviors
Design a complete behavioral system


Understand how to develop a “behavioral table”
for behaviors
Understand how to sequence behaviors
Designing Behaviors

Issues:



More “art” than “science”
How to build up to integrated systems?
Approaches:


View behaviors as objects in object-oriented
programming (OOP)
Sequence behaviors using:


Finite state automata
Scripts
Behaviors as Objects in OOP



Object-Oriented Programming: data-centered view of
programming
Schema theory is well suited for transferring theoretical
concepts to OOP
An object consists of:



A Schema contains:



Data (attributes)
Methods (operations)
Knowledge of how to act and/or perceive (knowledge, data
structures, models)
Computational process (the algorithms)
Following Arbib, a schema as a programming object will be a
class
Behaviors as Objects in OOP

Coordinated control program:


Perceptual schema:



Has at least one method, which takes sensor input and transforms it into a data
structure, called a percept
Linked to sensor(s)
Motor schema:



A function that coordinates any methods or schemas in the derived class
Has at least one method, which transforms percept into a vector representing an
action
Linked to actuator(s)
Behaviors are composed of at least one perceptual schema and one motor
schema
Primitive vs. Abstract Behaviors

Primitive behaviors:





Only one perceptual schema
Only one motor schema
No need for coordinated control
Usually programmed as single method
Abstract behaviors:


Behaviors that are assembled from other behaviors or have
multiple perceptual schema and motor schema
Since they are farther removed from the sensors and
actuators than a primitive behavior
Example: Pick Up the Trash

1994 AAAI Mobile Robot Competition:




Robot is placed in an empty arena about the size
of an office
Coca-Cola cans (red) and white Styrofoam cups
at random locations
Blue recycling bin in two corners; two trash bin
with a different color in the other two corners
The winner robot is the one who picks up the
most trash and placed them in the correct bin
Example Primitive Behavior: Move_to_goal

Rather than write:



Instead, write a single generic behavior:


Move_to_red
Move_to_blue
Move_to_goal(color)
Minimizes opportunity for introducing
multiple bugs
Move_to_goal as Primitive Behavior
how to calculate goal_angle
and goal_strength?


“pfields” is a class
“Attraction” is a method within the pfields class
Important Points about Programming with Behaviors

Behavior is the “glue” between perceptual and
motor schemas



Behaviors can (and should) use libraries of schemas


The schemas don’t communicate with each other
Behavior puts “percept” created by perceptual schema in a
local place where the motor schema can get it
E.g., “pfields” class can encapsulate five primitive potential
fields, which any motor schema can use
Behaviors can be reused if written properly

E.g., “go_to_goal” can be reused with different colors
More Complex Example: Follow-Corridor

Two different implementations possible:

First, use primitive potential fields as motor schemas
An Abstract Follow-Corridor Behavior
find-walls will examine the sonar polar plot and extract the
relative location of the corridor walls and return the
distance to the left wall and the right wall.
Second Implementation: Summation of Behaviors

Here, follow corridor composed of two instances of follow wall
behavior
Objectives


Use schema theory to design and program
behaviors
Design a complete behavioral system


Understand how to develop a “behavioral table”
for behaviors
Understand how to sequence behaviors
Steps in Designing a Reactive Behavioral System
Case Study: 1994 Unmanned Ground
Robotics Competition


Objective: have small unmanned
vehicle autonomously navigate
around an outdoor course of white
lines painted on grass
Step 1: Describe the task






Follow path with hairpin turns,
stationary obstacles, and sand pit
Robot that went furthest without
going out of bounds is winner
Tie breaker: robot that goes
fastest
Max. velocity: 5mph
Penalties: for going out of bounds,
for hitting and moving obstacles
3 runs allowed, after 2 days of
practice
10 ft wide lane
Case Study (Con’t.)

Step 2: Describe the robot

Usually: robot provided, which gives fixed
constraints on what is possible



Sensors: only specific sensors available
Effectors: max speed, turning radius
In this case study, additional constraints
specified:

Robot footprint within given size


at least 3ft by 3.5ft but no bigger than a golf cart
Robot carries own power, on-board computing
The Robot
Camcorder on a
Panning mast
Sonar on a panning
mast
33MHz 486 PC running
Lynx (commercial unix)
3 ft wide
Omnibot
Case Study (Con’t.)

Step 3: Describe the environment







Grassy field with gentle slopes
Ten-foot wide lane marked in white paint
Exact length and layout of course not
known in advance
Obstacles were stationary, and were
bales of hay wrapped in white or red
plastic
2x4 ft obstacle that never extended
more than 3 feet into the lane
Sonar could detect hay bales at 8 feet
Run times would be between 9AM and
5PM on May 22, rain or shine



Given the task, the environment and the
robot
Think about how this robot is able to
accomplish its task
What might be the potential problems?
Analysis of the Above

Identify the affordance for controlling the robot


Potential problem?



have the camera pointing directly at one line, instead of trying to see both
lines
reduction in the signal to noise ratio
Have to use computer vision



lighting value of the white line changed with the weather
Solution?


white line, which should have a high contrast to the green grass
White should be in the center of the image
Reflections on grass are white, but random, so average out
If stay in the middle, never encounter any obstacle

10-foot wide lane, 2x4 ft obstacle that never extended more than 3 feet
into the lane
Case Study (Con’t.)

Step 4: Describe how the robot should act in
response to its environment



Define candidate primitive behaviors
In case study: follow-line
Helpful: Behavior Table
Behavior Table

Helpful organizing tool
• stay-on-path is reflexive (stimulus-response) and
taxis (it orients the robot relative to the stimulus)
• compute-centroid: extracts an affordance of the
centroid of white from the image as being the line
Case Study (Con’t.)

Step 5: Refine each behavior:


Focus on design of each individual behavior
Consider:



Example: follow-line()


Both normal range of environmental conditions
And conditions in which behavior will fail
Bales of hay are bright compared to grass, change the
centroid to cause collision
Refinement:

Follow line until “see” an obstacle, then just go straight
until things return to normal

Sonar! Look to the side and when something is close, it’s a
bale, so go straight
Oops

In case study:

Follow-line behavior analysis assumed only white things in
environment were lines and plastic bales of hay

Other white objects: judges shoes, dandelions, etc.
Case Study (Con’t.)

Step 6: Test each behavior independently



Helpful to use simulation
Keep in mind that simulators do not usually
incorporate accurate models of the robot’s
perceptual abilities
Often, only way to verify perceptual schema is to
try it in real world
Case Study (Con’t.)

Step 7: Test with other behaviors



Integration testing, where behaviors are combined
Testing in actual environment
In case study:



Follow_line fooled by hay bales
Perceptual schema included bright pixels from the hay bales
Solution: “close robot eyes” for about 2 seconds if hay bale
nearby (detected by sonar)
Finally, $5K

Round 1


Round 2


OOPS: sonar connection
off so it hit the bale
White shoes and
dandelions, plus Killer Bale
Round 3

Trapped by sand, but $5K
richer!
Some Important Points

Let the world be its own best representation




“line” wasn’t a line, but just centroid of brightest pixels in
the image
Design process was iterative; rarely get a workable
emergent behavior on the first try
There is no single right answer
Could have been done with subsumption, pfields,
rules, whatever
Assemblages of Behaviors



Many applications: require some concurrent behaviors and
some behaviors in sequence
Question: How to formally represent the releasers so that the
robot execute the behaviors correctly, and so that the human
designer can understand what is going on?
Three common methods for behavior sequencing:




Finite state automata (FSA)
Scripts
Skills
Key concept: make world trigger, or release, the next step in
the sequence, rather than on an internal model of what the
robot has done recently
Recall: FSA Sequencing of Motor Schemas

Can sequence motor schemas if one activity
needs to be completed before another
Example FSA for Our Case Study
Summary

Describe the task
Describe the robot
Describe the environment
Describe how the robot should act in
response to its environment
Refine each behavior
Test each behavior independently
Test with other behaviors

Repeat as needed






Midterm Study Guide
In-Class Team Design



Form a group of 2
Project: design a driverless golf cart running on
campus, for example, bring a guest from one
building to another building
Design the behavior-based system for the project
above

Should at least complete the first four steps