1 / 25

Insect Behaviours

Insect Behaviours. Designing Robot Behaviours. Designing robot behaviours requires more imagination than knowledge. You have to “think like a cockroach”. Where have we heard a comparison of imagination and knowledge before?

zaynah
Download Presentation

Insect Behaviours

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. Insect Behaviours Intro to Robots

  2. Designing Robot Behaviours • Designing robot behaviours requires more imagination than knowledge. • You have to “think like a cockroach”. • Where have we heard a comparison of imagination and knowledge before? • In this chapter you will need to “think like a cockraoch” and a lot of other interesting beasts. Intro to Robots

  3. Braitenburg Vehicles • 1984, Valentino Braitenburg published “Vehicles: Experiments in Synthetic Psychology” • Imaginary vehicles with simple motor skills and simple control mechanisms but complex behaviour. • Trying to understand human and other animal brains. • Braitenburg connected simple sensors to simple motors to produce complex behaviours that humans would recognize as fear, aggression, love, logic and free will. • Is it “fear” when a robot avoids all obstacles? • What are you teaching your children when you tell them, “never talk to strangers”? Intro to Robots

  4. Braitenburg’s Law • Uphill Analysis and Downhill Invention. • It is harder to guess internal structure from external behaviour than to build something that will exhibit such behaviour • It is harder to describe correctly the program that gives a robot a certain behaviour than it is to produce a program that will produce a specified behaviour. Intro to Robots

  5. Vehicle 1: • One sensor connected directly to one motor (in the Scribbler case, one light sensor connected to both wheels equally). • Behaviour: More light, faster turn the wheels. Intro to Robots

  6. Vehicle 1: • Problem: Light Sensors range from 0 (very bright) to 5000 (very dark) while motor speeds run from -1 (fast backward to 1 (fast forward). • We simplify the motor speeds by just considering forward motion (motor speeds in the range [0,1]). • We need a function that converts light intensity into motor speed as follows: • We call this process, normalizing the sensor readings. motor speed = f(light intensity) where f(0) = 1 and f(5000) = 0 Intro to Robots

  7. d – b c - a y – d = (x – c) Normalizing Sensor Readings • The formula for a line that passes through two points, (a,b) and (c,d), is: s = 1 - i/5000 (s) (i) Exercise: Calculate this function for variables i and s. Intro to Robots

  8. normalize(): • Problem with this formula: Instead of having the robot come to a complete stop when it is pitch dark, we would like it to stop in ambient light and move forward when the light is brighter than ambient. • Since ambient light might be in the 200 to 500 range we may still have the robot moving at 90% top speed in ambient light – too fast. def normalize(i): return 1 – i/5000.0 Exercise: show this to yourself. Intro to Robots

  9. Final normalize(): • We first need to calculate the average ambient light (Ambient) and then use it to formulate a new normalize() function. • Exercise: Prove the robot stops in ambient light. • Problem: How to calculate the value of Ambient? • Take the average of left, right and center sensors • Have the robot make a 360 degree circle and measure ambient light in all directions; then take the average. def normalize(i): if i > Ambient: i = Ambient return 1 – i/Ambient Intro to Robots

  10. Vehicle1.py • Let’s analyze the while-loop • It loops forever • To stop, execute stop() from the command line • Every time you execute forward() the speed changes. # Braitenberg Vehicle#1: Alive from myro import * initialize("com"+ask("What port?")) Ambient = getLight("center") def normalize(v): if v > Ambient: v = Ambient return 1.0 - v/Ambient def main(): # Braitenberg vehicle#1: Alive while True: l = getLight("center") forward(normalize(l)) Exercise: Modify thisprogram to use other values for Ambient. Intro to Robots

  11. Vehicle 2a: • Two sensors, each one driving a different motor. • Behaviour: More light, faster turn the wheels. Intro to Robots

  12. Vehicle2a.py: # Vraitenberg Vehicle#2a from myro import * initialize("com"+ask("What port?")) Ambient = sum(getLight())/3.0 def normalize(v): if v > Ambient: v = Ambient return 1.0 - v/Ambient def main(): # Braitenberg vehicle#2a: Coward while True: l = getLight("left") r = getLight("right") motors(normalize(l), normalize(r)) The method getLight()returns a list of readings(left,center,right). The function sum() can take a list as an argument andadd its contents. motors() drives both motors,the left and the right. Thereforeit takes two arguments. Intro to Robots

  13. Exercises: • Implement the above program and observe the behaviour of the robot when shining a light on the various sensors – left, center and right. • How would you describe the vehicle2a behaviour? Intro to Robots

  14. Vehicle 2b: • Two sensors, each driving a different (opposite) motor. • Behaviour: More light, faster turn the wheels. Intro to Robots

  15. Vehicle2b.py: • Exercise: Modify the program vehicle2a.py to implement the behaviour of vehicle2b. • Describe the behaviour of this new robot. Intro to Robots

  16. Robot Setup: • Sometimes the robot needs to be set up before actually doing what it is supposed to do. • For example, calculate the value if Ambient light intensity before executing any of the Vehicle programs. • If multiple things need to be done, it is often necessary for you to prevent the robot from jumping into the main program. • Exercise: modify the Vehicle programs to use this approach def main(): # Description of the behavior... # Give user the opportunity to set up the robot askQuestion("Press OK to begin...", ["OK"]) # Write your robot's behavior commands here Intro to Robots

  17. d – b c - a y – d = (x – c) Different normalizations: • The normalization we used in the previous examples is called excitatory. This is because the more intense the light (sensor activity), the faster we drive the motor. • We could do the inverse. We could slow down the motors under intense light. This is called inhibitory. s = i/5000.0 (s) (i) Intro to Robots

  18. Inhibitory normalize(): • Remembering to take into account ambient light, the function for inhibitory normalization is: • Vehicles 2a and 2b with inhibitory normalization (we call them 3a and 3b) are referred to by Braitenburg as love and explore. Why? • Implement 3a and 3b, observe their behaviour and answer the above question. def normalize(i): if i > Ambient: i = Ambient return i/Ambient Intro to Robots

  19. Other normalizations: • Any function that has a domain and range inside the box in the diagram below can be the basis of a normalization function. Intro to Robots

  20. Various normalizations: Vfunction step function bell curve Braitenburg calls thesenormalization functions,instincts. circlearc ? Intro to Robots

  21. Exercise: • Compare instinct to intuition. • How do they differ as reasoning tools? • How do they differ from logic as a reasoning tool? • We can make the robot simulate instinct and we can have it emulate logical reasoning. Can we make the robot display intuition? Intro to Robots

  22. A Robot’s “self”: • Clearly we can change a robot’s behaviour by changing its program. • It’s behaviour is not inherently what the robot is all about. • The part of the robot that observes/controls the robot’s sensing/reaction behaviours is its CPU. • So the CPU is the closest thing we can identify in the robot to a “self”. • Indeed, we often say that the architecture of a computer is the set of basic instructions its CPU understands. • How does this compare to person’s “self”? Intro to Robots

  23. Sine Function sin() is a built-in Python functionfound in the math module. pi is a built-in value.from math import * • Amplitude = 1 • Period = 4 * Ambient = 2π/b • b = π/2*Ambient • So if Ambient = 250 then theequation is y = asin(bx) where a = amplitude period = 2 π/b y = sin((π/500)x) def normalize(v): if v > Ambient: v = Ambient return sin((pi/500)*v) Ambient Intro to Robots

  24. Creating Python normalization functions: • Bell Curve: • Other Functions: • Final Analysis: We can create a behaviour/instinct from any mapping of sensor range values to [0,1]. def normalize(v): mean = Ambient/2.0 stddev = Ambient/6.0 # rough guess if v >= Ambent: v = Ambient return exp(-(v – mean)**2 / 2 * (stddev**2)) π = meanσ = standard dev exp() is a built-in Python functionfound in the math module.from math import * Exercise: Create a normalize() function for the - step function - circle arc - V function Intro to Robots

  25. Alternative sensors: • All the vehicles we have seen implemented until now could be re-implemented using the IR sensors instead of light sensors. • Our lab exercises will do this and we can then describe the behaviour of these other vehicles. Intro to Robots

More Related