Ask Your Question
0

another "fatal error: ros/ros.h: No such file or directory"

asked 2020-12-23 15:54:54 -0600

ticotico gravatar image

updated 2021-01-02 13:56:05 -0600

Good evening

Sorry for asking another "ros/ros.h: No such file or directory" question. Unfortunately, none of the following did work/is applicable: 2xFindPackage, InitWorkspace or MissingCatkin_INCLUDE_DIRS.

Some back ground info:

  • Ubuntu 20.04 with Noetic
  • catkin build was working nicely till recently
  • might be related to the installation and removal of miniconda (?) (.bashrc does not contain anything related to conda anymore)
  • ROS environment variables look good (ROS_ETC_DIR=/opt/ros/noetic/etc/ros, ROS_ROOT=/opt/ros/noetic/share/ros, ROS_PACKAGE_PATH=/home/xxx/...)

Dummy sample from beginner_tutorials:

package.xml

<?xml version="1.0"?>
<package format="2">
    <name>beginner_tutorials</name>
    <version>0.0.0</version>
    <description>my dummy sample</description>
    <maintainer email="me@todo.todo">me</maintainer>
    <license>TODO</license>

    <buildtool_depend>catkin</buildtool_depend>
    <build_depend>roscpp</build_depend>
    <build_depend>rospy</build_depend>
    <build_depend>std_msgs</build_depend>
    <build_export_depend>roscpp</build_export_depend>
    <build_export_depend>rospy</build_export_depend>
    <build_export_depend>std_msgs</build_export_depend>
    <exec_depend>roscpp</exec_depend>
    <exec_depend>rospy</exec_depend>
    <exec_depend>std_msgs</exec_depend>

    <export>
        <!-- Other tools can request additional information be placed here -->
    </export>
</package>

CMakeLists.txt

cmake_minimum_required(VERSION 3.11)
project(beginner_tutorials)

find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs)

catkin_package()

include_directories(include ${catkin_INCLUDE_DIRS})

message( "found catkin: ${catkin_FOUND}" ) # shows '1'
message( "roscpp include_dir: ${roscpp_INCLUDE_DIRS}" ) # shows *nothing*

add_executable(listener src/listener.cpp)
target_link_libraries(listener ${catkin_LIBRARIES})

# inspect variables for debugging (=> output: see edit2)
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
    message("${_variableName}=${${_variableName}}")
endforeach()

listener.cpp

#include "ros/ros.h"
#include "std_msgs/String.h"

// This tutorial demonstrates simple receipt of messages over the ROS system.
void chatterCallback(const std_msgs::String::ConstPtr& msg)
{
    ROS_INFO("I heard: [%s]", msg->data.c_str());
}

int main(int argc, char **argv)
{
    ros::init(argc, argv, "listener");
    ros::NodeHandle n;
    ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);
    ros::spin();
    return 0;
}

I seems that catkin_INCLUDE_DIRS and catkin_LIBRARIES are empty in the CMakeLists.txt. What value/path do they normally have? Thank you for any other hint or tip!

PS: I already did catkin clean and even reinstall ROS...out of luck unfortunately.

* edit1: some more info about the error *

Errors     << beginner_tutorials:make /home/me/catkin_ws/logs/beginner_tutorials/build.make.002.log                                  
/home/me/catkin_ws/src/beginner_tutorials/src/listener.cpp:1:10: fatal error: ros/ros.h: No such file or directory
1 | #include "ros/ros.h"
  |          ^~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/listener.dir/build.make:63: CMakeFiles/listener.dir/src/listener.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:305: CMakeFiles/listener.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:141: all] Error 2

* edit2: cmake variables containing "catkin" *

catkin_ALL_FOUND_COMPONENTS=roscpp
catkin_BUILDTOOL_DEPENDS=cmake;python-setuptools;python3-setuptools
catkin_BUILDTOOL_EXPORT_DEPENDS=cmake;python3-setuptools
catkin_BUILD_DEPENDS=python-argparse;python-catkin-pkg;python3-catkin-pkg;python-empy;python3-empy
catkin_BUILD_DEPENDS_python-catkin-pkg_VERSION_GT=0.4.3
catkin_BUILD_DEPENDS_python3-catkin-pkg_VERSION_GT=0.4.3
catkin_BUILD_EXPORT_DEPENDS=google-mock;gtest;python-nose;python3-nose;python-argparse;python-catkin-            
pkg;python3-catkin-pkg;python-empy;python3-empy
catkin_BUILD_EXPORT_DEPENDS_python-catkin-pkg_VERSION_GT=0.4.3
catkin_BUILD_EXPORT_DEPENDS_python3-catkin-pkg_VERSION_GT=0.4.3
catkin_CONFIG=/opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake
catkin_CONSIDERED_CONFIGS=/opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake
catkin_CONSIDERED_VERSIONS=0.8.9
catkin_DEPRECATED=
catkin_DIR=/opt/ros/noetic/share/catkin/cmake
catkin_EXEC_DEPENDS=python-argparse;python-catkin-pkg;python3-catkin-pkg;python-empy;python3-empy
catkin_EXEC_DEPENDS_python-catkin-pkg_VERSION_GT=0.4.3
catkin_EXEC_DEPENDS_python3-catkin-pkg_VERSION_GT=0.4.3
catkin_EXPORTED_TARGETS=_catkin_empty_exported_target
catkin_EXTRAS_DIR=/opt/ros/noetic/share ...
(more)
edit retag flag offensive close merge delete

Comments

I seems that catkin_INCLUDE_DIRS and catkin_LIBRARIES are empty in the CMakeLists.txt.

That would most likely be the cause of your error(s).

What value/path do they normally have?

paths in /opt/ros (and some others).

I would try and figure out why they are empty.

Anything else (ie: setting them manually) would be a brittle work-around.

gvdhoorn gravatar image gvdhoorn  ( 2020-12-24 07:11:31 -0600 )edit

Wow, thank you very much for your quick reply and glad to hear that my guess points in the right direction. Do you have an idea, how I could debug/fix/set these variables?

ticotico gravatar image ticotico  ( 2020-12-24 09:34:09 -0600 )edit

As I already wrote: do not set them manually. Things not working as they normally do is indicative of something which is not right with your setup.

I would suggest to write a minimal CMakeLists.txt which just runs find_package(catkin REQUIRED COMPONENTS roscpp) (for instance) and then prints out the values of the various catkin_* variables.

gvdhoorn gravatar image gvdhoorn  ( 2020-12-28 02:35:29 -0600 )edit

I probably wasn't clear enough: I did not set anything manually yet...I am still in the process of understanding. Above (under "edit2") you find the variables containing catkin_*. This again confirms that both catkin_INCLUDE_DIRS and catkin_LIBRARIES* are empty. You wrote in your first comment that they should be something like /opt/ros...any idea how to fix this?

ticotico gravatar image ticotico  ( 2020-12-28 06:07:41 -0600 )edit

Could it be, that this is somehow related?

ticotico gravatar image ticotico  ( 2021-01-02 12:44:25 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-01-02 14:05:45 -0600

ticotico gravatar image

Solved the issue by another complete removal and re-installation of ROS:

  • sudo apt-get purge ros-*
  • sudo apt-get autoremove
  • deleted catkin_ws
  • deleted .ros-folder in home

Then, reboot and reinstall according to the tutorials. Now all the catkin_*-variables are set and the compilation runs nicely without any errors. Thx for the hints and tips @gvdhoorn, really appreciate it!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-12-23 15:54:54 -0600

Seen: 383 times

Last updated: Jan 02