Installing Eclipse IDE platform on Ubuntu 12.04
Open a terminal and enter the following commands, the second command will install C/C++ development tools packages for Eclipse.
sudo apt-get install eclipse-platform sudo apt-get install eclipse-cdt
roscd ~/groovy_workspace$ roscreate-pkg test std_msgs rospy roscpp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING: current working directory is not on ROS_PACKAGE_PATH! Please update your ROS_PACKAGE_PATH environment variable. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Created package directory /home/ma/groovy_workspace/test Created include directory /home/ma/groovy_workspace/test/include/test Created cpp source directory /home/ma/groovy_workspace/test/src Created package file /home/ma/groovy_workspace/test/Makefile Created package file /home/ma/groovy_workspace/test/manifest.xml Created package file /home/ma/groovy_workspace/test/CMakeLists.txt Created package file /home/ma/groovy_workspace/test/mainpage.dox Please edit test/manifest.xml and mainpage.dox to finish creating your package
edit the .bashrc file and add ~/groovy_workspace/test
cd test ~/groovy_workspace/test$ make eclipse-project mv Makefile Makefile.ros if ! (cmake -G"Eclipse CDT4 - Unix Makefiles" -Wno-dev . && rm Makefile && rm CMakeCache.txt && rm -rf CMakeFiles); then mv Makefile.ros Makefile && echo "**ERROR building Eclipse project!**" && false; fi -- The C compiler identification is GNU -- The CXX compiler identification is GNU -- Could not determine Eclipse version, assuming at least 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong. -- Check for working C compiler: /usr/bin/gcc -- Check for working C compiler: /usr/bin/gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Found PythonInterp: /usr/bin/python (found version "2.7.3") [rosbuild] Building package test [rosbuild] Cached build flags older than manifests; calling rospack to get flags -- Using CATKIN_DEVEL_PREFIX: /home/ma/groovy_workspace/test/devel -- Using CMAKE_PREFIX_PATH: /opt/ros/groovy -- This workspace overlays: /opt/ros/groovy -- Looking for include files CMAKE_HAVE_PTHREAD_H -- Looking for include files CMAKE_HAVE_PTHREAD_H - found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Found gtest sources under '/usr/src/gtest': gtests will be built -- catkin 0.5.63 [rosbuild] Including /opt/ros/groovy/share/roscpp/rosbuild/roscpp.cmake [rosbuild] Including /opt/ros/groovy/share/rospy/rosbuild/rospy.cmake -- Configuring done -- Generating done -- Build files have been written to: /home/ma/groovy_workspace/test mv Makefile.ros Makefile mv .project .project-cmake awk -f /opt/ros/groovy/share/mk/eclipse.awk .project-cmake > .project rm .project-cmake python /opt/ros/groovy/share/mk/make_pydev_project.py Creating pydev project for package 'test' Writing .pydevproject, adding 22 modules
Open in a new terminal
eclipse
Now, select File –> Import –> Select--> General --> Existing projects into workspace, hit next then browse for your package’s directory. Just the, click finish.
Right click on src and select New –> Source File, and create a file named test.cpp. Then Finish. And add the next lines:
#include "stdio.h"#include "stdlib.h"int main(void){ printf("Hello World\n"); }
In your package folder, you will find a file named CMakeLists.txt, we are going to edit it. To do it, in our terminal, we go to our package file and type:
~/groovy_workspace//test$ gedit CMakeLists.txt
And we replace the next line: #rosbuild_add_executable(example examples/example.cpp)
With this: rosbuild_add_executable(srctest src/test.cpp)
Save it, and close it.
Finally we build our project by typing in terminal
~/groovy_workspace/test$ rosmake test [ rosmake ] rosmake starting... [ rosmake ] Packages requested are: ['test'] [ rosmake ] Logging to directory /home/ma/.ros/rosmake/rosmake_output-20130207-105113 [ rosmake ] Expanded args ['test'] to: ['test'] [rosmake-0] Starting >>> catkin [ make ] [rosmake-0] Finished <<< catkin ROS_NOBUILD in package catkin No Makefile in package catkin [rosmake-4] Starting >>> cpp_common [ make ] [rosmake-0] Starting >>> genmsg [ make ] [rosmake-3] Starting >>> rospack [ make ] [rosmake-1] Starting >>> rosgraph [ make ] [rosmake-0] Finished <<< genmsg ROS_NOBUILD in package genmsg No Makefile in package genmsg [rosmake-3] Finished <<< rospack ROS_NOBUILD in package rospack No Makefile in package rospack [rosmake-0] Starting >>> genlisp [ make ] [rosmake-5] Starting >>> genpy [ make ] [rosmake-3] Starting >>> gencpp [ make ] [rosmake-2] Starting >>> roslib [ make ] [rosmake-1] Finished <<< rosgraph ROS_NOBUILD in package rosgraph No Makefile in package rosgraph [rosmake-4] Finished <<< cpp_common ROS_NOBUILD in package cpp_common No Makefile in package cpp_common [rosmake-0] Finished <<< genlisp ROS_NOBUILD in package genlisp No Makefile in package genlisp [rosmake-1] Starting >>> roslang [ make ] [rosmake-3] Finished <<< gencpp ROS_NOBUILD in package gencpp No Makefile in package gencpp [rosmake-2] Finished <<< roslib ROS_NOBUILD in package roslib No Makefile in package roslib [rosmake-4] Starting >>> rostime [ make ] [rosmake-3] Starting >>> xmlrpcpp [ make ] [rosmake-2] Starting >>> rosunit [ make ] [rosmake-5] Finished <<< genpy ROS_NOBUILD in package genpy No Makefile in package genpy [rosmake-5] Starting >>> message_generation [ make ] [rosmake-1] Finished <<< roslang ROS_NOBUILD in package roslang No Makefile in package roslang [rosmake-4] Finished <<< rostime ROS_NOBUILD in package rostime No Makefile in package rostime [rosmake-2] Finished <<< rosunit ROS_NOBUILD in package rosunit No Makefile in package rosunit [rosmake-4] Starting >>> roscpp_traits [ make ] [rosmake-3] Finished <<< xmlrpcpp ROS_NOBUILD in package xmlrpcpp No Makefile in package xmlrpcpp [rosmake-5] Finished <<< message_generation ROS_NOBUILD in package message_generation No Makefile in package message_generation [rosmake-2] Starting >>> rosconsole [ make ] [rosmake-4] Finished <<< roscpp_traits ROS_NOBUILD in package roscpp_traits No Makefile in package roscpp_traits [rosmake-4] Starting >>> roscpp_serialization [ make ] [rosmake-2] Finished <<< rosconsole ROS_NOBUILD in package rosconsole No Makefile in package rosconsole [rosmake-4] Finished <<< roscpp_serialization ROS_NOBUILD in package roscpp_serialization No Makefile in package roscpp_serialization [rosmake-4] Starting >>> message_runtime [ make ] [rosmake-4] Finished <<< message_runtime ROS_NOBUILD in package message_runtime No Makefile in package message_runtime [rosmake-4] Starting >>> std_msgs [ make ] [rosmake-4] Finished <<< std_msgs ROS_NOBUILD in package std_msgs No Makefile in package std_msgs [rosmake-4] Starting >>> rosgraph_msgs [ make ] [rosmake-4] Finished <<< rosgraph_msgs ROS_NOBUILD in package rosgraph_msgs No Makefile in package rosgraph_msgs [rosmake-4] Starting >>> rospy [ make ] [rosmake-2] Starting >>> roscpp [ make ] [rosmake-2] Finished <<< roscpp ROS_NOBUILD in package roscpp No Makefile in package roscpp [rosmake-4] Finished <<< rospy ROS_NOBUILD in package rospy No Makefile in package rospy [rosmake-2] Starting >>> test [ make ] [rosmake-2] Finished <<< test [PASS] [ 13.02 seconds ] [ rosmake ] Results: [ rosmake ] Built 23 packages with 0 failures. [ rosmake ] Summary output to directory [ rosmake ] /home/ma/.ros/rosmake/rosmake_output-20130207-105113
Now, on eclipse IDE, press a right click on the test directory and choose Run As --> Run Configurations...
double click on C/C++ Application --> Browse ~/groovyworkspace/test/bin/srctest --> Apply --> Run
References:
How to use Eclipse with ROS[ENG],
Uploaded on 10 Jan 2012
http://www.youtube.com/watch?v=grlBIimWXgU
David Lavy, Setting up Eclipse with ROS
http://davidlavy.wordpress.com/ros/setting-up-eclipse-with-ros/