This section is dedicated to explaining how to create more advanced applications. This code was created to be robot independent, and has been tested with several robot platforms. The way I achieved this is by using Object Oriented Programing. The code can be used immediately with a skid/steer robot built using the Lego Mindstorms EV3 kit.
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.
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:
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.
A video of the system in action can be found below.
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:
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.
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.
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.
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:
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