Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The further installation is explained in detail at httphttps://wwwlejos.lejossourceforge.orgio/nxt/nxj/tutorial/Preliminaries/GettingStarted.htm.

Do not forget to flash the download leJOS firmware to the Mindstorms brick as explained in the tutorial!

Known issues or remarks

Linux

You can switch your currently used java

After installing leJOS make sure that all commands are available in the PATH.

Make sure that this is also the case for gcc or javac/java if you plan to simulate your model.

You might have to start KIELER from the console to access all comands in the PATH.

Known issues or remarks

Linux

You can switch your currently used java version via sudo update-alternatives --config java

...

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.

On Linux there is on an issue that the NXT is found, but uploading any file to it does not progress after Found nxt <name>. Try to connect via bluetooth (-b option) if this is the case.

...

The setup.exe of the current LEGO Fantom driver for Windows (1.2.0) has an awkward issue. If you get an error message (Developer Error) because an .msi file could not be found, don't panic. The file is part of the downladed downoladed archive (in the Products folder) but you have to start it manually. You may also try to install the necessary drivers by following the Guide to install on Windows 10 on Reddit.

If you get a runtime error when starting the ssetusetup.exe also don't panic. The file is part of the downladed downloaded archive (in the Products folder) but you have to start it manually.

...

A simple Hello World application for the Mindstorms is developed as part of the leJOS tutorial.

If get a compilation error, set the java compliance level (target and source are necessary if you are using java 11 or something like that and have not set LEJOS_NXT_JAVA_HOME to a java 8 installation).

...

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

...

However you might still need a java 1.8 or lower, since KIELER does not add target and source per default.

Renaming your NXT brick

If you plan to use bluetooth to connect to your NXT it might help to change the name of your NXt brick.

...

  1. Choose File > New > Project > General > Project (do never convert your project in an Xtext-project)
  2. The project is created.
  3. Create a SCChart inside the project.
  4. Open the SCCharts modeling perspective (Window > Perspective > Open Perspective > Other)
  5. Edit the model
  6. Compile the model using the KIELER compiler (using the Netlist-Based Deployment (NXT) compilation system)

Edit the Model:

Change the contents of the model file to the following code and save it.

Code Block
languagesct
themeEclipse
titleFloodlight.sctsctx
scchart FlashlightFloodlight {
    
    input bool @macro "Button", "ENTER" button
    
    output bool @macro "Floodlight", "S1" light
    
    initial state lightOff
    if button do light = true go to lightOn
    
    state lightOn
    if !button do light = false go to lightOff
}

...

There are several wrapper code snippets that can be used as annotations on input and output variables in the model file. These snippets are inserted in the main file template as part of the project build. The available snippets are listed below.

For sensors, the port has to be on of S1, S2, S3, S4.

For motors / actuators the port has to be one of A, B, C.

...

Resets a clock, such that the full time interval of the clock has to elapse, before the clock will be set to true again.

If autoFalse is true, the reset variable will be set to false automatically.

...

Delays the execution until the tick loop takes at least as long as the given target duration.

The input variable is set to the actual tick loop duration.

...

Should be used on the very first input variable in the model, such that waiting is the last action in the tick loop.

In case the actual tick loop duration is longer than the target duration, the modeler can provide some error handling.

...

Sets the input variable to the current system time (milliseconds). The model can add to this variable to get a new value. This is the next system time the tick function will be called.

In other words, the next tick function call is delayed until the wake up time has been reached.

For instance the statement nextTickWakeUp += 500 could be used to call the tick function again in 500 milliseconds, if nextTickWakeUp is an input with the corresponding annotation.

...

Should be used on the very last input variable in the model, such that waiting and settings the system time is the last action done, before the tick function call.

...

Reads  the value of a light sensor.

If percentValue is true, the a percent value is returned, based on the light sensor calibration.

...

output

...

output

...

Lets a motor rotate the variable value in degrees. This is only done if the value is unequal zero. If the value is negative, the motor rotates backwards. The variable is set to zero afterwards, such that setting the variable once to a value X, will let the motor rotate X degrees.

...

Plays a sequence of tones in either ascending or descending tone frequency if the variable is true.

The variable is set to false automatically.

...

direction has to be one of Up, Down

default volume is 10

...

Not available on NXT

mode hat to be one of Angle, Rate

...

Resets a gyroscope if the variable is true.

If autoReset is true, the variable is set to false automatically.

...

the project build. The available snippets are listed here.


...

Using the Remote Console (RConsole)

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.

To use Use the RConsole , uncomment the RConsole lines in the wrapper code template Main.ftlcompilation system to deploy to the NXT (Currently called Netlist-Based Deployment (NXT) via RConsole). 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.

To stop this nxt is this mode the ENTER and ESC button (orange and dark grey) have to be pressed at the same time. Yu have to disconnect and reconnect via the nxjconsoleviewer tool if you restart the application.

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.

...

The following presents typical issues and how to solve them.

IssueTypical Error MessagesDescriptionSolution
leJOS EV3 does not support Java 8

"java.lang.UnsupportedClassVersionError"

"unsupported major.minor version"

You compile the sources in your project with Java 8 and upload them to the brick. However the lejos EV3 does not support Java 8Go to the project properties and switch to Java 7 (Right Click on project > Properties > Java Compiler > Compiler compliance level)

Uploading to the brick does not respond


You compile a file successfully and when uploading the result, the connected brick is found. Anyway the upload does not terminate and does not react.Flash the brick with the current leJOS firmware. If the brick is recognized correctly and the attempt to upload a compiled file fails then the firmware on the brick might be outdated. If connecting via bluetooth works add -b to the uxjupload/nxj command.
Compilation and uploading works from command line but not when using KIELER

This Java instance does not support a 32-bit JVM. Please install the desired version.

You can compile and upload code to the brick using the command line tools but when using KIELER an error message apprears because Java does not support 32-bit JVM.Set the LEJOS_NXT_JAVA_HOME environment variable, such that it points to an 32-bit JDK and is visible for GUI applications (or at least KIELER). The process to do so differs on every OS. As alternative, execute KIELER from terminal.
Brick does nothing after program finished and prints "Program exit"
A program was uploaded and finished without errors. Afterwards the brick prints "Program exit" but does not open the main menu.

This is normal behaviour if uploading a program in debug mode instead run mode (Debug As instead Run As in Eclipse). To get back to the main menu, press the ENTER and ESCAPE button of the brick at the same time.

Cannot simulate but compileJavac/gcc not foundJavac and gcc have to be available in the pathAdd javac/gcc to your path
Cannot simulate but compileCannot find fileKIELER has no rights to write to the file systemUse a workspace in which KIELER has write access
LEFT and RIGHT button cannot be pressed at the same time
If you press the ENTER and LEFT button both are true, if you press the ENTER and RIGHT button both are true. If you press the LEFT and RIGHT button only the LEFT button is true.Do not write a program that requires the LEFT and RIGHT button to be presssed at the same time.
Too many variablesNo more than 255 fields expectedIf your generated Java Code uses more than 255 variables it cannot run on the NXT.Try using less super states or concurrent regions (during actions create concurrent regions).
KIELER and compilation use two different java versions

Main

has

been

compiled

by

a

more

recent

version

of

the

Java

Runtime

(class

file

version

55.0),
this

version

of

the

Java

Runtime

only

recognizes

class

file

versions

up

to

52.0


Make sure KIELER uses the same java version as the one in the path (for example Java 11). Lejos can still use java 8, if you set the LEJOS_NXT_JAVA_HOME variable (in windows this is a 32-bit java installation)
NXT program cannot be stopped in RConsole mode
You deploy a program to the NXT with RConsole enabledPress Esc (dark grey button) and Enter (organge Button) at the same time