Ask Your Question
0

no such file or directory ros/ros.h

asked 2021-08-31 09:14:41 -0600

cyberoverlord gravatar image

updated 2021-09-16 14:17:05 -0600

Mike Scheutzow gravatar image

In my file I have included #include "ros/ros.h" it says no such file or directory. I am using VS Code, ROS noetic on Ubuntu 20.04 LTS.

Here is my package.xml:

<?xml version="1.0"?>
<package format="2">
  <name>beginner_tutorials</name>
  <version>0.0.0</version>
  <description>The beginner_tutorials package</description>

  <!-- One maintainer tag required, multiple allowed, one person per tag -->
  <!-- Example:  -->
  <!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
  <maintainer email="harry@todo.todo">harry</maintainer>


  <!-- One license tag required, multiple allowed, one license per tag -->
  <!-- Commonly used license strings: -->
  <!--   BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
  <license>TODO</license>


  <!-- Url tags are optional, but multiple are allowed, one per tag -->
  <!-- Optional attribute type can be: website, bugtracker, or repository -->
  <!-- Example: -->
  <!-- <url type="website">http://wiki.ros.org/beginner_tutorials</url> -->


  <!-- Author tags are optional, multiple are allowed, one per tag -->
  <!-- Authors do not have to be maintainers, but could be -->
  <!-- Example: -->
  <!-- <author email="jane.doe@example.com">Jane Doe</author> -->


  <!-- The *depend tags are used to specify dependencies -->
  <!-- Dependencies can be catkin packages or system dependencies -->
  <!-- Examples: -->
  <!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
  <!--   <depend>roscpp</depend> -->
  <!--   Note that this is equivalent to the following: -->
  <!--   <build_depend>roscpp</build_depend> -->
  <!--   <exec_depend>roscpp</exec_depend> -->
  <!-- Use build_depend for packages you need at compile time: -->
  <!--   <build_depend>message_generation</build_depend> -->
  <!-- Use build_export_depend for packages you need in order to build against this package: -->
  <!--   <build_export_depend>message_generation</build_export_depend> -->
  <!-- Use buildtool_depend for build tool packages: -->
  <!--   <buildtool_depend>catkin</buildtool_depend> -->
  <!-- Use exec_depend for packages you need at runtime: -->
  <!--   <exec_depend>message_runtime</exec_depend> -->
  <!-- Use test_depend for packages you need only for testing: -->
  <!--   <test_depend>gtest</test_depend> -->
  <!-- Use doc_depend for packages you need only for building documentation: -->
  <!--   <doc_depend>doxygen</doc_depend> -->
  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>message_generation</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>
  <exec_depend>message_runtime</exec_depend>


  <!-- The export tag contains other, unspecified, tags -->
  <export>
    <!-- Other tools can request additional information be placed here -->

  </export>
</package>

Here is my CMakeLists.txt

cmake_minimum_required(VERSION 3.0.2)
project(beginner_tutorials)

## 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
  rospy
  std_msgs
  message_generation
)

## 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 ...
(more)
edit retag flag offensive close merge delete

Comments

Are you having trouble finding ros/ros.h, or are you talking about VS Code? Or are you talking about the build?

miura gravatar image miura  ( 2021-08-31 18:25:19 -0600 )edit

I’m having trouble finding ros/ros.h

cyberoverlord gravatar image cyberoverlord  ( 2021-09-01 03:56:28 -0600 )edit

You are getting an error message in the code editor(VS Code, Atom, Eclipse, Pycharm) or in your terminal(when you run code).

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2021-09-01 04:49:59 -0600 )edit

Hello @cyberoverlord,

If you are having issues in Ide (Code editor) then look at this #382798

and if you are having issues while running your code then you have to add this code to your CMakeLists.txt

look over here, https://answers.ros.org/question/2374...

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2021-09-01 05:03:17 -0600 )edit

I am still getting no such file or directory

cyberoverlord gravatar image cyberoverlord  ( 2021-09-01 06:47:37 -0600 )edit

You are talking about setting.json in VS code?

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2021-09-01 06:49:18 -0600 )edit
1

No, I think it’s the CMakeLists.txt file

cyberoverlord gravatar image cyberoverlord  ( 2021-09-01 07:06:48 -0600 )edit

find_package(catkin REQUIRED)

include_directories(${catkin_INCLUDE_DIRS})

find_package(catkin REQUIRED COMPONENTS 
  ...
)

Just copy and past in your CMakeLists file. I think it will work.

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2021-09-01 07:31:10 -0600 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2021-09-01 10:27:22 -0600

Ranjit Kathiriya gravatar image

updated 2021-09-16 01:36:09 -0600

find_package(catkin REQUIRED)

include_directories(${catkin_INCLUDE_DIRS})

find_package(catkin REQUIRED COMPONENTS 
  ...
)

Can you please! have a look at your project directory. If it is include/<project-name> then you have to add this.

edit flag offensive delete link more
0

answered 2021-09-01 05:43:29 -0600

GeorgNo gravatar image

Since you are using VS Code, try this extension: ms-iot.vscode-ros After installing make sure to start VS Code using the terminal from your sourced ROS Workspace

edit flag offensive delete link more

Comments

I am still getting no such file or directory

cyberoverlord gravatar image cyberoverlord  ( 2021-09-01 06:49:57 -0600 )edit

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2021-08-31 09:14:41 -0600

Seen: 68 times

Last updated: Sep 16