ROS 之IDE
之前的ROS项目都是用vim编辑的代码, 无论是CMList还是cpp文件, launch什么的, 都是复制粘贴, 或者小改动, 时间长了发现真的顶不住, 那么问题来了, 怎么在ubuntu下面高效率的编辑ros项目呢?
答案是用IDE啊, 废话..
这个链接讲了如何用Eclipse CDT来编辑, 编译甚至运行你的ROS项目.
http://wiki.ros.org/IDEs
值得注意的是:
1. eclipse启动的时候, 最好加上-i -c, 加的方法是编译一个desktop文件:
marc@marc-ThinkPad-T450:/opt/ros/indigo$ sudo cat /usr/share/applications/eclipse.desktop [Desktop Entry] Name=Eclipse Type=Application Exec=bash -i -c "source /opt/ros/indigo/setup.bash && source /media/marc/data/ros_ws/devel/setup.bash && /opt/eclipse/eclipse" Terminal=false Icon=/opt/eclipse/icon.xpm Comment=Integrated Development Environment NoDisplay=false Categories=Development;IDE Name[en]=eclipse.desktop
2. 下载的eclipse, 要放在/opt/下面, 不过如果你用的是上面的desktop文件方式从"Dash Bar"启动, 搞笑的是有人在问什么是dash bar..
3. 要将现有的项目, 用catkin build --force-cmake -G"Eclipse CDT4 - Unix Makefiles", build成eclipse的项目, 同时要用下面的代码为eclipse生成.project文件
ROOT=$PWD cd build for PROJECT in `find $PWD -name .project`; do DIR=`dirname $PROJECT` echo $DIR cd $DIR awk -f $(rospack find mk)/eclipse.awk .project > .project_with_env && mv .project_with_env .project done cd $ROOT
写个文件名放在ws目录下, 转成+x, 生成了新的package, 就运行一下吧, 包括上面那build语句也是.
4. 用dash bar启动eclipse之后, import你的项目, 如果上一步成功, 找到对应的路径会发现对应的project文件, 才能import的, 不要硬来...
5. 导入项目之后, 有可能会发现, 很多的problem, 比如甚至找不到对应的头文件, printf啊, string啊这些std的东西, 解决办法是:
勾选最下面那个"CDT GCC Build-in Compiler Settings"
具体其他问题可以参考下面几点:
- If the dependencies of your project have changed since first adding them to Eclipse, regenerate the project files and reimport the project into your workspace.
-
Making sure to load your .bashrc environment with Eclipse, by launching it using bash -i -c "eclipse" (see Reusing your shell's environment).
-
In Eclipse, right click the project, click properties -> C/C++ general -> Preprocessor Include Paths, Macros etc. Click the tab "Providers" and check the box next to "CDT GCC Built-in Compiler Settings [ Shared ]".
-
Afterwards, right click the project, select Index -> Rebuild. This will rebuild your index. Once this is done, usually all includes will resolve.
-
As a last resort, you can also manually add folders that will be searched for headers, using right click project -> properties -> C/C++ Include Paths and Symbols. This is usually not necessary though.
修改完记得项目上右键, Index->Rebuild一下, 恭喜你, printf变成紫色了, 表示编辑器知道丫的爹在哪了...
5. 发现编译是ok的, 但是最后一步, 在eclipse运行, 首先开启master, roscore
指定devel/lib/包名/可执行文件名
原来这位大神总结得挺好, 害我折腾半天:
http://www.cnblogs.com/cv-pr/p/4871546.html