Workflow for CLion and ROS

So I've had a pretty good start with ROS using the tutorials, but the entire build toolchain is an absolute nightmare as far as I understand. Having to continuously add the executable and source files to the CMakeList.txt is not really efficient. For example, creating a package, adding source files and then running catkin_make and sourcing the setup.sh file is just so cumbersome.

I then found Roboware which is a derivative of Visual Code and automates all of the above. It's fine but I actually prefer CLion due to extensive debugging and refactoring capabilities (and many other editor shortcomings of Roboware). However, it doesn't seem to automate the CMakeList tasks that I've just described above. Am I missing something here? Does anyone have a good automated workflow in CLion for ROS?

edit retag close merge delete

Not an answer, but just wanted to make sure you've seen jetbrains.com/ROS Setup Tutorial.

( 2019-03-22 05:41:06 -0600 )edit
( 2019-03-22 06:11:43 -0600 )edit

Sort by » oldest newest most voted

As far as I understand, you are not missing anything.

The core problem with ROS workflow is that ROS is still very immature when it comes to dependency management and building: you have to manually edit package.xml and CMakeLists.txt for rather simple operations like adding messages. Furthermore, macros like find_package(catkin REQUIRED COMPONENTS ...) are ROS-specific and thus not recognized by traditional Linux C/C++ toolchains.

I failed to find a good CLion plugin working with ROS. Even such primitive operations like debugging are made upside-down: you have to attach to existing process for debugging since targets are not extracted from CMake catkin directives. When my patience comes to an end, I will consider writing my own CLion plugin to automate scanning and modifying ROS-specific files.

more

Furthermore, macros like find_package(catkin REQUIRED COMPONENTS ...) are ROS-specific and thus not recognized by traditional Linux C/C++ toolchains.

find_package(..) is standard CMake functionality. The result of find_package(catkin REQUIRED COMPONENTS ...) is the definition of a nr of CMake variables (catkin_LIBRARIES, catkin_INCLUDE_DIRS, etc). A call to find_package(Boost REQUIRED COMPONENTS ..) would result in those same variables.

I'm not using CLion, so I wouldn't know whether it actually supports CMake or extracting information from it, but I would think that if an IDE can deal with CMake, it should be able to deal with Catkin (which is basically CMake).

( 2019-03-22 05:43:30 -0600 )edit

My bad, find_package is a standard CMake part indeed. Things like add_action_files and catkin_add_gtest can be considered standard CMake macros as well, but details of their definition are ROS-specific and some additional work has to be done by IDE to fully support them, say, automate their editing based on source code changes. On the contrast, addition of new header files CLion proposes valid CMake editing, while editing package.xml is not monitored by CLion in any way.

( 2019-03-22 06:05:41 -0600 )edit
1

On the contrast, addition of new header files CLion proposes valid CMake editing, while editing package.xml is not monitored by CLion in any way.

well, no. Not without a plugin adding that probably.

But is that situation so different from using CLion with any other package system that relies on metadata not captured by CMakeLists.txt? The additional metadata is needed (#q217475), CMakeLists.txt does not contain it or it's hard to extract it.

( 2019-03-22 06:21:08 -0600 )edit

Thank you for the link on CMake/package.xml differences. I agree that working with distributed metadata is hardly seen in any IDE, but again adding at least some background analysis on the connections of source files and metadata, even though distributed and probably overlapping, would make things easier from a developer's prospective. And complete (in my opinion) lack of it is what made me write my answer on the original question if there is a good workflow automation as no, not today at least.

( 2019-03-22 06:39:43 -0600 )edit

I agree there is no automated way to handle this in CLion at the moment, so your answer is not wrong. That's also not what I was trying to say.

I was more triggered by this part:

ROS is still very immature when it comes to dependency management and building: you have to manually edit package.xml and CMakeLists.txt for rather simple operations like adding messages.

If you have any ideas on how to automate this then there would be more than enough interest in that.

A complicating factor is that CMakeLists.txt can be arbitrarily complex, so writing a tool that can update a CMakeLists.txt without destroying what is already there is not trivial. So far no-one has bothered to do that, so that's why manual updating is still preferred/used.

If you know of a way to address this, please suggest one.

( 2019-03-22 06:55:27 -0600 )edit