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

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

asked 2018-02-25 09:10:37 -0500

FrankFacundo gravatar image

I have created a package using catkin_create_pkg on my raspberry pi 3 where I have previously installed Ubuntu Xenial and ROS kinetic. I'm trying to use a Pixy Camera in ROS with this code pixy_ros ,but everytime I am trying to compile (doing catkin_make) the cpp with file included in the created package I get the following error:

[ 78%] Building CXX object pixy_node/CMakeFiles/pixy_node.dir/src/pixy_node.cpp.o
[ 98%] Built target duckietown_msgs_generate_messages_py
[ 98%] Built target pixy_msgs_generate_messages
/home/cachanmtp/robot_ws/src/pixy_node/src/pixy_node.cpp:21:21: fatal error: ros/ros.h: No such file or directory compilation terminated.
[ 98%] Built target duckietown_msgs_generate_messages
pixy_node/CMakeFiles/pixy_node.dir/build.make:62: recipe for target 'pixy_node/CMakeFiles/pixy_node.dir/src/pixy_node.cpp.o' failed
make[2]: *** [pixy_node/CMakeFiles/pixy_node.dir/src/pixy_node.cpp.o] Error 1
CMakeFiles/Makefile2:4547: recipe for target 'pixy_node/CMakeFiles/pixy_node.dir/all' failed
make[1]: *** [pixy_node/CMakeFiles/pixy_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

In my CMakeLists.txt file, I have the following:

cmake_minimum_required(VERSION 2.8.3)
project(pixy_node)

## 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 sensor_msgs message_generation roscpp tf rospy)

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


## 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()

add_subdirectory(libpixyusb)
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libpixyusb_SOURCE_DIR}/cmake" )
find_package ( libusb-1.0 REQUIRED )


###################################
## 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 you 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: system dependencies of this project that dependent projects also need
catkin_package(
  INCLUDE_DIRS libpixyusb/include libpixyusb/common
  LIBRARIES pixyusb
#  CATKIN_DEPENDS other_catkin_pkg
#  DEPENDS system_lib

)

###########
## Build ##
###########

## Specify additional locations of header files

## Your package locations should be listed before other locations
include_directories(include libpixyusb/include libpixyusb/common  ${LIBUSB_1_INCLUDE_DIRS})

## Declare a cpp library
# add_library(pixy_ros
#   src/${PROJECT_NAME}/pixy_ros.cpp
# )

## Declare a cpp executable
add_executable(pixy_node src/pixy_node.cpp)

## Add cmake target dependencies of the executable/library

## as an example, message headers may need to be generated before nodes
add_dependencies(pixy_node pixy_msgs_generate_messages_cpp)

## Specify libraries to link a library or executable target against
target_link_libraries(pixy_node
  ${catkin_LIBRARIES}
  pixyusb
  ${Boost_LIBRARIES}
  ${LIBUSB_1_LIBRARY}
  )

And in my package.xml I have

<?xml version="1.0"?>
<package>
  <name>pixy_node</name>
  <version>1.0.0</version>
  <description>The pixy_node package</description>

  <maintainer email="justin.eskesen@gmail.com">Justin Eskesen</maintainer>

  <license>GPLv2</license>

  <author email="justin.eskesen@gmail.com">Justin Eskesen</author>

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>libusb-1.0-0-dev</build_depend>
  <build_depend>pixy_msgs</build_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>libusb-1.0-0</run_depend>
  <run_depend>pixy_msgs</run_depend>

  <export>

  </export>
</package>
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-02-25 09:29:39 -0500

Wolf gravatar image

You missed adding ${catkin_INCLUDE_DIRS} to the include_directories, i.e. change

include_directories(include libpixyusb/include libpixyusb/common  ${LIBUSB_1_INCLUDE_DIRS})

for

include_directories(include libpixyusb/include libpixyusb/common  ${LIBUSB_1_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-02-25 09:10:37 -0500

Seen: 1,692 times

Last updated: Feb 25 '18