Reactive robots UPNA The Public University of Navarra Material for pupils & students
Simple 2 motor cars….with sensors ENGAGEMENT STAGE
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
Building instructions LXF file: Have a look to the pictures… Think about it….what car design do you want to make….. EXPLORATION STAGE
Sensors EXPLORATION STAGE Sensors & bricks
Sensors…. Touch sensor EXPLORATION STAGE
Sound sensor Sensors…. EXPLORATION STAGE
Light sensor Sensors…. EXPLORATION STAGE
Programming with NXT-G EXPLORATION STAGE
Programming with NXT-G EXPLORATION STAGE
Touch sensor, switch & loops EXPLORATION STAGE
Wait & push EXPLORATION STAGE
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
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
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
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…:
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…:
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
About the cars PRODUCTION & EVALUATION STAGE Direction: is the sensor working well Is the car moving OK….
About the programs PRODUCTION & EVALUATION STAGE How it is big in bytes or KB How it is easy to understand How it is good
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…..
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…
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…..
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)
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)
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)
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)
This is another version of the two-button remote. APPLICATION STAGE
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