ethz-asl / rotors_simulator

RotorS is a UAV gazebo simulator
1.26k stars 765 forks source link

include generated headers form external package #607

Open BeatScherrer opened 4 years ago

BeatScherrer commented 4 years ago

My goal is to create a gazebo lidar which publishes its transform to ROS. Therefore I created a package which depends on rotors_simulator_plugin to make use of your ROS interface plugin which takes care of the conversion.

I created a plugin for the lidar which is supposed to publish gazebo transforms (and get converted to ROS tf)

Therefore I included the TransformStamped.ph.h header in my plugin implementation:

#include <rotors_gazebo_plugins/TransformStamped.pb.h>

It seems I cannot get access to your generated pb.h files and printing the include_directories of the rotors_gazebo_plugins does not include the location of the generated files.

output of the rotors_gazebo_plugins_INCLUDE_DIRS

/home/beat/catkin_ws/src/rotors_simulator/rotors_gazebo_plugins/include/usr/include/eigen3/usr/include/gazebo-9/gazebo/msgs/usr/include/usr/include/opencv/opt/ros/melodic/include/home/beat/catkin_ws/devel/.private/mav_msgs/include/home/beat/catkin_ws/src/mav_comm/mav_msgs/include/opt/ros/melodic/share/xmlrpcpp/cmake/../../../include/xmlrpcpp/home/beat/catkin_ws/src/pcl_catkin/geometry2/tf2_ros/include/home/beat/catkin_ws/src/pcl_catkin/geometry2/tf2/include/home/beat/catkin_ws/devel/.private/tf2_msgs/include/home/beat/catkin_ws/src/pcl_catkin/geometry2/tf2_msgs/include/home/beat/catkin_ws/devel/.private/rotors_comm/include/home/beat/catkin_ws/src/rotors_simulator/rotors_control/include

The cmake file of my package looks as follows:

cmake_minimum_required(VERSION 2.8.3)
project(heap_gazebo_plugins)

add_definitions(-std=c++17)

# Gazebo
find_package(gazebo_dev QUIET)
if (NOT GAZEBO_DEV_FOUND)
  find_package(gazebo REQUIRED)
endif()

include_directories(${GAZEBO_INCLUDE_DIRS})
link_directories(${GAZEBO_LIBRARY_DIRS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GAZEBO_CXX_FLAGS}")

# Catkin
find_package(catkin REQUIRED COMPONENTS
  rotors_gazebo_plugins
)

catkin_package(
  INCLUDE_DIRS
    include
  LIBRARIES
    hokuyo_lidar_model_plugin
  CATKIN_DEPENDS
    rotors_gazebo_plugins
  DEPENDS
    gazebo
)

# Debug the rotors_gazebo_plugins include directories
#message(FATAL_ERROR ${rotors_gazebo_plugins_INCLUDE_DIRS})

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${GAZEBO_INCLUDE_DIRS}
)

# Build our plugin
add_library(hokuyo_lidar_model_plugin SHARED src/hokuyo_lidar_model_plugin.cc)
target_link_libraries(hokuyo_lidar_model_plugin ${GAZEBO_LIBRARIES})

Am I missing something or is it intentional that the headers are not exposed?

BeatScherrer commented 4 years ago

The PROTOBUF_GENERATE_CPP macro gives a list of the headers and sources. maybe there is a way to get the directory and add it to the catkin_package(INCLUDE_DIRS). GAZEBO_MSG_INCLUDE_DIRS would also need to be added in this case.