Changes for page LEGO Mindstorms with leJOS and SCCharts
Last modified by Alexander Schulz-Rosengarten on 2023/09/11 16:17
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -8,88 +8,103 @@ 8 8 9 9 == Overview == 10 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 , thus //Mindstorms// will be used exchangeable with //NXT brick//.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 12 13 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 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 + 15 15 ---- 16 16 17 17 == Download and install leJOS == 18 18 19 -Download and extract the newest archives for your Operating System from [[Sourceforce>>url:http://sourceforge.net/projects/nxt.lejos.p/files/||shape="rect"]]. 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). 20 20 21 21 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"]]. 22 22 29 +Do not forget to flash the download leJOS firmware to the Mindstorms brick as explained in the tutorial! 30 + 23 23 === Known issues === 24 24 25 -== Linux == 33 +==== Linux ==== 26 26 27 27 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. 28 28 29 29 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}}**. 30 30 31 -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**. 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**. 32 32 33 - ----41 +==== Windows ==== 34 34 35 - ==Test theMindstorm==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. 36 36 37 - Asimple Hello Worldapplicationfor the Mindstorms is developed as part of the leJOStutorial[[http:~~/~~/www.lejos.org/nxt/nxj/tutorial/Preliminaries/FirstProgram.htm>>url:http://www.lejos.org/nxt/nxj/tutorial/Preliminaries/FirstProgram.htm||shape="rect"]]45 +==== Mac OS X ==== 38 38 39 - Ifthisworkswithyourdevice,youare able to startusingKIELERto developications for the NXTbrick.\\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. 40 40 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 + 41 41 ---- 42 42 43 -== T heEclipsepluginforleJOS==53 +== Test the Mindstorm == 44 44 45 - Thereisan EclipsepluginforeJOS which addsaroject creationwizardand launchconfigurationto theplatform.You caninstallt viatheEclipse Marketplace(//Help > Eclipse Marketplace...//)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"]] 46 46 47 - [[image:attach:lejos_eclipse_plugin.png]]57 +If this works with your device, you are able to start using KIELER to develop applications for the NXT brick. 48 48 49 49 ---- 50 50 51 -== Configure KIELER == 61 +== Download and Configure KIELER 62 + == 52 52 53 - WiththeEclipse plugin forleJOSinstalled,youcan now useKIELERSCChartsforanmodel-basedapproach ofprogramming.64 +Download and unpack the nightly build of KIELER for your OS. It is available at the [[doc:Downloads]] page.\\ 54 54 55 - Firstcheck thenvironmentsettingsforNXJoftheKIELER tool(//Window>Preferences>KIELER>Environments//).Ensurethat thecommandsoftheexecutetabhavecorrectpaths.Theyhavetousethelibdirectoryof your leJOSinstallation.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. 56 56 57 - [[image:attach:lejos_nxj_environment.png]]68 +=== The Eclipse plugin for leJOS === 58 58 59 - Create a first project using theSCCharts projectwizard (//File > New > Project > KIELER SCCharts> SCT Project//)andselect the environment forleJOS NXJ. Whenpressing thefinishbutton, the projectwizard of theleJOSpluginwill start. Set theproject name andhit finish.Theprojectwill becreated by the leJOS plugin andinitializedby the KIELER plugin,giving it a model file and afile with wrapper codetoinitalize and runthe model.70 +There is an Eclipse plugin for leJOS which adds a project creation wizard and launch configuration to the platform. 60 60 61 -When you choose //Debug As > KiCo Compilation// on the model, it is compiled by the KIELER Compiler to Java code and further compiled and deployed to the NXT brick using the commands from aforesaid environment. 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"]] 62 62 63 - Foradeeperunderstandingoftheprojectlaunchandinitialization,take alookat the[[wiki pageforProm>>url:http://rtsys.informatik.uni-kiel.de/confluence/pages/viewpage.action?pageId=13762626||shape="rect"]].78 +If you have an **NXT** **brick**, install the **leJOS NXJ** Plug-in. If you have an **EV3 brick**, install the **leJOS EV3** plugin. 64 64 65 - ----80 +[[image:attach:Screenshot_20171016_130805.png]] 66 66 67 - ==UsingtheRemoteConsole (RConsole)==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). 68 68 69 - 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.84 +\\ 70 70 71 - To use theRConsole, **uncomment**the**RConsole** linesin the wrappercodetemplate**Main.ftl**.Startthe**nxjconsoleviewer**tool in the bindirectory of your **leJOS installation**.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**. 72 72 73 - Now,when**startingthe application**,the brick tries toconnectwiththe nxjconsoleviewer.**Pressthe//Connect//**button.If connectedsuccesfully,RConsole.println(...)commandswillbewrittento thiswindow.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). 74 74 75 75 ---- 76 76 77 77 == Creating an Example Project == 78 78 79 -The following shows how to create a project, thatwill turn on a light if a button is pressed.94 +The following shows how to create a project, which will turn on a light if a button is pressed. 80 80 81 81 === Create a new project: === 82 82 83 -1. Choose //File > New > Project > SCCharts Project// 84 -1. In the project creation wizard that opens, select //Mindstorms NXJ// as environment and hit //finish// 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// 85 85 1. The project wizard from the leJOS plugin opens. Set the project name to //Flashlight// and click //finish//. 86 86 1. The project is created and the model file is opened in an editor (This might take a few seconds). 87 87 88 -=== Edit the model: ===103 +=== Edit the Model: === 89 89 90 90 Change the contents of the model file to the following code and save it. 91 91 92 -{{code title="Floodlight.sct" theme="Eclipse" language="sct"}}107 +{{code language="sct" theme="Eclipse" title="Floodlight.sct"}} 93 93 scchart Flashlight { 94 94 95 95 @Wrapper TouchSensor, S4 ... ... @@ -108,11 +108,598 @@ 108 108 109 109 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. 110 110 111 -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.** 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).** 112 112 ** 113 113 114 -=== Launchtheproject: ===135 +=== Build the Project: === 115 115 116 - Withthe mouse over theSCTfile in the projectexplorer,perform//RightClick>RunAs>KiCoCompilation.//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. 117 117 118 -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 shell commands that are defined in the Mindstorms NXJ environment. 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 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 +)))|(% colspan="1" %)(% colspan="1" %) 258 +((( 259 +timing.ftl 260 +))) 261 +|(% colspan="1" %)(% colspan="1" %) 262 +((( 263 +**TickWakeUp** 264 +)))|(% colspan="1" %)(% colspan="1" %) 265 +((( 266 +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. 267 + 268 +This means the next tick function call is delayed until the wake up time has been reached. 269 +)))|(% colspan="1" %)(% colspan="1" %) 270 +((( 271 +input 272 +)))|(% colspan="1" %)(% colspan="1" %) 273 +((( 274 +int 275 +)))|(% colspan="1" %)(% colspan="1" %) 276 +((( 277 +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. 278 +)))|(% colspan="1" %)(% colspan="1" %) 279 +((( 280 +timing.ftl 281 +))) 282 +|(% colspan="1" %)(% colspan="1" %) 283 +((( 284 +**Sleep** 285 +)))|(% colspan="1" %)(% colspan="1" %) 286 +((( 287 +Lets the current thread sleep the time in milliseconds of the variable value. 288 +)))|(% colspan="1" %)(% colspan="1" %) 289 +((( 290 +output 291 +)))|(% colspan="1" %)(% colspan="1" %) 292 +((( 293 +int 294 +)))|(% colspan="1" %)(% colspan="1" %) 295 +((( 296 +\\ 297 +)))|(% colspan="1" %)(% colspan="1" %) 298 +((( 299 +timing.ftl 300 +))) 301 +|(% colspan="1" %)(% colspan="1" %) 302 +((( 303 +**Print,** autoReset 304 +)))|(% colspan="1" %)(% colspan="1" %) 305 +((( 306 +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 307 +)))|(% colspan="1" %)(% colspan="1" %) 308 +((( 309 +output 310 +)))|(% colspan="1" %)(% colspan="1" %) 311 +((( 312 +string 313 +)))|(% colspan="1" %)(% colspan="1" %) 314 +((( 315 +autoReset is true per default. 316 +)))|(% colspan="1" %)(% colspan="1" %) 317 +((( 318 +print.ftl 319 +))) 320 +|(% colspan="1" %)(% colspan="1" %) 321 +((( 322 +**DrawString,** x, y 323 +)))|(% colspan="1" %)(% colspan="1" %) 324 +((( 325 +Prints a string to the given x and y coordinate on the LCD. 326 +)))|(% colspan="1" %)(% colspan="1" %) 327 +((( 328 +output 329 +)))|(% colspan="1" %)(% colspan="1" %) 330 +((( 331 +string 332 +)))|(% colspan="1" %)(% colspan="1" %) 333 +((( 334 +\\ 335 +)))|(% colspan="1" %)(% colspan="1" %) 336 +((( 337 +print.ftl 338 +))) 339 +|(% colspan="1" %)(% colspan="1" %) 340 +((( 341 +**Button, **buttonId 342 +)))|(% colspan="1" %)(% colspan="1" %) 343 +((( 344 +Sets a variable to true iff the button on the Mindstorms device is pressed. 345 +)))|(% colspan="1" %)(% colspan="1" %) 346 +((( 347 +input 348 +)))|(% colspan="1" %)(% colspan="1" %) 349 +((( 350 +bool 351 +)))|(% colspan="1" %)(% colspan="1" %) 352 +((( 353 +The buttonId has to be one of ENTER, LEFT, RIGHT 354 +)))|(% colspan="1" %)(% colspan="1" %) 355 +((( 356 +touch_and_buttons.ftl 357 +))) 358 +|(% colspan="1" %)(% colspan="1" %) 359 +((( 360 +**TouchSensor**, port 361 +)))|(% colspan="1" %)(% colspan="1" %) 362 +((( 363 +Sets a variable to true iff the touch sensor on the given port is pressed. 364 +)))|(% colspan="1" %)(% colspan="1" %) 365 +((( 366 +input 367 +)))|(% colspan="1" %)(% colspan="1" %) 368 +((( 369 +bool 370 +)))|(% colspan="1" %)(% colspan="1" %) 371 +((( 372 +\\ 373 +)))|(% colspan="1" %)(% colspan="1" %) 374 +((( 375 +touch_and_buttons.ftl 376 +))) 377 +|(% colspan="1" %)(% colspan="1" %) 378 +((( 379 +**LightSensor,** port, percentValue 380 +)))|(% colspan="1" %)(% colspan="1" %) 381 +((( 382 +Reads the value of a light sensor. 383 + 384 +If percentValue is true, the a percent value is retured, based on the light sensor calibration. 385 +)))|(% colspan="1" %)(% colspan="1" %) 386 +((( 387 +input 388 +)))|(% colspan="1" %)(% colspan="1" %) 389 +((( 390 +int 391 +)))|(% colspan="1" %)(% colspan="1" %) 392 +((( 393 +percentValue is not available on EV3 394 +)))|(% colspan="1" %)(% colspan="1" %) 395 +((( 396 +light.ftl 397 +))) 398 +|(% colspan="1" %)(% colspan="1" %) 399 +((( 400 +**CalibrateLightSensor,** port, signal 401 +)))|(% colspan="1" %)(% colspan="1" %) 402 +((( 403 +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. 404 +)))|(% colspan="1" %)(% colspan="1" %) 405 +((( 406 +output 407 +)))|(% colspan="1" %)(% colspan="1" %) 408 +((( 409 +bool 410 +)))|(% colspan="1" %)(% colspan="1" %) 411 +((( 412 +signal has to be one of High, Low 413 +)))|(% colspan="1" %)(% colspan="1" %) 414 +((( 415 +light.ftl 416 +))) 417 +|(% colspan="1" %)(% colspan="1" %) 418 +((( 419 +**Floodlight,** port 420 +)))|(% colspan="1" %)(% colspan="1" %) 421 +((( 422 +Reads / Sets the state of the red lamp of the light sensor. 423 +)))|(% colspan="1" %)(% colspan="1" %) 424 +((( 425 +input 426 + 427 +output 428 +)))|(% colspan="1" %)(% colspan="1" %) 429 +((( 430 +bool 431 +)))|(% colspan="1" %)(% colspan="1" %) 432 +((( 433 +\\ 434 +)))|(% colspan="1" %)(% colspan="1" %) 435 +((( 436 +light.ftl 437 +))) 438 +|(% colspan="1" %)(% colspan="1" %) 439 +((( 440 +**RCXLamp,** port 441 +)))|(% colspan="1" %)(% colspan="1" %) 442 +((( 443 +Turns an RCX lamp on (variable is true) or off (variable is false) 444 +)))|(% colspan="1" %)(% colspan="1" %) 445 +((( 446 +output 447 +)))|(% colspan="1" %)(% colspan="1" %) 448 +((( 449 +bool 450 +)))|(% colspan="1" %)(% colspan="1" %) 451 +((( 452 +\\ 453 +)))|(% colspan="1" %)(% colspan="1" %) 454 +((( 455 +light.ftl 456 +))) 457 +|(% colspan="1" %)(% colspan="1" %) 458 +((( 459 +**MotorSpeed,** port, brake 460 +)))|(% colspan="1" %)(% colspan="1" %) 461 +((( 462 +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). 463 +)))|(% colspan="1" %)(% colspan="1" %) 464 +((( 465 +input 466 + 467 +output 468 +)))|(% colspan="1" %)(% colspan="1" %) 469 +((( 470 +int 471 +)))|(% colspan="1" %)(% colspan="1" %) 472 +((( 473 +brake is true per default. 474 +)))|(% colspan="1" %)(% colspan="1" %) 475 +((( 476 +motor.ftl 477 +))) 478 +|(% colspan="1" %)(% colspan="1" %) 479 +((( 480 +**MotorIsMoving,** port 481 +)))|(% colspan="1" %)(% colspan="1" %) 482 +((( 483 +Sets a variable to true iff the motor on the given port is moving. 484 +)))|(% colspan="1" %)(% colspan="1" %) 485 +((( 486 +input 487 +)))|(% colspan="1" %)(% colspan="1" %) 488 +((( 489 +bool 490 +)))|(% colspan="1" %)(% colspan="1" %) 491 +((( 492 +\\ 493 +)))|(% colspan="1" %)(% colspan="1" %) 494 +((( 495 +motor.ftl 496 +))) 497 +|(% colspan="1" %)(% colspan="1" %) 498 +((( 499 +**MotorRotation,** port 500 +)))|(% colspan="1" %)(% colspan="1" %) 501 +((( 502 +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. 503 +)))|(% colspan="1" %)(% colspan="1" %) 504 +((( 505 +output 506 +)))|(% colspan="1" %)(% colspan="1" %) 507 +((( 508 +int 509 +)))|(% colspan="1" %)(% colspan="1" %) 510 +((( 511 +\\ 512 +)))|(% colspan="1" %)(% colspan="1" %) 513 +((( 514 +motor.ftl 515 +))) 516 +|(% colspan="1" %)(% colspan="1" %) 517 +((( 518 +**Beep,** volume 519 +)))|(% colspan="1" %)(% colspan="1" %) 520 +((( 521 +Plays a beep sound as long as the variable is true. 522 +)))|(% colspan="1" %)(% colspan="1" %) 523 +((( 524 +output 525 +)))|(% colspan="1" %)(% colspan="1" %) 526 +((( 527 +bool 528 +)))|(% colspan="1" %)(% colspan="1" %) 529 +((( 530 +default volume is 10 531 +)))|(% colspan="1" %)(% colspan="1" %) 532 +((( 533 +sound.ftl 534 +))) 535 +|(% colspan="1" %)(% colspan="1" %) 536 +((( 537 +**Buzz,** volume 538 +)))|(% colspan="1" %)(% colspan="1" %) 539 +((( 540 +Plays a buzz sound as long as the variable is true. 541 +)))|(% colspan="1" %)(% colspan="1" %) 542 +((( 543 +output 544 +)))|(% colspan="1" %)(% colspan="1" %) 545 +((( 546 +bool 547 +)))|(% colspan="1" %)(% colspan="1" %) 548 +((( 549 +default volume is 10 550 +)))|(% colspan="1" %)(% colspan="1" %) 551 +((( 552 +sound.ftl 553 +))) 554 +|(% colspan="1" %)(% colspan="1" %) 555 +((( 556 +**BeepSequence,** direction, volume 557 +)))|(% colspan="1" %)(% colspan="1" %) 558 +((( 559 +Plays a sequence of tones in either ascending or descending tone frequency if the variable is true. 560 + 561 +The variable is set to false automatically. 562 +)))|(% colspan="1" %)(% colspan="1" %) 563 +((( 564 +output 565 +)))|(% colspan="1" %)(% colspan="1" %) 566 +((( 567 +bool 568 +)))|(% colspan="1" %)(% colspan="1" %) 569 +((( 570 +direction has to be one of Up, Down 571 + 572 +default volume is 10 573 +)))|(% colspan="1" %)(% colspan="1" %) 574 +((( 575 +sound.ftl 576 +))) 577 +|(% colspan="1" %)(% colspan="1" %) 578 +((( 579 +**UltrasonicSensor,** port 580 +)))|(% colspan="1" %)(% colspan="1" %) 581 +((( 582 +Reads the distance that an ultrasonic sensor measures. 583 +)))|(% colspan="1" %)(% colspan="1" %) 584 +((( 585 +input 586 +)))|(% colspan="1" %)(% colspan="1" %) 587 +((( 588 +int 589 +)))|(% colspan="1" %)(% colspan="1" %) 590 +((( 591 +\\ 592 +)))|(% colspan="1" %)(% colspan="1" %) 593 +((( 594 +ultrasonic.ftl 595 +))) 596 +|(% colspan="1" %)(% colspan="1" %) 597 +((( 598 +**Gyro,** port, mode 599 +)))|(% colspan="1" %)(% colspan="1" %) 600 +((( 601 +Reads the value of a gyroscope. 602 +)))|(% colspan="1" %)(% colspan="1" %) 603 +((( 604 +input 605 +)))|(% colspan="1" %)(% colspan="1" %) 606 +((( 607 +int 608 +)))|(% colspan="1" %)(% colspan="1" %) 609 +((( 610 +Not available on NXT 611 + 612 +mode hat to be one of Angle, Rate 613 +)))|(% colspan="1" %)(% colspan="1" %) 614 +((( 615 +gyro.ftl 616 +))) 617 +|(% colspan="1" %)(% colspan="1" %) 618 +((( 619 +**CalibrateGyro,** port, autoReset 620 +)))|(% colspan="1" %)(% colspan="1" %) 621 +((( 622 +Resets a gyroscope if the variable is true. 623 + 624 +If autoReset is true, the variable is set to false automatically. 625 +)))|(% colspan="1" %)(% colspan="1" %) 626 +((( 627 +output 628 +)))|(% colspan="1" %)(% colspan="1" %) 629 +((( 630 +bool 631 +)))|(% colspan="1" %)(% colspan="1" %) 632 +((( 633 +autoReset is true per default 634 +)))|(% colspan="1" %)(% colspan="1" %) 635 +((( 636 +gyro.ftl 637 +))) 638 + 639 +\\ 640 + 641 +---- 642 + 643 +== Using the Remote Console (RConsole) == 644 + 645 +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. 646 + 647 +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. 648 + 649 +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. 650 + 651 +---- 652 + 653 +== Problem Solving == 654 + 655 +The following presents typical issues and how to solve them. 656 + 657 +(% class="wrapped" %) 658 +|=((( 659 +Issue 660 +)))|=((( 661 +Typical Error Messages 662 +)))|=((( 663 +Description 664 +)))|=((( 665 +Solution 666 +))) 667 +|((( 668 +leJOS EV3 does not support Java 8 669 +)))|((( 670 +"java.lang.UnsupportedClassVersionError" 671 + 672 +"unsupported major.minor version" 673 +)))|((( 674 +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 675 +)))|((( 676 +Go to the project properties and switch to Java 7 (Right Click on project > Properties > Java Compiler > Compiler compliance level) 677 +))) 678 +|(% colspan="1" %)(% colspan="1" %) 679 +((( 680 +Uploading to the brick does not respond 681 +)))|(% colspan="1" %)(% colspan="1" %) 682 +((( 683 +\\ 684 +)))|(% colspan="1" %)(% colspan="1" %) 685 +((( 686 +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. 687 +)))|(% colspan="1" %)(% colspan="1" %) 688 +((( 689 +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. 690 +))) 691 +|(% colspan="1" %)(% colspan="1" %) 692 +((( 693 +Compilation and uploading works from command line but not when using KIELER 694 +)))|(% colspan="1" %)(% colspan="1" %) 695 +((( 696 +This Java instance does not support a 32-bit JVM. Please install the desired version. 697 +)))|(% colspan="1" %)(% colspan="1" %) 698 +((( 699 +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. 700 +)))|(% colspan="1" %)(% colspan="1" %) 701 +((( 702 +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. 703 +))) 704 +|(% colspan="1" %)(% colspan="1" %) 705 +((( 706 +Brick does nothing after program finished and prints "Program exit" 707 +)))|(% colspan="1" %)(% colspan="1" %) 708 +((( 709 +\\ 710 +)))|(% colspan="1" %)(% colspan="1" %) 711 +((( 712 +A program was uploaded and finished without errors. Afterwards the brick prints "Program exit" but does not open the main menu. 713 +)))|(% colspan="1" %)(% colspan="1" %) 714 +((( 715 +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. 716 +))) 717 + 718 +\\ 719 + 720 +\\
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 - 137634091 +37814287 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/ 13763409/LEGO Mindstorms with leJOS and SCCharts1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/37814287/LEGO Mindstorms with leJOS and SCCharts