Documente Academic
Documente Profesional
Documente Cultură
Christopher Batten
Maslab IAP Robotics Course
January 7, 2005
Building a control system for
a mobile robot can be very challenging
– Model-Plan-Act Approach
– Behavioral Approach
– Finite State Machine Approach
Model-Plan-Act Approach
Model
Plan
Act
Sensors Actuators
Environment
• Advantages
– Global knowledge in the model enables optimization
• Disadvantages
– Must implement all functional units before any testing
– Computationally intensive
– Requires very good sensor data for accurate models
– Models are inherently an approximation
– Works poorly in dynamic environments
Behavioral Approach
Behavior C
Behavior B
Behavior A
Sensors Actuators
Environment
Ball Gate
Bump Switches
Infrared Rangefinders
Camera
Layering simple behaviors can create
Cruise Motors
Subsumption
Infrared Avoid
Cruise S Motors
Bump Escape
Infrared Avoid S
Cruise S Motors
Bump Escape
Infrared Avoid S
Cruise S S Motors
Ball
Switch Ball
Hold Ball
Gate
Camera Track Ball
Bump Escape
Infrared Avoid S
Cruise S S Motors
Track Goal
Ball
Switch Ball
Hold Ball S
Gate
Camera Track Ball
Bump Escape
Infrared Avoid S
Cruise S S S Motors
Track Goal
Ball
Switch Ball
Hold Ball S
Gate
Camera Track Ball
Bump Escape
Infrared Avoid S
Cruise S S S Motors
• Disadvantages
– Difficult to judge what robot will actually do
Behavior C
Model
Plan
Act
Behavior B
Behavior A
Environment Environment
Model-Plan-Act
Behavioral
(Fixed Plan of Behaviors)
(Layered Behaviors)
Model-plan-act fuses sensor data,
Behavior C
Model
Plan
Act
Behavior B
Behavior A
Environment Environment
Model-Plan-Act Behavioral
(Sensor Fusion) (Behavior Fusion)
Finite State Machines offer another
Fwd
(2ft)
TurnR
(90°)
Fwd
(2ft)
TurnR
(90°)
Fwd
(2ft)
TurnR
(90°)
Fwd
(2ft)
TurnR
(90°)
Fwd
(2ft)
TurnR
(90°)
Fwd
(1ft)
Obstacle
Within 2ft
No
Obstacle
TurnR Closed loop finite state machines use
(45°) sensor data as feedback to make
state transitions
Obstacle
Within 2ft
Finite State Machines offer another
Fwd
(1ft)
Obstacle
Within 2ft
No
Obstacle
TurnR Closed loop finite state machines use
(45°) sensor data as feedback to make
state transitions
Obstacle
Within 2ft
Finite State Machines offer another
Fwd
(1ft)
Obstacle
Within 2ft
No
Obstacle
TurnR Closed loop finite state machines use
(45°) sensor data as feedback to make
state transitions
Obstacle
Within 2ft
Finite State Machines offer another
Fwd
(1ft)
Obstacle
Within 2ft
No
Obstacle
TurnR Closed loop finite state machines use
(45°) sensor data as feedback to make
state transitions
Obstacle
Within 2ft
Finite State Machines offer another
Fwd
(1ft)
Obstacle
Within 2ft
No
Obstacle
TurnR Closed loop finite state machines use
(45°) sensor data as feedback to make
state transitions
Obstacle
Within 2ft
Implementing a // State transitions
switch ( state ) {
FSM in Java case States.Fwd_1 :
if ( distanceToObstacle() < 2 )
No Obstacle state = TurnR_45;
break;
// State outputs
switch ( state ) {
case States.Fwd_1 :
TurnR moveFoward(1); break;
(45°)
case States.TurnR_45 :
turnRight(45); break;
Obstacle
}
Within 2ft
Fwd
Until
Obs
Turn
Can also fold closed loop feedback
To
Open into the behaviors themselves
Simple finite state machine
to locate red balls
Found
Wander Scan
Ball
TurnR
(20sec) 360
No Balls
Lost
Ball
Ball
Align < 1ft
Stop
Ball
Ball
> 1ft
Fwd
(1ft)
Simple finite state machine
to locate red balls
Found
Wander Scan
Ball
TurnR
(20sec) 360
No Balls
Lost
Ball
Ball
Align < 1ft
Stop
Ball
Ball
> 1ft
No Balls
Lost
Ball
Ball
Align < 1ft
Stop
Ball
What if robot Ball
has trouble > 1ft
correctly
approaching
Obstacle < 2ft Fwd
(1ft)
the ball?
To debug a FSM control system
No Balls
Lost
Ball
Ball
Align < 1ft
Stop
Ball
Ball
Independently > 1ft
verify Align
Ball and Fwd
Obstacle < 2ft Fwd
behaviors (1ft)
Improve FSM control system by replacing
No Balls
Lost
Ball
Ball
Align < 1ft
Stop
Ball
– Image processing is
ball = false
time consuming so
turn both motors on
while ( !timeout and !ball )
might not check for
capture and process image
obstacles until too late
if ( red ball ) ball = true
monolithic
endwhile
Multi-threaded
Obstacle Image
Sensors Compute
Thread Thread
Controller
FSM
Drive Motors
Multi-threaded
Obstacle Image
Sensors Compute
Thread Thread
Controller
FSM
Drive Motors
Multi-threaded
Controller
FSM
Drive Motors
Multi-threaded
finite state machine control systems
Short IR Stalk
+ Bump Camera Sensors
Controller
FSM
Mapping
Thread
Drive Motors
FSMs in Maslab
– Model-Plan-Act Approach
– Behavioral Approach
– Finite State Machine Approach
Actual
Desired Controller Motor
Adjusted Velocity
Velocity
Voltage
Step response
with no controller
Velocity
several differential
equations
• Slow rise time
• Stead-state offset
Time (sec)
Step response
Desired Actual
Velocity Controller Motor Velocity
Adjusted (Vact)
(Vdes) Voltage (X)
Velocity
• Big error big = big adj
• Faster rise time
• Overshoot
• Stead-state offset
Time (sec)
Step response
Desired Actual
Velocity Controller Motor Velocity
Adjusted (Vact)
(Vdes) Voltage (X)
de(t )
X = Vdes + K P e(t ) − K D
dt
Velocity
• When approaching desired
velocity quickly, de/dt term
counteracts proportional
term slowing adjustment
• Faster rise time
• Reduces overshoot Time (sec)
Step response
Desired Actual
Velocity Controller Motor Velocity
Adjusted (Vact)
(Vdes) Voltage (X)
Velocity
• Integral term eliminates
accumulated error
• Increases overshoot
Time (sec)
Step response
with PID controller
Desired Actual
Velocity Controller Motor Velocity
Adjusted (Vact)
(Vdes) Voltage (X)
X = Vdes + K P e(t )
Velocity
+ K I ∫ e(t ) dt
de(t )
− KD
dt
Time (sec)
Choosing and tuning
a controller
Desired Actual
Velocity Controller Motor Velocity
Adjusted (Vact)
(Vdes) Voltage (X)
the motors
estimate error