2

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.

Handuo
  • 21
  • 1
  • 3

2 Answers2

2

Note: The following solution works for catkin build, but not for catkin_make. If you are using catkin_make, please visit:
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: CMake Settings

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.
svenlr
  • 86
  • 1
  • 6
0

I have had success using Eclipse to work with ROS in the past. See: http://wiki.ros.org/IDEs#Creating_the_Eclipse_project_files for setup details.

If you want something that works right out of the box, you can try a free IDE called RoboWare that is specifically built for and integrates with ROS very well. http://www.roboware.me/#/home

Luke
  • 1
  • 2