jabotics logo

Usage of Lego-EV3 robots

Preparing the robot

For running Java programs on EV3 robots, a micro SD card (with FAT file system) has to be prepared with the leJOS software and a suitable version of the Java Runtime Environment (JRE). The runtime environment is being provided by Oracle and can be downloaded from this page (as of November 2016). It is necessary to register at the Oracle site to download the archive file (e.g. ejre-7u75-fcs-b13-linux-arm-sflt-headless-18_dec_2014.tar.gz).

After mounting the micro SD card to the PC (using a SD card reader if necessary), open BlueJ to select the menu command Tools → Robot → EV3 SD card creator in the project view. The tool is a slightly modified version of the original leJOS tool, that will also work on Linux systems where the SD card candidates will be identified by the FAT file system. In the card creator tool the SD card, the leJOS image file (lejosimage.zip in the leJOS_EV3 installation directory) and the JRE archive file have to be selected before starting the file transfer to the SD card (see the following figure for a Linux system). The button for downloading the JRE is not linked to the latest version and therefore should not be used. Once prepared, the SD card can be plugged into the SD card slot of the EV3 robot before turning on the robot brick. During the first start-up the installation of the leJOS system on the SD card will be completed automatically. After the robot has been booted, it can be managed with the leJOS menu control. Navigate with the left, right, up and down buttons. The central square button serves as enter button and the button at the top left as escape button.

fig ev3 sdcard

The communication between PC and EV3 robot brick can take place via USB or WLAN. If the robot is being connected to the PC with a USB cable, a LAN will be established. In this case it will not be necessary to modify the IP address of the robot (default value: Under Ubuntu the cable network connection will be established automatically. Under Windows 7 the RNDIS driver that is necessary to establish a network via USB needs to be activated manually. A description how to install the driver can be found here. For a WLAN based communication a suitable WiFi dongle is required. Information can be found on the Internet on which dongles will work with the EV3 brick. There is a WiFi item in the leJOS menu control of the EV3 brick to complete all related configuration like setting the IP address. Search for more detailed manuals on the Internet if necessary.

To establish a connection to the robot, the tools integrated in BlueJ need the IP address of the EV3 brick. The IP address can be set within the BlueJ IDE by means of the menu command Tools → Robot → Select robot (EV3). After all settings have been completed, call the menu item Tools → Robot → Upload EV3 libraries to tranfer all libraries to the robot that are necessary to execute robot programs based on Jabotics. Note: This command should be called again after an update of the Jabotics installation. It will copy all files from the subdirectory lib/userlib of the leJOS_EV3 installation directory on the PC to the directory /home/lejos/lib on the robot. By default these are the files jabotics-ev3.jar and manifest.ev3 (see installation instructions). The text file manifest.ev3 defines the classpath including all Java libraries that have to be loaded when starting a program based on the leJOS or Jabotics libraries. It is possible to add one's own Java libraries for robot programs on the EV3 by copying the Java archive files to the subfolder lib/userlib of the EV3 installation, extending the classpath in the file manifest.ev3 accordingly and starting an upload of EV3 libraries to the robot.

Specific features of EV3 robots

Since the Jabotics libraries have been designed for NXT robots at first, there are currently small limitations to the use of EV3 robots. These limitations will be removed in a future version of Jabotics. The first limitation is related to the buttons of the EV3 brick: The up and down buttons, which are not present on NXT robots, are currently not being supported by the sensor interfaces. The same applies to the gyroscope sensor of the EV3. Since the EV3 robot does not own a sound sensor in its standard configuration, it is an option to use a second touch sensor at the front of the robot instead (see picture at the very top). The class templates for robot programs could be modified accordingly.

The start-up and shutdown procedures on EV3 robots take considerably more time than on NXT robots. Therefore the robot should not be turned off between different program runs. It is a little bit annoying that starting a robot program on the EV3 robot is associated with another time delay. Obviously the basic initialization procedures on the leJOS program level are very time consuming. This in particular applies to the initialization of sensors as can be seen when switching on or off the LED of the light sensor which is accompanied by a lengthy change of the sensor mode.

There is an issue with rotations of the EV3 robot. Due to the flat tire tread, the track width is not well defined. Depending on the condition of the ground, a rotation can be considerably smaller or larger than intended. The behaviour is more predictable if the wheels are being replaced by those from a (disused) NXT robot. Since the track width and the wheel diameter do not change, no changes will be necessary in robot programs.

Executing robot programs

To upload programs, perform a right-click on the corresponding class icon in the BlueJ project view and select the menu item Robot → Upload (EV3) in the context menu. The class will be compiled once again and transferred to the robot. Status messages will be displayed as shown in the figure below. The log window can be closed after the file transfer has been completed.

fig ev3 en upload

To start a program on the robot, navigate to the menu item Programs and press the enter button. A list of all programs stored on the robot will be displayed. Navigate to the program entry of interest with the up and down buttons and open its context menu by pressing the enter button. By pressing it once again the execution can directly be started (menu item Execute program). Alternatively, the program can be marked as the default executable by pressing the right button twice (menu item Set as Default) followed by enter. After switching on the robot or uploading a file, the default program can be started by simply pressing the enter button (menu item Run Default). A program run can be interrupted by pressing the enter and the down button simultaneously.

As with the NXT robot, program files stored on the EV3 brick can be managed via a connected PC. For deleting files, select the menu item Tools → Robot → EV3 control viewer in the BlueJ project view. Connect to the robot of interest and open the Programs tab (see figure below). All files that are to be deleted have to be marked in the corresponding column before clicking on the button Delete Files. The control viewer can be closed afterwards. Alternatively, the files can be deleted via the leJOS menu control on the robot. Go to the menu item Programs, select a file in the files list and choose the command Delete file.

fig ev3 control center


Severe errors during a program run on the robot (like uncaught exceptions) will be indicated by an acoustic signal. An error message will be displayed, which might not be completely readable due to the limited size of the brick's monitor. In addition, leJOS will save the error message in a file in the Programs directory of the EV3. The file name starts with the name of the program and ends with the extension .err. The file can be downloaded from the robot to the PC by means of the EV3 control viewer (to be started in BlueJ with menu item Tools → Robot → EV3 control viewer, see above). The error message on the robot display can be cleared by pressing the escape button. In case of a system crash on the robot that cannot be reset via its buttons, temporarily remove the batteries from the EV3 brick.

Bug fixing in more complex programs can be very troublesome since debugging on the robot is not possible in the usual way. The following hints (to the advisors) might be helpful:

  • For programs based on the Jabotics libraries it should be checked if the problem can be reproduced within the simulation tool. If not, the program should be tested on a different robot to rule out hardware issues. If the problem cannot be reproduced on other robots either, the cable connections between robot brick and motors / sensors might be mixed up for the robot in question.
  • It is possible to send information from the robot to a connected PC during a program run and to have this information displayed in a so-called remote console. The console is integrated in the EV3 control viewer on the Console tab. More details can be found in the documentation for the interface org.jabotics.robot.en.IPCConsole. The object factory provided by the class XRobot gives access to the corresponding control object (see documentation of XRobot and IObjectFactory).
  • Robot programs can in principle be debugged within the robot simulation. It must be kept in mind though that the robot simulation is a multithreaded application. Apart from the main thread of the robot program, there are controller threads for the motor and sensor control just as on the real robot. In addition there are threads for generating graphics and sound as well as for simulating the physical world that the robot is interacting with. More details for debugging robot programs can be found on the pages on the simulation tool.
  • Finally it cannot completely be ruled out that an issue is caused by a bug in the leJOS or Jabotics libraries.