Control - PowerPoint PPT Presentation

About This Presentation
Title:

Control

Description:

Control Some Material taken from RobotSubsumption.pdf * * * * * * * * Remember Where Are We Going? Sumo-Bot competitions Controlling Robot Movement Based on QTI (or ... – PowerPoint PPT presentation

Number of Views:70
Avg rating:3.0/5.0
Slides: 21
Provided by: Comput269
Learn more at: https://www.cs.unca.edu
Category:
Tags: control | sumo

less

Transcript and Presenter's Notes

Title: Control


1
Control
  • Some Material taken from RobotSubsumption.pdf

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

4
Code
  • ' ----- Subroutine - Test_Light --------------
  • Test_Light
  • HIGH 3 ' activate Left QTI sensor
  • HIGH 2
  • PAUSE 1
  • RCTIME 2, 1, timeLeft
  • LOW 3 deactivate sensor
  • HIGH 7 ' activate right QTI sensor
  • HIGH 6
  • PAUSE 1
  • RCTIME 6, 1, timeRight
  • LOW 7 deactivate sensor

5
Code
  • ' ----- Subroutine - Navigate to avoid light
    -------------
  • Navigate
  • IF (timeLeft lt LeftThreshold) AND
  • (timeRight lt RightThreshold) THEN
  • PULSOUT 13, 650 go backwards
  • PULSOUT 12, 850
  • ELSEIF (timeLeft lt LeftThreshold) THEN
  • PULSOUT 13, 800 go right
  • PULSOUT 12, 600
  • ELSEIF (timeRight lt RightThreshold) THEN
  • PULSOUT 13, 600 go left
  • PULSOUT 12, 800
  • ELSE
  • PULSOUT 13, 850 go forwards
  • 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
Measurement
  • ' STAMP BS2
  • ' PBASIC 2.5
  • ' ----- Pins -----------------------------------
  • Trigger PIN 0
  • Echo PIN 1
  • ' ----- Variables -----------------------------
  • samples VAR Nib ' loop counter
  • pWidth VAR Word ' pulse width sonic
    sensor
  • rawDist VAR Word ' filtered distance
  • cm VAR Word
  • inches VAR Word
  • irDetectLeft VAR Bit
  • irDetectRight VAR Bit
  • pulseCount VAR Byte
  • ' ----- Constants ------------------------------
    -----
  • Trig10 CON 5 ' trigger pulse 10 uS

8
Code
  • ' ----- Main Routine ---------------------------
    --------
  • DO
  • GOSUB Read_IR
  • GOSUB Read_Sonar
  • IF (sonarForward 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 IN3
  • RETURN
  • Read_Sonar
  • rawDist 0
  • FOR samples 1 TO 5 ' take five
    samples
  • PULSOUT Trigger, Trig10 ' 10 uS trigger
    pulse
  • PULSIN Echo, 1, pWidth ' measure pulse
  • rawDist rawDist (pWidth / 5)
  • PAUSE 10
  • NEXT
  • IF ( ((rawDist / ToCm) / 03EF) ) lt 36 THEN
  • sonarForward 0
  • ELSE sonarForward 1 ENDIF

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

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

12
Finite State Machine (FSM) Representation
13
How to Put It Together?
No Obj
Obj left
Obj right
Obj forward
Read IR sonar
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
  • Never detect opponent
  • 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

16
FSM
17
Alternative FSM
Go forward
turn left
turn right
go forward
18
Program High-Level Outline
  • Declare pin assignments, constants and variables
  • Initialize thresholds
  • Wait the required start delay
  • Read boundary line sensors and move accordingly
  • If the boundary line is not detected, read
    proximity sensors and move accordingly
  • Repeat steps 4 and 5 until completion

19
Main Loop
  • Do
  • GOSUB Read_Line_Sensors
  • IF (lightLeft lt leftThresh) AND (lightRight lt
    rightThresh) THEN
  • GOSUB About_Face '
    boundary ahead
  • ELSEIF (lightLeft lt leftThresh) THEN
  • GOSUB Spin_Right
    ' boundary to left
  • ELSEIF (lightRight lt rightThresh) THEN
  • GOSUB Spin_Left
    ' boundary to right
  • ELSE
  • PULSOUT LMotor, LFwdFast
  • PULSOUT RMotor, RFwdFast
  • GOSUB Search_For_Opponent
  • ENDIF
  • Loop

20
Possible Enhancements
  • Optimize the position of the sensors
  • Optimize your mechanical design for fighting
  • Consider using lego components including motors
  • Design against being pushed out of the ring
  • Optimize the code to maximize bot performance
  • Evaluate tradeoffs in movement choices and sensor
    reading
  • Optimize the programming constructs that you use
    to increase processing speed
  • BRANCH value, (Case_0, Case_1, Case_2)
  • LOOKUP Index, (Value0, Value1, ...ValueN),
    Variable
  • LOOKDOWN Target, ComparisonOp Value0, Value1,
    ...ValueN, Variable
Write a Comment
User Comments (0)
About PowerShow.com