180 likes | 324 Views
5 th Annual Robofest 2004 Informational Meeting Mar. 20, 2004. Chan Jin Chung Ali Khazaal Jason Lo Computer Science Lawrence Technological University. Agenda. Introduction to Robofest and Game Rules Go to www.robofest.net and click on Announcement link Tech Resource link
E N D
5th Annual Robofest 2004Informational MeetingMar. 20, 2004 Chan Jin Chung Ali Khazaal Jason Lo Computer Science Lawrence Technological University chung
Agenda • Introduction to Robofest and Game Rules • Go to www.robofest.net and click on Announcement link • Tech Resource link • 9:15am: NQC Installation and Basics • 10:45am: Java, LeJos, Eclipse setup • Announcements chung
NQC installation • You must install RIS or RoboLab software to install the drivers for your IR tower. • Tech Resource or CD-ROM given today • Bricxcc 3.3.7.7 chung
NQC • NQC complier – David Baum • Brick Command Center (bricxcc) – IDE tool • Tutorial: www.robofest.net - TechResource chung
The first NQC program task main() { OnFwd(OUT_A); OnFwd(OUT_B); Wait(400); // 4 sec OnRev(OUT_A+OUT_B); Wait(400); Off(OUT_A+OUT_B); } chung
Control Structures • repeat(n) • while • if • if else • do while chung
Using variables #define TURN_TIME 85 int move_time; // define a variable task main() { move_time = 20; // set the initial value repeat(50) { OnFwd(OUT_A+OUT_C); Wait(move_time); // use the variable for sleeping OnRev(OUT_C); Wait(TURN_TIME); move_time += 5; // increase the variable } Off(OUT_A+OUT_C); } chung
Sensors task main() { SetSensor(SENSOR_1,SENSOR_TOUCH); OnFwd(OUT_A+OUT_C); until (SENSOR_1 == 1); Off(OUT_A+OUT_C); } chung
A Simple Line Following #define THRESHOLD 40 task main() { SetSensor(SENSOR_2,SENSOR_LIGHT); OnFwd(OUT_A+OUT_C); while (true) { if (SENSOR_2 > THRESHOLD) { OnRev(OUT_C); Wait(10); // make smooth movement until (SENSOR_2 <= THRESHOLD); OnFwd(OUT_A+OUT_C); } } } chung
Why Java? • Write once, run anywhere • Professional OO software development • AP exam from C++ to Java, 2004- chung
Install Java, LeJos, and Eclipse! Acknowledgement: Based on web page created by Jason Chien-Tai and updated by Tim Cahoon, a robofest coach • Install RCX or Robolab software to install the drivers for your Infrared Tower. RCX v1.X only supports the serial tower. RCX 2.x supports both the serial and USB versions of the Tower (You can skip this step if you havealready installed RCX or Robolab) • Download Java J2SE SDK from http://java.sun.com/j2se/1.4.2/download.htmlInstall the program by running it. This may take 4-5 minutes to install. (Windows 98 users may need to use the older 1.3.x version if there errorsinstalling the newest version) chung
Dowload leJOS from http://lejos.sourceforge.net/download.html(Start with Version 2.xx) • Extract downloaded leJOS ZIP file to a directory (eg.C:\lejos) Whendoing the unzip, specify unzip to C:\. The zip file will build the lejosdirectory for you. • Download eclipse from http://www.eclipse.org/downloads/index.php(With Latest Release Start with Version 2.xx) • Extract downloaded eclipse ZIP file to a directory (eg. C:\eclipse)When doing the unzip, specify unzip to C:\. The zip file will build the eclipse directory for you. • Download the following zip-bundle org.lejos_1.0.2.zip chung
Unzip it into your eclipse plugin directory. (The files go intoc:\eclipse\plugins ) • Start eclipse by double-clicking eclipse.exe under C:\eclipse(Double-click again if eclipse is not started) HINT: Make a shortcut for eclipse and put it on your desktop. • When eclipse is running, go to the leJOS preference page, usingWindow->Preferences->Lejos page or Lejos->Preferences. chung
Lejos Installation Directory = C:\lejos (where you installed Lejos files)RCX comm port = com1, com1, USB (depends on how infrared tower is connected)Data Transfer Rate = fast, slow (select fast. If you have problems try slow) • If lejos is not listed on the bar (with file, edit, source, etc..) at thetop of eclipse, the lejos plugins were not put in the right directory. (eclipse\plugins is where the files go). Exit eclipse and redo step 8 again. chung
How to write a LeJos Java Program using Eclispe • Create a project: File -> New -> Project • Highlight leJOS Project and click Next (or double click leJOS Project) • Type in your Project Name and Click on Finish • Create a Java class file: File -> New -> Other; double click on Class • Type a Java class name; check public static void main() and click on Finish chung
Compile, download, and run • Save the file (compile is done) • Select: leJOS -> firmware download (for the first time run, takes more than 5 min) • Select: leJOS -> bytecode download to download your program • Press the green Run button to execute your program chung
1010 Announcement 4-3-03: RCX code and RoboLab Workshop 4-17-03 Warm-up Competition at Cranbrook Institute of Science. Only for 10 teams We need referees! chung