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,75 @@ 40 40 41 41 [[image:attach:lejos_eclipse_plugin.png]] 42 42 43 - =ProgramLEGOMindstormswithleJOS andSCCharts=49 +After the installation, the plugin requires a little configuration. Go to //Window > Preferences > leJOS NXJ //and enter the base directory of your **leJOS** **installation** in the **NXJ_HOME field**. 44 44 51 +---- 45 45 53 +== Configure KIELER == 46 46 47 - {{tocminLevel="2"/}}55 +With the Eclipse plugin for leJOS installed, you can now use KIELER SCCharts for an model-based approach of programming. 48 48 49 - ----57 +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. 50 50 51 - ==Overview==59 +Hit the //Variables// button and search for **nxj.home**. If the variable exists, your good. If it does not exist, ensure that you installed and configured the Ecplise plugin for leJOS NXJ correctly. 52 52 53 - Mindstorms isaproduct family from Lego, with sensors, motorsand a programmable brick. Theewestiterationof the product family is theEV3 programmable brick. Itsdecessors areNXT and RCX. In thefollowing we willsee how to developapplications for the NXT brick, thus //Mindstorms// will be used exchangeable with //NXT brick//.61 +[[image:attach:environments_preferences.png]] 54 54 55 - Severalopen-source,third-party replacementsfortheofficalLego firmwarehave beendeveloped.These support many wellknown programminglanguages, such asJava, C/C++, Python, Lua,etc.Inthefollowing we will useKIELER SCChartsto program MindstormsrunningtheLego Java Operating System([[leJOS>>url:http://www.lejos.org/||shape="rect"]]).Thereforewe willfirststallleJOS NXJ and flash itsfirmware.AfterwardswewillcreateasimpleSCChartsprojectKIELERthat wewillcompileanddeploytotheNXT brick.63 +**Note:** If you already created and launched a project, the settings of the environment are copied to the launch configuration. It thus may be necessary to alter settings on the launch configuration as well as the environment. 56 56 57 57 ---- 58 58 59 -== DownloadandinstallleJOS==67 +== Creating an Example Project == 60 60 61 - DownloadandextractthenewestarchivesforyourOperatingSystemfrom[[Sourceforce>>url:http://sourceforge.net/projects/nxt.lejos.p/files/||shape="rect"]].69 +The following shows how to create a project, that will turn on a light if a button is pressed. 62 62 63 - Thefurther installation isexplainedindetailat [[http:~~/~~/www.lejos.org/nxt/nxj/tutorial/Preliminaries/GettingStarted.htm>>url:http://www.lejos.org/nxt/nxj/tutorial/Preliminaries/GettingStarted.htm||shape="rect"]].71 +=== Create a new project: === 64 64 65 -=== Known issues === 73 +1. Choose //File > New > Project > KIELER SCCharts > SCCharts Project// 74 +1. In the project creation wizard that opens, select //Mindstorms NXJ// as environment and hit //finish// 75 +1. The project wizard from the leJOS plugin opens. Set the project name to //Flashlight// and click //finish//. 76 +1. The project is created and the model file is opened in an editor (This might take a few seconds). 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 uploadthe firmware withyour Linux OS, add **blacklistcdc_acm**{{code language="none"}}{{/code}} at thevery 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.78 +=== Edit the model: === 68 68 69 - ----80 +Change the contents of the model file to the following code and save it. 70 70 71 -== Test leJOS == 82 +{{code title="Floodlight.sct" theme="Eclipse" language="sct"}} 83 +scchart Flashlight { 84 + 85 + @Wrapper TouchSensor, S4 86 + input bool button; 87 + 88 + @Wrapper Floodlight, S1 89 + output bool light; 90 + 91 + initial state lightOff 92 + --> lightOn with button / light = true; 93 + 94 + state lightOn 95 + --> lightOff with !button / light = false; 96 +} 97 +{{/code}} 72 72 73 - A simpleHelloWorldapplicationfortheMindstormsisdevelopedaspart ofthe leJOStutorial[[http:~~/~~/www.lejos.org/nxt/nxj/tutorial/Preliminaries/FirstProgram.htm>>url:http://www.lejos.org/nxt/nxj/tutorial/Preliminaries/FirstProgram.htm||shape="rect"]]99 +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. 74 74 75 -If this works with your device, you are able to start using KIELER to develop applications for the NXT brick.\\ 101 +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.** 102 +** 76 76 77 - ----104 +=== Launch the project: === 78 78 79 - ==TheEclipse pluginfor leJOS==106 +With the mouse over the SCT file in the project explorer, perform //Right Click > Run As > KiCo Compilation.// 80 80 81 - ThereisanEclipse pluginforleJOSwhichaddsaprojectcreationwizard andlaunchconfigurationtotheplatform.You can installitviatheEclipseMarketplace(//Help> Eclipse Marketplace...//)108 +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. 82 82 83 - [[image:attach:lejos_eclipse_plugin.png]]110 +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"]]. 84 84 85 -On the preference page (//Window > Preferences > leJOS NXJ//) you have to set the path of your leJOS installation, the NXJ_HOME directory. 86 - 87 -[[image:attach:lejos_eclipse_plugin_preferences.png]] 88 - 89 89 ---- 90 90 91 -== Configure KIELER == 92 - 93 -Environment setup. Sample project creation. Project launch. 94 - 95 ----- 96 - 97 97 == Using the Remote Console (RConsole) == 98 98 99 -n xjconsoleviewer116 +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. 100 100 101 - 118 +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**. 119 + 120 +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.
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -1376 27311 +13763597 - 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/13763597/LEGO Mindstorms with leJOS and SCCharts