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 **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).
81
82 [[image:attach:lejos_eclipse_plugin.png]]
83
84 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**.
85
86 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).
87
88 ----
89
90 == Creating an Example Project ==
91
92 The following shows how to create a project, which will turn on a light if a button is pressed.
93
94 === Create a new project: ===
95
96 1. Choose //File > New > Project > KIELER SCCharts > SCCharts Project//
97 1. In the project creation wizard that opens, select //Mindstorms NXJ// or// Mindstorms EV3// (depending on your brick) as environment and hit //finish//
98 1. The project wizard from the leJOS plugin opens. Set the project name to //Flashlight// and click //finish//.
99 1. The project is created and the model file is opened in an editor (This might take a few seconds).
100
101 === Edit the model: ===
102
103 Change the contents of the model file to the following code and save it.
104
105 {{code language="sct" theme="Eclipse" title="Floodlight.sct"}}
106 scchart Flashlight {
107
108 @Wrapper TouchSensor, S4
109 input bool button;
110
111 @Wrapper Floodlight, S1
112 output bool light;
113
114 initial state lightOff
115 --> lightOn with button / light = true;
116
117 state lightOn
118 --> lightOff with !button / light = false;
119 }
120 {{/code}}
121
122 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.
123
124 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.
125
126 The available wrapper code snippets are defined in the //snippets// directory of the project in ftl files (FreeMarker template files). The table below gives an overview of the available wrapper code snippets.
127
128 **Note:** The Floodlight of the EV3 has a pretty high latency when switching between on and off.
129
130 **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).**
131 **
132
133 === Launch the project: ===
134
135 With the mouse over the SCT file in the project explorer, perform //Right Click > Run As > KiCo Compilation.//
136
137 A launch config is created, which compiles the model to Java code and creates wrapper code from the annotations in the model file. Afterwards this output is compiled and deployed to the Mindstorms brick, by using the launch shortcut from the leJOS plugin. If any errors occur, you can see them in the Console View.
138
139 For a deeper understanding of the project launch and initialization, take a look at the [[wiki page for Prom>>url:http://rtsys.informatik.uni-kiel.de/confluence/pages/viewpage.action?pageId=13762626||shape="rect"]].
140
141 === Available Wrapper Code Snippets ===
142
143 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 launch. The available snippets are listed below.
144
145 For sensors, the port has to be on of S1, S2, S3, S4.
146
147 For motors / actuators the port has to be one of A, B, C, D.
148
149 (% class="wrapped" %)
150 |=(((
151 Snippet Name and Parameters
152 )))|=(((
153 Description
154 )))|=(((
155 Use on
156 )))|=(% colspan="1" %)(% colspan="1" %)
157 (((
158 Variable type
159 )))|=(((
160 Remark
161 )))|=(% colspan="1" %)(% colspan="1" %)
162 (((
163 Defined in File
164 )))
165 |(% colspan="1" %)(% colspan="1" %)
166 (((
167 **Clock,** milliseconds
168 )))|(% colspan="1" %)(% colspan="1" %)
169 (((
170 Sets a variable to true for one tick if the time in milliseconds passed since the last time it was set to true.
171 )))|(% colspan="1" %)(% colspan="1" %)
172 (((
173 input
174 )))|(% colspan="1" %)(% colspan="1" %)
175 (((
176 bool
177 )))|(% colspan="1" %)(% colspan="1" %)
178 (((
179 See also ResetClock.
180 )))|(% colspan="1" %)(% colspan="1" %)
181 (((
182 timing.ftl
183 )))
184 |(% colspan="1" %)(% colspan="1" %)
185 (((
186 **ResetClock,** clockVariableName, autoFalse
187 )))|(% colspan="1" %)(% colspan="1" %)
188 (((
189 Resets a clock, such that the full time intervall of the clock has to elapse, before the clock will be set to true again.
190
191 If autoFalse is true, the reset variable will be set to false automatically.
192 )))|(% colspan="1" %)(% colspan="1" %)
193 (((
194 output
195 )))|(% colspan="1" %)(% colspan="1" %)
196 (((
197 bool
198 )))|(% colspan="1" %)(% colspan="1" %)
199 (((
200 autoFalse is true per default.
201 )))|(% colspan="1" %)(% colspan="1" %)
202 (((
203 timing.ftl
204 )))
205 |(% colspan="1" %)(% colspan="1" %)
206 (((
207 **Time**
208 )))|(% colspan="1" %)(% colspan="1" %)
209 (((
210 Reads the elapsed time since program start
211 )))|(% colspan="1" %)(% colspan="1" %)
212 (((
213 input
214 )))|(% colspan="1" %)(% colspan="1" %)
215 (((
216 int
217 )))|(% colspan="1" %)(% colspan="1" %)
218 (((
219 \\
220 )))|(% colspan="1" %)(% colspan="1" %)
221 (((
222 timing.ftl
223 )))
224 |(% colspan="1" %)(% colspan="1" %)
225 (((
226 **TickLoopDuration,** targetInMilliseconds
227 )))|(% colspan="1" %)(% colspan="1" %)
228 (((
229 Delays the execution until the tick loop takes at least as long as the given target duration.
230
231 The input variable is set to the actual tick loop duration.
232 )))|(% colspan="1" %)(% colspan="1" %)
233 (((
234 input
235 )))|(% colspan="1" %)(% colspan="1" %)
236 (((
237 int
238 )))|(% colspan="1" %)(% colspan="1" %)
239 (((
240 Should be used on the very first input variable in the model, such that waiting is the last action in the tick loop.
241 )))|(% colspan="1" %)(% colspan="1" %)
242 (((
243 timing.ftl
244 )))
245 |(% colspan="1" %)(% colspan="1" %)
246 (((
247 **TickWakeUp**
248 )))|(% colspan="1" %)(% colspan="1" %)
249 (((
250 Sets the input variable to the current system time. The model can add to this variable to get a new value. This is the next system time it will be called.
251
252 This means the next tick function call is delayed until the wake up time has been reached.
253 )))|(% colspan="1" %)(% colspan="1" %)
254 (((
255 input
256 )))|(% colspan="1" %)(% colspan="1" %)
257 (((
258 int
259 )))|(% colspan="1" %)(% colspan="1" %)
260 (((
261 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.
262 )))|(% colspan="1" %)(% colspan="1" %)
263 (((
264 timing.ftl
265 )))
266 |(% colspan="1" %)(% colspan="1" %)
267 (((
268 **Sleep**
269 )))|(% colspan="1" %)(% colspan="1" %)
270 (((
271 Lets the current thread sleep the time in milliseconds of the variable value.
272 )))|(% colspan="1" %)(% colspan="1" %)
273 (((
274 output
275 )))|(% colspan="1" %)(% colspan="1" %)
276 (((
277 int
278 )))|(% colspan="1" %)(% colspan="1" %)
279 (((
280 \\
281 )))|(% colspan="1" %)(% colspan="1" %)
282 (((
283 timing.ftl
284 )))
285 |(% colspan="1" %)(% colspan="1" %)
286 (((
287 **Print,** autoReset
288 )))|(% colspan="1" %)(% colspan="1" %)
289 (((
290 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
291 )))|(% colspan="1" %)(% colspan="1" %)
292 (((
293 output
294 )))|(% colspan="1" %)(% colspan="1" %)
295 (((
296 string
297 )))|(% colspan="1" %)(% colspan="1" %)
298 (((
299 autoReset is true per default.
300 )))|(% colspan="1" %)(% colspan="1" %)
301 (((
302 print.ftl
303 )))
304 |(% colspan="1" %)(% colspan="1" %)
305 (((
306 **DrawString,** x, y
307 )))|(% colspan="1" %)(% colspan="1" %)
308 (((
309 Prints a string to the given x and y coordinate on the LCD.
310 )))|(% colspan="1" %)(% colspan="1" %)
311 (((
312 output
313 )))|(% colspan="1" %)(% colspan="1" %)
314 (((
315 string
316 )))|(% colspan="1" %)(% colspan="1" %)
317 (((
318 \\
319 )))|(% colspan="1" %)(% colspan="1" %)
320 (((
321 print.ftl
322 )))
323 |(% colspan="1" %)(% colspan="1" %)
324 (((
325 **Button, **buttonId
326 )))|(% colspan="1" %)(% colspan="1" %)
327 (((
328 Sets a variable to true iff the button on the Mindstorms device is pressed.
329 )))|(% colspan="1" %)(% colspan="1" %)
330 (((
331 input
332 )))|(% colspan="1" %)(% colspan="1" %)
333 (((
334 bool
335 )))|(% colspan="1" %)(% colspan="1" %)
336 (((
337 The buttonId has to be one of ENTER, LEFT, RIGHT
338 )))|(% colspan="1" %)(% colspan="1" %)
339 (((
340 touch_and_buttons.ftl
341 )))
342 |(% colspan="1" %)(% colspan="1" %)
343 (((
344 **TouchSensor**, port
345 )))|(% colspan="1" %)(% colspan="1" %)
346 (((
347 Sets a variable to true iff the touch sensor on the given port is pressed.
348 )))|(% colspan="1" %)(% colspan="1" %)
349 (((
350 input
351 )))|(% colspan="1" %)(% colspan="1" %)
352 (((
353 bool
354 )))|(% colspan="1" %)(% colspan="1" %)
355 (((
356 \\
357 )))|(% colspan="1" %)(% colspan="1" %)
358 (((
359 touch_and_buttons.ftl
360 )))
361 |(% colspan="1" %)(% colspan="1" %)
362 (((
363 **LightSensor,** port, percentValue
364 )))|(% colspan="1" %)(% colspan="1" %)
365 (((
366 Reads  the value of a light sensor.
367
368 If percentValue is true, the a percent value is retured, based on the light sensor calibration.
369 )))|(% colspan="1" %)(% colspan="1" %)
370 (((
371 input
372 )))|(% colspan="1" %)(% colspan="1" %)
373 (((
374 int
375 )))|(% colspan="1" %)(% colspan="1" %)
376 (((
377 percentValue is not available on EV3
378 )))|(% colspan="1" %)(% colspan="1" %)
379 (((
380 light.ftl
381 )))
382 |(% colspan="1" %)(% colspan="1" %)
383 (((
384 **CalibrateLightSensor,** port, signal
385 )))|(% colspan="1" %)(% colspan="1" %)
386 (((
387 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.
388 )))|(% colspan="1" %)(% colspan="1" %)
389 (((
390 output
391 )))|(% colspan="1" %)(% colspan="1" %)
392 (((
393 bool
394 )))|(% colspan="1" %)(% colspan="1" %)
395 (((
396 signal has to be one of High, Low
397 )))|(% colspan="1" %)(% colspan="1" %)
398 (((
399 light.ftl
400 )))
401 |(% colspan="1" %)(% colspan="1" %)
402 (((
403 **Floodlight,** port
404 )))|(% colspan="1" %)(% colspan="1" %)
405 (((
406 Reads / Sets the state of the red lamp of the light sensor.
407 )))|(% colspan="1" %)(% colspan="1" %)
408 (((
409 input
410
411 output
412 )))|(% colspan="1" %)(% colspan="1" %)
413 (((
414 bool
415 )))|(% colspan="1" %)(% colspan="1" %)
416 (((
417 \\
418 )))|(% colspan="1" %)(% colspan="1" %)
419 (((
420 light.ftl
421 )))
422 |(% colspan="1" %)(% colspan="1" %)
423 (((
424 **RCXLamp,** port
425 )))|(% colspan="1" %)(% colspan="1" %)
426 (((
427 Turns an RCX lamp on (variable is true) or off (variable is false)
428 )))|(% colspan="1" %)(% colspan="1" %)
429 (((
430 output
431 )))|(% colspan="1" %)(% colspan="1" %)
432 (((
433 bool
434 )))|(% colspan="1" %)(% colspan="1" %)
435 (((
436 \\
437 )))|(% colspan="1" %)(% colspan="1" %)
438 (((
439 light.ftl
440 )))
441 |(% colspan="1" %)(% colspan="1" %)
442 (((
443 **MotorSpeed,** port, brake
444 )))|(% colspan="1" %)(% colspan="1" %)
445 (((
446 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).
447 )))|(% colspan="1" %)(% colspan="1" %)
448 (((
449 input
450
451 output
452 )))|(% colspan="1" %)(% colspan="1" %)
453 (((
454 int
455 )))|(% colspan="1" %)(% colspan="1" %)
456 (((
457 brake is true per default.
458 )))|(% colspan="1" %)(% colspan="1" %)
459 (((
460 motor.ftl
461 )))
462 |(% colspan="1" %)(% colspan="1" %)
463 (((
464 **MotorIsMoving,** port
465 )))|(% colspan="1" %)(% colspan="1" %)
466 (((
467 Sets a variable to true iff the motor on the given port is moving.
468 )))|(% colspan="1" %)(% colspan="1" %)
469 (((
470 input
471 )))|(% colspan="1" %)(% colspan="1" %)
472 (((
473 bool
474 )))|(% colspan="1" %)(% colspan="1" %)
475 (((
476 \\
477 )))|(% colspan="1" %)(% colspan="1" %)
478 (((
479 motor.ftl
480 )))
481 |(% colspan="1" %)(% colspan="1" %)
482 (((
483 **MotorRotation,** port
484 )))|(% colspan="1" %)(% colspan="1" %)
485 (((
486 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.
487 )))|(% colspan="1" %)(% colspan="1" %)
488 (((
489 output
490 )))|(% colspan="1" %)(% colspan="1" %)
491 (((
492 int
493 )))|(% colspan="1" %)(% colspan="1" %)
494 (((
495 \\
496 )))|(% colspan="1" %)(% colspan="1" %)
497 (((
498 motor.ftl
499 )))
500 |(% colspan="1" %)(% colspan="1" %)
501 (((
502 **Beep,** volume
503 )))|(% colspan="1" %)(% colspan="1" %)
504 (((
505 Plays a beep sound as long as the variable is true.
506 )))|(% colspan="1" %)(% colspan="1" %)
507 (((
508 output
509 )))|(% colspan="1" %)(% colspan="1" %)
510 (((
511 bool
512 )))|(% colspan="1" %)(% colspan="1" %)
513 (((
514 default volume is 10
515 )))|(% colspan="1" %)(% colspan="1" %)
516 (((
517 sound.ftl
518 )))
519 |(% colspan="1" %)(% colspan="1" %)
520 (((
521 **Buzz,** volume
522 )))|(% colspan="1" %)(% colspan="1" %)
523 (((
524 Plays a buzz sound as long as the variable is true.
525 )))|(% colspan="1" %)(% colspan="1" %)
526 (((
527 output
528 )))|(% colspan="1" %)(% colspan="1" %)
529 (((
530 bool
531 )))|(% colspan="1" %)(% colspan="1" %)
532 (((
533 default volume is 10
534 )))|(% colspan="1" %)(% colspan="1" %)
535 (((
536 sound.ftl
537 )))
538 |(% colspan="1" %)(% colspan="1" %)
539 (((
540 **BeepSequence,** direction, volume
541 )))|(% colspan="1" %)(% colspan="1" %)
542 (((
543 Plays a sequence of tones in either ascending or descending tone frequency if the variable is true.
544
545 The variable is set to false automatically.
546 )))|(% colspan="1" %)(% colspan="1" %)
547 (((
548 output
549 )))|(% colspan="1" %)(% colspan="1" %)
550 (((
551 bool
552 )))|(% colspan="1" %)(% colspan="1" %)
553 (((
554 direction has to be one of Up, Down
555
556 default volume is 10
557 )))|(% colspan="1" %)(% colspan="1" %)
558 (((
559 sound.ftl
560 )))
561 |(% colspan="1" %)(% colspan="1" %)
562 (((
563 **UltrasonicSensor,** port
564 )))|(% colspan="1" %)(% colspan="1" %)
565 (((
566 Reads the distance that an ultrasonic sensor measures.
567 )))|(% colspan="1" %)(% colspan="1" %)
568 (((
569 input
570 )))|(% colspan="1" %)(% colspan="1" %)
571 (((
572 int
573 )))|(% colspan="1" %)(% colspan="1" %)
574 (((
575 \\
576 )))|(% colspan="1" %)(% colspan="1" %)
577 (((
578 ultrasonic.ftl
579 )))
580 |(% colspan="1" %)(% colspan="1" %)
581 (((
582 **Gyro,** port, mode
583 )))|(% colspan="1" %)(% colspan="1" %)
584 (((
585 Reads the value of a gyroscope.
586 )))|(% colspan="1" %)(% colspan="1" %)
587 (((
588 input
589 )))|(% colspan="1" %)(% colspan="1" %)
590 (((
591 int
592 )))|(% colspan="1" %)(% colspan="1" %)
593 (((
594 Not available on NXT
595
596 mode hat to be one of Angle, Rate
597 )))|(% colspan="1" %)(% colspan="1" %)
598 (((
599 gyro.ftl
600 )))
601 |(% colspan="1" %)(% colspan="1" %)
602 (((
603 **CalibrateGyro,** port, autoReset
604 )))|(% colspan="1" %)(% colspan="1" %)
605 (((
606 Resets a gyroscope if the variable is true.
607
608 If autoReset is true, the variable is set to false automatically.
609 )))|(% colspan="1" %)(% colspan="1" %)
610 (((
611 output
612 )))|(% colspan="1" %)(% colspan="1" %)
613 (((
614 bool
615 )))|(% colspan="1" %)(% colspan="1" %)
616 (((
617 autoReset is true per default
618 )))|(% colspan="1" %)(% colspan="1" %)
619 (((
620 gyro.ftl
621 )))
622
623 \\
624
625 ----
626
627 == Using the Remote Console (RConsole) ==
628
629 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.
630
631 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.
632
633 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.
634
635 ----
636
637 == Problem Solving ==
638
639 The following presents typical issues and how to solve them.
640
641 (% class="wrapped" %)
642 |=(((
643 Issue
644 )))|=(((
645 Typical Error Messages
646 )))|=(((
647 Description
648 )))|=(((
649 Solution
650 )))
651 |(((
652 leJOS EV3 does not support Java 8
653 )))|(((
654 "java.lang.UnsupportedClassVersionError"
655
656 "unsupported major.minor version"
657 )))|(((
658 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
659 )))|(((
660 Go to the project properties and switch to Java 7 (Right Click on project > Properties > Java Compiler > Compiler compliance level)
661 )))
662 |(% colspan="1" %)(% colspan="1" %)
663 (((
664 Uploading to the brick does not respond
665 )))|(% colspan="1" %)(% colspan="1" %)
666 (((
667 \\
668 )))|(% colspan="1" %)(% colspan="1" %)
669 (((
670 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.
671 )))|(% colspan="1" %)(% colspan="1" %)
672 (((
673 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.
674 )))
675 |(% colspan="1" %)(% colspan="1" %)
676 (((
677 Compilation and uploading works from command line but not when using KIELER
678 )))|(% colspan="1" %)(% colspan="1" %)
679 (((
680 This Java instance does not support a 32-bit JVM. Please install the desired version.
681 )))|(% colspan="1" %)(% colspan="1" %)
682 (((
683 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.
684 )))|(% colspan="1" %)(% colspan="1" %)
685 (((
686 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.
687 )))
688 |(% colspan="1" %)(% colspan="1" %)
689 (((
690 Brick does nothing after program finished and prints "Program exit"
691 )))|(% colspan="1" %)(% colspan="1" %)
692 (((
693 \\
694 )))|(% colspan="1" %)(% colspan="1" %)
695 (((
696 A program was uploaded and finished without errors. Afterwards the brick prints "Program exit" but does not open the main menu.
697 )))|(% colspan="1" %)(% colspan="1" %)
698 (((
699 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.
700 )))
701
702 \\
703
704 \\
705
706 input