ROS进阶学习手记 4 -- 使用Eclipse开发ROS

本文档详细记录了如何在Eclipse中设置和运行ROS项目。从在catkin工作空间创建package,将项目导入Eclipse,到配置环境变量进行编译、构建和调试代码。在运行过程中,重点介绍了如何解决Eclipse中不显示项目的问题,以及如何正确设置ROS环境变量以运行和调试executables。此外,还分享了一些Eclipse的实用技巧,如设置文件模板、启用Doxygen和使用emacs键绑定等。
摘要由CSDN通过智能技术生成



http://wiki.ros.org/IDEs

遇到无法导入到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/

【步骤】

1. 在catkin 's workspace下建立自己的package: beginner_tutorials

2. Transfor your catkin project into Eclipse project. i.e. create the .project files.

3. import the Eclipse's project into Eclipse.

4. 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的代码。




  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值