ros/ros.h: No such file or directory

asked 2021-10-12 01:05:49 -0600

Benjaminong gravatar image

Hello, I was following this page on instructions for orbslam https://github.com/snakehaihai/Tello_... . When I got to the part where I compile the code for orbslam (installing orbslam2) I get the following

Errors     << orb_slam2_ros:make /home/asd/ROS/Tello_ROS_ORBSLAM/ROS/tello_catkin_ws/logs/orb_slam2_ros/build.make.000.log           
In file included from /home/asd/ROS/Tello_ROS_ORBSLAM/ROS/tello_catkin_ws/src/orb_slam_2_ros/ros/src/StereoNode.cc:1:0:
/home/asd/ROS/Tello_ROS_ORBSLAM/ROS/tello_catkin_ws/src/orb_slam_2_ros/ros/include/StereoNode.h:8:10: fatal error: ros/ros.h: No such file or directory
 #include <ros/ros.h>
          ^~~~~~~~~~~
compilation terminated.

I tried applying many of the solutions I found online but I still cant solve it. Any help will be appreciated.

CmakeList.txt

    cmake_minimum_required(VERSION 2.8.3)
    project(orb_slam2_ros)

    IF(NOT CMAKE_BUILD_TYPE)
      SET(CMAKE_BUILD_TYPE Release)
    ENDIF()

    # Check for c++11 support
    INCLUDE(CheckCXXCompilerFlag)
    CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
    CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X

    )
    IF(COMPILER_SUPPORTS_CXX11)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
       add_definitions(-DCOMPILEDWITHC11)
       message(STATUS "Using flag -std=c++11.")
    elseif(COMPILER_SUPPORTS_CXX0X)
       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
       add_definitions(-DCOMPILEDWITHC0X)
       message(STATUS "Using flag -std=c++0x.")
    ELSE()
      MESSAGE(ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ 

    compiler.")
    ENDIF()

    LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/orb_slam2/cmake_modules)

    #find_package (catkin REQUIRED COMPONENTS
    #roscpp
    #rospy
    #std_msgs
    #cv_bridge
    #image_transport

    #tf
    #sensor_msgs
    #dynamic_reconfigure
    #message_generation
    #)

    #find_package(OpenCV 3.0 QUIET)
    #if(NOT OpenCV_FOUND)
    #   find_package(OpenCV 2.4.3 QUIET)
    #   if(NOT OpenCV_FOUND)
    #      message(FATAL_ERROR "OpenCV > 2.4.3 not found.")
    #   endif()
    #endif()


find_package(Pangolin REQUIRED)
find_package(Eigen3 3.1.0 REQUIRED)



    set (DYNAMIC_RECONFIGURE_PATH ros/config/dynamic_reconfigure.cfg)
    execute_process(COMMAND chmod a+x ${DYNAMIC_RECONFIGURE_PATH}
            WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
            RESULT_VARIABLE cmd_result
            OUTPUT_VARIABLE cmd_ver)

    message(STATUS "Chmod a+x the dynamic_reconfigure file")

    #generate_dynamic_reconfigure_options(
    #        ${DYNAMIC_RECONFIGURE_PATH}
    #)

    set(LIBS_ORBSLAM
    ${OpenCV_LIBS}

    ${EIGEN3_LIBS}
    ${PROJECT_SOURCE_DIR}/orb_slam2/Thirdparty/DBoW2/lib/libDBoW2.so
    ${PROJECT_SOURCE_DIR}/orb_slam2/Thirdparty/g2o/lib/libg2o.so
    )

    set(LIBS_ROS
    ${PROJECT_SOURCE_DIR}/orb_slam2/lib/lib${PROJECT_NAME}.so

    ${OpenCV_LIBS}
    ${catkin_LIBRARIES}
    )

    #add_service_files(
    #        FILES
    #        SaveMap.srv
    #)

    #generate_messages(

    #        DEPENDENCIES
    #        std_msgs
    #)

    #catkin_package (
    #  INCLUDE_DIRS include CATKIN_DEPENDS roscpp rospy std_msgs cv_bridge image_transport tf sensor_msgs dynamic_reconfigure message_runtime
    #  LIBRARIES {PROJECT_NAME} libDBoW2 libg2o
    #)

    include_directories(

    include ${catkin_INCLUDE_DIRS}
    include ${PROJECT_SOURCE_DIR}/orb_slam2
    include ${PROJECT_SOURCE_DIR}/orb_slam2/include
    include ${PROJECT_SOURCE_DIR}/ros/include
    include ${EIGEN3_INCLUDE_DIR}
    include ${Pangolin_INCLUDE_DIRS}

    )

    include(${PROJECT_SOURCE_DIR}/orb_slam2/Thirdparty/DBoW2/CMakeLists.txt)
    include(${PROJECT_SOURCE_DIR}/orb_slam2/Thirdparty/g2o/CMakeLists.txt)

    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/orb_slam2/lib)

    add_library(${PROJECT_NAME} SHARED
    orb_slam2/src/System.cc
    orb_slam2/src/Tracking.cc
    orb_slam2/src/LocalMapping.cc
    orb_slam2/src/LoopClosing.cc
    orb_slam2/src/ORBextractor.cc
    orb_slam2/src/ORBmatcher.cc
    orb_slam2/src/FrameDrawer.cc

    orb_slam2/src/Converter.cc
    orb_slam2/src/MapPoint.cc
    orb_slam2/src/KeyFrame.cc
    orb_slam2/src/Map.cc
    orb_slam2/src/MapDrawer.cc
    orb_slam2/src/Optimizer.cc
    orb_slam2/src/PnPsolver.cc
    orb_slam2/src/Frame.cc
    orb_slam2/src/KeyFrameDatabase.cc
    orb_slam2/src/Sim3Solver.cc
    orb_slam2/src/Initializer.cc
    orb_slam2/src/Viewer.cc

    )
    add_dependencies (${PROJECT_NAME} g2o DBoW2)

    target_link_libraries(${PROJECT_NAME}
    ${LIBS_ORBSLAM}
    ${Pangolin_LIBRARIES}
    )

    # map serialization addition - library boost serialization 
    message(STATUS "Compile With map save/load function")
    find_library(BOOST_SERIALIZATION boost_serialization)
    if (NOT BOOST_SERIALIZATION)
        message(FATAL_ERROR "Can't find libboost_serialization")
    endif()
    target_link_libraries(${PROJECT_NAME} ${BOOST_SERIALIZATION})

    add_executable (${PROJECT_NAME}_mono
    ros/src/MonoNode ...
(more)
edit retag flag offensive close merge delete

Comments

Hi @Benjaminong reading the repo. Since you are using Melodic, are you using CMakeLists_melodic.txt? ,

First - if using Melodic version of ROS, change the ~/ROS/Tello_ROS_ORBSLAM/ROS/tello_catkin_ws/src/orb_slam_2_ros/CMakeLists.txt To the CMakeLists_melodic.txt
osilva gravatar image osilva  ( 2021-10-12 09:04:46 -0600 )edit

Yes at first glance melodic version requires that you uncomment find_package() section.

osilva gravatar image osilva  ( 2021-10-12 09:13:28 -0600 )edit