Configure Eclipse IDE in catkin of Ros Groovy

posted @ 2013-05-16 17:03 from [FreedomShe]

由于Groovy之前是rosbuild workspace为主,官方的IDE环境配置以rosbuild为范例来介绍,而目前(2013.5)对预备取代rosbuild的catkin并无提及(refer1 http://www.ros.org/wiki/IDEs)。熟悉Cmake的人已经解决catkin中配置Eclipse for C/C++的问题(refer2 http://answers.ros.org/question/52013/catkin-and-eclipse/),但试验时出现过无法调试的问题。后来加上CMAKE_BUILD_TYPE=Debug就好了,借此总结一下配置过程。

Enviorment: Ubuntu 12.04 + Ros Groovy + catkin workspace.

1. Installing Eclipse

1.1. Download Eclipse IDE for C/C++

Do not use "sudo apt-get install eclipse" to install Eclipse. Instead, go to www.eclipse.org to download the Eclipse IDE for C/C++ (http://www.eclipse.org/downloads/). And then extract to your folder of your choice.

1.2. Install Java 7 if you have not

If you have not installed Java7, you need to setup Java7 before Eclipse could be run successfully. To install Java7 in Ubuntu 12.04, follow as (refer3 http://www.ubuntugeek.com/how-to-install-oracle-java-7-in-ubuntu-12-04.html):

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

If something wrong happens, you may execute these commands before:

sudo apt-get purge openjdk*
sudo rm /var/lib/dpkg/info/oracle-java7-installer*
sudo apt-get purge oracle-java7-installer*
sudo rm /etc/apt/sources.list.d/*java*
sudo apt-get update

More details to refer the refer3 page above.

1.3. Create a launcher to run Eclipse from your ROS-sourced shell

Open a terminal, and then go to:

cd /usr/share/applications/

Create a launcher with gedit:

sudo gedit eclipse.desktop

Edit the launcher as follows:

[Desktop Entry]
Name=eclipse
Type=Application
Exec=bash -i -c /opt/eclipse/eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false

Note: Do replace “/opt/eclipse/” with your Eclipse path. “bash -i -c /opt/eclipse/eclipse” is to source ROS and start your IDE, then your IDE will run with ROS environment.

Save the file, and grant it with:

sudo chmod 777 eclipse.desktop

Open the dash (Alt+F2), and search “eclipse” from it, you can see your Eclipse now:

image

Now, I guess you can launch the Eclipse successfully!

2. Creating Eclipse project files

Go to your catkin workspace directory and run catkin_make with options to generate Eclipse project files:

cd ~/catkin_ws
catkin_make --force-cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j8 .

catkin_make command will make cmake to generate several Eclipse files in the build/ folder, with these files you can import the catkin project into Eclipse IDE.

3. Importing the project into Eclipse

Start Eclipse from your Eclipse launcher, select File --> Import --> Existing projects into workspace, hit next, then browse for your catkin_ws directory (just select workspace directory). Do NOT select Copy projects into workspace. Then finish.

If you haven't created any package, you may follow Writing a Publisher/Subscriber (C++) to create a package with source files before we test our environment.

image

Your project construction may be looked like this, the [Source directory] contains your source code, you may edit the code under this directory later.

You can build your project inside Eclipse with Ctrl+B.

4. Running and debugging your executables within Eclipse

Open “Debug Configurations” in Eclipse. Create a new “C/C++ Application”.

image

Click “Browse” from the “Main” tab to select your executable file. The file should be generated after you build your project (Ctrl+B), in ~/catkin_ws/devel/lib/$yourpakage/ (your path must not as same as mine as showing in the picture.)

image

You can debug your executable file in Eclipse for Ros catkin workspace now!

Note: 对于refer2(http://answers.ros.org/question/52013/catkin-and-eclipse/),如果用第二种方法,会在src里面生成垃圾文件,破坏了catkin的原始结构;用第一中方法保证了原始结构,但是会遇到调试不成功的问题,我是在生成Eclipse project时候加上CMAKE_BUILD_TYPE=Debug才可以的。英文不好的应该不会研究Ros吧,翻译得太别扭,就用我别扭的E文总结了下……

posted @ 2013-05-16 17:02  FreedomShe  阅读(...)  评论(... 编辑 收藏