ROS进阶学习手记 4 – 使用Eclipse开发ROS
遇到无法导入到eclipse的问题,用下一篇文章的思路进行解决:
http://www.cnblogs.com/freedomshe/archive/2013/05/16/configure_eclipse_in_catkin.html
http://blog.csdn.net/sujun3304/article/details/18572017
http://answers.ros.org/question/52013/catkin-and-eclipse/
【步骤】
在catkin ’s workspace下建立自己的package: beginner_tutorials
Transfor your catkin project into Eclipse project. i.e. create the .project files.
import the Eclipse’s project into Eclipse.
Try to compile, build and debug your code.
中途我遇到一点问题,就是我在exbot上下载安装的Ubuntu12.04 for ROS in Hydro(开发版), 打开Eclipse发现Project Pannel里不显示任何项目。后来重装了一次才解决。
完成了make the Eclipse Project以后,就可以follow the http://wiki.ros.org/IDEs to import » Build.
我做得还比较顺利。
下面就是运行了:
Running and debugging your executables within Eclipse
As for building within Eclipse, the crucial step here is to set the required environment variables correctly in the launch configuration. As the same for building, this should work out-of-the-box, especially if you follow Reusing your shell’s environment from above.
Create a new launch configuration:
by clicking on Run –> Run configurations… –> C/C++ Application (double click or click on New). Select the correct binary on the main tab (Search project should work when your binary was already built). Then in the environment tab, add (at least)
- ROS_ROOT
- ROS_MASTER_URI
again with the values of your installation. If you are unsure about them, open a terminal and run
echo $ROS_ROOT
echo $ROS_MASTER_URI
Finally, if you cannot save the configuration, remove the @ character in the name of the new run configuration.
This should now allow you to run and debug your programs within Eclipse. The output directly goes into the Console of Eclipse. Note that the ROS_INFO macros use ANSI escape sequences, which are not parsed by Eclipse; therefore, the output might look similar to this one (from Writing a Publisher/Subscriber (C++)):
[0m[ INFO] [1276011369.925053237]: I published [Hello there! This is message [0]][0m
[0m[ INFO] [1276011370.125082573]: I published [Hello there! This is message [1]][0m
[0m[ INFO] [1276011370.325025148]: I published [Hello there! This is message [2]][0m
[0m[ INFO] [1276011370.525034947]: I published [Hello there! This is message [3]][0m
You could use an ANSI console plugin (e.g. http://www.mihai-nita.net/eclipse/) to get rid of the “[0m” characters in the output.
More eclipse goodies
- Setup a file template that pre-formats whenever a new source or header file is created. The template could for example contain the license header, author name, and include guards (in case of a header file). To setup the templates, choose in the Preferences C/C++->Code Style->Code Templates. For example, to add the license header choose Files->C++ Source File->Default C++ source template and click on Edit…. Paste the license header and click OK. From now on, all source files while automatically contain the license header.
- Enable Doxygen with the project properties clicking on C/C++ General, enabling project specific settings and selecting Doxygen as Documentation tool. This option automatically completes Doxygen style comments highlights them.
- People that are used to the emacs key bindings can select emacs-style bindings in Windows->Preferences General->Keys and selecting the emacs Scheme. Also, other useful key bindings (e.g. make project) can easily be added.
- To also index files that live outside the ROS tree (e.g. the boost include files) you can add them in project properties C/C++ General->Paths and Symbols.
- The generated eclipse project also works great for Python code. Just install the PyDev plugin for syntax highlighting and code completion.
Finished.
======= 开始用Eclipse写一个发布给Turtlesim_node驱动和角度Msg的 my_node1 =====
参考Youtube上两个视频:
[CS460] ROS Tutorial 4.1 Turtlesim Cleaner Application - An Overview
[CS460] ROS Tutorial 4.2 Moving in a Straight Line (Turtlesim Cleaner)
我们来在Eclipse里写这个node的代码。