350 likes | 477 Views
How do our Robots sense what’s around them?. Dr. Paige H. Meeker. Slides from Institute for Personal Robots in Education (IPRE) s. Senses. Humans rely on their senses to understand what’s going on in the world. Touch, Vision, Hearing, Taste, and Smelling (sometimes Balance)
E N D
How do our Robots sense what’s around them? Dr. Paige H. Meeker Slides from Institute for Personal Robots in Education (IPRE)s
Senses • Humans rely on their senses to understand what’s going on in the world. • Touch, Vision, Hearing, Taste, and Smelling (sometimes Balance) • Inner Senses (we keep up with our “internal state” – what’s going on inside you and where everything is) • Now that we have our robots, let’s take a look at how they “see/sense” the world around them…
Python’s Senses • To get a quick, overall look at the behavior of the senses of the robot’s sensors, use the Myro function “senses()” • You will see the results of all the sensor calls in real time (except the camera)
IR Obstacle Sensors • The Scribbler has two IR obstacle sensors (under the light sensors) that return a binary value of 0 or 1. • The robot actually has 1 IR receiver located in the center, and two emitters located on the left and right side of the emitter.
IR Obstacle Sensors • Return value of: 0 – IR light is bouncing back to the receiver (off of an obstacle)
IR Obstacle Sensors • Return value of: 1 means that infrared light is not bouncing back to the receiver, so nothing is in front of the emitter/detector.
IR Obstacle Sensors • getIR() returns a list of two items [1,1]. You can also call getIR(“left”) to get just the left sensor, and similarly with getIR(“right”). The function also accepts 0 and 1 as the parameter to select which sensor value to return.
IR Obstacle Sensors • With the “senses()” function running, place various objects in front of the IR sensors and see what values are being reported. How near/far must an object be to be detected?
Light Sensors (3) • The scribbler has 3 light sensors pointing Left, Center and Right on the same side as the getIR sensors. • [45, 200, 430] = getLight()
Light Sensors (3) • Light sensor values range from 0 to 5000. Zero is very bright, 5000 is full dark. • getLight() returns a list of all 3 values. • getLight(“left” / “center” / “right”) or getLight(0/1/2) selects one value
Light Sensors (3) • Can we make the robot move using the light sensors? • Let’s type in the code on p. 105 -106 of your text (chapter 5) and play with the robot and a flashlight.
Internal Scribbler Sensors • getBattery() - returns battery voltage • getStall() - returns stall condition (0 or 1) • This value changes to a 1 when the motors are working extra hard (possibly due to the robot hitting something and being unable to turn the wheels) • Note that it takes a half second to re-set the stall sensor once the motors are turned off, so wait a bit before sampling it again. • getName() - returns the robot's name (can be changed with setName(“newName”)
Fluke Board • The Fluke add-on board has its own IR obstacle sensors and a camera.
Fluke Board – IR Obstacle sensors • Myro uses the getObstacle() function to differentiate the IR sensors on the Fluke from the IR sensors on the Scribbler. • The fluke sensors are more sensitive than the Scribbler sensors Instead of just returning a zero or one, they return an integer value between zero and 7000.
Fluke Board – IR Obstacle sensors • The fluke has 3 IR emitters, one pointing forward...
Fluke Board – IR Obstacle sensors • The fluke has 3 IR emitters, one pointing forward... • And two pointing to the left and right.
Fluke Board – IR Obstacle sensors • The fluke has 3 IR emitters, one pointing forward... • And two pointing to the left and right. • They all bounce light back to a center mounted receiver.
Fluke Board – IR Obstacle sensors • Zero indicates no IR light is bouncing back from an obstacle. • [0,0,0] = getObstacle()
Fluke Board – IR Obstacle sensors • Larger numbers indicate that more IR light is bouncing back. • [0, 1842, 0] = getObstacle()
Fluke Board – IR Obstacle sensors • As with the Scribbler, you can select individual sensors to use (I recommend using the “center” sensor). • getObstacle(0 / 1 / 2) • getObstacle(“left” / “center” / “right”)
Fluke Board – Camera • You can take a picture using the camera on the Fluke board. • p = takePicture() • show(p)
Fluke Board – Camera • You can then save your photo as a .jpg (savePicture(picName, “name.jpg”) • You can turn a series of photos into an animated gif • (type in code from p. 102, Chapter 5)
Fluke – Camera as a brightness sensor • Similar to the getLight() function on the Scribbler, the fluke allows you to use the camera as a “brightness” sensor with the getBright() function call. • getBright() returns a list of three values • getBright(0 / 1 / 2) or getBright( “right” / “center” / “left”) return a single value. • The numbers returned represent the sum of the luminance values of the pixels in the right/center/left of the camera, so they are quite large! • The lower the number, the darker that area of the camera is.
Robot Actuators • Beep • Motors • LED Lights
Speaker command – Beep • beep() - issues a random beep • beep(1) – random beep for 1 second • beep(1,800) – Beep at 800Hz for 1 second • beep(1,440,880) – two tone beep at 440 & 880Hz for 1 second.
Robot Actuators - Motors • Two motors (left,right) that can be set to a power level between -1 and 1. • -1 is full reverse • 0 is stopped • 1 is full speed forward. • Controlled directly with the motors(left,right) function.
Robot Actuators – Motors – Utility Functions • These functions make it easier to use the motors to do simple things: • forward(speed, seconds) – Moves the robot forward at the specified speed for the specified seconds, and then stops. • turnLeft(speed,seconds) – Turns the robot left at the specified speed and for the specified seconds, then stops. • turnRight() and backward() are similar.
Robot Actuators – Motors – Utility Functions • The previous functions would all start the robot, go for a certain amount of time, and then stop the robot automatically. • You an also start the robot moving without specifying how long it should do so: • forward(speed), turnLeft(speed), backward(speed), turnRight(speed), stop() • Very important to call the stop() function when you want the robot to stop! • The wait(seconds) function can be used to specify how long the robot should travel: forward(0.85) wait(1.5) stop()
Motor commands – Synchronous vs Asynchronous • What is the difference between these pieces of code? forward(0.85) wait(1.5) stop() • And... forward(0.85, 1.5)
Motor commands – Synchronous vs Asynchronous • What is the difference between these pieces of code? forward(0.85) beep(1.5,880) stop() • And... forward(0.85, 1.5) beep(1.5,880)
Motor commands – Translate & Rotate • Other functions exist: • translate(speed) • rotate(speed) • These functions allow you to add together different types of motion, allowing the robot to move forward -- translate(1) while also turning—rotate(0.5). • stop() is equivalent to translate(0); rotate(0)
LED commands – setLED() • The Scribbler robot has 3 green LED lights. • You can control these three lights with setLED(position, value). • Position is a number: 0, 1, or 2 or a string “left”, “center”, or “right” • Value is either 0 (“off”) or 1 (“on”) • The center light blinks continuously, so unless you keep setting it's value, it will just start blinking again.
LED commands – setLEDFront() and setLEDBack() • The Fluke board has 2 user controlled red LED lights. • One on the front (small, near the camera) and one on the back (large, near the white GPIO connector) • You can control these three lights with setLEDFront(value) and setLEDBack(value) functions. • Value is either 0 (“off”) or 1 (“on”) • The back LED is VERY bright! And you can set it to half power with a 0.5 value, or quarter power with 0.25.
Go play with your robot! Go play with your robot's sensors and actuators!