Report

EV3 Software EV3 Robot Workshop 2015 Instructor: Assistants: Lawrence Technological University Course Overview • 2015 Robofest competition Robobowl • SPbot introduction • Using the SPbot to solve the Robobowl challenge 2 2015 Robofest competition • Video overview http://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 3 2015 Robofest competition • Please note that bowling the tennis balls are outside the scope of this workshop 4 LEGO EV3 robot used – SPbot Right Motor: C Touch Sensor EV3 Computer Sonar Sensor Left Motor: B Color Sensor Remember the connections! • 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 Please note that the retail version of EV3 uses an infrared sensor, not a sonar sensor. 6 EV3 Versions Used • 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 7 Free EV3 Software Download • 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: www.lego.com/en-us/mindstorms/downloads 8 Task 0 Move forward and stop when the rectangular shape is reached 9 Task 0: Example Solutions • Using wait block • Using loop block 10 Task 1 Measure the height of the rectangle Watch the YouTube videos at: http://youtu.be/iDSttcFmYqI (MeasureDistance) http://youtu.be/4e8T0bbh7bM (MeasureRectangle) 11 Measure Distances • Determine how far the robot travels while moving forward Compute distance traveled by measuring the number of rotations of the wheel Distance 12 Measure Distances • Use the wheel geometry PI = 3.14 Radius How can use this information? 13 Measure Distances • 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) Program: MeasureDistance.ev3 14 Measure The Rectangle Height • 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 15 Measure The Rectangle Height • Example of measuring the rectangle height Program: MeasureRectangle.ev3 16 Task 2 Compute the location of pin 3 & 4 17 EV3 Mathematical Operations • We can use math blocks to compute the location of pins 3 & 4 • For example, assume mm • How can we compute this using our robot? 18 EV3 Mathematical Operations • We can use simple math blocks – Assumes that x = 200mm Program: SampleMath1.ev3 19 EV3 Mathematical Operations • Here is another approach using advanced blocks Program: SampleMath2.ev3 20 Task 3 Follow the edge of the table Watch the YouTube videos at: http://youtu.be/3pRbiHxd-Gc (LineFollowZZ) 21 Left Edge • 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 Right Edge Follow The Edge Of The Table Table 22 Follow The Edge Of The 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 = ______ Color Sensor Reading 23 Follow The Edge Of The Table • 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. 24 Simple Line Following Algorithm Program: LineFollowZZ.ev3 25 How to improve our line following algorithm • Zig-zag method can cause a bumpy response • To improve the response, you can use a 3-level line follower (concept shown below) Off Table On Table Off Table On Table 26 Task 4 Find the bowl zone Watch the YouTube videos at: http://youtu.be/zUnIvl3klLA (LineCrossing) 27 Find The Bowl Zone • 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 28 Line Crossing • How can we use our robot to detect lines? – Travel straight and look…. Crossing Lines • Off Line = waiting to cross line • On Line = reached line • Off Line = crossed line 29 Line Crossing • Sample approach Program: LineCrossing.ev3 30 Task 5 Find a set of pins Watch the YouTube videos at: http://youtu.be/SAI0tS1K4_s (TravelDistance) http://youtu.be/bABKx8o9QJQ (SpinSearch) 31 Find A Set Of Pins • Couple methods – Line follow for a given distance – Spin until the pins are detected with the sonar sensor 32 Line Follow For A Given Distance • 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 33 Follow A Line A Given Distance • Example solution Program: TravelDistance.ev3 34 Spin And Search • Here we are going to have the robot spin until it “sees” the pins with the sonar sensor Program: SpinSearch.ev3 35 Task 6 Bowl a tennis ball 36 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 37 Task 7 Return home Watch the YouTube videos at: http://youtu.be/dEioHkb4Y98 (FindHome) 38 Return Home • 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 39 Return Home • Two cases – Light sensor reading > 50. On home base. – Light sensor reading < 50. Off home base. Program: FindHome.ev3 40 Putting It All Together • 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 41 Little Robots, Big Missions Questions? [email protected] 42