Show last authors
1 = Program LEGO Mindstorms with leJOS and SCCharts =
2
3
4
5 {{toc minLevel="2"/}}
6
7 ----
8
9 == Overview ==
10
11 Mindstorms is a product family from Lego, with sensors, motors and a programmable brick. The newest iteration of the product family is the EV3 programmable brick. Its predecessors are NXT and RCX. In the following we will see how to develop applications for the NXT brick.
12
13 Several open-source, third-party replacements for the offical Lego firmware have been developed. These support many well known programming languages, such as Java, C/C++, Python, Lua, etc. In the following we will use KIELER SCCharts to program Mindstorms running the Lego Java Operating System ([[leJOS>>url:http://www.lejos.org/||shape="rect"]]). Therefore we will first install leJOS NXJ and flash its firmware. Afterwards we will create a simple SCCharts project in KIELER that we will compile and deploy to the NXT brick.
14
15 If you want to learn the SCCharts langugage first, you can follow these links:
16
17 * [[Introduction to SCCharts>>doc:SCCharts]]
18 * [[The Textual SCCharts Language SCT>>doc:Textual SCCharts Language SCT]]
19 * [[SCCharts Examples>>doc:Examples]]
20
21 ----
22
23 == Download and install leJOS ==
24
25 Download and extract the newest archives for your Operating System from [[Sourceforce>>url:http://sourceforge.net/projects/nxt.lejos.p/files/||shape="rect"]] (Linux/Mac) or use the Setup.exe (Windows).
26
27 The further installation is explained in detail at [[http:~~/~~/www.lejos.org/nxt/nxj/tutorial/Preliminaries/GettingStarted.htm>>url:http://www.lejos.org/nxt/nxj/tutorial/Preliminaries/GettingStarted.htm||shape="rect"]].
28
29 Do not forget to flash the download leJOS firmware to the Mindstorms brick as explained in the tutorial!
30
31 === Known issues ===
32
33 ==== Linux ====
34
35 On Linux there is an issue when uploading the firmware because of a kernel module ([[http:~~/~~/ubuntuforums.org/showthread.php?t=1123633>>url:http://ubuntuforums.org/showthread.php?t=1123633||shape="rect"]]). If you can't upload the firmware with your Linux OS, add **blacklist cdc_acm**{{code language="none"}}{{/code}} at the very end of the file **{{code language="none"}}/etc/modprobe.d/blacklist.conf{{/code}}**. Afterwards execute **{{code language="none"}}sudo rmmod cdc_acm{{/code}}**. This will remove the cdc_acm module from the kernel and prevent its restart. Now try to flash the firmware again.
36
37 Another issue is that the development package of **libusb** has to be installed. On Ubuntu you can do this by using **{{code language="none"}}sudo apt-get install libusb-dev{{/code}}**.
38
39 Furthermore, to use USB connection, a java library has to be compiled via **ant**. To do this perform **cd /path/to/leJOS/build** and start **ant**. If the ant build tool is not installed on your system, you can do so via **sudo apt-get install ant**.
40
41 ==== Windows ====
42
43 The setup.exe of the current LEGO Fantom driver for Windows (1.2.0) has an awkward issue. If you get an error message (Developer Error) because an .msi file could not be found, don't panic. The file is part of the downladed archive (in the Products folder) but you have to start it manually.
44
45 ==== Mac OS X ====
46
47 The **leJOS NXJ** tools require a **32 Bit** version of Java. However, newer 32 Bit versions of Java are not longer available for Mac. Thus to use leJOS the installation of **Java 1.6 is required**, which is the last one that supports a 32 Bit mode. You can download the installer for Java 1.6 from [[https:~~/~~/support.apple.com/kb/dl1572?locale=en_US>>url:https://support.apple.com/kb/dl1572?locale=en_US||shape="rect"]]. It will install Java 1.6 to ///System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home// so that the environment variable //LEJOS_NXT_JAVA_HOME//, which is set in the installation instructions, points to the correct path.
48
49 The environment variable LEJOS_NXT_JAVA_HOME is set in the installation tutorial by editing ~~/.profile. However, on a Mac the environment variables defined in this file are not visible for GUI Applications, only for apps started from terminal. Thus to use leJOS together with KIELER, one either has to start KIELER from terminal or set the environment variable so that all GUI applications can access it. However, this does not seem to be trivial on Mac (see also [[http:~~/~~/stackoverflow.com/questions/135688/setting-environment-variables-in-os-x>>url:http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x||shape="rect"]]).
50
51 ----
52
53 == Test the Mindstorm ==
54
55 A simple Hello World application for the Mindstorms is developed as part of the leJOS tutorial [[http:~~/~~/www.lejos.org/nxt/nxj/tutorial/Preliminaries/FirstProgram.htm>>url:http://www.lejos.org/nxt/nxj/tutorial/Preliminaries/FirstProgram.htm||shape="rect"]]
56
57 If this works with your device, you are able to start using KIELER to develop applications for the NXT brick.
58
59 ----
60
61 == Download and Configure KIELER
62 ==
63
64 Download and unpack the nightly build of KIELER for your OS. It is available at the [[doc:Downloads]] page.\\
65
66 **Note:** Java 1.8 is needed on all operating systems. With Java 1.7 not all plugins of KIELER will be loaded. **Furthermore on Windows**, you will need to download the **32 Bit version of KIELER** – even if you have a 64 bit operating system! Otherwise flashing the brick and uploading to the brick will fail.
67
68 === The Eclipse plugin for leJOS ===
69
70 There is an Eclipse plugin for leJOS which adds a project creation wizard and launch configuration to the platform.
71
72 1. You have to install it via the Eclipse Marketplace (//Help > Eclipse Marketplace...//).
73 OR
74 1. Install the plugin manually (Help > Install new Software...). Use the following update site\\
75 11. for NXT: [[http:~~/~~/www.lejos.org/tools/eclipse/plugin/nxj/>>url:http://www.lejos.org/tools/eclipse/plugin/nxj/||shape="rect"]]
76 11. for EV3: [[http:~~/~~/www.lejos.org/tools/eclipse/plugin/ev3/>>url:http://www.lejos.org/tools/eclipse/plugin/ev3/||shape="rect"]]
77
78 If you have an **NXT** **brick**, install the **leJOS NXJ** Plug-in. If you have an **EV3 brick**, install the **leJOS EV3** plugin.
79
80 [[image:attach:Screenshot_20171016_130805.png]]
81
82 **Tip:** To speed up the installation, uncheck the option "Contact all update sites during install to find required software". This will reduce the installation time from drastically (around 30 seconds instead 10 minutes).
83
84 \\
85
86 After the installation, the plugin requires a **little configuration**. Go to //Window > Preferences > leJOS NXJ// (//Window > Preferences > leJOS EV3 //respectively) and enter the base directory of your **leJOS** **installation** in the **NXJ_HOME field**.
87
88 For EV3, the plugin requires the IP address to connect to the brick (it may work without, but its safer to directly set the name. Reduces headache ). Check **Connect to named brick** and enter the **IP adress** of the brick (displayed on the brick at startup).
89
90 ----
91
92 == Creating an Example Project ==
93
94 The following shows how to create a project, which will turn on a light if a button is pressed.
95
96 === Create a new project: ===
97
98 1. Choose //File > New > Project > KIELER SCCharts > SCCharts Project//
99 1. In the project creation wizard that opens, select //Mindstorms NXJ// or// Mindstorms EV3// (depending on your brick) as environment and hit //finish//
100 1. The project wizard from the leJOS plugin opens. Set the project name to //Flashlight// and click //finish//.
101 1. The project is created and the model file is opened in an editor (This might take a few seconds).
102
103 === Edit the Model: ===
104
105 Change the contents of the model file to the following code and save it.
106
107 {{code language="sct" theme="Eclipse" title="Floodlight.sct"}}
108 scchart Flashlight {
109
110 @Wrapper TouchSensor, S4
111 input bool button;
112
113 @Wrapper Floodlight, S1
114 output bool light;
115
116 initial state lightOff
117 --> lightOn with button / light = true;
118
119 state lightOn
120 --> lightOff with !button / light = false;
121 }
122 {{/code}}
123
124 This model will start in the state lightOff. If the button is pressed, it will turn on the light and change to the corresponding state, where the light is turned off, as soon as the button is not pressed anymore.
125
126 The annotations on the input and output variable are used to define which wrapper code is used to set / read them. **@Wrapper TouchSensor, S4** will set the input variable to true iff the touch sensor on the port S4 is pressed. **@Wrapper Floodlight, S1** on the output variable will turn on the red led of the light sensor that is attatched to port S1 iff the variable is true.
127
128 The available wrapper code snippets are defined in the directory //assets/snippets// in ftl files (FreeMarker template files). The table below gives an overview of the available wrapper code snippets.
129
130 **Note:** The Floodlight of the EV3 has a pretty high latency when switching between on and off.
131
132 **Note: **To view ftl files with highlighting, you may want to install the //FreeMarker IDE// feature from the JBoss Tools. However, this is not necessary to work with KIELER. JBoss Tools is available in the Eclipse Market Place and via update site. The update site for stable releases is [[http:~~/~~/download.jboss.org/jbosstools/neon/stable/updates/ >>url:http://download.jboss.org/jbosstools/neon/stable/updates/||shape="rect"]]. Note that only the //FreeMarker IDE// feature is required (Abridged JBoss Tools > FreeMarker IDE).**
133 **
134
135 === Build the Project: ===
136
137 The model is now ready to be compiled. Compilation is done in the background when the project is built. There are two ways to build a project: manually using //Project > Build Project//, or automatically via //Project > Build Automatically//. If the automatic build is enabled, resources are built when they are saved.
138
139 Building the project will create a new folder //kieler-gen// in which all results are saved. This includes the compiled code from the model, an executable simulation for the model and wrapper code that is ready to be deployed to the Mindstorms Brick.
140
141 The simulation is saved as JAR file in //kieler-gen/sim/bin// and can be started via //Right Click > Run as > KIELER Simulation//. Models and variables of a running simulation are displayed in the Data Pool View.
142
143 [[image:attach:Screenshot_20171016_110005.png]]
144
145 Besides the simulation, the finished wrapper code that can be uploaded to the Mindstorms brick is created as part of the project build. It is saved in //kieler-gen/model//. To upload it to the Mindstorms brick, use //Right Click > Run as > leJOS NXT Program//.
146
147 [[image:attach:Screenshot_20171016_120554.png]]
148
149 ==== Excluding the Simulation from the NXT Build ====
150
151 It is necessary to exclude the simulation directory and org.json directory inside kieler-gen from the NXT project specific build via //Right Click > Build Path > Exclude//. Afterwards the project has to be build again to remove all error markers in these directories.
152
153 [[image:attach:Screenshot_20171016_105821.png]]
154
155 Normally the NXT project attempts to compile all Java files in the kieler-gen directory for the platform. However, the simulation that is generated is not targeted at the Mindstorms brick and has compilation errors. It is compiled separately by KIELER.
156
157 === Available Wrapper Code Snippets ===
158
159 There are several wrapper code snippets that can be used as annotations on input and output variables in the model file. These snippets are inserted in the main file template as part of the project build. The available snippets are listed below.
160
161 For sensors, the port has to be on of S1, S2, S3, S4.
162
163 For motors / actuators the port has to be one of A, B, C, D.
164
165 (% class="wrapped" %)
166 |=(((
167 Snippet Name and Parameters
168 )))|=(((
169 Description
170 )))|=(((
171 Use on
172 )))|=(% colspan="1" %)(% colspan="1" %)
173 (((
174 Variable type
175 )))|=(((
176 Remark
177 )))|=(% colspan="1" %)(% colspan="1" %)
178 (((
179 Defined in File
180 )))
181 |(% colspan="1" %)(% colspan="1" %)
182 (((
183 **Clock,** milliseconds
184 )))|(% colspan="1" %)(% colspan="1" %)
185 (((
186 Sets a variable to true for one tick if the time in milliseconds passed since the last time it was set to true.
187 )))|(% colspan="1" %)(% colspan="1" %)
188 (((
189 input
190 )))|(% colspan="1" %)(% colspan="1" %)
191 (((
192 bool
193 )))|(% colspan="1" %)(% colspan="1" %)
194 (((
195 See also ResetClock.
196 )))|(% colspan="1" %)(% colspan="1" %)
197 (((
198 timing.ftl
199 )))
200 |(% colspan="1" %)(% colspan="1" %)
201 (((
202 **ResetClock,** clockVariableName, autoFalse
203 )))|(% colspan="1" %)(% colspan="1" %)
204 (((
205 Resets a clock, such that the full time intervall of the clock has to elapse, before the clock will be set to true again.
206
207 If autoFalse is true, the reset variable will be set to false automatically.
208 )))|(% colspan="1" %)(% colspan="1" %)
209 (((
210 output
211 )))|(% colspan="1" %)(% colspan="1" %)
212 (((
213 bool
214 )))|(% colspan="1" %)(% colspan="1" %)
215 (((
216 autoFalse is true per default.
217 )))|(% colspan="1" %)(% colspan="1" %)
218 (((
219 timing.ftl
220 )))
221 |(% colspan="1" %)(% colspan="1" %)
222 (((
223 **Time**
224 )))|(% colspan="1" %)(% colspan="1" %)
225 (((
226 Reads the elapsed time since program start (milliseconds)
227 )))|(% colspan="1" %)(% colspan="1" %)
228 (((
229 input
230 )))|(% colspan="1" %)(% colspan="1" %)
231 (((
232 int
233 )))|(% colspan="1" %)(% colspan="1" %)
234 (((
235 \\
236 )))|(% colspan="1" %)(% colspan="1" %)
237 (((
238 timing.ftl
239 )))
240 |(% colspan="1" %)(% colspan="1" %)
241 (((
242 **TickLoopDuration,** targetInMilliseconds
243 )))|(% colspan="1" %)(% colspan="1" %)
244 (((
245 Delays the execution until the tick loop takes at least as long as the given target duration.
246
247 The input variable is set to the actual tick loop duration.
248 )))|(% colspan="1" %)(% colspan="1" %)
249 (((
250 input
251 )))|(% colspan="1" %)(% colspan="1" %)
252 (((
253 int
254 )))|(% colspan="1" %)(% colspan="1" %)
255 (((
256 Should be used on the very first input variable in the model, such that waiting is the last action in the tick loop.
257
258 In case the actual tick loop duration is longer than the target duration, the modeler can provide some error handling.
259 )))|(% colspan="1" %)(% colspan="1" %)
260 (((
261 timing.ftl
262 )))
263 |(% colspan="1" %)(% colspan="1" %)
264 (((
265 **TickWakeUp**
266 )))|(% colspan="1" %)(% colspan="1" %)
267 (((
268 (% class="content-wrapper" %)
269 (((
270 Sets the input variable to the current system time (milliseconds). The model can add to this variable to get a new value. This is the next system time the tick function will be called.
271
272 In other words, the next tick function call is delayed until the wake up time has been reached.
273
274 For instance the statement **nextTickWakeUp += 500** could be used to call the tick function again in 500 milliseconds, if nextTickWakeUp is an input with the corresponding annotation.
275 )))
276 )))|(% colspan="1" %)(% colspan="1" %)
277 (((
278 input
279 )))|(% colspan="1" %)(% colspan="1" %)
280 (((
281 int
282 )))|(% colspan="1" %)(% colspan="1" %)
283 (((
284 Should be used on the very last input variable in the model, such that waiting and settings the system time is the last action done, before the tick function call.
285 )))|(% colspan="1" %)(% colspan="1" %)
286 (((
287 timing.ftl
288 )))
289 |(% colspan="1" %)(% colspan="1" %)
290 (((
291 **Sleep**
292 )))|(% colspan="1" %)(% colspan="1" %)
293 (((
294 Lets the current thread sleep the time in milliseconds of the variable value.
295 )))|(% colspan="1" %)(% colspan="1" %)
296 (((
297 output
298 )))|(% colspan="1" %)(% colspan="1" %)
299 (((
300 int
301 )))|(% colspan="1" %)(% colspan="1" %)
302 (((
303 \\
304 )))|(% colspan="1" %)(% colspan="1" %)
305 (((
306 timing.ftl
307 )))
308 |(% colspan="1" %)(% colspan="1" %)
309 (((
310 **Print,** autoReset
311 )))|(% colspan="1" %)(% colspan="1" %)
312 (((
313 Prints a string variable if the string is not empty. If autoReset is true then the string variable is set to the empty string after it has been printed
314 )))|(% colspan="1" %)(% colspan="1" %)
315 (((
316 output
317 )))|(% colspan="1" %)(% colspan="1" %)
318 (((
319 string
320 )))|(% colspan="1" %)(% colspan="1" %)
321 (((
322 autoReset is true per default.
323 )))|(% colspan="1" %)(% colspan="1" %)
324 (((
325 print.ftl
326 )))
327 |(% colspan="1" %)(% colspan="1" %)
328 (((
329 **DrawString,** x, y
330 )))|(% colspan="1" %)(% colspan="1" %)
331 (((
332 Prints a string to the given x and y coordinate on the LCD.
333 )))|(% colspan="1" %)(% colspan="1" %)
334 (((
335 output
336 )))|(% colspan="1" %)(% colspan="1" %)
337 (((
338 string
339 )))|(% colspan="1" %)(% colspan="1" %)
340 (((
341 \\
342 )))|(% colspan="1" %)(% colspan="1" %)
343 (((
344 print.ftl
345 )))
346 |(% colspan="1" %)(% colspan="1" %)
347 (((
348 **Button, **buttonId
349 )))|(% colspan="1" %)(% colspan="1" %)
350 (((
351 Sets a variable to true iff the button on the Mindstorms device is pressed.
352 )))|(% colspan="1" %)(% colspan="1" %)
353 (((
354 input
355 )))|(% colspan="1" %)(% colspan="1" %)
356 (((
357 bool
358 )))|(% colspan="1" %)(% colspan="1" %)
359 (((
360 The buttonId has to be one of ENTER, LEFT, RIGHT
361 )))|(% colspan="1" %)(% colspan="1" %)
362 (((
363 touch_and_buttons.ftl
364 )))
365 |(% colspan="1" %)(% colspan="1" %)
366 (((
367 **TouchSensor**, port
368 )))|(% colspan="1" %)(% colspan="1" %)
369 (((
370 Sets a variable to true iff the touch sensor on the given port is pressed.
371 )))|(% colspan="1" %)(% colspan="1" %)
372 (((
373 input
374 )))|(% colspan="1" %)(% colspan="1" %)
375 (((
376 bool
377 )))|(% colspan="1" %)(% colspan="1" %)
378 (((
379 \\
380 )))|(% colspan="1" %)(% colspan="1" %)
381 (((
382 touch_and_buttons.ftl
383 )))
384 |(% colspan="1" %)(% colspan="1" %)
385 (((
386 **LightSensor,** port, percentValue
387 )))|(% colspan="1" %)(% colspan="1" %)
388 (((
389 Reads  the value of a light sensor.
390
391 If percentValue is true, the a percent value is retured, based on the light sensor calibration.
392 )))|(% colspan="1" %)(% colspan="1" %)
393 (((
394 input
395 )))|(% colspan="1" %)(% colspan="1" %)
396 (((
397 int
398 )))|(% colspan="1" %)(% colspan="1" %)
399 (((
400 percentValue is not available on EV3
401 )))|(% colspan="1" %)(% colspan="1" %)
402 (((
403 light.ftl
404 )))
405 |(% colspan="1" %)(% colspan="1" %)
406 (((
407 **CalibrateLightSensor,** port, signal
408 )))|(% colspan="1" %)(% colspan="1" %)
409 (((
410 Calibrates a light sensors high or low values. This means if the variable is true, the current value of the light sensor is taken as its reference high / low value.
411 )))|(% colspan="1" %)(% colspan="1" %)
412 (((
413 output
414 )))|(% colspan="1" %)(% colspan="1" %)
415 (((
416 bool
417 )))|(% colspan="1" %)(% colspan="1" %)
418 (((
419 signal has to be one of High, Low
420 )))|(% colspan="1" %)(% colspan="1" %)
421 (((
422 light.ftl
423 )))
424 |(% colspan="1" %)(% colspan="1" %)
425 (((
426 **Floodlight,** port
427 )))|(% colspan="1" %)(% colspan="1" %)
428 (((
429 Reads / Sets the state of the red lamp of the light sensor.
430 )))|(% colspan="1" %)(% colspan="1" %)
431 (((
432 input
433
434 output
435 )))|(% colspan="1" %)(% colspan="1" %)
436 (((
437 bool
438 )))|(% colspan="1" %)(% colspan="1" %)
439 (((
440 \\
441 )))|(% colspan="1" %)(% colspan="1" %)
442 (((
443 light.ftl
444 )))
445 |(% colspan="1" %)(% colspan="1" %)
446 (((
447 **RCXLamp,** port
448 )))|(% colspan="1" %)(% colspan="1" %)
449 (((
450 Turns an RCX lamp on (variable is true) or off (variable is false)
451 )))|(% colspan="1" %)(% colspan="1" %)
452 (((
453 output
454 )))|(% colspan="1" %)(% colspan="1" %)
455 (((
456 bool
457 )))|(% colspan="1" %)(% colspan="1" %)
458 (((
459 \\
460 )))|(% colspan="1" %)(% colspan="1" %)
461 (((
462 light.ftl
463 )))
464 |(% colspan="1" %)(% colspan="1" %)
465 (((
466 **MotorSpeed,** port, brake
467 )))|(% colspan="1" %)(% colspan="1" %)
468 (((
469 Reads / Sets the speed of the motor in degrees per minute. If the speed value is negative, the motor will drive backwards. If the speed is zero, the motor will actively brake until it stops (brake is true) or remove all power and rollout (brake is false).
470 )))|(% colspan="1" %)(% colspan="1" %)
471 (((
472 input
473
474 output
475 )))|(% colspan="1" %)(% colspan="1" %)
476 (((
477 int
478 )))|(% colspan="1" %)(% colspan="1" %)
479 (((
480 brake is true per default.
481 )))|(% colspan="1" %)(% colspan="1" %)
482 (((
483 motor.ftl
484 )))
485 |(% colspan="1" %)(% colspan="1" %)
486 (((
487 **MotorIsMoving,** port
488 )))|(% colspan="1" %)(% colspan="1" %)
489 (((
490 Sets a variable to true iff the motor on the given port is moving.
491 )))|(% colspan="1" %)(% colspan="1" %)
492 (((
493 input
494 )))|(% colspan="1" %)(% colspan="1" %)
495 (((
496 bool
497 )))|(% colspan="1" %)(% colspan="1" %)
498 (((
499 \\
500 )))|(% colspan="1" %)(% colspan="1" %)
501 (((
502 motor.ftl
503 )))
504 |(% colspan="1" %)(% colspan="1" %)
505 (((
506 **MotorRotation,** port
507 )))|(% colspan="1" %)(% colspan="1" %)
508 (((
509 Lets a motor rotate the variable value in degrees. This is only done if the value is unequal zero. If the value is negative, the motor rotates backwards. The variable is set to zero afterwards, such that setting the variable once to a value //X//, will let the motor rotate //X// degrees.
510 )))|(% colspan="1" %)(% colspan="1" %)
511 (((
512 output
513 )))|(% colspan="1" %)(% colspan="1" %)
514 (((
515 int
516 )))|(% colspan="1" %)(% colspan="1" %)
517 (((
518 \\
519 )))|(% colspan="1" %)(% colspan="1" %)
520 (((
521 motor.ftl
522 )))
523 |(% colspan="1" %)(% colspan="1" %)
524 (((
525 **Beep,** volume
526 )))|(% colspan="1" %)(% colspan="1" %)
527 (((
528 Plays a beep sound as long as the variable is true.
529 )))|(% colspan="1" %)(% colspan="1" %)
530 (((
531 output
532 )))|(% colspan="1" %)(% colspan="1" %)
533 (((
534 bool
535 )))|(% colspan="1" %)(% colspan="1" %)
536 (((
537 default volume is 10
538 )))|(% colspan="1" %)(% colspan="1" %)
539 (((
540 sound.ftl
541 )))
542 |(% colspan="1" %)(% colspan="1" %)
543 (((
544 **Buzz,** volume
545 )))|(% colspan="1" %)(% colspan="1" %)
546 (((
547 Plays a buzz sound as long as the variable is true.
548 )))|(% colspan="1" %)(% colspan="1" %)
549 (((
550 output
551 )))|(% colspan="1" %)(% colspan="1" %)
552 (((
553 bool
554 )))|(% colspan="1" %)(% colspan="1" %)
555 (((
556 default volume is 10
557 )))|(% colspan="1" %)(% colspan="1" %)
558 (((
559 sound.ftl
560 )))
561 |(% colspan="1" %)(% colspan="1" %)
562 (((
563 **BeepSequence,** direction, volume
564 )))|(% colspan="1" %)(% colspan="1" %)
565 (((
566 Plays a sequence of tones in either ascending or descending tone frequency if the variable is true.
567
568 The variable is set to false automatically.
569 )))|(% colspan="1" %)(% colspan="1" %)
570 (((
571 output
572 )))|(% colspan="1" %)(% colspan="1" %)
573 (((
574 bool
575 )))|(% colspan="1" %)(% colspan="1" %)
576 (((
577 direction has to be one of Up, Down
578
579 default volume is 10
580 )))|(% colspan="1" %)(% colspan="1" %)
581 (((
582 sound.ftl
583 )))
584 |(% colspan="1" %)(% colspan="1" %)
585 (((
586 **UltrasonicSensor,** port
587 )))|(% colspan="1" %)(% colspan="1" %)
588 (((
589 Reads the distance that an ultrasonic sensor measures.
590 )))|(% colspan="1" %)(% colspan="1" %)
591 (((
592 input
593 )))|(% colspan="1" %)(% colspan="1" %)
594 (((
595 int
596 )))|(% colspan="1" %)(% colspan="1" %)
597 (((
598 \\
599 )))|(% colspan="1" %)(% colspan="1" %)
600 (((
601 ultrasonic.ftl
602 )))
603 |(% colspan="1" %)(% colspan="1" %)
604 (((
605 **Gyro,** port, mode
606 )))|(% colspan="1" %)(% colspan="1" %)
607 (((
608 Reads the value of a gyroscope.
609 )))|(% colspan="1" %)(% colspan="1" %)
610 (((
611 input
612 )))|(% colspan="1" %)(% colspan="1" %)
613 (((
614 int
615 )))|(% colspan="1" %)(% colspan="1" %)
616 (((
617 Not available on NXT
618
619 mode hat to be one of Angle, Rate
620 )))|(% colspan="1" %)(% colspan="1" %)
621 (((
622 gyro.ftl
623 )))
624 |(% colspan="1" %)(% colspan="1" %)
625 (((
626 **CalibrateGyro,** port, autoReset
627 )))|(% colspan="1" %)(% colspan="1" %)
628 (((
629 Resets a gyroscope if the variable is true.
630
631 If autoReset is true, the variable is set to false automatically.
632 )))|(% colspan="1" %)(% colspan="1" %)
633 (((
634 output
635 )))|(% colspan="1" %)(% colspan="1" %)
636 (((
637 bool
638 )))|(% colspan="1" %)(% colspan="1" %)
639 (((
640 autoReset is true per default
641 )))|(% colspan="1" %)(% colspan="1" %)
642 (((
643 gyro.ftl
644 )))
645
646 \\
647
648 ----
649
650 == Using the Remote Console (RConsole) ==
651
652 The display of the **NXT brick** is rather small compared to a Monitor. To ease debugging, one can print to a Remote Console (RConsole), if the USB cable is connected. This enables easier collection for example of sensor data.
653
654 To use the RConsole, **uncomment** the **RConsole** lines in the wrapper code template **Main.ftl**. Start the **nxjconsoleviewer** tool in the bin directory of your **leJOS installation**. Now, when **starting the application**, the brick tries to connect with the nxjconsoleviewer. **Press the //Connect//** button. If connected succesfully, RConsole.println(...) commands will be written to this window.
655
656 The **EV3 brick** has a similar feature. However it does not require any code changes. Just run the ev3console program in the bin directory of your leJOS installation from command line. The output of the brick will be printed to this command line.
657
658 ----
659
660 == Problem Solving ==
661
662 The following presents typical issues and how to solve them.
663
664 (% class="wrapped" %)
665 |=(((
666 Issue
667 )))|=(((
668 Typical Error Messages
669 )))|=(((
670 Description
671 )))|=(((
672 Solution
673 )))
674 |(((
675 leJOS EV3 does not support Java 8
676 )))|(((
677 "java.lang.UnsupportedClassVersionError"
678
679 "unsupported major.minor version"
680 )))|(((
681 You compile the sources in your project with Java 8 and upload them to the brick. However the lejos EV3 does not support Java 8
682 )))|(((
683 Go to the project properties and switch to Java 7 (Right Click on project > Properties > Java Compiler > Compiler compliance level)
684 )))
685 |(% colspan="1" %)(% colspan="1" %)
686 (((
687 Uploading to the brick does not respond
688 )))|(% colspan="1" %)(% colspan="1" %)
689 (((
690 \\
691 )))|(% colspan="1" %)(% colspan="1" %)
692 (((
693 You compile a file successfully and when uploading the result, the connected brick is found. Anyway the upload does not terminate and does not react.
694 )))|(% colspan="1" %)(% colspan="1" %)
695 (((
696 Flash the brick with the current leJOS firmware. If the brick is recognized correctly and the attempt to upload a compiled file fails then the firmware on the brick might be outdated.
697 )))
698 |(% colspan="1" %)(% colspan="1" %)
699 (((
700 Compilation and uploading works from command line but not when using KIELER
701 )))|(% colspan="1" %)(% colspan="1" %)
702 (((
703 This Java instance does not support a 32-bit JVM. Please install the desired version.
704 )))|(% colspan="1" %)(% colspan="1" %)
705 (((
706 You can compile and upload code to the brick using the command line tools but when using KIELER an error message apprears because Java does not support 32-bit JVM.
707 )))|(% colspan="1" %)(% colspan="1" %)
708 (((
709 Set the LEJOS_NXT_JAVA_HOME environment variable, such that it points to an 32-bit JDK and is visible for GUI applications (or at least KIELER). The process to do so differs on every OS. As alternative, execute KIELER from terminal.
710 )))
711 |(% colspan="1" %)(% colspan="1" %)
712 (((
713 Brick does nothing after program finished and prints "Program exit"
714 )))|(% colspan="1" %)(% colspan="1" %)
715 (((
716 \\
717 )))|(% colspan="1" %)(% colspan="1" %)
718 (((
719 A program was uploaded and finished without errors. Afterwards the brick prints "Program exit" but does not open the main menu.
720 )))|(% colspan="1" %)(% colspan="1" %)
721 (((
722 This is normal behaviour if uploading a program in debug mode instead run mode (//Debug As// instead //Run As// in Eclipse). To get back to the main menu, press the ENTER and ESCAPE button of the brick at the same time.
723 )))
724
725 \\
726
727 \\