another "fatal error: ros/ros.h: No such file or directory"
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 ...
That would most likely be the cause of your error(s).
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.
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?
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 runsfind_package(catkin REQUIRED COMPONENTS roscpp)
(for instance) and then prints out the values of the variouscatkin_*
variables.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 bothcatkin_INCLUDE_DIRS
andcatkin_LIBRARIES*
are empty. You wrote in your first comment that they should be something like/opt/ros
...any idea how to fix this?Could it be, that this is somehow related?