EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest...

53
EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version Developed by CJ Chung, Ph.D. Professor / Robofest Founder & Director

Transcript of EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest...

Page 1: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

EV3 Workshop

Lawrence Technological University

Curriculum Developed by Joe DeRose, Ph.D.Robefest Lead Instructor

10/26/2013

Curriculum Based Off NXT Version Developed by CJ Chung, Ph.D.Professor / Robofest Founder & Director

Page 2: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Lego NXT robot used – OmniBot

Color Sensor

NXT Computer

Left Motor: B

Right Motor: C

2

Touch Sensor

Sonar Sensor Sound Sensor

Page 3: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• Left Motor connects to B• Right Motor connects to C

• Color sensor connects to port no. 1• Touch sensor connects to port no. 2• Sound sensor connects to port no. 3 • Sonar sensor connects to port no. 4

Remember the connections!

3

Page 4: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• Examples are using EV3 Version 1.0.1

• NXT Firmware version: 1.31

• All example programs in RoboParade.ev3

• Free version from EV3 may be downloaded

EV3 Versions Used

4

http://www.lego.com/en-us/mindstorms/downloads/software/ddsoftwaredownload/download-software

Page 5: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Go straight for 2 seconds using different power levels

Mission 0:

5

LAUNCHLEGO MINDSTORMS

Education EV3

Page 6: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Go forward for 2 seconds with power level 40 %

6

EV3 offers two move blocks

Move Steering Block: Controls and regulates two motors with a steering input and single power level. (+) steering = right; (-) steering = left

Move Tank Block: Controls two motors with a power level to each motor

In this course we will sue the Move Steering Block.

Page 7: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• Connect the NXT to the laptop (if this is the first time, then a “Found New Hardware” message will appear)

• Click on the ‘Download’ button• It’s recommended to always unplug the cable

from the bot before running the program• Navigate through the NXT’s menu:

– Turn On > My Files > Software Files– Then select your program and run it!

Let’s test it

7

Page 8: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• How many centimeters when 40% power used?

• How many centimeters when 70% power used?

How to find out the current battery voltage level?

Let’s measure the distance traveled

8

Page 9: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

NXT motors: geared motor with built-in rotation sensor

Rotation sensor gives “degrees” turned. (It can also give “rotations,” but the pop-up incorrectly displays “degrees.”)For example, if the value is 360, the motor turned one rotation.

Page 10: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Display the “degrees” when the bot goes forward for 4 seconds

Mission 1:

10

Page 11: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Display the “degrees” turned for going forward for 4 seconds

11

Program: DisplayDegrees

Page 12: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• Number of rotations = degrees / 360• Circumference of a circle = diameter * 3.14 • Travel distance = number of rotations *

circumference of the wheel

• Speed = distance / time

Review

12

Page 13: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

1) If “degrees” were 1,300, then how many times the wheel was rotated?

2) If the circumference of the wheel is 17cm, what is the travel distance for 4 sec?

3) Then what is the averaged speed of the robot for the 4 seconds?

• Note: RoboParade has min and max speed limits. 7 ~ 17 cm/sec

How to calculate the average speed of robot for that 4 seconds ?

13

Page 14: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Display the “speed” when the bot goes forward for 4 seconds

Mission 2:

14

Page 15: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

HOW DO YOU CALCULATE SPEED?v = distance / time (cm/second)

distance

t2t1

15

Page 16: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Example when the degrees = 1300

16

Page 17: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Program: DisplaySpeed

17

Page 18: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• We can make the program shorter

• Instead of multiplying by 17 and then dividing by 360*4=1440, we can just multiply by 17/1440=0.0118

• This uses one math block instead of two

Exercise

18

Page 19: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

NXT-G BasicsSONAR (ULTRASONIC) SENSORENDLESS LOOPDECISION MAKINGSOUND SENSOR

19

Page 20: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

20

Ultrasonic Sensor• Uses the same scientific principle as bats• Can measure in centimeters or inches• Large objects with hard surfaces return the

best readings

Page 21: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Can you tell what the following program, usTst2, is doing?

21

Page 22: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• Use a Sound Sensor connected to port no. 3• If sound level is greater than 70, go for 1 rotation• Otherwise, do nothing

Mission 3: Clap -> Move(Program: clapMove1)

22

Page 23: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Line following using a Color Sensor

Mission 4:

23

Page 24: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

24

NXT Color Sensor

• Percent Mode:– 5% = lowest dark– 100% = very bright

• Reflected Light Mode: shines a red light• The light can be turned off – detecting

ambient light (surrounding light)• We will use EV3 Experiments to test our

color sensor

Page 25: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

25

• Create a New Experiment

NXT Color Sensor

Page 26: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

26

• Set up the experiment to plot the color sensor reading using “Reflective Light Intensity”

• Run the experiment with the light sensor over various objects

NXT Color Sensor

Run

Page 27: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

27

• Sample results

NXT Color Sensor

Black Tape

Test Mat

Reflective Tape

Page 28: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Zigzag Line following IdeaLeft side following Right side following

Page 29: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Simple Line Following AlgorithmProgram: LineFlowZZ

29Right side or Left side following?

Page 30: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

How and Where to start the robot?

B C

Page 31: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

How and Where to start the robot?

31

B C

Page 32: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

How and Where to start the robot?

B CLost…

Page 33: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

FOLLOW THE PARADE ROUTE AND STOP WHEN AN OBJECT IS SENSED IN FRONT

Mission 5:

33

Page 34: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Endless loop{

If sonar sensor detects an objectStop!!!!!

OtherwiseFollow the black line

}

Parade Program

Page 35: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Program: Roboparade

35

Page 36: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• Two methods– Spilt sequence beam

– Add additional Start Blocks

How to connect a parallel sequence beam?

Page 37: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Mission 6: RoboParade with Speed Display (every 2 seconds) – RoboParadeSD

Page 38: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• Go to www.robofest.net– Click on Tech Resources button on the left– There will be a PPT with more ideas and tips for

Roboparade

How to improve your robot and computer program for the Parade

38

Page 39: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

Smoother Line following using a Color Sensor

Mission 7:

39

Page 40: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• Zig-zag method can cause a bumpy response• We can improve the performance by using a

more sophisticated algorithm

How to improve our line following algorithm

40

Line Line LineMat Mat Mat

Page 41: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• Divide light sensor reading range into three levels

• For your robot

3-Level Line Follower

41

Line MatLine + σ Mat - σ

σ

Turn Right Straight Turn left

Line = _____ Mat = _____ σ = _____

Line + σ = _____ Mat - σ = _____

Page 42: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

42

Program: LineFollowThreeState

Line MatLine + σ Mat - σ

Turn Right Straight Turn Left

Page 43: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• Use linear relationship between the light sensor reading and steering

Proportional Control Line Follower

43

Light Sensor Reading(x)S

teer

ing

Inp

ut

(y)

(Black Line, Steer Right) (23, 15) for my robot

(Mat, Steer Left)(44,-15) for my robot

y = m*x + b

(x1,y1)

(x2,y2)

Page 44: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• Find the line slope (m)

• Find the y-axis intercept

Proportional Control Line Follower

44

𝑚=𝑟𝑖𝑠𝑒𝑟𝑢𝑛

=𝑦 2−𝑦 1𝑥2−𝑥1

𝑦− 𝑦 1=𝑚(𝑥−𝑥1) (Point slope form)

(Rearrange to y=mx+b)

(Find expression for b)

Page 45: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• An example

• Find the y-axis intercept

Proportional Control Line Follower

45

𝑚=𝑟𝑖𝑠𝑒𝑟𝑢𝑛

=𝑦 2−𝑦 1𝑥2−𝑥1

=−15−1544−23

=−𝟏 .𝟒𝟑

𝑦− 𝑦 1=𝑚(𝑥−𝑥1) (Point slope form)

(Rearrange to y=mx+b)

(Find expression for b)

(x1,y1) = (23, 15)

(x2,y2) = (44, -15)

Page 46: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

• An example

Proportional Control Line Follower

46

𝑚 𝑏 𝑥 𝑚∗𝑥 𝑦=𝑚𝑥+𝑏

𝑥= h𝑙𝑖𝑔 𝑡 𝑠𝑒𝑛𝑠𝑜𝑟 𝑟𝑒𝑎𝑑𝑖𝑛𝑔𝑦=𝑟𝑜𝑏𝑜𝑡 𝑠𝑡𝑒𝑒𝑟𝑖𝑛𝑔𝑎𝑛𝑔𝑙𝑒

Page 47: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

47

• My Blocks allow you to group a number of blocks into a single block

• Let’s create P-Control Line Following block

• Step 1: Select the P-Control blocks

Creating a Custom My Block

Unconnected/broken data wires will be inputs

Page 48: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

48

• Step 2: Open Tools -> My Block Builder GUI

Creating a Custom My Block

Page 49: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

49

• Step 3: Select Icons, and set up parameters

• Step 4: Name the My Block as PControlLineF

Creating a Custom My Block

Page 50: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

50

• Once the your my block is created, it will be placed in your My Block palette

• Now, we can reconstruct the line following using the My Block

Using A Custom My Block

Page 51: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

51

• To successfully complete the RoboParade, you need your robot to…– Line Follow– Stop safely when needed– Display the average speed– Perform float operations with other motors

• This can be achieve using parallel sequence beams

RoboParade Program Concept

Page 52: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

52

RoboParade Program ConceptLine Following With Stop

Float Motor

Display Robot Speed

Page 53: EV3 Workshop Lawrence Technological University Curriculum Developed by Joe DeRose, Ph.D. Robefest Lead Instructor 10/26/2013 Curriculum Based Off NXT Version.

[email protected]

Questions?

Little Robots, Big Missions

53