1chung 5 th Annual Robofest 2004 Informational Meeting Mar. 20, 2004 Chan Jin Chung Ali Khazaal...
-
Upload
madison-weaver -
Category
Documents
-
view
212 -
download
0
Transcript of 1chung 5 th Annual Robofest 2004 Informational Meeting Mar. 20, 2004 Chan Jin Chung Ali Khazaal...
1chung
5th Annual
Robofest 2004Informational Meeting
Mar. 20, 2004
Chan Jin ChungAli Khazaal
Jason LoComputer Science
Lawrence Technological University
2chung
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
3chung
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
4chung
NQC
• NQC complier – David Baum• Brick Command Center (bricxcc) –
IDE tool• Tutorial: www.robofest.net -
TechResource
5chung
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);}
6chung
Control Structures
• repeat(n)• while• if• if else• do while
7chung
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);}
8chung
Sensors
task main(){ SetSensor(SENSOR_1,SENSOR_TOUCH); OnFwd(OUT_A+OUT_C); until (SENSOR_1 == 1); Off(OUT_A+OUT_C);}
9chung
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); } }}
10chung
Why Java?
• Write once, run anywhere• Professional OO software
development• AP exam from C++ to Java, 2004-
11chung
Install Java, LeJos, and Eclipse!
1. 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)
2. 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)
Acknowledgement: Based on web page created by Jason Chien-Tai and updated by Tim Cahoon, a robofest coach
12chung
3. Dowload leJOS from http://lejos.sourceforge.net/download.html(Start with Version 2.xx)
4. 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.
5. Download eclipse from http://www.eclipse.org/downloads/index.php(With Latest Release Start with Version 2.xx)
6. 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.
7. Download the following zip-bundle org.lejos_1.0.2.zip
13chung
8. Unzip it into your eclipse plugin directory. (The files go intoc:\eclipse\plugins )
9. 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.
10.When eclipse is running, go to the leJOS preference page, usingWindow->Preferences->Lejos page or Lejos->Preferences.
14chung
• 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 88 again.
15chung
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
16chung
17chung
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
18chung
1010Announcement
4-3-03:RCX code and RoboLabWorkshop
4-17-03Warm-up Competition at Cranbrook Institute ofScience.Only for 10 teams
We need referees!