[Discourse.ros.org] [Next Generation ROS] ROS2 + Clion

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [Next Generation ROS] ROS2 + Clion

Dirk Thomas via ros-users


I am just posting this here for completeness (thx @dirk-thomas) and complement to https://groups.google.com/forum/#!topic/ros-sig-ng-ros/UMjVH047nVc:

In ROS2 you can not have (yet?) your full workspace being imported in your IDE. However what you can have is individual packages and an environment for all dependencies. Say for e.g. rclcpp this what you do to get it imported into Clion:

You first need to compile ros_ws with ament: https://github.com/ros2/ros2/wiki/Linux-Development-Setup.

> $ source ~/ros_ws/build/rclcpp/cmake__build.sh #this will setup your environment
> $ clion # go to File => Open => ~/ros2_ws/src/ros2/rclcpp => click OK

That's it!





---
[Visit Topic](https://discourse.ros.org/t/ros2-clion/2508/1) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [Next Generation ROS] ROS2 + Clion

Dirk Thomas via ros-users


I have now also found a way to load a whole ROS2 workspace into Clion. At least code browsing is now made easy.

a) You first need to compile ros_ws with ament: https://github.com/ros2/ros2/wiki/Linux-Development-Setup.

b) Second you need to prepare you top level CMakeLists.txt file:
- cd ros_ws
- find src -name CMakeLists.txt -not -name setup.py -print0 | xargs -0 -n1 dirname | sort --unique
- after I manually removed all fastRTPS subfolders and test subfolders
- I also skipped all ament_* folders
- I used emacs to replace ./ with add_subdirectory and to add ) at the end of every line (replace-string, C-q C-j)

c)  Put this CMakeLists.txt into your ros_ws.

d) Comment out the following line in ament_cmake_core/ament_cmake_uninstall_target-extras.cmake:

```
=== ./src/ament/ament_cmake (git) ===
diff --git a/ament_cmake_core/ament_cmake_uninstall_target-extras.cmake b/ament_cmake_core/ament_cmake_uninstall_target-extras.cmake
index f6805e8..c89f289 100644
--- a/ament_cmake_core/ament_cmake_uninstall_target-extras.cmake
+++ b/ament_cmake_core/ament_cmake_uninstall_target-extras.cmake
@@ -32,6 +32,6 @@ if(AMENT_CMAKE_UNINSTALL_TARGET)
   )

   # register uninstall target to run generated CMake script
-  add_custom_target(uninstall
-    COMMAND ${CMAKE_COMMAND} -P "${AMENT_CMAKE_UNINSTALL_TARGET_UNINSTALL_SCRIPT}")
+#  add_custom_target(uninstall
+#    COMMAND ${CMAKE_COMMAND} -P "${AMENT_CMAKE_UNINSTALL_TARGET_UNINSTALL_SCRIPT}")
 endif()
```

e)

$ source ~/ros_ws/build/rclcpp/cmake__build.sh #this will setup your environment
$ clion # go to File => Open => ~/ros2_ws/CMakeLists.txt => click OK

f)
Disable BUILD_TESTING:

In Clion File => Settings => Build, Execution, Deployment => CMake => Cmake options: -DBUILD_TESTING=OFF

g)
You can right click on the Clion project => Reload CMake Project. There will be some warnings about missing OpenSplice dependecies which you can safely ignore.





---
[Visit Topic](https://discourse.ros.org/t/ros2-clion/2508/2) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>