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
-
... ... @@ -77,9 +77,11 @@ 77 77 78 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 79 80 +[[image:attach:Screenshot_20171016_130805.png]] 81 + 80 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 81 82 - [[image:attach:lejos_eclipse_plugin.png]]84 +\\ 83 83 84 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 85 ... ... @@ -98,7 +98,7 @@ 98 98 1. The project wizard from the leJOS plugin opens. Set the project name to //Flashlight// and click //finish//. 99 99 1. The project is created and the model file is opened in an editor (This might take a few seconds). 100 100 101 -=== Edit the model: ===103 +=== Edit the Model: === 102 102 103 103 Change the contents of the model file to the following code and save it. 104 104 ... ... @@ -123,24 +123,38 @@ 123 123 124 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 125 126 -The available wrapper code snippets are defined in the //snippets//directoryof theroject in ftl files (FreeMarker template files). The table below gives an overview of the available wrapper code snippets.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. 127 127 128 128 **Note:** The Floodlight of the EV3 has a pretty high latency when switching between on and off. 129 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 EclipseLuna isupdates/stable/luna/>>url:http://download.jboss.org/jbosstools/updates/stable/luna/||shape="rect"]]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).** 131 131 ** 132 132 133 -=== Launchtheproject: ===135 +=== Build the Project: === 134 134 135 - 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. 136 136 137 - A launchconfigiscreated,whichcompilesthemodel toJava code and createswrappercode from the annotationsinthe modelfile.Afterwardsthis outputiscompiledand deployed to the Mindstormsbrick, by using the launch shortcut from the leJOS plugin.If any errors occur, you can see them in the Console View.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. 138 138 139 - For a deeperunderstandingoftheprojectlaunchandinitialization,take alook atthe [[wikipageforProm>>url:http://rtsys.informatik.uni-kiel.de/confluence/pages/viewpage.action?pageId=13762626||shape="rect"]].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. 140 140 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 + 141 141 === Available Wrapper Code Snippets === 142 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.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. 144 144 145 145 For sensors, the port has to be on of S1, S2, S3, S4. 146 146 ... ... @@ -207,7 +207,7 @@ 207 207 **Time** 208 208 )))|(% colspan="1" %)(% colspan="1" %) 209 209 ((( 210 -Reads the elapsed time since program start 226 +Reads the elapsed time since program start (milliseconds) 211 211 )))|(% colspan="1" %)(% colspan="1" %) 212 212 ((( 213 213 input ... ... @@ -216,7 +216,7 @@ 216 216 int 217 217 )))|(% colspan="1" %)(% colspan="1" %) 218 218 ((( 219 - 235 +\\ 220 220 )))|(% colspan="1" %)(% colspan="1" %) 221 221 ((( 222 222 timing.ftl ... ... @@ -238,6 +238,8 @@ 238 238 )))|(% colspan="1" %)(% colspan="1" %) 239 239 ((( 240 240 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. 241 241 )))|(% colspan="1" %)(% colspan="1" %) 242 242 ((( 243 243 timing.ftl ... ... @@ -247,9 +247,14 @@ 247 247 **TickWakeUp** 248 248 )))|(% colspan="1" %)(% colspan="1" %) 249 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. 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. 251 251 252 -This means the next tick function call is delayed until the wake up time has been reached. 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 +))) 253 253 )))|(% colspan="1" %)(% colspan="1" %) 254 254 ((( 255 255 input ... ... @@ -277,7 +277,7 @@ 277 277 int 278 278 )))|(% colspan="1" %)(% colspan="1" %) 279 279 ((( 280 - 303 +\\ 281 281 )))|(% colspan="1" %)(% colspan="1" %) 282 282 ((( 283 283 timing.ftl ... ... @@ -315,7 +315,7 @@ 315 315 string 316 316 )))|(% colspan="1" %)(% colspan="1" %) 317 317 ((( 318 - 341 +\\ 319 319 )))|(% colspan="1" %)(% colspan="1" %) 320 320 ((( 321 321 print.ftl ... ... @@ -353,7 +353,7 @@ 353 353 bool 354 354 )))|(% colspan="1" %)(% colspan="1" %) 355 355 ((( 356 - 379 +\\ 357 357 )))|(% colspan="1" %)(% colspan="1" %) 358 358 ((( 359 359 touch_and_buttons.ftl ... ... @@ -414,7 +414,7 @@ 414 414 bool 415 415 )))|(% colspan="1" %)(% colspan="1" %) 416 416 ((( 417 - 440 +\\ 418 418 )))|(% colspan="1" %)(% colspan="1" %) 419 419 ((( 420 420 light.ftl ... ... @@ -433,7 +433,7 @@ 433 433 bool 434 434 )))|(% colspan="1" %)(% colspan="1" %) 435 435 ((( 436 - 459 +\\ 437 437 )))|(% colspan="1" %)(% colspan="1" %) 438 438 ((( 439 439 light.ftl ... ... @@ -473,7 +473,7 @@ 473 473 bool 474 474 )))|(% colspan="1" %)(% colspan="1" %) 475 475 ((( 476 - 499 +\\ 477 477 )))|(% colspan="1" %)(% colspan="1" %) 478 478 ((( 479 479 motor.ftl ... ... @@ -492,7 +492,7 @@ 492 492 int 493 493 )))|(% colspan="1" %)(% colspan="1" %) 494 494 ((( 495 - 518 +\\ 496 496 )))|(% colspan="1" %)(% colspan="1" %) 497 497 ((( 498 498 motor.ftl ... ... @@ -572,7 +572,7 @@ 572 572 int 573 573 )))|(% colspan="1" %)(% colspan="1" %) 574 574 ((( 575 - 598 +\\ 576 576 )))|(% colspan="1" %)(% colspan="1" %) 577 577 ((( 578 578 ultrasonic.ftl ... ... @@ -620,7 +620,7 @@ 620 620 gyro.ftl 621 621 ))) 622 622 623 - 646 +\\ 624 624 625 625 ---- 626 626 ... ... @@ -664,7 +664,7 @@ 664 664 Uploading to the brick does not respond 665 665 )))|(% colspan="1" %)(% colspan="1" %) 666 666 ((( 667 - 690 +\\ 668 668 )))|(% colspan="1" %)(% colspan="1" %) 669 669 ((( 670 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. ... ... @@ -690,7 +690,7 @@ 690 690 Brick does nothing after program finished and prints "Program exit" 691 691 )))|(% colspan="1" %)(% colspan="1" %) 692 692 ((( 693 - 716 +\\ 694 694 )))|(% colspan="1" %)(% colspan="1" %) 695 695 ((( 696 696 A program was uploaded and finished without errors. Afterwards the brick prints "Program exit" but does not open the main menu. ... ... @@ -699,8 +699,6 @@ 699 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 700 ))) 701 701 702 - 725 +\\ 703 703 704 - 705 - 706 -input 727 +\\
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 - 274596071 +37814289 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/ 27459607/LEGO Mindstorms with leJOS and SCCharts1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/37814289/LEGO Mindstorms with leJOS and SCCharts