EV3 Software EV3 Robot Workshop 2015 Lawrence Technological University Instructor: Assistants:

Preview:

Citation preview

EV3 SoftwareEV3 Robot

Workshop 2015

Lawrence Technological University

Instructor:Assistants:

• 2015 Robofest competition Robobowl

• SPbot introduction

• Using the SPbot to solve the Robobowl challenge

Course Overview

2

• Video overviewhttp://youtu.be/LJ0afkDSuZA

• Key tasks– Measure the height of the rectangular shape– Compute location of pin 3 & 4– Follow the edge of the table– Find the bowl zone– Find a set of pins– Bowl a tennis ball– Return home

2015 Robofest competition

3

• Please note that bowling the tennis balls are outside the scope of this workshop

2015 Robofest competition

4

LEGO EV3 robot used – SPbot

Color Sensor

EV3 Computer

Left Motor: B

Right Motor: C Touch Sensor

Sonar Sensor

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

– If your motors are upside down forward will be backwards in your program

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

Remember the connections!

6

Please note that the retail version of EV3 uses an infrared sensor, not a sonar sensor.

• Examples use EV3 Educational Version 1.0.1 or EV3 Home Edition 1.1.0

• EV3 Firmware version: V1.06H

• PowerPoint and all example programs are available at robofest.net under Tech Resources:• EV3 RoboFest Workshop Sp2015.pptx• RoboBowlWorkshop.ev3

EV3 Versions Used

7

• LEGO offers a home edition of the EV3 software

• It is free to download and use, but has some limitations– No experiments– Limited built-in sensor support

• You can download all sensor blocks

• Main download page:

Free EV3 Software Download

8

www.lego.com/en-us/mindstorms/downloads

9

Task 0

Move forward and stop when the rectangular shape is reached

• Using wait block

• Using loop block

Task 0: Example Solutions

10

11

Task 1

Measure the height of the rectangle

Watch the YouTube videos at:http://youtu.be/iDSttcFmYqI (MeasureDistance)

http://youtu.be/4e8T0bbh7bM (MeasureRectangle)

• Determine how far the robot travels while moving forward

Measure Distances

12

Distance

Compute distance traveled by measuring the number of rotations of the wheel

• Use the wheel geometry

Measure Distances

13

PI = 3.14

Circ

umfe

renc

e =

Dia

× P

I

Radius

Dia

met

er =

2 ×

Rad

ius

How can use this information?

• For each rotation of the wheel, the robot will travel (Wheel Diameter) x (PI)

• Distance = (Wheel Diameter) x (PI) x (# Rotations)• Distance = (55 mm) x (PI) x (# Rotations)• Distance = 172.8 x (# Rotations)

Measure Distances

14Program: MeasureDistance.ev3

• One method could be:– Go forward until the black rectangle is found– Reset motor rotation sensor– Go until the end of the rectangle is found– Read the motor rotations– Compute the distance traveled

Measure The Rectangle Height

15

• Example of measuring the rectangle height

Measure The Rectangle Height

16Program: MeasureRectangle.ev3

17

Task 2

Compute the location of pin 3 & 4

• We can use math blocks to compute the location of pins 3 & 4

• For example, assume

• How can we compute this using our robot?

EV3 Mathematical Operations

18

 mm

• We can use simple math blocks– Assumes that x = 200mm

EV3 Mathematical Operations

19Program: SampleMath1.ev3

• Here is another approach using advanced blocks

EV3 Mathematical Operations

20Program: SampleMath2.ev3

21

Task 3

Follow the edge of the table

Watch the YouTube videos at:http://youtu.be/3pRbiHxd-Gc (LineFollowZZ)

Follow The Edge Of The Table

22

• Use the zig-zag method to follow the edge of the table

• Edge following is also referred to as line following

• We need to determine when the robot is on or off the table

Rig

ht

Ed

ge

Le

ft E

dg

e

Table

• Get color sensor values to determine when the robot is on or off the table. We will use the color sensor in Reflective Light Intensity mode.– Off table = ______– On table = ______– On foil = ______

Follow The Edge Of The Table

23

ColorSensorReading

• Light sensor settings example– Off table = 10– On table = 40– Median threshold = (10+40)/2 = 25

• Two cases– Light sensor reading > 25. On table.– Light sensor reading < 25. Off table.

Follow The Edge Of The Table

24

Simple Line Following Algorithm

25Program: LineFollowZZ.ev3

• Zig-zag method can cause a bumpy response• To improve the response, you can use a 3-level

line follower (concept shown below)

How to improve our line following algorithm

26

Off Table Off TableOn Table On Table

27

Task 4

Find the bowl zone

Watch the YouTube videos at:http://youtu.be/zUnIvl3klLA (LineCrossing)

• Assuming that the robot is in the no-bowl zone, we must enter the bowl zone in order to bowl a tennis ball to knock down pins

• One method for finding the bowl zone is reach and cross the black line that separates the bowl zone and no bowl zone

• This concept is called line crossing

Find The Bowl Zone

28

• How can we use our robot to detect lines?– Travel straight and look….

• Off Line = waiting to cross line

• On Line = reached line

• Off Line = crossed line

Line Crossing

29

CrossingLines

• Sample approach

Line Crossing

30Program: LineCrossing.ev3

31

Task 5

Find a set of pins

Watch the YouTube videos at:http://youtu.be/SAI0tS1K4_s (TravelDistance)http://youtu.be/bABKx8o9QJQ (SpinSearch)

• Couple methods– Line follow for a given distance– Spin until the pins are detected with the sonar

sensor

Find A Set Of Pins

32

• First, we need to know how far to go– Let’s assume that the robot must travel 30 cm– How many wheel rotations is 30 cm?

• Distance = (Wheel Diameter) x (PI) x (# Rotations)

• Solve for # Rotations….• # Rotations = Distance / [ (Wheel Diameter) x (PI) ]

• For our robot…• # Rotations = 30 cm / [ (5.5 cm) x (PI) ] = 1.74 rotations

Line Follow For A Given Distance

33

• Example solution

Follow A Line A Given Distance

34Program: TravelDistance.ev3

• Here we are going to have the robot spin until it “sees” the pins with the sonar sensor

Spin And Search

35Program: SpinSearch.ev3

36

Task 6

Bowl a tennis ball

• Again, this task is outside the scope of this workshop

• However, your robot should be in position to deliver a tennis ball if the previous tasks were completed successfully

Bowl A Tennis Ball

37

38

Task 7

Return home

Watch the YouTube videos at:http://youtu.be/dEioHkb4Y98 (FindHome)

• One method to have the robot return home is to line follow until home base is detected

• Using the same principal as line detection, we can determine the threshold for detecting home base– On table / off home base = 40– On home base = 60– Median threshold = (40+60)/2 = 50

Return Home

39

• Two cases– Light sensor reading > 50. On home base.– Light sensor reading < 50. Off home base.

Return Home

40Program: FindHome.ev3

• In this course we learned how to– Measure the height of the rectangular shape– Compute location of pin 3 & 4– Follow the edge of the table– Find the bowl zone– Find a set of pins– Return home

Putting It All Together

41

robofest@LTU.edu

Questions?

Little Robots, Big Missions

42

Recommended