1 / 18

Control

Control. Some Material taken from RobotSubsumption.pdf. Remember Where Are We Going?. Sumo-Bot competitions. Controlling Robot Movement Based on QTI Readings. #include <Servo.h> // Include servo library // pin designations int LeftQTI = 8; int RightQTI = 2;

dwayne
Download Presentation

Control

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Control Some Material taken from RobotSubsumption.pdf

  2. Remember Where Are We Going? Sumo-Bot competitions

  3. Controlling Robot Movement Based on QTI Readings #include <Servo.h> // Include servo library // pin designations int LeftQTI = 8; int RightQTI = 2; int leftServoPin = 12; int rightServoPin = 3; // program parameters int moveTime = 500; int turnTime = 800; int debug = 0; // previously established average QTI readings const int LeftDark = 1000; const int RightDark = 1000; const int LeftWhite = 60; const int RightWhite = 60;

  4. Code // Threshold for strong light and dark differences int LeftThreshold = LeftWhite * 2; int RightThreshold = RightWhite * 2; // declare servo objects Servo servoLeft; Servo servoRight; void setup() { pinMode(leftServoPin, OUTPUT); pinMode(rightServoPin, OUTPUT); servoLeft.attach(leftServoPin); servoRight.attach(rightServoPin); Serial.begin(9600); }

  5. Code void loop() // Main loop auto-repeats { long tLeft = rcTime(LeftQTI); // Left rcTime -> tLeft long tRight = rcTime(RightQTI); // Right rcTime -> tRight if (debug == 1) { Serial.print(tLeft); Serial.print(" "); Serial.println(tRight); }

  6. Code if((tLeft < LeftThreshold) && (tRight < RightThreshold)) { maneuver(-200, -200, moveTime); } else if(tLeft < LeftThreshold) { maneuver(-200, -200, moveTime); maneuver(-200, 200, turnTime); } else if(tRight < RightThreshold) { maneuver(-200, -200, moveTime); maneuver(200, -200, turnTime); } else { maneuver(200, 200, 20); } } rcTime() and maneuver() not shown

  7. Read QTIs backup turn right turn left go forward Finite State Machine (FSM) Representation both high left low right low both low

  8. Controlling Robot Movement Based on Proximity Measurement void loop () { sonar.fire(); double forwardDistance = sonar.inches(); int irLeft = irDetect(LeftLED, LeftDec, 38000); int irRight = irDetect(RightLED, RightDec, 38000); if (forwardDistance>0 && forwardDistance<MAX_DISTANCE) { maneuver(200, 200, forwardTime); } else if(irLeft == 0) { maneuver(200, -200, SearchTurnTime); } else if(irRight == 0) { maneuver(-200, 200, SearchTurnTime); } else { maneuver(200, 200, 20); } }

  9. No Obj Obj left Obj right Obj forward Read IR & Sonar Go forward turn right turn left go forward Finite State Machine (FSM) Representation

  10. go forward turn left turn right backup Read QTIs How to Put It Together? No Obj Obj left Obj right Obj forward Read IR & sonar Go forward turn right turn left go forward both high left low right low both low

  11. Possible Problems • Jerky or halting movement • Chase object over boundary • Never detect opponent • More?

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

  13. Go forward Go backwards turn teft turn right read IR & sonar and set nextState variable read QTIs and set nextState variable check nextState variable and branch FSM

  14. backup turn right turn left go forward read QTIs and set nextState variable check nextState variable and branch Read IR Alternative FSM Go forward turn right turn left go forward

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

  16. Main Loop if((tLeft < LeftThreshold) && (tRight < RightThreshold)) { maneuver(-200, -200, backwardTime); } else if(tLeft < LeftThreshold) { maneuver(-200, -200, backwardTime); maneuver(-200, 200, LineTurnTime); } else if(tRight < RightThreshold) { maneuver(-200, -200, backwardTime); maneuver(200, -200, LineTurnTime); } else { maneuver(200, 200, 20); searchForOpponent(); }

  17. SearchForOpponent() void searchForOpponent() { sonar.fire(); double forwardDistance = sonar.inches(); int irLeft = irDetect(LeftLED, LeftDec, 38000); int irRight = irDetect(RightLED, RightDec, 38000); if (forwardDistance>0 && forwardDistance<MAX_DISTANCE) { maneuver(200, 200, forwardTime); } else if(irLeft == 0) { maneuver(200, -200, SearchTurnTime); } else if(irRight == 0) { maneuver(-200, 200, SearchTurnTime); } else { maneuver(200, 200, 20); } }

  18. Possible Enhancements • Optimize the position of the sensors • Optimize your mechanical design for fighting • Design against being pushed out of the ring • Optimize the code to maximize bot performance • Evaluate tradeoffs in movement choices and sensor reading

More Related