Graphical RobotC NXT (EV3) Robot Workshop 2015 Instructor:

Graphical RobotC NXT (EV3) Robot Workshop 2015 Instructor:

Graphical RobotC NXT (EV3) Robot Workshop 2015 Instructor: Dr. Fred Brauchler Assistant: Chris Parker 2/7/2015 Lawrence Technological University 1 Workshop Overview 2015 RoboFest competition RoboBowl RoBot and Software introduction Using RoBot to solve the RoboBowl challenge

2/7/2015 Lawrence Technological University 2 2015 RoboFest Competition 2/7/2015 Lawrence Technological University 3 2015 RoboFest Competition RoboBowl animation https://www.youtube.com/watch?v=LJ0afkDSuZA&feature=youtu.be

Key Tasks Search for black rectangle or edge Measuring height of a rectangle Follow the edge of the table or a line Compute and move to location of pins 3 & 4 Bowl a tennis ball* Return to home base *Please note that bowling the tennis balls is outside the scope of this workshop

2/7/2015 Lawrence Technological University 4 Lego NXT robot RoBot Right motor: B NXT Brick (Computer) Left motor: C Right Light Sensor:port 3 Left Light Sensor:port 2

2/7/2015 The parts shown here may be different from yours. You may need to adapt a design for your parts. Lawrence Technological University 5 Remember the connections! Left Motor connects to C Right Motor connects to B If your motors are upside down, you can change the direction in the program or select reverse in motor and sensors setup

Left Light sensor connects to port no. 2 Right Light sensor connects to port no. 3 Unused ports: A, 1, and 4 2/7/2015 Lawrence Technological University 6 Software and Links How to get RobotC? Version 4.27 download Link: www.robotc.net/robofest/ Or search RobotC 4.28. Currently in Beta. PowerPoint and all example programs are available at robofest.net select menu

RoboBowlWorkshopGRobotC.pptx RoboBowlWorkshopGRobotC.zip In order to use the custom graphical blocks, you must replace some include files in your RobotC directory. Please see ReadmeFirst.txt in zip file. 2/7/2015 Lawrence Technological University 7 Getting Started Launch Graphical RobotC Power up and Connect NXT to Computer

Firmware Download is only needed once per NXT brick Menu: Robot -> Download Firmware -> Standard File Or click on F/W Download button Click on the button Click on button after receiving completed message 2/7/2015 Lawrence Technological University

8 General steps to create a new program & run 1. 2. 3. 4. 5. 6. 7. File -> New -> New file or Robot -> Motors and Sensors Setup or Write the code by dragging command blocks Save your program Ctrl+[s] or Compile by pressing function key F7 or

Download through USB cable key F5 or Run on NXT robot via buttons or 2/7/2015 Lawrence Technological University 9 How to setup RobotC motors Launch RobotC New File Motors and Sensors Setup 2/7/2015

Lawrence Technological University 10 Sensor set up Change S2 for the second light sensor Name: Light2 Sensor Type: Light-Reflected (NXT) 2/7/2015 Lawrence Technological University 11 2015 RoboFest Competition

Recall Key Tasks for Workshop Search for black edge Measuring height of a rectangle Follow a line or table edge Compute and move to location of pins 3 & 4 Bowl a tennis ball* Return to home base *Please note that bowling the tennis balls is outside the scope of this workshop

2/7/2015 Lawrence Technological University 12 Task 1 Search for Black Edge 2/7/2015 Lawrence Technological University 13 SearchForBlack.rbg Program sequence

Move forward Wait until sensor reads value < threshold (50) Stop 2/7/2015 Lawrence Technological University 14 How to See Sensor Values Run any program, for Example: Menu: Robot->Debugger Window->NXT Devices Light Sensor Values 2/7/2015

Lawrence Technological University 15 Choose a Light Sensor Threshold Light sensor settings example On black line = 9 Off black line = 71 Average = (9+71)/2 = 40 use as threshold Get light sensor values On black line = ______

On table = ______ Average = ______ use as threshold 2/7/2015 Lawrence Technological University 16 Task 2 Measure Height of Rectangle 2/7/2015 Lawrence Technological University 17

Measure Distance Determine how far the robot travels when moving forward Compute distance traveled by measuring the number of rotations of the wheel Distance 2/7/2015 Lawrence Technological University 18 Measure Distance Use the wheel geometry

2/7/2015 R =2 Radius D ia me ter Cir cu mf ere

nce =D ad ius ia PI PI = 3.14 Lawrence Technological University How can use this information?

19 Measure Distance For each rotation of the wheel, the robot will travel the distance of the Wheel Circumference Circumference = (Wheel Diameter) x (PI) 56mm x 3.14 = 176mm Distance = Circumference x (# Rotations) 176mm x (# Rotations) 2/7/2015 Lawrence Technological University 20

MeasureRectangle.rbg Comments Program sequence Search for black Reset motor encoder (start counting from zero) Search for white Calculate distance (Circumference) x (# of Rotations) and Display distance Stop 2/7/2015

Lawrence Technological University 21 MeasureRectangle.rbg Wheel circumference = 176mm 2/7/2015 Lawrence Technological University 22 Remote NXT display/control Run any program Menu: Robot->Debugger Window->NXT Remote Screen Can see the brick display

Can click on buttons 2/7/2015 Lawrence Technological University 23 Task 3 Follow a Line or Table Edge 2/7/2015 Lawrence Technological University 24

Follow the Edge of a line Use the zig-zag method to follow the edge of the table Lets add search for the Bowl Zone line. Can we use waitUntil? Must use a loop block like Left Edge Right Edge Table

2/7/2015 Lawrence Technological University 25 EdgeFollowZZ.rbg Program Loop while light sensor > threshold If light2 > threshold, move left (right motor fast, left motor slow) Else move to the right (left motor fast, right motor slow) 2/7/2015 Lawrence Technological University 26

EdgeFollow.rbg Program Loop while light sensor > threshold If light2 > threshold, move left (right motor fast, left motor slow) Use function: lineTra ckfast, Righright t motor slow) Else move to the right (left motor Slow speed Fast speed Threshold value 2/7/2015

Lawrence Technological University 27 Which box is which? ? ? ? Look at text based program then declaration Menu: View -> Convert Graphical File to Text Right-click on function -> Go to Declaration 2/7/2015

Lawrence Technological University 28 How to Improve Edge Following Zig-zag method can cause a bumpy response To improve the response, try a smooth line follower (concept shown below) Turn Left Turn Left 50 30

Light Sensor Reading 50 30 Turn Right 2/7/2015 Light Sensor Reading Turn Right

40 40 2-Level Line Follower Zig-Zag Go Straight Proportional Line Follower Smooth Lawrence Technological University 29 SmoothEdgeFollow.rbg

Turn Left Average Speed Gain or Slope Light Threshold Light Sensor Port Go Straight (30) Slope (100) Light Sensor 50 Reading 30 Turn Right Light Threshold (40)

Proportional Line Follower 2/7/2015 Important: If Gain is set too high or low, the robot will not follow the Edge well. Lawrence Technological University 30 Task 4 Compute and Move to Location for Pins 3&4

2/7/2015 Lawrence Technological University 31 Graphical Robot C Custom Functions* Description Displays the distance and stores value internally Displays the internal value at any time Function for smooth line tracking Function for smooth line tracking Adds number to internal value and stores Multiplies number with internal value and stores Subtracts number from internal value and stores Moves distance corresponding to stored value

*Custom functions were written by the instructor and are not officially supported by RobotC. Please see files NatLang_NXT.c NatLang_EV3.c and BuiltInVariable.txt in directory C:\Program Files (x86)\Robomatter Inc\ROBOTC Development Environment 4.X\Includes\ 2/7/2015 Lawrence Technological University 32 Calculate Distance d Pins 3&4 are located d from edge A formula is unveiled for students to enter Example formula: d = 300 x/5 mm Black rectangle height x is measured with robot during the round Calculated d with custom functions but first we

need to change to multiplication: d = 300 0.2*x mm 2/7/2015 Lawrence Technological University 33 CalculateDistance_d.rbg d = 100 0.2*x mm 2/7/2015 Lawrence Technological University 34

CalculateMove_d.rbg d = 100 0.2*x mm Circumference Speed (negative backup) 2/7/2015 Lawrence Technological University 35 Task 5 Bowl a Tennis Ball 2/7/2015 Lawrence Technological University

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 2/7/2015 Lawrence Technological University 37 Task 6

Return to Home Base 2/7/2015 Lawrence Technological University 38 ReturnHome.rbg One Possibility While looking for foil tape Follow the edge 2/7/2015 Lawrence Technological University

39 Putting It All Together Recall Key Tasks for Workshop 2/7/2015 Search for black edge Measuring height of a rectangle Follow a line or table edge Compute and move to location of pins 3 & 4 Return to home base

Lawrence Technological University 40 Little Robots, Big Missions Questions? [email protected] 2/7/2015 Lawrence Technological University 41

Recently Viewed Presentations

  • NUCLEAR FISSION AND FUSION - Teacher.co.ke

    NUCLEAR FISSION AND FUSION - Teacher.co.ke

    understand that a nucleus of U-235 can be split (the process of fission) by collision with a neutron, and that this process releases energy in the form of kinetic energy of the fission products. understand that the fission of U-235...
  • William Shakespeare

    William Shakespeare

    * * * * * * * * * * * * * * * * * William Shakespeare Born (baptized) April 23, 1564 in Stratford on Avon Father -John Mother---Mary Arden Married Anne Hathaway in 1582 (@18 & she...
  • How did Historical Globalization Affect Canada?

    How did Historical Globalization Affect Canada?

    How did Historical Globalization Affect Canada? Learn the Terms Refer to Chapter 7 for the answers Indian Act Status Indian Residential Schools Multiculturalism Cultural pluralism Quiet Revolution Boarding schools where First Nations children were collected to live, work, study and,...
  • The Scientific Case Against Evolution

    The Scientific Case Against Evolution

    Times New Roman Wingdings Arial Amery Tahoma Tms Rmn Nature The Scientific Case Against Evolution Overview PowerPoint Presentation Darwinian Evolution Darwinian Evolution - 2 The Evolution Model Some Definitions Debunking The Myths in the Creation/Evolution Debate Science Challenges to Evolutionism...
  • Leicester Education Strategic Partnership improving lives | releasing

    Leicester Education Strategic Partnership improving lives | releasing

    What the law says about education for young people in the UKThe age young people 'leave school' in the UK is 18 years, although in practice most young people continue until the end of the academic year in which they...
  • Chapter 15

    Chapter 15

    Chapter 3 Formalism Observables If Then If two operators commute, there is an orthonormal basis with eigenvectors common to both operators 3.2 Questions QM answers 1) How is the state of a system described mathematically?
  • Dot Plots &amp; Box Plots

    Dot Plots & Box Plots

    Box Plot (aka box-and-whisker plot) A box plot splits the data set into quartiles and graphs the 5 number summary. A quartile is . ΒΌ. or . 25% . of the total data. The body of the box plot consists...
  • AP Literature and Composition - Mrs. Schultz

    AP Literature and Composition - Mrs. Schultz

    Hamlet makes an allusion to himself not being like Hercules and to his father being like the sun god of Greek mythology. AMBIGUITY. deliberately suggesting two or more different, and sometimes conflicting, meanings in a work. ... dreary, while I...