how to build and debug ROS2 nodes with clion and docker

asked 2022-05-29 16:09:48 -0500

os gravatar image

Hi, Currently, I'm using docker as my ROS2 environment(using the official humble image file). I want to use the clion debugger to debug my code. How can I configure the Clion so it will use Colcon and compile the code with the docker? also for debugging On my ubuntu machine, the ROS2 is not installed

I tried to use the docker Toolchain (as here:https://www.jetbrains.com/help/clion/clion-toolchains-in-docker.html#sample-dockerfile) combine with this tutorial:https://www.jetbrains.com/he...

what am I missing?

edit retag flag offensive close merge delete

Comments

I can't speak exactly to this, but I use clion daily to debug native (not inside docker) ros2 nodes and plugins. For debugging outside docker, the trick is 1) ensure that you start clion from a terminal that has all the ros2 stuff sourced and 2) ensure that any libraries your node links to is the version of that library that clion has built, otherwise it won't recognize it as something it can debug through. An easy way to ensure #2 that I've found is to use colcon to build things as normal, then change the libraries in question inside install/lib (assuming merge install) to symbolic links pointing to the lib inside the clion build folder.

Hope that at least helps answer some of your questions.

ChuiV gravatar image ChuiV  ( 2022-05-31 20:55:12 -0500 )edit

I've been running into some issues getting headers to sync properly in CLion when using the docker toolchain. https://youtrack.jetbrains.com/issue/...

I can build, run, and debug individual packages but get bad intellisense. It sounds like you want to be able to build, run, and debug individual packages with the entire workspace open, which I have not had any real luck doing.

maspe36 gravatar image maspe36  ( 2022-07-07 10:22:44 -0500 )edit