Download presentation
Presentation is loading. Please wait.
Published byJason Shirar Modified over 9 years ago
1
Graphical RobotC NXT (EV3) Robot Workshop 2015 Instructor: Dr. Fred Brauchler Assistant: Chris Parker 2/7/2015Lawrence Technological University1
2
2/7/2015Lawrence Technological University2 2015 RoboFest competition RoboBowl RoBot and Software introduction Using RoBot to solve the RoboBowl challenge Workshop Overview
3
2/7/2015Lawrence Technological University3 2015 RoboFest Competition
4
2/7/2015Lawrence Technological University4 RoboBowl animation – https://www.youtube.com/watch?v=LJ0afkDSuZA&feature=youtu.be 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 2015 RoboFest Competition
5
2/7/2015Lawrence Technological University5 Lego NXT robot – RoBot Left Light Sensor:port 2 NXT Brick (Computer) Left motor: C Right Light Sensor:port 3 The parts shown here may be different from yours. You may need to adapt a design for your parts. Right motor: B
6
2/7/2015Lawrence Technological University6 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 Remember the connections!
7
2/7/2015Lawrence Technological University7 How to get RobotC? Version 4.27 download Link: www.robotc.net/robofest/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. Software and Links
8
2/7/2015Lawrence Technological University8 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 thebutton Click on button after receiving “completed” message Getting Started
9
2/7/2015Lawrence Technological University9 1.File -> New -> New file or 2.Robot -> Motors and Sensors Setup or 3.Write the code by dragging command blocks 4.Save your program Ctrl+[s] or 5.Compile by pressing function key F7 or 6.Download through USB cable key F5 or 7.Run on NXT robot via buttons or General steps to create a new program & run
10
2/7/2015Lawrence Technological University10 Launch RobotC New File Motors and Sensors Setup How to setup RobotC motors
11
2/7/2015Lawrence Technological University11 Sensor set up Change S2 for the second light sensor Name: Light2 Sensor Type: Light-Reflected (NXT)
12
2/7/2015Lawrence Technological University12 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 2015 RoboFest Competition
13
Task 1 Search for Black Edge 2/7/2015Lawrence Technological University13
14
2/7/2015Lawrence Technological University14 Program sequence – Move forward – Wait until sensor reads value < threshold (50) – Stop SearchForBlack.rbg
15
2/7/2015Lawrence Technological University15 Run any program, for Example: Menu: Robot->Debugger Window->NXT Devices Light Sensor Values How to See Sensor Values
16
2/7/2015Lawrence Technological University16 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 Choose a Light Sensor Threshold
17
Task 2 Measure Height of Rectangle 2/7/2015Lawrence Technological University17
18
2/7/2015Lawrence Technological University18 Determine how far the robot travels when moving forward Measure Distance Distance Compute distance traveled by measuring the number of rotations of the wheel
19
2/7/2015Lawrence Technological University19 Use the wheel geometry Measure Distance PI = 3.14 Circumference = Dia × PI Radius Diameter = 2 × Radius How can use this information?
20
2/7/2015Lawrence Technological University20 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) Measure Distance
21
2/7/2015Lawrence Technological University21 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 MeasureRectangle.rbg
22
2/7/2015Lawrence Technological University22 MeasureRectangle.rbg Wheel circumference = 176mm
23
2/7/2015Lawrence Technological University23 Run any program Menu: Robot->Debugger Window->NXT Remote Screen Can see the brick display Can click on buttons Remote NXT display/control
24
Task 3 Follow a Line or Table Edge 2/7/2015Lawrence Technological University24
25
Table 2/7/2015Lawrence Technological University25 Use the zig-zag method to follow the edge of the table Let’s add search for the Bowl Zone line. Can we use waitUntil? Must use a loop block like Follow the Edge of a line Right Edge Left Edge
26
2/7/2015Lawrence Technological University26 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) EdgeFollowZZ.rbg
27
2/7/2015Lawrence Technological University27 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) EdgeFollow.rbg “Slow” speed “Fast” speed Threshold value Use function: lineTrackRight
28
2/7/2015Lawrence Technological University28 Look at text based program then declaration – Menu: View -> Convert Graphical File to Text Which box is which? ??? Right-click on function -> Go to Declaration
29
Zig-zag method can cause a bumpy response To improve the response, try a smooth line follower (concept shown below) 2/7/2015Lawrence Technological University29 How to Improve Edge Following Light Sensor Reading Turn Left Turn Right 40 30 50 2-Level Line Follower Zig-Zag Light Sensor Reading Turn Left Turn Right 40 30 50 Proportional Line Follower Smooth Go Straight
30
2/7/2015Lawrence Technological University30 SmoothEdgeFollow.rbg Average Speed Gain or Slope Light Threshold Light Sensor Port Important: If Gain is set too high or low, the robot will not follow the Edge well. Light Sensor Reading Turn Left Turn Right Light Threshold (40) 30 50 Proportional Line Follower Go Straight (30) Slope (100)
31
Task 4 Compute and Move to Location for Pins 3&4 2/7/2015Lawrence Technological University31
32
2/7/2015Lawrence Technological University32 Graphical Robot C “Custom” Functions * *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\ Description Displays the distance and stores value internally Displays the internal value at any time 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
33
2/7/2015Lawrence Technological University33 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
34
2/7/2015Lawrence Technological University34 CalculateDistance_d.rbg d = 100 – 0.2*x mm
35
2/7/2015Lawrence Technological University35 CalculateMove_d.rbg d = 100 – 0.2*x mm Circumference Speed (negative backup)
36
Task 5 Bowl a Tennis Ball 2/7/2015Lawrence Technological University36
37
2/7/2015Lawrence Technological University37 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
38
Task 6 Return to Home Base 2/7/2015Lawrence Technological University38
39
2/7/2015Lawrence Technological University39 ReturnHome.rbg One Possibility – While looking for foil tape – Follow the edge
40
2/7/2015Lawrence Technological University40 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 – Return to home base Putting It All Together
41
2/7/2015Lawrence Technological University41 chung@LTU.edu Questions? Little Robots, Big Missions
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.