29
Reactive robots UPNA The Public University of Navarra Material for pupils & students

Reactive robots UPNA The Public University of Navarra Material for pupils & students

Embed Size (px)

Citation preview

Page 1: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Reactive robots

UPNAThe Public University of Navarra

Material for pupils & students

Page 2: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Simple 2 motor cars….with sensors

ENGAGEMENT STAGE

Page 3: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Objectives

A very simple 2 motor moving robotic construction with several sensors Touch sensor Sound sensor Light sensor

Programming with Loops Programming with Switches (IF’s)

Shall we make a robot that senses & react?

ENGAGEMENT STAGE

Page 4: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Building instructions

LXF file: Have a look to the pictures… Think about it….what car design do

you want to make…..

EXPLORATION STAGE

Page 5: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Sensors

EXPLORATION STAGE

Sensors & bricks

Page 6: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Sensors….

Touch sensor

EXPLORATION STAGE

Page 7: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Sound sensor

Sensors….

EXPLORATION STAGE

Page 8: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Light sensor

Sensors….

EXPLORATION STAGE

Page 9: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Programming with NXT-G

EXPLORATION STAGE

Page 10: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Programming with NXT-G

EXPLORATION STAGE

Page 11: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Touch sensor, switch & loops

EXPLORATION STAGE

Page 12: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Wait & push

EXPLORATION STAGE

Page 13: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Application

Each group decides to use one type of sensor with one of the following scenarios in orden to achieve one of the proposed goals

Makes programmming and Testing with his own circuit

To explain to the rest what they have done, etc…

INVESTIGATION STAGE

Page 14: Reactive robots UPNA The Public University of Navarra Material for pupils & students

With touch sensor… escaping from walls….

INVESTIGATION STAGE

We need walls (boxes or similar)

Goal: to be able to “escape” from walls

Different ideas: when the robots touches the wall,

It changes direction

It goes back, rotates 90º and continues

It goes back, rotates” random” º and continues

Repeat these things

Page 15: Reactive robots UPNA The Public University of Navarra Material for pupils & students

With sound sensor… our 2-ear dog….

INVESTIGATION STAGE

We have a car with 2 ears, one at each side, it is our “dog”….let’s call him “Terecop”

Goal: to call “Terecop” (clapping for example or with our voice) and (the most important) to be listened by him

Ideas:

To measure the sound at each sensor

To decide which sensor is nearer from the source of sound

To move into this direction

Repeat these things

Page 16: Reactive robots UPNA The Public University of Navarra Material for pupils & students

With sound sensor… our 2-ear dog….

INVESTIGATION STAGE

• the nearer we are from the sound source the higher the value of the sensor is,

• the value is satured at 100%, etc….

Expected outcomes…:

Page 17: Reactive robots UPNA The Public University of Navarra Material for pupils & students

With sound sensor… our 2-ear dog….

INVESTIGATION STAGE

The writting of a procedure with:

• a loop integrating the 2 measures and •a switch decision

expected outcomes…:

Page 18: Reactive robots UPNA The Public University of Navarra Material for pupils & students

With light sensor….. leaving the dark side of the moon….

INVESTIGATION STAGE

We have a car with a light sensor

Goal: the idea is to go the nearest possible to the light source, that is to live the dark side of the moon….

Ideas:

To measure the light

To move a little

To measure the light again

If we have bigger value, we are approaching the goal….

Repeat these things

Page 19: Reactive robots UPNA The Public University of Navarra Material for pupils & students

About the cars

PRODUCTION & EVALUATION STAGE

Direction: is the sensor working well

Is the car moving OK….

Page 20: Reactive robots UPNA The Public University of Navarra Material for pupils & students

About the programs

PRODUCTION & EVALUATION STAGE

How it is big in bytes or KB

How it is easy to understand

How it is good

Page 21: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Rules to classify cars….

PRODUCTION & EVALUATION STAGE

Rules to evaluate the cars:

1. Does the robot & program solve the problem

2. Slowly or quickly

3. Is complicate the program or no

Etc…..

Page 22: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Rules to classify programs….

PRODUCTION & EVALUATION STAGE

Rules to evaluate the programs:

1. Number of the instructions

2. Size of the downloaded code

3. Easy to understand…..Etc…

Page 23: Reactive robots UPNA The Public University of Navarra Material for pupils & students

Lets classify and conclude somethings…

APPLICATION STAGE

“How we can know if the combination of robot & program do well what we want it to do?”

Analyse every case…..

Page 24: Reactive robots UPNA The Public University of Navarra Material for pupils & students

This program is works like the Line Follower: Wait for Dark program but it uses a Switch. The program runs a Switch--in a infinite Loop--that runs Motor A and makes sounds when reading light. The program stops Motor A then runs Motor C for 0.25 seconds when reading dark.

APPLICATION STAGE

More ideas…. (from LEGO engineering web site)

Page 25: Reactive robots UPNA The Public University of Navarra Material for pupils & students

There are many ways to stop a car at a black line. Using a light sensor attached to Port 1, the program takes the initial light reading, drives forward (one motor car) and waits for a difference greater than or equal to 5. Once this difference is reached, the Switch stops the NXT and exits the program.

APPLICATION STAGE

More ideas…. (from LEGO engineering web site)

Page 26: Reactive robots UPNA The Public University of Navarra Material for pupils & students

This program uses two touch sensors combined with two Switches--all in an infinite loop--to display a number on the screen. Port 1 adds 1 and Port 2 adds 100. The "adder" variable is set to zero at the beginning of this program.

APPLICATION STAGE

More ideas…. (from LEGO engineering web site)

Page 27: Reactive robots UPNA The Public University of Navarra Material for pupils & students

The two-button remote control is a very versatile program for controlling Lego robots. It uses a series of touch sensor Switches to determine which behavior you want to trigger. Since the Switches are between a set of Loops, the program loops infinitely, and the behavior of the robot will change every time a different touch sensor is hit.

In this program, the two-button remote is setup to control a car with motors connected to Ports A and C. When only touch sensor 1 is pressed, Motor A spins forward and Motor C spins backward. This will turn the car left or right. When only touch sensor 2 is pressed, the motors are reversed and the car will spin the opposite direction. If both touch sensors are held, the motors go forward. When no touch sensors are held, the car does not move. Remember, each branch of the Switch can control something different. It does not only work for a car. The touch sensors can trigger music, events, even mail to other robots. The possibilities are endless.

APPLICATION STAGE

More ideas…. (from LEGO engineering web site)

Page 28: Reactive robots UPNA The Public University of Navarra Material for pupils & students

More ideas…. (from LEGO engineering web site)

This is another version of the two-button remote.

APPLICATION STAGE

Page 29: Reactive robots UPNA The Public University of Navarra Material for pupils & students

More ideas…. (from LEGO engineering web site)

Like its smaller cousin, the three-button remote control is a great way to define unique behaviors for your robot. The advantage to the three-button control is that there are now 8 possible behavior combinations, compared to just 4 on the 2-button remote. In addition to forward, left and right motion on our two motor car, it is now possible to move in reverse, and even control a third motor. With so many combinations, it is possible that you don?t need them all. In that case just leave one branch of the Switch empty.

APPLICATION STAGE