Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to Robots Lab 6: Robot Behaviours. Intro to Robots Further Braitenberg Vehicles: Timid: –Moves forward in a straight line –One threshold light sensor.

Similar presentations


Presentation on theme: "Intro to Robots Lab 6: Robot Behaviours. Intro to Robots Further Braitenberg Vehicles: Timid: –Moves forward in a straight line –One threshold light sensor."— Presentation transcript:

1 Intro to Robots Lab 6: Robot Behaviours

2 Intro to Robots Further Braitenberg Vehicles: Timid: –Moves forward in a straight line –One threshold light sensor –Detects light above threshold, moves forward; otherwise stops –Threshold should be Ambient. –Test with a flashlight; from time to time covering the light beam with your hand. –Explain why we call this behaviour “timid”.

3 Intro to Robots Further Braitenberg Vehicles: Indecisive: –Moves forward in a straight line –One threshold light sensor –Detects light above threshold, moves forward; otherwise moves in reverse – never stops. –Threshold should be Ambient. –Watch where the robot seems to focus its attention. –Explain why we call this behaviour “indecisive”.

4 Intro to Robots Further Braitenberg Vehicles: Paranoid: –Capable of turning by moving right motor forward and left motor backward simultaneously –One threshold light sensor –Detects light above threshold, moves forward; when it enters a shadow, drives left motor backward. –Threshold should be Ambient. –Watch how the robot responds to shadow. –Explain why we call this behaviour “paranoid”.

5 Intro to Robots Single Algorithm: All the previous projects will use programs that comply with the following paradigm: while timeRemaning( ):

6 Intro to Robots Alternative Projects: Refrigerator Detective: Write a program that determines how dark it is inside a closed refrigerator. Watchdog: Write a program that allows the robot to stand beside a closed door. If the door is opened the robot will beep loudly, move out of the way and continue beeping. Drawer Detective: Write a program that will cause the robot to beep loudly if a drawer is opened. The robot should be inside the drawer. Motion Detector: Write a program that has the robot beep when something moves across a beam from a flashlight that is shining on one of the robot’s light sensors.

7 Intro to Robots Alternative Projects: Suerte de Capote: Write a program that allows the robot to simulate a bull (el toro) trying to attack a “red cape”. See if you can make the bull charge straight ahead or in a curved line. Follower: Write a program that causes the robot to search for and find an obstacle and then, as the obstacle is pulled away, follows the obstacle at a distance. If the obstacle pulls away to one side or the other the robot will turn to that side. Circle Drawer: Write a program that will ask the user for a radius and then draw a circle of that radius (in feet). Exercise: Read up in Wikipedia on “Spanish-stype bullfighting”.

8 Intro to Robots translate(), rotate() and move(): In all situations below, the value of x is velocity. translate(x): 0 <= x <= 1, forward; -1 <= x <= 0, backward rotate(x): 0 <= x <= 1, left turn; -1 <= x <= 0, right turn move(translate, rotate): move() is a function that combines the translate() and rotate() functions. –move(0,1): turn left at full speed –move(1,0.5): turn left at half speed while moving ahead at full speed.

9 Intro to Robots Light Seeking Behaviour: Implement and test the following code that makes the robot exhibit light-seeking behaviour. # Light follower from myro import * initialize(ask("What port?")) # program settings... thresh = 50 fwdSpeed = 0.8 cruiseSpeed = 0.5 turnSpeed = 0.7 # +ve left turn, -ve right turn main() def main(): while True: # get 3 light sensor values L, C, R = getLight() # based on sensors; act appropriately if C < thresh: # bright light ahead, go forward move(fwdSpeed, 0) elif L < thresh: # bright light at left, turn left move(cruiseSpeed, turnSpeed) elif R < thresh: # bright light on right, turn right move(cruiseSpeed, -turnSpeed) else: # no bright light, forward slowly move(cruiseSpeed/2, 0) Exercise: Adjust the values of thresh, fwdSpeed, cruiseSpeed & turnSpeed

10 Intro to Robots Obstacle Avoiding Behaviour: Scribbler only has obstacle detectors in the general direction of straight ahead. Scribbler won’t sense a wall if it is off to one side. Adding the Fluke board the robot can also detect obstacles to the left or right. Regardless, a basic algorithm for obstacle avoidance is if obstacle straight ahead: turn (left or right?) elif obstacle on left: turn right elif obstacle on right: turn left else: otherwise cruise

11 Intro to Robots Obstacle Avoidance Program: Implement and test the following code that makes the robot exhibit obstacle avoidance behaviour. # Avoiding Obstacles from myro import * from random import * initialize(ask("What port?")) # program settings... cruiseSpeed = 0.6 turnSpeed = 0.5 # +ve left turn, # -ve right turn def multiplier(): # choice([0,1]) randomly pick 0 or 1 # f(x) = 2x - 1; f(0) = -1, f(1) = 1 return 2 * choice([0,1]) -1 main() def main(): while True: # get left, right IR sensor values L, R = getIR() L = 1 – L # flip sensor variable; obs == Ttue R = 1 - R # decide how to act based on sensors values if L and R: # obstacle straight ahead, turn (randomly) move(0, multiplier() * turnSpeed) elif L: # obstacle on left, turn right move(cruiseSpeed, -1 * turnSpeed) elif R: # obstacle on right, turn left move(cruiseSpeed, turnSpeed) else: # no obstacles move(cruiseSpeed, 0) Exercise: Adjust the values of cruiseSpeed & turnSpeed

12 Intro to Robots Obstacle Avoidance Program 2: Implement and test the following code that makes the robot exhibit obstacle avoidance by bumping behaviour. # Avoiding Obstacles by bumping from myro import * from random import * initialize(ask("What port?")) # program settings... cruiseSpeed = 1.0 turnSpeed = 0.5 # +ve left turn, # -ve right turn def multiplier(): # choice([0,1]) randomly pick 0 or 1 # f(x) = 2x - 1; f(0) = -1, f(1) = 1 return 2 * choice([0,1]) -1 main() def main(): while True: if getStall(): # I am stalled, turn (randomly?) move(0, multiplier() *turnSpeed) else: # I am not stalled, cruise on move(cruiseSpeed, 0) Exercise: Adjust the values of cruiseSpeed & turnSpeed

13 Intro to Robots Maze Solving Robot: Create a simple maze (all walls connected to the outside wall) and have the robot try to exit the maze using either of the previous obstacle avoidance programs. Since we do not have side IP sensors we may need to have the robot stop and nudge left periodically

14 Intro to Robots Corral Exiting Robot This robot uses light to guide its way out of an enclosure. Possible Strategy: Follow a wall until light is detected then switch to light-seeking strategy.


Download ppt "Intro to Robots Lab 6: Robot Behaviours. Intro to Robots Further Braitenberg Vehicles: Timid: –Moves forward in a straight line –One threshold light sensor."

Similar presentations


Ads by Google