Changes for page LEGO Mindstorms with leJOS and SCCharts
Last modified by Alexander Schulz-Rosengarten on 2023/09/11 16:17
Summary
-
Page properties (2 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. cmot1 +XWiki.aas2 - Content
-
... ... @@ -8,7 +8,7 @@ 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. 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//. 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 ... ... @@ -16,7 +16,7 @@ 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"]] (Linux/Mac) or use the Setup.exe (Windows).19 +Download and extract the newest archives for your Operating System from [[Sourceforce>>url:http://sourceforge.net/projects/nxt.lejos.p/files/||shape="rect"]]. 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 ... ... @@ -42,23 +42,26 @@ 42 42 43 43 == The Eclipse plugin for leJOS == 44 44 45 -There is an Eclipse plugin for leJOS which adds a project creation wizard and launch configuration to the platform. 45 +There is an Eclipse plugin for leJOS which adds a project creation wizard and launch configuration to the platform. You can install it via the Eclipse Marketplace (//Help > Eclipse Marketplace...//). If you have an **NXT** **brick**, install the **leJOS NXJ** Plug-in. 46 46 47 -1. You have to install it via the Eclipse Marketplace (//Help > Eclipse Marketplace...//). 48 -OR 49 -1. Install the plugin manually (Help > Install new Software...). Use the following update site\\ 50 -11. for NXT: [[http:~~/~~/www.lejos.org/tools/eclipse/plugin/nxj/>>url:http://www.lejos.org/tools/eclipse/plugin/nxj/||shape="rect"]] 51 -11. for EV3: [[http:~~/~~/www.lejos.org/tools/eclipse/plugin/ev3/>>url:http://www.lejos.org/tools/eclipse/plugin/ev3/||shape="rect"]] 52 -\\\\ 47 +[[image:attach:lejos_eclipse_plugin.png]] 53 53 54 - Ifyouhave an**NXT****brick**,install the**leJOS NXJ**Plug-in.If youhavean**EV3brick**,install the **leJOSEV3**plugin.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**. 55 55 56 - [[image:attach:lejos_eclipse_plugin.png]]51 +---- 57 57 58 - Afterthe 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_HOMEfield**.53 +== Configure KIELER == 59 59 60 - Forthe**EV3 plugin**, therequired dialogs under //Window> Preferences>leJOSEV3//. You have to set the **leJOSinstallation directory**.FurthermoretheleJOS EV3 pluginrequiresthe IPaddress to connect to the brick (it may work without, but itssafer todirectlyset the name.Reducesheadache). Check **Connect to named brick**and enter the**IP adress**ofthe brick (displayedon the brickat startup).55 +With the Eclipse plugin for leJOS installed, you can now use KIELER SCCharts for an model-based approach of programming. 61 61 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. 58 + 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. 60 + 61 +[[image:attach:environments_preferences.png]] 62 + 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. 64 + 62 62 ---- 63 63 64 64 == Creating an Example Project == ... ... @@ -68,7 +68,7 @@ 68 68 === Create a new project: === 69 69 70 70 1. Choose //File > New > Project > KIELER SCCharts > SCCharts Project// 71 -1. In the project creation wizard that opens, select //Mindstorms NXJ// or// Mindstorms EV3// (depending on your brick)as environment and hit //finish//74 +1. In the project creation wizard that opens, select //Mindstorms NXJ// as environment and hit //finish// 72 72 1. The project wizard from the leJOS plugin opens. Set the project name to //Flashlight// and click //finish//. 73 73 1. The project is created and the model file is opened in an editor (This might take a few seconds). 74 74 ... ... @@ -95,11 +95,7 @@ 95 95 96 96 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. 97 97 98 -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. 99 - 100 -The available wrapper code snippets are defined in the //snippets// directory of the project in ftl files (FreeMarker template files). (To view ftl files with highlighting, you may want to install the FreeMarker IDE feature from the JBoss tools that is available in the Eclipse Market Place.) 101 - 102 -**Note:** The Floodlight of the EV3 has a pretty high latency when switching between on and off.** 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.** 103 103 ** 104 104 105 105 === Launch the project: === ... ... @@ -106,7 +106,7 @@ 106 106 107 107 With the mouse over the SCT file in the project explorer, perform //Right Click > Run As > KiCo Compilation.// 108 108 109 -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 launchshortcut from theeJOS plugin.If any errors occur, you caneethemin theConsoleView.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. 110 110 111 111 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"]]. 112 112 ... ... @@ -114,41 +114,8 @@ 114 114 115 115 == Using the Remote Console (RConsole) == 116 116 117 -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.116 +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. 118 118 119 -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.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**. 120 120 121 -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. 122 - 123 ----- 124 - 125 -== Problem Solving == 126 - 127 -The following presents typical issues and how to solve them. 128 - 129 -|=((( 130 -Issue 131 -)))|=((( 132 -Typical Error Messages 133 -)))|=((( 134 -Description 135 -)))|=((( 136 -Solution 137 -))) 138 -|((( 139 -leJOS EV3 does not support Java 8 140 -)))|((( 141 -"java.lang.UnsupportedClassVersionError" 142 - 143 -"unsupported major.minor version" 144 -)))|((( 145 -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 146 -)))|((( 147 -Go to the project properties and switch to Java 7 (Right Click on project > Properties > Java Compiler > Compiler compliance level) 148 -))) 149 - 150 - 151 - 152 ----- 153 - 154 - 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 -145162 771 +14516260 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/145162 77/LEGO Mindstorms with leJOS and SCCharts1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/14516260/LEGO Mindstorms with leJOS and SCCharts