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,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 ... ... @@ -42,16 +42,38 @@ 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. You havetoinstall it via the Eclipse Marketplace (//Help > Eclipse Marketplace...//). If you have an **NXT** **brick**, install the **leJOS NXJ** Plug-in. If you have an **EV3 brick**, install the **leJOS EV3** plugin.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...//) 46 46 47 47 [[image:attach:lejos_eclipse_plugin.png]] 48 48 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**.49 +---- 50 50 51 - Forthe **EV3 plugin**, the required dialog is under //Window > Preferences > leJOS EV3//. You have to set the **leJOSinstallation directory**. Furthermore the leJOS EV3 plugin requirestheIP address to connect to the brick (it may work without, but its safer to directly set the name.Reducesheadache ). Check **Connect to named brick** and enter the **IP adress** of the brick (displayed on the brick at startup).51 +== Configure KIELER == 52 52 53 +With the Eclipse plugin for leJOS installed, you can now use KIELER SCCharts for an model-based approach of programming. 54 + 55 +First check the environment settings for NXJ of the KIELER tool (//Window > Preferences > KIELER > Environments//). Ensure that the commands of the execute tab have correct paths. They have to use the lib directory of your leJOS installation. 56 + 57 +[[image:attach:lejos_nxj_environment.png]] 58 + 59 +Create a first project using the SCCharts project wizard (//File > New > Project > KIELER SCCharts > SCT Project//) and select the environment for leJOS NXJ. When pressing the finish button, the project wizard of the leJOS plugin will start. Set the project name and hit finish. The project will be created by the leJOS plugin and initialized by the KIELER plugin, giving it a model file and a file with wrapper code to initalize and run the model. 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. 62 + 63 +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"]]. 64 + 53 53 ---- 54 54 67 +== Using the Remote Console (RConsole) == 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. 70 + 71 +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**. 72 + 73 +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. 74 + 75 +---- 76 + 55 55 == Creating an Example Project == 56 56 57 57 The following shows how to create a project, that will turn on a light if a button is pressed. ... ... @@ -58,8 +58,8 @@ 58 58 59 59 === Create a new project: === 60 60 61 -1. Choose //File > New > Project > KIELERSCCharts> SCChartsProject//62 -1. In the project creation wizard that opens, select //Mindstorms NXJ// or// Mindstorms EV3// (depending on your brick)as environment and hit //finish//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// 63 63 1. The project wizard from the leJOS plugin opens. Set the project name to //Flashlight// and click //finish//. 64 64 1. The project is created and the model file is opened in an editor (This might take a few seconds). 65 65 ... ... @@ -86,11 +86,7 @@ 86 86 87 87 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. 88 88 89 -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. 90 - 91 -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.) 92 - 93 -**Note:** The Floodlight of the EV3 has a pretty high latency when switching between on and off.** 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.** 94 94 ** 95 95 96 96 === Launch the project: === ... ... @@ -97,16 +97,4 @@ 97 97 98 98 With the mouse over the SCT file in the project explorer, perform //Right Click > Run As > KiCo Compilation.// 99 99 100 -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 launch shortcut from the leJOS plugin. If any errors occur, you can see them in the Console View. 101 - 102 -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"]]. 103 - 104 ----- 105 - 106 -== Using the Remote Console (RConsole) == 107 - 108 -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. 109 - 110 -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. 111 - 112 -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. 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.
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -1 45162661 +13763409 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/1 4516266/LEGO Mindstorms with leJOS and SCCharts1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/13763409/LEGO Mindstorms with leJOS and SCCharts