ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

rclcpp file not found error for creating GUI user interface with ROS2 (Humble) using QT Creator

asked 2022-07-26 14:38:48 -0500

Newton gravatar image

updated 2022-07-26 19:04:31 -0500

William gravatar image

I would like to create an user interface with QT Creator for RO2 (Humble). I'm using Ubuntu 22.04 LTS (jammy) These are the different steps that I've done :

First step : I check if the ROS2 is successfully installed and well configured. For that, i use printenv | grep ROS command in the terminal and this is the output :

ROS_VERSION=2
ROS_PYTHON_VERSION=3
ROS_PACKAGE_PATH=/home/hessanon/dev_ws/src:/opt/ros/humble/share
ROS_LOCALHOST_ONLY=0
ROS_DISTRO=humble

Second step: I've installed QT Creator 4.9.2 for ROS development using this link : https://ros-qtc-plugin.readthedocs.io... The installation was successfully done.

Third step : I've created an empty project in QT Creator and I've configured the .pro file like this:

INCLUDEPATH += /opt/ros/humble/include
LIBS += -L/opt/ros/humble/lib -lrclcpp

And I have this error when I include : #include "rclcpp/rclcpp/rclcpp.hpp" in the QT Project :

/opt/ros/humble/include/rclcpp/rclcpp/rclcpp.hpp:155: error: rclcpp/executors.hpp: No such file or directory
  155 | #include "rclcpp/executors.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~

This is the path where the file executors.hpp is : /opt/ros/humble/include/rclcpp/rclcpp

**My question are :

1) Is the path correct ?

2) How can I fix this error?**

Thanks for your help

Willy

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-07-26 19:18:16 -0500

William gravatar image

updated 2022-07-26 19:20:07 -0500

Hi Willy,

I don't have any experience with "QT Creator 4.9.2 for ROS development", so maybe someone from that team (ROS-Industrial) can answer your questions about it.

However, I will try to answer your questions more directly:

1) Is the path correct ?

No, not in my opinion. Adding the compiler flags, e.g. manually setting the INCLUDEPATH and LIBS settings in Qt Creator, is really fragile, because if these settings change in ROS 2, your project will break.

There are many things you could do instead, but I think the easiest thing for you to do is to create a CMake based ROS package and have Qt Creator open it, which is something it can do:

https://doc-snapshots.qt.io/qtcreator...

This documentation gives you an overview on how to make a ROS 2 package:

http://docs.ros.org/en/humble/Tutoria...

It tells you how to build it using colcon, but you can build a single package without colcon, using the normal CMake procedure, i.e. cmake ..., cmake --build ..., etc., or using tools that understand CMake, like Qt Creator.

Now, after you setup a ROS 2 package using CMake, you still need to use Qt in your CMake project, which is detailed here:

https://doc.qt.io/qt-6/cmake-get-star...

I think between this Qt docs, the Qt docs about using CMake with Qt Creator, and the ROS 2 documentation on how to setup a new package that uses rclcpp and CMake, you should be able to build your application.

It's a bit complicated, but you can see an example of this in rviz2 which uses CMake, ROS 2, and Qt:

https://github.com/ros2/rviz/blob/rol...

Note, that also in your project you should include #include <rclcpp/rclcpp.hpp>, not having the extra rclcpp. More on that below.

2) How can I fix this error?

Like I said above I think a change in approach is the right solution.

However, you can fix your problem by changing your INCLUDEPATH to include /opt/ros/humble/include/rclcpp. This is because rclcpp nests its headers in a sub directory, for a variety of technical reasons. This is actually somewhat new in Humble (I think), but in the past what you are doing would have worked.

Unfortunately, this will just lead you to new errors of missing headers, because other packages also nest their headers, rather than putting them directly into /opt/ros/humble/include, so you'd also have to extend the INCLUDEPATH with things like /opt/ros/humble/include/rcl and /opt/ros/humble/include/rcutils, just to name a few.

This is why using CMake is better, because these settings are gathered automatically by the packages you're depending on. So you don't need to set your compiler flags manually.


Hope that helps.

I will also point you (and others) to this example of using "pure" CMake, in case you don't want to have a dependency on ament_cmake (ROS 2's cmake ... (more)

edit flag offensive delete link more

Comments

Thanks William for your response. I'll try do it and keep you informed. Willy

Newton gravatar image Newton  ( 2022-07-27 10:32:21 -0500 )edit

Question Tools

Stats

Asked: 2022-07-26 14:35:32 -0500

Seen: 996 times

Last updated: Jul 26 '22