0
$\begingroup$

Rosanswers logo

Hi everyone,

I'm facing an error when trying to build the tutorial on the pluginlib.
I updated my CMakeLists.txt, package.xml and created a polygon_loader.xml as described in the tutorial, but when I try to build the project, it fails stating that in [my_workspace]/pluginlib_tutorials_/src/polygon_loader.cpp the included header file pluginlib_tutorials_/polygon_base.h could not be found.

The funny thing is, if I change my CMakeLists.txt by adding the line

 target_link_libraries(polygon_loader polygon_plugins)  

my polygon_loader.cpp is fine, but my polygon_plugins.cpp throws the previous mentioned error. It seems I missed some configuring in the ROS toolchain I guess. Could please someone help me out?

Thanks in advance,
Roberto

P.S.: Here are the relevant fragments, if something is missing, please ask!

My file structure:

catkin_ws_plugins/
-> build
-> devel
-> src
--> CMakeList.txt
--> pluginlib_tutorials_
---> CMakeLists.txt
---> package.xml
---> polygon_plugins.xml
---> include
----> pluginlib_tutorials_
-----> polygon_base.h
-----> polygon_plugins.h
---> src
-----> polygon_loader.cpp
-----> polygon_plugins.cpp

catkin_ws_plugins/src/pluginlib_tutorials_/CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(pluginlib_tutorials_)
find_package(catkin REQUIRED COMPONENTS
    pluginlib
    roscpp
)
catkin_package()
include_directories(
    ${catkin_INCLUDE_DIRS}
)
add_library(polygon_plugins src/polygon_plugins.cpp)
add_executable(polygon_loader src/polygon_loader.cpp)
target_link_libraries(polygon_loader ${catkin_LIBRARIES})  

catkin_ws_plugins/src/pluginlib_tutorials_/package.xml (only the changes):

<export>
    <pluginlib_tutorials_ plugin="${prefix}/polygon_plugins.xml" />
</export>

catkin_ws_plugins/src/pluginlib_tutorials_/polygon_plugins.xml:

<library path="lib/libpolygon_plugins">
    <class type="polygon_plugins::Triangle" base_class_type="polygon_base::RegularPolygon">
         <description>This is a triangle plugin</description>
    </class>
    <class type="polygon_plugins::Square" base_class_type="polygon_base::RegularPolygon">
         <description>This is a square plugin</description>
    </class>
</library>

Last but not least the line where the error occurs in
catkin_ws_plugins/src/pluginlib_tutorials_/src/polygon_loader.cpp

#include <pluginlib_tutorials_/polygon_base.h>

Originally posted by bnm-rc on ROS Answers with karma: 22 on 2014-02-17

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You need to add your local include directory to the include_directories in your CMakeLists.txt

It shold look more like:

include_directories(
    include
    ${catkin_INCLUDE_DIRS}
)

Originally posted by tfoote with karma: 58457 on 2015-03-03

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.