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
-
... ... @@ -22,8 +22,14 @@ 22 22 23 23 === Known issues === 24 24 25 +== Linux == 26 + 25 25 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. 26 26 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 + 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**. 32 + 27 27 ---- 28 28 29 29 == Test the Mindstorm == ... ... @@ -40,62 +40,73 @@ 40 40 41 41 [[image:attach:lejos_eclipse_plugin.png]] 42 42 43 - = Program LEGO Mindstorms with leJOS and SCCharts =49 +---- 44 44 51 +== Configure KIELER == 45 45 53 +With the Eclipse plugin for leJOS installed, you can now use KIELER SCCharts for an model-based approach of programming. 46 46 47 - {{toc minLevel="2"/}}55 +First check the environment settings for NXJ of the KIELER tool (//Window > Preferences > KIELER > Environments//). On the **Execute** tab, ensure that only the commands for your operating system are checked. 48 48 49 - ----57 +Hit the //Variables// button and search for **nxj.home**. If the variable exists, your good. If it does not exist, create a new variable (//Edit Variables... > New//) with that name and point it to the base folder of your leJOS installation. The variable is referenced by the shell commands of the environment. 50 50 51 - == Overview ==59 +[[image:attach:environments_preferences.png]] 52 52 53 - Mindstormsisa productfamilyfrom Lego, with sensors,motorsand a programmablebrick.Thenewest iteration of theproductfamilyistheEV3programmable brick. ItspredecessorsareNXTand RCX. Inthefollowing we willsee howto develop applicationsfortheNXT brick, thus//Mindstorms//willbe usedexchangeablewith //NXT brick//.61 +**Note:** If you already created and launched a project, the settings of the environment are copied to the launch configuration. It is thus may be necessary to alter settings on the launch configuration as well as the environment. 54 54 55 -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. 56 - 57 57 ---- 58 58 59 -== Downloadandinstall leJOS==65 +== Using the Remote Console (RConsole) == 60 60 61 - DownloadandextractthenewestarchivesforyourOperatingSystemfrom[[Sourceforce>>url:http://sourceforge.net/projects/nxt.lejos.p/files/||shape="rect"]].67 +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. 62 62 63 -T hefurtherinstallationisexplainedin 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"]].69 +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**. 64 64 65 - ===Known issues===71 +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. 66 66 67 -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. 68 - 69 69 ---- 70 70 71 -== Test leJOS==75 +== Creating an Example Project == 72 72 73 - A simpleHelloWorld applicationfortheMindstormsis developedaspartoftheleJOStutorial[[http:~~/~~/www.lejos.org/nxt/nxj/tutorial/Preliminaries/FirstProgram.htm>>url:http://www.lejos.org/nxt/nxj/tutorial/Preliminaries/FirstProgram.htm||shape="rect"]]77 +The following shows how to create a project, that will turn on a light if a button is pressed. 74 74 75 - Ifthis works with your device, youare ableto start using KIELER to developapplications fortheNXT brick.\\79 +=== Create a new project: === 76 76 77 ----- 81 +1. Choose //File > New > Project > KIELER SCCharts > SCCharts Project// 82 +1. In the project creation wizard that opens, select //Mindstorms NXJ// as environment and hit //finish// 83 +1. The project wizard from the leJOS plugin opens. Set the project name to //Flashlight// and click //finish//. 84 +1. The project is created and the model file is opened in an editor (This might take a few seconds). 78 78 79 -== TheEclipseplugin for leJOS==86 +=== Edit the model: === 80 80 81 - There isanEclipse plugin for leJOSwhich adds a projectcreationwizard andlaunch configurationto theplatform. YoucaninstallitviatheEclipseMarketplace(//Help> Eclipse Marketplace...//)88 +Change the contents of the model file to the following code and save it. 82 82 83 -[[image:attach:lejos_eclipse_plugin.png]] 90 +{{code title="Floodlight.sct" theme="Eclipse" language="sct"}} 91 +scchart Flashlight { 92 + 93 + @Wrapper TouchSensor, S4 94 + input bool button; 95 + 96 + @Wrapper Floodlight, S1 97 + output bool light; 98 + 99 + initial state lightOff 100 + --> lightOn with button / light = true; 101 + 102 + state lightOn 103 + --> lightOff with !button / light = false; 104 +} 105 +{{/code}} 84 84 85 - On thepreferencepage(//Window> Preferences>leJOSNXJ//)youhave tosetthe pathof yourleJOSinstallation,theNXJ_HOMEdirectory.107 +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. 86 86 87 -[[image:attach:lejos_eclipse_plugin_preferences.png]] 109 +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.** 110 +** 88 88 89 - ----112 +=== Launch the project: === 90 90 91 - ==ConfigureKIELER==114 +With the mouse over the SCT file in the project explorer, perform //Right Click > Run As > KiCo Compilation.// 92 92 93 - Environmentsetup.Sampleproject creation.Project launch.116 +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. 94 94 95 ----- 96 - 97 -== Using the Remote Console (RConsole) == 98 - 99 -nxjconsoleviewer 100 - 101 - 118 +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"]].
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -1376 27311 +13763595 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/1376 2731/LEGO Mindstorms with leJOS and SCCharts1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/13763595/LEGO Mindstorms with leJOS and SCCharts