14midterm (2)

Embed Size (px)

Citation preview

  • 8/11/2019 14midterm (2)

    1/9

    Design of the Control Strategy

    System

    Dynamics

    Environmental Disturbances

    Control

    StrategyGoal Output

    Feedback

    Sensors

  • 8/11/2019 14midterm (2)

    2/9

    Linebot Control Strategy

    System

    Dynamics

    Environmental Disturbances

    motion_controlGoal Output

    Feedback

    decision

    Task decision() monitors the sensors and issues a control signal

    dirto 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.

  • 8/11/2019 14midterm (2)

    3/9

    Design of the Control Strategy

    SystemDynamics

    Environmental DisturbancesGoal2

    Output

    feedback

    navigate

    line_follow

    Goal1

    Goal 1: Follow the line

    Goal 2: Navigate to desired position

  • 8/11/2019 14midterm (2)

    4/9

    Task Structure line_follow() This is the old

    motion_control used in linebot to controlthe lateral line-following motion.

    navigate() a new task that takes over at

    an intersection. It decides which way toturn and executes the motion control toeffect turning.

    feedback() is the old decision() task. Itmeasures the sensors and changes thedir variable.

  • 8/11/2019 14midterm (2)

    5/9

    Task Structure Continued The tasks navigate and line_follow

    cannot function at the same time. Iftask feedbacksignals that the bot hasreached an intersection, line_follow

    must be stopped and navigate must bestarted.

  • 8/11/2019 14midterm (2)

    6/9

    Variables

    What variables do we need? We alreadyhave one which we called dir-- it is issued byfeedback() 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 bekept as a variable.

    What intersection are we at? Our decision toturn right or left at an intersection dependsupon: Where we are and Where we want togo.

  • 8/11/2019 14midterm (2)

    7/9

    Navigation Strategy Suppose we can count the

    intersections. Depending upon the intersection

    number, certain destinations will only beachieved if we turn right, others if weturn left.

    We could use a bunch of if statementsto branch to the decision rules for each

    intersection, or we could use a switchcontrol structure.

  • 8/11/2019 14midterm (2)

    8/9

    The switch control structureswitch(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 ;

    }

  • 8/11/2019 14midterm (2)

    9/9

    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