Embeding KDL within Gazebo plugin

For controlling a 6-d.f. robotic arm I need to make the inverse kinematics maths within a plugin. I installed KDL and Eigen2 and 3 but at runtime (I used an example source code taken from KDL org) I get an error message like, symbol not found -random letters-chain-random letters-. Questions: what kinematics library, most compatible with Gazebo’s plugins, should I use? How to install/link the kinematics library with Gazebo’s plugins?

Sounds like you have a linking error. You should be able to use KDL with Gazebo. Chances are you just need to include the correct libraries in your CMake or Makefile.

Hi @chris-mt (sorry for the late, i will answer for who could met the same problem), if u mean a message in the bash like this:
gzserver: symbol lookup error: /home/alessandro/ros_ws/devel/lib/libplugin_control_iiwa.so: undefined symbol: _ZN3KDL4TreeC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

To be clear, I want to implement a gazebo plugin using ros, the file .cpp in ros use the KDL libraries.

How I fixed it

I fixed it with modifying the CMakeList that compile the plugin the command, in particular adding **{catkin_LIBRARIES}** to the istruction **target_link_libraries**. So I changed: `target_link_libraries(plugin_ros_gazebo {GAZEBO_LIBRARIES} ${Boost_LIBRARIES})`

to:

target_link_libraries(plugin_ros_gazebo ${GAZEBO_LIBRARIES} ${Boost_LIBRARIES} ${catkin_LIBRARIES})

Where plugin_ros_gazebo is the name of the executable .cpp that defines the plugin.

I think that is caused by the dependencies of KDL to Eigen, and Eigen is in catkin_LIBRARIES (but is just a hypothesis).

To be more accurate I past all my CMakeList.txt:

cmake_minimum_required(VERSION 2.8.3)
project(gazebo_plugin_iiwa)

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
    set(CMAKE_CXX_FLAGS "-std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
    set(CMAKE_CXX_FLAGS "-std=c++0x")
else()
    message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()

find_package(catkin REQUIRED COMPONENTS 
  roscpp 
  gazebo_ros 
  

  geometry_msgs
  kdl_parser
  sensor_msgs
)



find_package(gazebo REQUIRED)

link_directories(${GAZEBO_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIR} ${catkin_INCLUDE_DIRS} ${GAZEBO_INCLUDE_DIRS})

catkin_package(
  DEPENDS 
    roscpp 
    gazebo_ros

)


include (FindPkgConfig)
if (PKG_CONFIG_FOUND)
	pkg_check_modules(GAZEBO gazebo)
endif()

include_directories(${GAZEBO_INCLUDE_DIRS})
link_directories(${GAZEBO_LIBRARY_DIRS})
add_library(plugin_control_iiwa SHARED src/control.cpp)
target_link_libraries(plugin_control_iiwa ${GAZEBO_LIBRARIES} ${Boost_LIBRARIES} ${catkin_LIBRARIES})