Control - PowerPoint PPT Presentation

About This Presentation
Title:

Control

Description:

Sumo-Bot competitions. Controlling Robot Movement Based on Photo-Resistor Readings ' ... IF (timeLeft LeftThreshold) AND (timeRight RightThreshold) THEN ... – PowerPoint PPT presentation

Number of Views:75
Avg rating:3.0/5.0
Slides: 22
Provided by: scie189
Learn more at: https://www.cs.unca.edu
Category:

less

Transcript and Presenter's Notes

Title: Control


1
Control
  • Material taken from RobotSubsumption.pdf and
    SumoBot Mini-Sumo Robotics

2
Remember Where Are We Going?
Sumo-Bot competitions
3
Controlling Robot Movement Based on
Photo-Resistor Readings
  • ' ----- Constants ------------------------------
    ---------
  • LeftDark CON 108
  • RightDark CON 114
  • LeftWhite CON 20
  • RightWhite CON 22
  • ' Average Scale factor
  • LeftThreshold CON LeftWhite LeftDark / 2
  • RightThreshold CON RightWhite RightDark / 2
  • ' ----- Variables ------------------------------
    ----------
  • timeLeft VAR Word
  • timeRight VAR Word
  • ' ----- Main Routine ---------------------------
    ---------
  • DO
  • GOSUB Test_Photoresistors
  • GOSUB Navigate
  • LOOP

4
Code
  • ' ----- Subroutine - Test_Photoresistors
    --------------
  • Test_Photoresistors
  • HIGH 6 ' Left RC time measurement.
  • PAUSE 3
  • RCTIME 6,1,timeLeft
  • HIGH 3 ' Right RC time measurement.
  • PAUSE 3
  • RCTIME 3,1,timeRight
  • RETURN

5
Code
  • ' ----- Subroutine - Navigate ------------------
    --------
  • Navigate
  • IF (timeLeft lt LeftThreshold) AND (timeRight lt
    RightThreshold) THEN
  • PULSOUT 13, 650
  • PULSOUT 12, 850
  • ELSEIF (timeLeft lt LeftThreshold) THEN
  • PULSOUT 13, 800
  • PULSOUT 12, 600
  • ELSEIF (timeRight lt RightThreshold) THEN
  • PULSOUT 13, 600
  • PULSOUT 12, 800
  • ELSE
  • PULSOUT 13, 850
  • PULSOUT 12, 650
  • ENDIF
  • PAUSE 20
  • RETURN

6
Finite State Machine (FSM) Representation
both high
left low
right low
both low
7
Controlling Robot Movement Based on Proximity
  • ' STAMP BS2
  • ' PBASIC 2.5
  • ' ----- Variables ------------------------------
    -----
  • irDetectLeft VAR Bit
  • irDetectRight VAR Bit
  • pulseCount VAR Byte

8
Code
  • ' ----- Main Routine ---------------------------
    --------
  • DO
  • GOSUB Read_IR
  • IF (irDetectLeft 0) AND (irDetectRight 0)
    THEN
  • GOSUB Forward_Pulse
  • ELSEIF (irDetectLeft 0) THEN
  • GOSUB Turn_Left
  • ELSEIF (irDetectRight 0) THEN
  • GOSUB Turn_Right
  • ELSE
  • GOSUB Forward_Pulse
  • ENDIF
  • LOOP

9
Code
  • ' ----- Subroutines ----------------------------
    ---------
  • Read_IR
  • FREQOUT 8, 1, 38500
  • irDetectLeft IN9
  • FREQOUT 2, 1, 38500
  • irDetectRight IN0

10
Code
  • ' ----- Subroutines ----------------------------
    ----------
  • Forward_Pulse
  • PULSOUT 13, 850
  • PULSOUT 12, 650
  • PAUSE 20
  • RETURN
  • Turn_Left
  • PULSOUT 13, 650
  • PULSOUT 12, 650
  • PAUSE 20
  • RETURN

11
Code
  • ' ----- Subroutines ----------------------------
    ----------
  • Turn_Right
  • PULSOUT 13, 850
  • PULSOUT 12, 850
  • PAUSE 20
  • RETURN
  • Back_Up
  • PULSOUT 13, 650
  • PULSOUT 12, 850
  • PAUSE 20
  • RETURN

12
Finite State Machine (FSM) Representation
13
How to Put It Together?
No Obj
Obj left
Obj right
Obj forward
Read IR
Go forward
turn left
turn right
go forward
both high
left low
right low
both low
14
Possible Problems
  • Jerky or halting movement
  • Chase object over boundary
  • More?

15
Possible Solution
  • Subsumption Architecture
  • A programming process by which one behavior
    subsumes, or over-rides another based on an
    explicit priority that we have defined. First
    described by Dr. Rodney Brooks in "A robust
    layered control system for a mobile robot, IEEE
    Journal of Robotics and Automation., RA-2, April,
    14-23, 1986.
  • FSM with exit conditions
  • Optimize PBasic control commands

16
FSM
17
Alternative FSM
Go forward
turn left
turn right
go forward
18
New PBasic Control Commands
  • BRANCH value, (Case_0, Case_1, Case_2)
  • is equivalent to
  • Test_Value
  • IF (value 0) THEN Case_0
  • ' value 0 go to label "Case_0"
  • IF (value 1) THEN Case_1
  • ' value 1 go to label "Case_1"
  • IF (value 2) THEN Case_2
  • ' value 2 go to label "Case_2"

19
New PBasic Control Commands
  • LOOKUP Index, (Value0, Value1, ...ValueN),
    Variable
  • Find the value at location Index and store it
    in Variable. If Index exceeds the highest index
    value of the items in the list, Variable is left
    unaffected.
  • LOOKDOWN Target, ComparisonOp Value0, Value1,
    ...ValueN, Variable
  • Compare Target value to a list of values and
    store the index number of the first value that
    matches into Variable. If no value in the list
    matches, Variable is left unaffected. The
    optional ComparisonOp is used as criteria for the
    match the default criteria is "equal to."

20
The Implementation
  • lineBits VAR Nib
  • lineLeft VAR lineBits.Bit1
  • lineRight VAR lineBits.Bit0
  • Main
  • GOSUB Read_Line_Sensors
  • BRANCH lineBits, Search_For_Opponent,
    Spin_Left, Spin_Right, About_Face
  • Read_Line_Sensors
  • HIGH LLineSnsIn
  • HIGH RLineSnsIn
  • PAUSE 10
  • RCTIME LLineSnsIn, 1, leftSense
  • RCTIME RLineSnsIn, 1, rightSense
  • ' convert readings to bits
  • lineBits 00
  • LOOKDOWN leftSense, gtblackThresh, 0,
    lineLeft
  • LOOKDOWN rightSense, gtblackThresh, 0,
    lineRight

21
A Bit More Complicated
  • Search_For_Opponent
  • GOSUB Read_IR_Sensors
  • ' If opponent is not in view, scan last known
    direction. Turn toward
  • ' opponent if seen by one "eye" -- if both,
    lunge forward
  • BRANCH irBits, Scan, Follow_Right,
    Follow_Left, Lunge
  • Scan
  • BRANCH lastIR, Move_Fwd, Scan_Right,
    Scan_Left
  • Lunge '
    locked on -- go get him!
  • FOR pulses 1 TO 15
  • PULSOUT LMotor, LFwdFast
  • PULSOUT RMotor, RFwdFast
  • GOSUB Read_Line_Sensors
  • IF (lineBits 11) THEN Match_Over
  • ' in sight and we're on the line
  • NEXT
  • GOTO Main
Write a Comment
User Comments (0)
About PowerShow.com