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

Add and run code for ROS-packages

In the “Project Explorer” tab expand the content of an imported project, select the “src” folder, click the right mouse button to show the context menu, select an item “New”, then an item “Source File”.

EclipseAddNewSourceFile

Type in the field “Source file” the name of the file (e.g “talker.cpp” taken from the  tutorial) and click the button “Finish”.

EclipseNewSourceFileDialog

Open the created file and copy/paste in it source code from the section “1.1.1 The Code” of the tutorial (or from GitHub). Errors may be indicating that dependency from ROS-packages are not resolved – it will be resolved in a while.

EclipseAddedSourceFile

Open the file “CMakeList.txt” and add the following line at the end (similar to existing commented lines) – this line specifies “make” to build an executable with name “talker” from the file “talker.cpp” located in the directory “src”.

rosbuild_add_executable(talker src/talker.cpp)

EclipseEditCMakeListTxtFile

For each file added to the directory “src” it is needed to add such line in the file CMakeList.txt

Build the project (as described earlier in this instruction) – a new directory “Binaries” will be created in the project hierarchy. This directory contains files with extension “.out” and an executable file “talker”.

Add a new run-configuration

  1. Click on the arrow-down on the right of a button “Run” EclipseIconRunProject to display a menu.
  2. Select an item “Run Configurations…”.
  3. In the dialog “Run Configurations” select one of existing configurations under the “C/C++ Application” item.
  4. Click on the button “Search Project”.
  5. In the dialog “Program Selection” select the file “talker” and click the button “Ok”.
  6. Click on the button “Apply” in the dialog “Run Configurations…” and close the dialog.

EclipseAddNewRunConfiguration

Run another copy of the Terminal (hit Ctrl+Alt+T) and run the following command starting ROS-core which allows services communicating – without this started “talker” will be terminated with an error “Failed to contact master”.

roscore

ROSCoreStarted

Switch to Eclipse, select the project in the “Project Explorer” tab and click on the button “Run” EclipseIconRunProject – “talker” package will start sending data shown in the “Console” tab. Click on the button “Terminate” to stop the application.

EclipseStartedTalkerWithTerminateButton

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmail