You're reading the documentation for a version of ROS 2 that has reached its EOL (end-of-life), and is no longer officially supported. If you want up-to-date information, please have a look at Humble.
Building ROS 2 on Linux with Eclipse Oxygen [community-contributed]
Some people have reported issues with this tutorial. If the steps work for you please leave a comment on https://github.com/ros2/ros2/issues/495 . If the steps don’t work then please comment with the first step that didn’t work.
This tutorial is based on a clean ubuntu-16.04.2 install and eclipse oxygen with egit. It uses RTI Connext as middleware for Realtime performance. The original Install page is perhaps more up-to-date, so check it for info.
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/dashing.list' sudo apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 421C365BD9FF1F717815A3895523BAEEB01FA116
sudo apt update sudo apt install git wget build-essential cppcheck cmake libopencv-dev python-empy python3-dev python3-empy python3-nose python3-pip python3-pyparsing python3-setuptools python3-vcstool python3-yaml libtinyxml-dev libeigen3-dev clang-format pydocstyle pyflakes python3-coverage python3-mock python3-pep8 uncrustify libasio-dev libtinyxml2-dev libcurl4-openssl-dev libqt5core5a libqt5gui5 libqt5opengl5 libqt5widgets5 libxaw7-dev libgles2-mesa-dev libglu1-mesa-dev qtbase5-dev
sudo pip3 install argcomplete flake8 flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-import-order flake8-quotes pytest pytest-cov pytest-runner
Create an eclipse workspace named ros2_ws (the name does not need to be ros2_ws).
Inside this eclipse-workspace create a C++ Project. This option creates an indexer for code-completion.
Name the project ros2_ws.
The project and some includes are shown. The includes don’t reside in our workspace, so don’t remove them, they are for the indexer.
Create a folder inside our project, named “src”.
The folder now exists in the project. This folder also exist in the workspace. Next go to a console and switch to the directory /home/ros/ros2_ws/ros2_ws. There enter:
wget https://raw.githubusercontent.com/ros2/ros2/dashing/ros2.repos vcs-import src < ros2.repos
Add export RTI_LICENSE_FILE=/home/ros/rti_connext_dds-5.3.1/rti_license.dat to .bashrc and source it.
An RTI license is now needed, which we can get on their website. Refer to Ubuntu Linux Development Setup page. The RTI license file will be directly sent via email after sign-up.
In the email is a link to the RTI software to download. Download the file, then run “chmod +x” on it to make it runnable.
Choose the home directory to install.
In the Launcher which started, select the RTI license file and copy it global.
Select the install button.
Install the security package from RTI software.
And the openssl package.
Unpack the openssl-1.0.2n package and copy it to the RTI install directory. source /home/ros/rti_connext_dds-5.3.1/resource/scripts/rtisetenv_x64Linux3gcc5.4.0.bash in a console and export RMW_IMPLEMENTATION=rmw_connext_cpp.
Close eclipse-IDE and open it from the shell we sourced all the scripts from above. Open Project->Preferences in Eclipse and go to Environment.
In Eclipse enter environment variables. The value of the variables can be obtained by running “env > /tmp/out”, then source the ROS 2 local_setup.bash, then “env > /tmp/out1” and “diff /tmp/out /tmp/out1”. The difference in that output is what should be entered into Eclipse environment variables so that Eclipse knows about e.g. the new PATH variable.
Go to Builders and click the “New” button.
Enter the ament.py settings.
Go to C++ Build and delete the build command make, because we’ll use ament.py.
Now right-click and run “Build Project”.
HINT: if you see the error error: NDDSHOME set to but could neither find all optimized libraries nor all debug libraries Delete the /home/ros/rti_connext_dds-5.3.1/lib/x64Linux3gcc5.4.0/5.3.1/5.3.1 directory with duplicated libraries.
Now open two consoles, source ros2_ws/install/local_setup.bash in both consoles and run talker and listener
In the Eclipse Project, go to git-repositories-view and import local repo.
Select our directory and select the repository we are interested in seeing. This will allow us to get git information about those repositories.
After adding the git repositories to the git-repository-view, right-click on it and select “Import projects”.
The import source is the directory of our project.
On the left hand side in the Project Explorer view we can see that this project is next to our ros2_ws project. Both use the same files, but one is linked with egit and can show git information, while the other cannot. Open the files from the project which is linked to Egit.
Below a file linked with Egit is shown. Right-click beside the line number in the editor and choose “Show Revision information” from the pop-up dialog, then you can see commit information if you hover over it with the mouse.