Top Banner
39

App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Aug 01, 2020

Download

Documents

dariahiddleston
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: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click
Page 2: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

App Inventor

meets NXT

Page 3: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Pre-day Questionnaires

Page 4: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

About Technocamps We go around schools like yours and show you lots of interesting stuff!

We also do things we call “bootcamps” during holidays!

Page 5: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

What is a STEM subject? Science

Technology

Engineering

Maths

They all link with each other!

Page 6: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

What are Robots?

Page 7: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Task Draw a Robot. What will it look like? What will it do? How will you interact with it?

Page 8: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Here is Tom’s Robot

What do you think it does? Now let’s see yours…

Page 9: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Robots This is the iCub, a robot used in research to simulate infant learning.

Page 10: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Robots!

Sometimes it is better to have machinery performing the dangerous

jobs.

This is common in the industry.

Machines may be used instead of humans if a repetitive job is required

e.g. assembly lines,

Page 11: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Robots!

In the 80s there was a program called “Knight Rider”. This car was features in

the program called “Kit”.

The car was designed to talk and interact with the driver and to think

like a human.

Although this is science-fiction, our cars today are pretty smart too!

Page 12: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Robots! Idris is a research robot, sent to complex

environments where it drives around on its own.

Usually use to research the environment.

Page 13: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Robots!

This is BeagleB, similar to Idris but more suitable for the sea.

It is used for example to measure

water quality or listen to dolphins as they communicate to one another.

Page 14: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Robots

Do you think a washing machine is a robot?

Why?

Why not?

Discuss as a group.

Page 15: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Robots… … are devices. … are programmable. …can sense their environment. …can act on and within their environment.

Page 16: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

App Inventor

Page 17: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

The interface: Design

Page 18: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

The interface: Develop

Page 19: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

App Inventor and NXT Robots

Page 20: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Buttons

Add the following buttons to your application: -  Move forward -  Move backward -  Turn Left -  Turn Right -  Stop

Page 21: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Events Button.click is an event. Event loop – Run through checking for events. Blocks correspond to the events. You can use these event blocks to control what happens when an event happens. You can use these events to make your robot move..

Page 22: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Experiment Before we move on, let’s play with some negative numbers. •  Change the numbers for the power that you are using when you go forward,

back, left and right to a negative number.. •  What happens? •  What do negative numbers mean?

•  Also, what is the slowest that our robot can move? Or the minimum speed?

Page 23: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Better Driving How do “normal” vehicles drive? How do you think our robots should drive? Acceleration and Deceleration. Better Turning? Differential Drive.

Page 24: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

How can we do this? We need to: •  Control each motor separately:

•  Use 2 NXT drives, add one now •  Store the speed we are moving, and how much we want to turn:

•  Using variables, create some

•  Change these values with our buttons: •  Use a combination of the variables to get a new speed •  A bit of an explanation first

Page 25: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Movement Speed +

Speed -

Turn + Turn -

Page 26: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Clock A clock allows us to keep changing how we drive. It can be found the the components menu. Use a clock to keep adjusting the motors to the values of speed and turn, using the timer event in the Blocks Editor. But what values do we give the motors?

Page 27: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

What if we are not moving? If we are not moving or:

speed = 0 turn = 0

Then you want to stop moving both motors. To check this we use a conditional statement, also known as an “IF statement”. IF *this* test is true, then do *this*, else do *this*…

Page 28: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

What if we are not moving? So if we are not moving, then we want to test the following: If “speed = 0 and turn = 0” Then

Stop Left motor Stop Right motor

Else…

Page 29: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

What if we are not moving? If we are moving forward, then is the speed of our robot positive or negative?

Page 30: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

What if we are not moving? If we are moving forward, then is the speed of our robot positive or negative? It has to be positive so we can test. If speed > 0 (is greater than) Then

Move left motor forward Move right motor forward

But what about the turn?

Page 31: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Task Speed = 30 Turn = 20 MinSpeed = 50 Left Motor = 0 Right Motor = 0

Page 32: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Task Speed = 30 Turn = 20 MinSpeed = 50 Left Motor = 0 Right Motor = 0 + MinSpeed +MinSpeed

Page 33: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Task Speed = 30 Turn = 20 MinSpeed = 50 Left Motor = 0 Right Motor = 0 + MinSpeed + MinSpeed + Speed + Speed Positive turn means what way?

Page 34: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Task Speed = 30 Turn = 20 MinSpeed = 50 Left Motor = 0 Right Motor = 0 + MinSpeed + MinSpeed + Speed + Speed + Turn - Turn MinSpeed + Speed + Turn MinSpeed + Speed - Turn Put this inside your conditional.

Page 35: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Backwards If we are not moving forward, we must be going backwards. Backwards is a little more complicated because Speed will be negative. So if you go backwards with a speed of -40 what direction are you moving?

Page 36: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Backwards If we are not moving forward, we must be going backwards. Backwards is a little more complicated because Speed will be negative. So if you go backwards with a speed of -40 what direction are you moving?

FORWARDS

You can either use move forward with a minus speed or you can do: 0 – speed

This will make your speed positive because - - = +

Page 37: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Backwards Now you have decided how you want to do it, see if you can move backward by going back through some of the maths we did earlier. Try numbers like: Speed = - 70 MinSpeed = 50 Turn = 10

Page 38: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

If you have finished… Let the delivery assistants know if you have finished and they can provide some sensors. See if you can get your robots to become “Autonomous” – so they move on their own. Make sure you complete all the required documentation! You can take the TOP TIPS home with you. Make a note of the following web address if you wish to make Android Applications at home:

http://beta.appinventor.mit.edu

Page 39: App Inventor · App Inventor and NXT Robots . Buttons Add the following buttons to your application: - Move forward - Move backward - Turn Left - Turn Right - Stop . Events Button.click

Don’t forget to save your work!

All of our software is OPEN-SOURCE (Free and available to download)

It can all be found on our Technocamps website:

www.technocamps.com