Sie sind auf Seite 1von 9

Design of the Control Strategy

System
Dynamics
Environmental Disturbances
Control
Strategy
Goal Output
Feedback
Sensors
Linebot Control Strategy
System
Dynamics
Environmental Disturbances
motion_control
Goal Output
Feedback
decision
Task decision() monitors the sensors and issues a control signal
dir to task motion_control(). The signal dir is a code -1,0,1,2 to
represent turn left, go straight, turn right, or stop. Task
motion_control() issues the steering commands to the bot.
Design of the Control Strategy
System
Dynamics
Environmental Disturbances
Goal2
Output
feedback
navigate
line_follow
Goal1
Goal 1: Follow the line
Goal 2: Navigate to desired position
Task Structure
line_follow() This is the old
motion_control used in linebot to control
the lateral line-following motion.
navigate() a new task that takes over at
an intersection. It decides which way to
turn and executes the motion control to
effect turning.
feedback() is the old decision() task. It
measures the sensors and changes the
dir variable.
Task Structure Continued
The tasks navigate and line_follow
cannot function at the same time. If
task feedback signals that the bot has
reached an intersection, line_follow
must be stopped and navigate must be
started.

Variables
What variables do we need? We already
have one which we called dir-- it is issued by
feedback() which assigns values to indicate:
turn right, turn left, go straight, and at an
intersection.
The master control is issuing a command to
go to some final destination. This must be
kept as a variable.
What intersection are we at? Our decision to
turn right or left at an intersection depends
upon: Where we are and Where we want to
go.

Navigation Strategy
Suppose we can count the
intersections.
Depending upon the intersection
number, certain destinations will only be
achieved if we turn right, others if we
turn left.
We could use a bunch of if statements
to branch to the decision rules for each
intersection, or we could use a switch
control structure.

The switch control structure
switch(x)
{
case 1:
// do something when x is 1
break;
case 2:
// do something when x is 2
break;
case 3:
// do something else when x is 3
break;
default:
// do this when x is not 1,2,or 3
break ;
}

This is equivalent to the following
if statements
//put default statement if x is not 1,2, or 3
if(x==1) //add statement executed when x is 1
if(x==2) //add statement executed when x is 2
if(x==3) //add statement executed when x is 3

Das könnte Ihnen auch gefallen