Some functionalities such as the graph search can optionally done in C++. The written code uses CMake and the C++ Boost libraries. In order to use them the following requirements must be met.
- Install CMake 3.19+
- Install C++ Compiler
- Windows: Microsoft Visual Studio Compiler 2019
- Ubuntu: GCC and G++ Version 10.x+
- Install Boost 1.76
- Install build-essential for Ubuntu
Under Ubuntu we use lanelet2 as one further map representation, because it offers libraries with lots of useful functionality. Since the libraries only exist in Python and C++, mex functions are used to benefit from that. In order to compile these mex functions the following requirements need to be met.
- Install Rosless Lanelet2
- Get Git Submodules:
git submodule update --init
- Windows Path Environment Variable
- Ubuntu Basics
- Matlab
- Python
- CMake
- C++ Compiler
- C++ Boost
- Rosless Lanelet2
Add a path to Path Environment Variable:
- Search for Environment Variables
- Select option Environment Variables
- Edit the variable Path
- Choose New for adding the path
- Package build-essential to compile basic C/C++ software:
sudo apt install build-essential
- Windows: Installation via GUI
- Download Matlab
- Run the installer
- Ubuntu: Installation via GUI
(Since Matlab installation does not follow the unix-style, you could install it in the directory“/opt/matlab/R2023a”
)- Download Matlab
- Extract the zip-file and change to the unzipped directory
unzip matlab_R2023a_glnxa64.zip -d matlab
cd matlab
- Run the installer
sudo ./install
- Remove files no longer needed
cd ..
rm -rf matlab
rm matlab_R2023a_glnxa64.zip
- Ubuntu: Create symbolic links to have Matlab available in every path
ln -s /opt/matlab/bin/matlab /usr/local/bin/matlab
If the link already exist,- either delete it:
rm /usr/local/bin/matlab
- or replace it:
ln -s --force /opt/matlab/bin/matlab /usr/local/bin/matlab
- either delete it:
- Windows: Install Python 3.9 via the provided binary (Windows Download)
- Ubuntu: Install Python 3.9 via package manager and official ppa
sudo apt install python3.9 python3.9-venv python3.9-dev
- Ubuntu: Install Python 3.9 via package manager and deadsnakes ppa for newer versions
- Add an additional package repository:
sudo add-apt-repository ppa:deadsnakes/ppa
- Update the apt cache:
sudo apt update
- Install python:
sudo apt install python3.9 python3.9-venv python3.9-dev
- Add an additional package repository:
- Ubuntu: Install Python 3.9.6 via build
- Install prerequisites for building Python
sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
- Download python zip-file
wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tgz
- Extract the zipped file and move in the directory
tar -xzf Python-3.9.6.tgz
cd Python-3.9.6
- Execute configure script. It will carry out some tests to ensure that the necessary dependencies are available. (options: python binary is optimized, shared libraries are build, pip is installed, installation directory will be “/usr/local”)
./configure --enable-optimizations --enable-shared --with-ensurepip=install --prefix=/usr/local
- Initiate the build process of the python binaries.
make
- Install python at the system. Use “altinstall” to not overwrite the default python version.
sudo make altinstall
- Remove files no longer needed
sudo cd ..
rm Python-3.9.6.tgz
rm -rf Python-3.9.6
- EOL: Uninstall python with (https://unix.stackexchange.com/questions/190794/uninstall-python-installed-by-compiling-source)
sudo rm -f /usr/local/bin/python3.9
sudo rm -f /usr/local/bin/pip3.9
sudo rm -f /usr/local/bin/pydoc
sudo rm -rf /usr/local/bin/include/python3.9
sudo rm -f /usr/local/lib/libpython3.9.a
sudo rm -rf /usr/local/lib/python3.9
- Install prerequisites for building Python
- Add Python to system path environment variable (Guide)
- See Path Environment Variable
- Windows: Standard installation path would look like
"C:\Users\USER\AppData\Local\Programs\Python\Python39\"
- Ubuntu: Not necessary
- Setup Python in Matlab command window as described in the ROS Toolbox Requirements
- Check the Python version of Matlab:
pyenv
- Configure a specific Python version:
pyenv(Version="3.9")
- If Matlab cannot find Python, try:
pyenv(Version=FullPath/Executable)
- Check the Python version of Matlab:
- Windows: Install CMake via the provided binary (Windows Download)
- Ubuntu: Install CMake latest version under Ubuntu via Kitware's PPA
-
Obtain a copy of kitware's signing key
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
-
Add kitware's repository to your sources list and update
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
sudo apt update
-
Install the kitware-archive-keyring package to ensure that your keyring stays up to date as we rotate our keys
sudo apt install kitware-archive-keyring
sudo rm /etc/apt/trusted.gpg.d/kitware.gpg
-
Note: If running sudo apt update gets the following error
Err:7 https://apt.kitware.com/ubuntu bionic InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6AF7F09730B3F0A4
Fetched 11.0 kB in 1s (7552 B/s)Copy the public key 6AF7F09730B3F0A4 and run the command
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6AF7F09730B3F0A4
-
Finally we can update and install the cmake package
sudo apt update
sudo apt install cmake
-
- Add CMake to system path environment variable
- See Path Environment Variable
- Windows: Standard installation path would look like
"C:\Program Files\CMake\bin\"
- Ubuntu: Not necessary
- Windows: Install the Visual Studio 2019 Community Edition. The (free) Community Edition is sufficient. Select "Desktop development with C++" during the installation.
- Ubuntu: Install gcc and g++ officially supported versions
- Install gcc/g++:
sudo apt install gcc-7 g++-7
- Set new gcc/g++ versions as default:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7
- Install gcc/g++:
- Ubuntu: Install gcc and g++ newer versions
- Add an additional package repository
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
- Update the apt cache:
sudo apt update
- Install gcc/g++:
sudo apt install gcc-10 g++-10
- Set new gcc/g++ versions as default:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10
- Add an additional package repository
- Setup the compiler in the Matlab command windows:
mex -setup
- Boost contains mostly header-only libraries (no build required) but also some libraries that must be built. These libraries are built with Boost.Build (B2)
- Windows: Installation Guide
- Download boost_1_76_0.7z
- Extract the zipped file into
"C:\Program Files\boost\boost_1_76_0"
(This directory is sometimes referred to as $BOOST_ROOT) - In Visual Studio: Add the directory to C/C++ Additional Include Directories
- In the boost directory run
bootstrap.bat
to prepare Boost.Build - In the boost directory run
.\b2.exe
to build the libraries (this takes some time) - CMake FindBoost searches for Boost in Environment Variables that must be set
BOOST_ROOT ="C:\Program Files\boost\boost_1_76_0"
BOOST_INCLUDEDIR ="C:\Program Files\boost\boost_1_76_0"
BOOST_LIBRARYDIR ="C:\Program Files\boost\boost_1_76_0\stage\lib"
- Ubuntu: Installation Guide or External Installation Guide
- Install dependencies:
sudo apt-get install build-essential g++ python-dev autotools-dev libicu-dev libbz2-dev libboost-all-dev
- Download boost_1_76_0.tar.bz2:
wget https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2
- Extract it:
tar -xvjf boost_1_76_0.tar.bz2
and change directory:cd boost_1_76_0
- Prepare installation:
./bootstrap.sh --prefix=/usr/local
. If there are multiple boost versions on your system, you might want to install boost in a local folder likeinstall
instead of/usr/local
. - Install libraries (header only and build required):
sudo ./b2 install
- Remove files no longer needed:
sudo cd ..
rm boost_1_76_0.tar.bz2
rm -rf boost_1_76_0
- EOL: Uninstall boost with: (https://stackoverflow.com/questions/8430332/uninstall-boost-and-install-another-version)
sudo apt-get -y --purge remove libboost-all-dev libboost-doc libboost-dev
echo "clear boost dir"
sudo rm -r /usr/local/lib/libboost*
sudo rm -r /usr/local/include/boost
sudo rm -r /usr/local/lib/cmake/*
sudo rm -f /usr/lib/libboost_*
sudo rm -r /usr/include/boost
- Install dependencies:
- Dependencies:
- boost
- eigen3
- pugixml (for lanelet2_io)
- geographic (for lanelet2_projection)
- Preparation:
- Install C++ boost version 1.76
- Install further dependencies of Lanelet2
sudo apt install libboost-dev libeigen3-dev libgeographic-dev libpugixml-dev
- Clone the repository Rosless-Lanelet2 from Github
git clone https://github.com/embedded-software-laboratory/Rosless-Lanelet2.git
- Change directory to the cloned repository
cd Rosless-Lanelet2
- Checkout specific commit to ensure the desired behavior
git checkout 0f190ed17d5060bc30eb03d7ac0d10bf06702096
- Installation:
- Make build directory and change to it
mkdir build
cd build
- Configure the project and specify the installation directory
(default installation destinations are in '/usr/local')
cmake .. -DCMAKE_INSTALL_PREFIX=<install-dir>
. If you installed the needed boost version in a local folder likeinstall
as mentioned above (step 4 of Ubuntu Boost Installation), you furthermore need to specify this folder here by using-DBOOST_ROOT=<path-to-your-boost-install-folder>
- Build the target install to install the libraries
(sudo rights are required for write access at the destinations)
sudo cmake --build . --target install
- Restart the computer that the environment variables can be updated
- Make build directory and change to it
Installing Matlab Updates or Toolboxes afterwards causes permission problems
-
Permission denied
- Since Matlab was installed with sudo, sudo rights are required to install a toolbox. But since Matlab is always started without sudo, the toolbox installer is started without sudo as well.
- Changing the owner of the Matlab installation directory solves this problem:
sudo chown -R $LOGNAME: /usr/opt/MATLAB/R2023a
(https://de.mathworks.com/matlabcentral/answers/334889-can-t-install-any-toolboxes-because-can-t-write-to-usr-local-matlab-r2017, https://de.mathworks.com/matlabcentral/answers/315712-why-do-i-receive-access-denied-or-folder-error-when-installing-matlab-on-linux)
Starting Matlab from terminal a message appears
-
Gtk-Message: : Failed to load module "canberra-gtk-module"
- Message is informal and has no effects on Matlab (https://de.mathworks.com/support/bugreports/1995075, https://de.mathworks.com/matlabcentral/answers/543536-matlab-on-linux-failed-to-load-module-canberra-gtk-module)
On startup Matlab command window shows a warning
-
Warning: X does not support locale en_US.UTF-8
- The warning message that can be disregarded and it has no impact on the functionality of MATLAB (https://www.mathworks.com/matlabcentral/answers/1929870-why-do-i-get-warning-on-startup-x-does-not-support-locale-en_us-utf-8-when-startup-matlab-with-r2?s_tid=answers_rc1-2_p2_MLT)
Searching for cmake via Matlab command window returns an error
!cmake --version
orsystem('cmake --version')
- ... results in error:
-
cmake: /usr/local/MATLAB/R2023a/bin/glnxa64/libcurl.so.4: no version information available (required by cmake)
cmake: /usr/local/MATLAB/R2023a/sys/os/glnxa64/libstdc++.so.6: version 'GLIBCXX_3.4.30' not found (required by cmake)
cmake: /usr/local/MATLAB/R2023a/sys/os/glnxa64/libstdc++.so.6: version 'GLIBCXX_3.4.29' not found (required by cmake)
cmake: /usr/local/MATLAB/R2023a/sys/os/glnxa64/libstdc++.so.6: version 'GLIBCXX_3.4.29' not found (required by /lib/x86_64-linux-gnu/libjsoncpp.so.25) - Similar errors: (https://de.mathworks.com/matlabcentral/answers/1461849-why-does-running-the-unix-curl-command-from-within-matlab-result-in-an-error, https://de.mathworks.com/matlabcentral/answers/1680154-matlab-cannot-find-cmake-on-ubuntu-20-04, https://de.mathworks.com/matlabcentral/answers/329796-issue-with-libstdc-so-6)
- Explanation: The libraries shipped with Matlab are incompatible with the operating system
- Force Matlab to load the external libcurl.so.4 with environment variable $LD_LIBRARY_PATH
(The path of the external libcurl.so.4 can be found out withwhereis libcurl.so.4
)
(https://de.mathworks.com/matlabcentral/answers/1461849-why-does-running-the-unix-curl-command-from-within-matlab-result-in-an-error) - Check if version of the external libstdc++.so.6 is available with
strings 'PATH'/libstdc++.so.6 | grep GLIBCXX
(The path of the external libstdc++.so.6 can be found out withwhereis libstdc++.so.6
)
(https://de.mathworks.com/matlabcentral/answers/329796-issue-with-libstdc-so-6) - If sufficient, update libstdc++6
sudo apt install libstdc++6
(https://askubuntu.com/questions/726539/sudo-apt-get-install-libstdc) - If necessary, upgrade libstdc++6 via package repository ppa:ubuntu-toolchain-r/test
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt upgrade libstdc++6
(LedgerHQ/ledger-live-desktop#4016 (comment)) - Force Matlab to load the external libstdc++.so.6 with environment variable $LD_PRELOAD
(https://de.mathworks.com/matlabcentral/answers/329796-issue-with-libstdc-so-6)
Windows: ROS Toolbox cannot find CMake (if you want to use an external CMake)
-
Error using ros.internal.utilities.getCMakeBinaryPath Unable to find CMake in your system. Please install CMake version 3.15.5 or higher and rerun the command.
- Explanation: Starting with Matlab R2022b, manual installation of CMake is not required since it is part of Matlab installation. If this is not the case and CMake is not contained, this leads to an error. The reason for this is that ROS Toolbox searches for the CMake executable in
"C:\Program Files\MATLAB\<VERSION>\bin\win64\cmake\bin\cmake"
.
Although, there is a fallback solution, that does not work on Windows OS.
[status, result] = system('which cmake');
- Possible Solutions:
- Installation of the Matlab Toolbox "Matlab Coder" will install CMake in the Matlab installation folder as suggested by the Matlab Staff
- Creating a symbolic link for the missing folder cmake with the mklink command in Windows command prompt
mklink /D "C:\Program Files\MATLAB\R2023a\bin\win64\cmake" "C:\Program Files\CMake"
- Adjusting the internal ROS Toolbox script that searches for the CMake executable by substituting
which
with the Windows equivalentwhere
in"C:\Program Files\MATLAB\<VERSION>\toolbox\ros\utilities\+ros\+internal\+utilities\getCMakeBinaryPath.m"
- Create an alias that calls the Windows equivalent
where
instead ofwhich
.
This can be done with the doskey commanddoskey which = where $*
in Windows command prompt (cmd). Since the alias would be temporary for the active cmd, it must be made permanent which requires adjusting the Windows registry as described here or here.
Boost warning massage during the build process
-
#pragma message: This header is deprecated. Use <iterator> instead.
- The message occurs for boost versions 1.74, 1.75, and 1.76 since the graph library uses the headers (boostorg/graph#228)
Mex file cannot find liblanelet2_<>.so
- Although rosless lanelet2 was installed under
/usr/local/lib
on some computers MATLAB does not find it. Before you then start matlab (from a terminal) runexport LD_LIBRARY_PATH=/usr/local/lib
. The same problem may arise with the boost library when installing in a local folder, e.g.,export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<path-to-your-boost-install-folder>/lib
.
Mathworks Platform Road Map shows an overview of supported OS for Matlab and Simulink.
Matlab Dependency Analyzer found additional toolboxes, that are not used anymore:
- Optimization Toolbox
- Symbolic Math Toolbox
CMake Minimum Version:
- Version 3.16.3+ for Matlab R2022a and earlier (see ROS Toolbox Requirements)
- Version 3.19.7 shipped with Matlab R2022b and later (Windows command prompt:
"C:\Program Files\MATLAB\'VERSION'\bin\win64\cmake\bin\cmake.exe" --version
) - Version 3.19 for graph search (see
.\hlc\optimizer\graph_search_mex\CMakeList.txt
)
GCC Minimum Version:
- Version 6.3+ (see ROS Toolbox Requirements)
- Version 7.x+ (see Supported Compilers)
- Version 10.x+ (see C++20 Feature "Coroutines" Requirements)
Boost Version:
- Version 1.76 (latest version which we managed running with Lanelet2)