Downloading and Compiling

skid_steer_lego_ev3_robot_with_xgl1300l_gyro
The following instructions assume that the GNU Cross Compiler has been already installed and the process of compiling, and running programs in the EV3 brick is well understood.
The Robot Navigation software uses C++ shared libraries that are not available in the EV3 Linux operating system. Therefore the compiler must be instructed to statically link the libraries during compilation time. This method creates quite large executable files as the external functions have to be embedded in the executable. I have provided instructions for Linux and Windows users. The software is been updated regularly, so it is advisable to check for updates.
User that are already familiar with the following compilation method can alternatively choose to copy add and load the necessary dynamic libraries, which has the advantage of creating significantly shorter executable files.

Linux Instructions
Download all the program files from the Robonav Github repository using the following command:

git clone https://github.com/robotnav/robotnav.git

The Makefile file must have the -static flag set in order to link the libraries statically.

CFLAGS = -g -Wall -static

Move to the directory containing the source code and compile the program using:

make

This command will create the executable main file. Copy this program and telnet (or ssh) into the EV3 Brick, then execute the program from the terminal window. The robot can be now controlled using the arrow keys directly from the computer terminal. There will be a lot of information presented on the screen, which shows the full state of the robot, sensors, and time. We will be using this information in future projects.
ev3_robotnavigation
A video of the system in action can be found below.

Windows Instructions
Download the programs from the Robonav Github repository. This can be done using the “Download Zip” button available in the Web interface. By default it will be saved in the Downloads directory with the name robotnav-master.zip. Uncompress the zip file in a working directory. This will show several C++ files (extension .cpp).
It is advisable to compile the program using command line instructions first in order to verify that the compiler was correctly installed. Move to the directory containing the source code, and run the following instruction:

arm-none-linux-gnueabi-g++ *.cpp -o main

This instruction only verifies that the cross-compiler was installed. If the make program was installed properly as part of the Brickxcc IDE installation, you can use it to compile the code as follows:

make

Both solutions (compiler only or make) will create the same result, but the latter is more efficient as it only recompiles the programs that have been modified.
The main executable file can now be copied to and executed in the EV3 Brick using ssh for Windows tools.

The following tutorial shows how to use the Bricxcc-test-version IDE:
1.- Start Bricxcc:
start_bricxcc_screen

2.- Open the main.cpp from the working directory.
open_main_cpp

3.- Open the Program Manager:
select_program_manager

4.- Press the right button and select add files:
add_files_in_program_manager

5.- Select all the files from the uncompressed working directory:
select_files_program_manager

6.- The program manager should now contain all the C++ files.
program_manager_with_files

7.- Before compiling, the C++ compiler must be instructed to statically link the libraries in the executable file. This is done by adding the -static directive under “how to link executable” available in the Edit/Preferences/Compiler/EV3 tab.
configure_bricxcc_compiler

8.- Compile the program files [F5] and download the executable main in the EV3 Brick [F6]. Keep in mind that Bricxcc places by default the executable files in ram memory, under the /mnt/ramdisk/prjs directory.

9.- Telnet (or ssh) in the EV3 Brick. Locate the executable main file and run it. The robot can be now controlled using the arrow keys directly from the computer terminal. All of the information that shows up on the screen is the full state of the robot, sensors, and time. This information will be used in later projects.
putty_run_robot_navigation_Lego_EV3

Using Dynamic Libraries
The EV3 Linux kernel does not include the libstdc++.so.6.0.10 library (click on VIEW RAW to download) that Robot Navigation requires to operate. However this library can be copied into the micro-SD card and loaded as needed. Users that want to try this method can compile the program without addind the -static flag in the Makefile (Linux) or EV3 preferences (Bricxcc). The resulting executable file is significantly smaller. In order to use this option, the operating system must be instructed to add the path containing the library before running the main program as follows:

export LD_LIBRARY_PATH="/media/card/lib/:$LD_LIBRARY_PATH"

This instruction assumes that the file libstdc++.so.6.0.10 is copied inside the /media/card/lib/ directory. This needs to be called every time a new telnet or ssh session is created. Users that may want to use the EV3 menu can load the library and run the program with a single instruction:

export LD_LIBRARY_PATH="/media/card/lib/:$LD_LIBRARY_PATH" && ./main

The following video shows the full system in action:

9 Responses to Downloading and Compiling
  1. Charly says:

    Just tried it on Linux. Direct compile and scp from brick. It brilliantly works!

    Looks very interesting,

  2. Brian says:

    I am using Windows 7 64bit and BCC 3.3 (Build 3.3.8.11)
    I get the following error:

    Compile/Download Failed
    Unknown GNU error code (-1)

    • admin says:

      I have only seen this error when I create a new program file and I try to compile it before saving it.

      • Konne says:

        Hi everybody,

        I get the same error:
        Compile/Download Failed
        Unknown GNU error code (-1)

        program is saved and I followed the instructions exactly. What can be the problem?

        • admin says:

          There is a good chance that the installation process was not done properly. I added a few more instructions that will help verifying that the cross-compiler and Linux-tools are properly installed. Please follow the additional instructions and let me know if you still have problems.

        • Psior says:

          Make sure you compile all the .cpp files, not just main.cpp. If they are all in the same directory this command should do the trick:

          arm-none-linux-gnueabi-g++ *.cpp -o robotnav

          • admin says:

            Yes, it is possible to compile the Robot Navigation code using that command. However using the “make” command has the advantage of compiling only the files that have been modified instead of all of them. The “make” command can also be used under Windows, provided that the Linux-tools were installed. This is a good option, if only the CrossCompiler is installed.

  3. Charly says:

    Hi

    I want to add the Lego gyro into robotnav, but cant find any info related to it.

    Any hint were to begin?

    thanks!

    • admin says:

      You could use the Xg1300LGyro class as guideline. Your class will be inherited from EV3 as well, but instead of opening an I2C device, you need to open an RS232 device (http:/www.robotnav.com/serial-interface/)