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

nodelets problem

asked 2019-09-24 00:36:21 -0500

listenreality gravatar image

Hi. I'm trying to create a custom pgk with nodelets. I read already manual http://wiki.ros.org/nodelet/Tutorials... And for more understanding I use the pkg: https://github.com/tysik/obstacle_det... And I got error

[ERROR] [1569303210.735895568]:Loader::load Failed to load nodelet [/test_nodelet1] of type [safety_zones/TestNodelet1] even after refreshing the cache: MultiLibraryClassLoader: Could not create object of class type safety_zones::TestNodelet1Nodelet as no factory exists for it. Make sure that the library exists and was explicitly loaded through MultiLibraryClassLoader::loadLibrary()
[ERROR] [1569303210.735951283]:Loader::load The error before refreshing the cache was: MultiLibraryClassLoader: Could not create object of class type safety_zones::TestNodelet1Nodelet as no factory exists for it. Make sure that the library exists and was explicitly loaded through MultiLibraryClassLoader::loadLibrary()

Any help, please. Thank you!

CMakeList.txt

cmake_minimum_required(VERSION 2.8.3)
project(safety_zones)

## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

## 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
  roslaunch
  sensor_msgs
  std_msgs
  std_srvs
  pluginlib
  nodelet
)


###################################
## 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 your 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 include
  LIBRARIES test_nodelet1 test_nodelet2 ${PROJECT_NAME}_nodelets
  CATKIN_DEPENDS
    roscpp
    roslaunch
    sensor_msgs
    std_msgs
    std_srvs
    pluginlib
    nodelet
#  DEPENDS system_lib
)

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

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
 include
  ${catkin_INCLUDE_DIRS}
)

## Declare a C++ library

add_library(test_nodelet1 src/test_nodelet1.cpp)
target_link_libraries(test_nodelet1 ${catkin_LIBRARIES})
add_dependencies(test_nodelet1 ${catkin_EXPORTED_TARGETS})

add_library(test_nodelet2 src/test_nodelet2.cpp)
target_link_libraries(test_nodelet2 ${catkin_LIBRARIES})
add_dependencies(test_nodelet2 ${catkin_EXPORTED_TARGETS})

#
# Build nodes
#

add_executable(test_nodelet1_node src/nodes/test_nodelet1_node.cpp)
target_link_libraries(test_nodelet1_node test_nodelet1)

add_executable(test_nodelet2_node src/nodes/test_nodelet2_node.cpp)
target_link_libraries(test_nodelet2_node test_nodelet2)

#
# Build nodelets
#
add_library(${PROJECT_NAME}_nodelets
  src/nodelets/test_nodelet1_nodelet.cpp
  src/nodelets/test_nodelet2_nodelet.cpp)
target_link_libraries(${PROJECT_NAME}_nodelets test_nodelet1 test_nodelet2)


#
# Install libraries
#
install(TARGETS test_nodelet1 test_nodelet2 ${PROJECT_NAME}_nodelets 
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION})


#
# Install nodes
#
install(TARGETS test_nodelet1_node test_nodelet2_node
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})


#
# Install header files
#
install(DIRECTORY include/${PROJECT_NAME}/
  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})


#
# Install nodelet #and rviz plugins description
#
install(FILES nodelet_plugins.xml
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

package.xml

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

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

  <license>TODO</license>
   <buildtool_depend>catkin</buildtool_depend>

  <build_depend>roscpp</build_depend>
  <build_depend>roslaunch</build_depend>
  <build_depend>sensor_msgs</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>std_srvs</build_depend>
  <build_export_depend>roscpp</build_export_depend>
  <build_export_depend>roslaunch</build_export_depend>
  <build_export_depend>sensor_msgs</build_export_depend>
  <build_export_depend>std_msgs</build_export_depend>
  <build_export_depend>std_srvs</build_export_depend>
  <exec_depend>roscpp</exec_depend>
  <exec_depend>roslaunch</exec_depend>
  <exec_depend>sensor_msgs</exec_depend>
  <exec_depend>std_msgs</exec_depend>
  <exec_depend>std_srvs</exec_depend>
  <exec_depend>pluginlib</exec_depend>
  <build_depend>pluginlib</build_depend>
  <build_depend>nodelet</build_depend>
  <exec_depend>nodelet</exec_depend>

  <!-- The export ...
(more)
edit retag flag offensive close merge delete

Comments

I would first check whether things work without forcing C++17 in your own package.

Plugin loading works by being able to introspection and by assuming certain functions/methods exist in your .so. But that requires ABI between the host and the library.

ROS Melodic is not compiled with C++17 enabled, so it may be that by forcing it in your nodelet, you're breaking ABI causing the plugin loader unable to load (or: find) your nodelet.

Everything could be fine ABI-wise, but it's easy to check and if it is the cause, prevents us from checking all sorts of other things.

gvdhoorn gravatar image gvdhoorn  ( 2019-09-24 02:29:18 -0500 )edit

@gvdhoorn so, I changed it to C++11, and still got the error

listenreality gravatar image listenreality  ( 2019-09-24 02:59:05 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-09-24 02:34:03 -0500

Delb gravatar image

<library path="lib/libsafety_zones">

Are you sure about this ? In your CMakeList you declare the library with add_library(${PROJECT_NAME}_nodelets so you should change libsafety_zones for libsafety_zones_nodelets or remove the _nodelets within the CMakeList.

edit flag offensive delete link more

Comments

Ah, @Delb's comment is probably the answer here.

I would still be careful with forcing C++17 in a package that basically requires ABI compatibility with the host that is going to load it, but not listing the correct library name is going to be an even bigger problem.

gvdhoorn gravatar image gvdhoorn  ( 2019-09-24 02:38:46 -0500 )edit

@Delb Thanks, that helped!

listenreality gravatar image listenreality  ( 2019-09-24 03:00:21 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-09-24 00:36:21 -0500

Seen: 1,446 times

Last updated: Sep 24 '19