Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Program LEGO Mindstorms with leJOS and SCCharts


Overview

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.

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). 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.


Download and install leJOS

Download and extract the newest archives for your Operating System from Sourceforce.

The further installation is explained in detail at http://www.lejos.org/nxt/nxj/tutorial/Preliminaries/GettingStarted.htm.

Known issues

On Linux there is an issue when uploading the firmware because of a kernel module (http://ubuntuforums.org/showthread.php?t=1123633). If you can't upload the firmware with your Linux OS, add blacklist cdc_acm at the very end of the file /etc/modprobe.d/blacklist.conf. Afterwards execute sudo rmmod cdc_acm. This will remove the cdc_acm module from the kernel and prevent its restart. Now try to flash the firmware again.


Test the Mindstorm

A simple Hello World application for the Mindstorms is developed as part of the leJOS tutorial http://www.lejos.org/nxt/nxj/tutorial/Preliminaries/FirstProgram.htm

If this works with your device, you are able to start using KIELER to develop applications for the NXT brick.


The Eclipse plugin for leJOS

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...)


Configure KIELER

With the Eclipse plugin installed, you can now use KIELER SCCharts for an model-based approach of programming.

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.

Create a first project using the SCChart 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.

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.

For a deeper understanding of the project launch and initialization, take a look at the wiki page for Prom.


Using the Remote Console (RConsole)

nxjconsoleviewer

 

  • No labels