Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to Robots Insect Behaviours. Intro to Robots Designing Robot Behaviours Designing robot behaviours requires more imagination than knowledge. You.

Similar presentations


Presentation on theme: "Intro to Robots Insect Behaviours. Intro to Robots Designing Robot Behaviours Designing robot behaviours requires more imagination than knowledge. You."— Presentation transcript:

1 Intro to Robots Insect Behaviours

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

3 Intro to Robots 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”?

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

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

6 Intro to Robots 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

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

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

9 Intro to Robots 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

10 Intro to Robots 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 this program to use other values for Ambient.

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

12 Intro to Robots 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 and add its contents. motors() drives both motors, the left and the right. Therefore it takes two arguments.

13 Intro to Robots 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?

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

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

16 Intro to Robots 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

17 Intro to Robots 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. y – d = (x – c) d – b c - a (s) (i) s = i/5000.0

18 Intro to Robots 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

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

20 Intro to Robots Various normalizations: bell curve step function V function circle arc ? Braitenburg calls these normalization functions, instincts.

21 Intro to Robots 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?

22 Intro to Robots 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”?

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

24 Intro to Robots 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 Exercise: Create a normalize() function for the - step function - circle arc - V function exp() is a built-in Python function found in the math module. from math import *

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


Download ppt "Intro to Robots Insect Behaviours. Intro to Robots Designing Robot Behaviours Designing robot behaviours requires more imagination than knowledge. You."

Similar presentations


Ads by Google