Setup on Ubuntu Eclipse IDE for ROS development on C++

Create Eclipse project for ROS-package

Set a directory for own ROS-packages as current (in this example “ros-sandbox”).

cd ~/ros-sandbox

hint How to setup a folder for own ROS-packages

Create a ROS package with first-order dependency to a ROS-package “roscpp”.

roscreate-pkg ExampleCpp1 roscpp

ROSCreatePackageExampleCpp1

Move to directory of created package.

roscd ExampleCpp1

Create an Eclipse project.

make eclipse-project

ROS.MakeEclipsePackage
. . .
ROS.MakeEclipsePackageEnd

hint When to use commands 'make' or 'rosmake'?

It is not needed to prepare a project for Eclipse. Run commands “make” or “rosmake” with a ROS-package name as an argument to build the package (“rosmake” also builds dependent ROS-packages). Errors during building the ROS-package indicate existing problems.

E.g. following errors:

/home/user1/ros-sandbox/ExampleCpp1/src/talker.cpp:49: undefined reference to `ros::Rate::Rate(double)’
/home/user1/ros-sandbox/ExampleCpp1/src/talker.cpp:67: undefined reference to `ros::console::g_initialized’
/home/user1/ros-sandbox/ExampleCpp1/src/talker.cpp:77: undefined reference to `ros::spinOnce()’

This most likely indicates that dependency on the package “roscpp” was not defined when ROS-package was created by the command “roscreate-pkg” or a following line was removed from the file “manifest.xml” located in the directory of this ROS-package

<depend package=”roscpp”/>

Import Eclipse project of ROS-package to Eclipse

Run Eclipse from the Terminal – this allows to use same environment variables as for ROS packages.

. eclipse

hint What is . ('dot' or 'full stop') in the command?

. (“dot” or “full stop”) as well as a command “source” – both followed by space – specifies that a command, script or program is needed to be run within same environment as it is in this shell session (in this started Terminal). Command like “./command_name” runs the command with a new shell.

In the Eclipse select menu items File/Import to open the dialog “Import”.

EclipseImportProjectDialog

In the dialog “Import” select “C/C++”/”Existing Code as Makefile Project”, click a button “Next”.

EclipseInImportProjectSelectROSPackage

In the dialog “Import Existing Code”  click a button “Browse”, find and select the folder with created ROS-package – “Project Name” will be automatically filled in with the package name. Leave check-boxes “Language” ticked for “C” and “C++”. Select an item “Linux GCC” in the list “Toolchain for Indexer Settings”. Click on the button “Finish” to complete import of the project.

EclipseImportExistingCodeDialog

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmail