Top Banner
CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education
30

CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Dec 20, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

CS 1 with Robots

Robot Sensors & Actuators

Institute for Personal Robots in Education

(IPRE)

Page 2: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 2

Page 3: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 3

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.

Page 4: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 4

IR Obstacle Sensors

Return value of: 0 – IR light is bouncing back to the receiver (off of an obstacle)

Page 5: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 5

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.

Page 6: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 6

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.

Page 7: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 7

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()

Page 8: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 8

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

Page 9: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 9

Internal Scribbler Sensors

getBattery() - returns battery voltagegetStall() - 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 agian.

getName() - returns the robot's name (can be changed with setName(“newName”)

Page 10: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 10

Fluke Board

The Fluke add-on board has its own IR obstacle sensors and a camera.

Page 11: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 11

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.

Page 12: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 12

Fluke Board – IR Obstacle sensors

The fluke has 3 IR emitters, one pointing forward...

Page 13: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 13

Fluke Board – IR Obstacle sensors

The fluke has 3 IR emitters, one pointing forward...And two pointing to the left and right.

Page 14: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 14

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.

Page 15: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 15

Fluke Board – IR Obstacle sensors

Zero indicates no IR light is bouncing back from an obstacle.[0,0,0] = getObstacle()

Page 16: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 16

Fluke Board – IR Obstacle sensors

Larger numbers indicate that more IR light is bouncing back.[0, 1842, 0] = getObstacle()

Page 17: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 17

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”)

Page 18: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 18

Fluke Board – Camera

You can take a picture using the camera on the Fluke board.p = takePicture() show(p)

Page 19: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 19

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 valuesgetBright(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.

Page 20: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 20

Robot Actuators

BeepMotorsLED Lights

Page 21: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 21

Speaker command – Beep

beep() - issues a random beepbeep(1) – random beep for 1 secondbeep(1,800) – Beep at 800Hz for 1 secondbeep(1,440,880) – two tone beep at 440 & 880Hz for 1 second.

Page 22: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 22

Robot Actuators - Motors

Two motors (left,right) that can be set to a power level between -1 and 1.-1 is full reverse0 is stopped1 is full speed forward.Controlled directly with the motors(left,right) function.

Page 23: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 23

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.

Page 24: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 24

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()

Page 25: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 25

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)

Page 26: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 26

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)

Page 27: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 27

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)

Page 28: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 28

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.

Page 29: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 29

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.

Page 30: CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)

Aug 29 2007 30

Go play with your robot!

Go play with your robot's sensors and actuators!