基于catkin_tools的IDE开放项目 [英] IDE open project based on catkin_tools

查看:174
本文介绍了基于catkin_tools的IDE开放项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在阅读基于catkin_tools构建的ROS软件包.它很复杂,所以我需要将此项目导入到一个IDE中(例如Clion,QT Creator等).尽管catkin-tools的官方文档说您不能依赖CMake的IDE集成(

说明:
当以上述方式进行配置时,CLion会重新使用生成的CMake文件和 catkin build 创建的构建文件.默认情况下,当不配置它以重用构建文件时,CLion将创建其自己的 cmake-build-debug/生成目录.在这个专用的生成/构建目录中,我遇到了以下问题:

未配置CLion的问题,如上述步骤所述:

  • 节点/库被构建两次(CLion, catkin build ),这增加了开发时间.
  • 库构建了两次,但是CLion生成的链接是〜/catkin_ws/devel .so文件,而不是 cmake-build-debug/ .so文件.在带有至少一个库的ROS软件包上工作时,这会造成混淆,因为在CLion中构建库是死胡同,并且从不使用.so-output.
  • 由于可执行文件生成两次,因此 rosrun 存在一个歧义性问题,因为它为指定节点找到了两个可执行文件.每次使用 rosrun 时,都会出现一个可执行的选择提示.

I am now reading a ROS package built on catkin_tools. It is complicated so I need to import this project into an IDE (like Clion, QT Creator, etc). Although the official doc of catkin-tools says you can't rely on CMake's IDE integration (http://catkin-tools.readthedocs.io/en/latest/migration.html?highlight=IDE), I still have some hope on this. So does anyone has such experience?

PS: I also found the author of ros_qtc_plugin claimed he has added the function of catkin_tools, but I still could not find how to do this.

解决方案

The solution does not work for catkin_make, if you are using it, please visit instead:
https://stackoverflow.com/a/35143865/2422098
https://www.jetbrains.com/help/clion/2020.2/ros-setup-tutorial.html#set-build-paths

CLion configuration for catkin_tools workspaces (catkin build)

Please excuse me for digging up an old question, but I just came across this problem and found a solution for CLion and catkin_tools (i.e., when building with catkin build). I tested the proposed solution on 20.04 with ROS Noetic and CLion 2020.2.4.

According to the docs, catkin_tools uses an individual devel workspace path for each ROS package:
https://catkin-tools.readthedocs.io/en/latest/advanced/linked_develspace.html

The devel prefix path for a package:

-DCATKIN_DEVEL_PREFIX:PATH=/home/<user-name>/catkin_ws/devel/.private/<package-name>

The build directory for a package:

/home/<user-name>/catkin_ws/build/<package-name>

To open and edit a ROS package in CLion, please follow these steps:

  1. run catkin build in the workspace
  2. Source /opt/ros/$ROS_DISTRO/setup.bash and your workspace setup.bash in the devel folder
  3. After that, start CLion from the command line, so that it inherits the environment variables
  4. In CLion's Open Project wizard, navigate to the ROS package, and select the CMakeLists.txt. When prompted, click Open as Project
  5. Open the Settings Window (usually Ctrl+Alt+S)
  6. Navigate to "Build, Execution, Deployment" > "CMake"
  7. Under "CMake options", specify the devel prefix as mentioned above, and under "Build directory", specifiy the build directory as mentioned above:

Explanation:
When configured in the aforementioned way, the generated CMake files and build files that catkin build creates are reused by CLion. By default, when not configuring it to reuse the build files, CLion would create its own cmake-build-debug/ generation directory. I experienced the following issues with this dedicated generation/build directory:

Problems when CLion is not configured as described in the above steps:

  • The nodes/libraries are built twice (CLion, catkin build), which increase development time.
  • Libraries are built twice, but the CLion build links with ~/catkin_ws/devel .so-files and not the cmake-build-debug/ .so-files. This is confusing when working on a ROS package with at least one library, since building the library in CLion is a dead-end and the .so-output is never used.
  • Since executables are built twice, rosrun has an ambiguity problem as it finds two executables for the specified node. An executable selection prompt appears each time rosrun is used.

这篇关于基于catkin_tools的IDE开放项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆