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

fatal error: 'ros/ros.h' file not found

asked 2021-10-17 23:43:00 -0500

Neil9 gravatar image

updated 2021-10-19 05:57:00 -0500

Mike Scheutzow gravatar image

I have created a package using Qt Creator 4.9.3.But when I edited my header file I got the following tip:

fatal error:'ros/ros.h' file not found.

I have read several answers to similar questions, most of them referred to find package(..) and include_directories(${catkin_INCLUDE_DIRS}).However,I checked my CMakeLists.txt and I didn't see any problem above.So I wonder why this is happening here.I'm using Ubuntu 18.04 with ROS melodic on an X86.

Here is the CMakeLists.txt:

cmake_minimum_required(VERSION 3.0.2)
project(ars408)

## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)


## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()

################################################
## Declare ROS messages, services and actions ##
################################################

## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
##   your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
##   * add a build_depend tag for "message_generation"
##   * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
##   * If MSG_DEP_SET isn't empty the following dependency has been pulled in
##     but can be declared for certainty nonetheless:
##     * add a exec_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
##   * add "message_generation" and every package in MSG_DEP_SET to
##     find_package(catkin REQUIRED COMPONENTS ...)
##   * add "message_runtime" and every package in MSG_DEP_SET to
##     catkin_package(CATKIN_DEPENDS ...)
##   * uncomment the add_*_files sections below as needed
##     and list every .msg/.srv/.action file to be processed
##   * uncomment the generate_messages entry below
##   * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)

## Generate messages in the 'msg' folder
# add_message_files(
#   FILES
#   Message1.msg
#   Message2.msg
# )

## Generate services in the 'srv' folder
# add_service_files(
#   FILES
#   Service1.srv
#   Service2.srv
# )

## Generate actions in the 'action' folder
# add_action_files(
#   FILES
#   Action1.action
#   Action2.action
# )

## Generate added messages and services with any dependencies listed here
# generate_messages(
#   DEPENDENCIES
#   roscpp std_msgs
# )

################################################
## Declare ROS dynamic reconfigure parameters ##
################################################

## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
##   * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
##   * add "dynamic_reconfigure" to
##     find_package(catkin REQUIRED COMPONENTS ...)
##   * uncomment the "generate_dynamic_reconfigure_options" section below
##     and list every .cfg file to be processed

## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
#   cfg/DynReconf1.cfg
#   cfg/DynReconf2.cfg
# )

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS ...
(more)
edit retag flag offensive close merge delete

Comments

Actually,I'm using Qt Creator 4.9.2 instead of 4.9.3.

Neil9 gravatar image Neil9  ( 2021-10-18 22:00:58 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-10-18 14:41:31 -0500

Mike Scheutzow gravatar image

updated 2021-10-19 15:21:36 -0500

Have you done a source /opt/ros/melodic/setup.bash? This must be done every time you open a command line window if you do not add it to your .bashrc.

Update: if you put qt_creator into the search box at the top of this page, you will get a lot of hits. #q336242 in particular looks helpful for your problem, but that answer assumes you will use catkin build, not catkin_make.

edit flag offensive delete link more

Comments

I'm using Qt Creator instead of command line window.But I think I have done that because I got this tip:

[ROS Debug]Sourced workspace:/home/ubuntu/Radar/devel/setup.bash
Neil9 gravatar image Neil9  ( 2021-10-18 22:06:09 -0500 )edit

Sorry, I don't know how to configure that tool. I assume you understand that this is catkin_make project, not a cmake project.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-10-19 05:54:39 -0500 )edit

Sorry for replying to you so late.I check my .bashrc and make sure that I have add source /opt/ros/melodic/setup.bash to it.But it doesn't work for my problem.I really appreciate for your advice and I do learn something from that,even though I still can't fix the problem.I will keep trying and update if I figure it out.

Neil9 gravatar image Neil9  ( 2021-10-24 03:31:53 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-10-17 23:43:00 -0500

Seen: 300 times

Last updated: Oct 19 '21