control

20
Control Some Material taken from RobotSubsumption.pdf

Upload: adara

Post on 04-Jan-2016

30 views

Category:

Documents


0 download

DESCRIPTION

Control. Some Material taken from RobotSubsumption.pdf. Remember Where Are We Going?. Sumo-Bot competitions. Controlling Robot Movement Based on Photo-Resistor Readings. ' -----[ Constants ]--------------------------------------- LeftDark CON 108 RightDark CON 114 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Control

Control

Some Material taken from RobotSubsumption.pdf

Page 2: Control

Remember Where Are We Going?

Sumo-Bot competitions

Page 3: Control

Controlling Robot Movement Based on Photo-Resistor Readings' -----[ Constants ]---------------------------------------LeftDark CON 108RightDark CON 114LeftWhite CON 20RightWhite CON 22' Average light sensor valueLeftThreshold CON LeftWhite + LeftDark / 2 RightThreshold CON RightWhite + RightDark / 2 ' -----[ Variables ]----------------------------------------timeLeft VAR WordtimeRight VAR Word' -----[ Main Routine ]------------------------------------DO GOSUB Test_Photoresistors GOSUB NavigateLOOP

Page 4: Control

Code' -----[ Subroutine - Test_Photoresistors ]--------------Test_Photoresistors: HIGH 6 ' Left RC time measurement. PAUSE 5 RCTIME 6, 1, timeLeft HIGH 3 ' Right RC time measurement. PAUSE 5 RCTIME 3, 1, timeRightRETURN

Page 5: Control

Code' -----[ Subroutine - Navigate to avoid light ]-------------Navigate: IF (timeLeft < LeftThreshold) AND (timeRight <

RightThreshold) THEN PULSOUT 13, 650 ‘ go backwards PULSOUT 12, 850 ELSEIF (timeLeft < LeftThreshold) THEN PULSOUT 13, 800 ‘ go right PULSOUT 12, 600 ELSEIF (timeRight < RightThreshold) THEN PULSOUT 13, 600 ‘ go left PULSOUT 12, 800 ELSE PULSOUT 13, 850 ‘ go forwards PULSOUT 12, 650 ENDIF PAUSE 20 RETURN

Page 6: Control

Finite State Machine (FSM) Representation

Read photo- resistors

backup turn right turn left go forward

both lowright low

left lowboth high

Page 7: Control

Controlling Robot Movement Based on Proximity Measurement' {$STAMP BS2} ' {$PBASIC 2.5}

' -----[ Pins ]-----------------------------------Trigger PIN 0Echo PIN 1

' -----[ Variables ]-----------------------------samples VAR Nib ' loop counterpWidth VAR Word ' pulse width sonic sensorrawDist VAR Word ' filtered distancecm VAR Wordinches VAR WordirDetectLeft VAR BitirDetectRight VAR BitpulseCount VAR Byte

' -----[ Constants ]-----------------------------------Trig10 CON 5 ' trigger pulse = 10 uSToCm CON 30 ' conversion factor to cm

Page 8: Control

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

Page 9: Control

Code' -----[ Subroutines ]-------------------------------------Read_IR: FREQOUT 8, 1, 38500 irDetectLeft = IN9 FREQOUT 2, 1, 38500 irDetectRight = IN3RETURN

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) ) < 36 THEN sonarForward = 0 ELSE sonarForward = 1 ENDIFRETURN

Page 10: Control

Code

' -----[ Subroutines ]--------------------------------------Forward_Pulse: PULSOUT 13, 850 PULSOUT 12, 650RETURN

Turn_Left: PULSOUT 13, 650 PULSOUT 12, 650RETURN

Page 11: Control

Code' -----[ Subroutines ]--------------------------------------Turn_Right: PULSOUT 13, 850 PULSOUT 12, 850RETURN

Back_Up: PULSOUT 13, 650 PULSOUT 12, 850RETURN

Page 12: Control

Finite State Machine (FSM) Representation

Read IR & Sonar

Go forward turn left turn right go forward

Obj forwardObj right

Obj leftNo Obj

Page 13: Control

How to Put It Together?

Read IR& sonar

Go forward turn left turn right go forward

Obj forwardObj right

Obj leftNo Obj

Read photo- resistors

backup turn right turn left go forward

both lowright low

left lowboth high

Page 14: Control

Possible Problems

Jerky or halting movement Chase object over boundary Never detect opponent More?

Page 15: Control

Possible Solution

o Subsumption ArchitectureA 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.

o FSM with exit conditions

Page 16: Control

FSM

read IR & sonarand set nextStatevariable

read Photoresistorsand set nextStatevariable

check nextStatevariable and branch

Go forward

Go backwards

turn teft

turn right

Page 17: Control

Alternative FSM

read Photoresistorsand set nextStatevariable

check nextStatevariable and branch

Read IR Go forward turn left turn right go forward

backup turn right turn left go forward

Page 18: Control

Program High-Level Outline1. Declare pin assignments,

constants and variables2. Initialize thresholds 3. Wait the required start delay4. Read boundary line sensors and

move accordingly5. If the boundary line is not

detected, read proximity sensors and move accordingly

6. Repeat steps 4 and 5 until completion

Page 19: Control

Main LoopDo GOSUB Read_Line_Sensors IF (lightLeft < leftThresh) AND (lightRight < rightThresh)

THEN GOSUB About_Face ' boundary ahead ELSEIF (lightLeft < leftThresh) THEN GOSUB Spin_Right ' boundary to left ELSEIF (lightRight < rightThresh) THEN GOSUB Spin_Left ' boundary to right ELSE PULSOUT LMotor, LFwdFast PULSOUT RMotor, RFwdFast GOSUB Search_For_Opponent ENDIFLoop

Page 20: Control

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