Inherit from nodelet

asked 2019-07-27 05:45:00 -0500

Gil404 gravatar image

updated 2022-01-22 16:16:21 -0500

Evgeny gravatar image

Hi Guys,

I would like create my own base nodelet that inherits from nodelet::Nodlet. Is that even possible?

I have tried to do the follwing:

I have MyNodelet:

#include "ros/ros.h"
#include <boost/thread.hpp>
#include <nodelet/nodelet.h>

namespace my_commons
{
class MyNodelet : public nodelet::Nodelet
{
  private:
  protected:
    ros::Publisher mHeartBeatPublisher;
    boost::shared_ptr<boost::thread> mHeartBeatThread; /**< thread to publish is alive msgs  */
    void publishHearBeat();

  public:
    MyNodelet();
    ~MyNodelet();
};
}

I exported this class and my CMakeLists looks like this:

cmake_minimum_required(VERSION 2.8.3)
project(my_commons)
set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")


find_package(catkin REQUIRED COMPONENTS
roscpp
)

catkin_package(CATKIN_DEPENDS tf
               INCLUDE_DIRS include)


include_directories(
  ${catkin_INCLUDE_DIRS}
   include/
)
###########
## Build ##
###########

add_library(my_commons SHARED
src/MyNodelet.cpp
src/Utils.cpp
)

set_target_properties(my_commons PROPERTIES LINKER_LANGUAGE CXX)

target_link_libraries(my_commons
                        ${catkin_LIBRARIES}
                        ${roscpp_LIBRARIES}
)


install(DIRECTORY include/
  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
  FILES_MATCHING PATTERN "*.hpp"
  PATTERN ".svn" EXCLUDE)


# Install library
install(TARGETS my_commons
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

In my project called MyManager I am trying to inherit from MyNodelet like this:

class IndoorMissionManagerNodelet : public indoor_commons::IndoorNodelet
{
  public:
private:
.
.
.
}

But getting the following error:

[ERROR] [1564223743.672241000]: **Failed to load nodelet [/my_manager] of type [my_manager/MyManagerNodelet] even after refreshing the cache: According to the loaded plugin descriptions the class indoor_mission_manager/IndoorMissionManagerNodelet with base class type nodelet::Nodelet does not exist**. Declared types are  SlamGMappingNodelet adding_images/adding_images camshift/camshift contour_moments/contour_moments convex_hull/convex_hull corner_harris/corner_harris depth_image_proc/convert_metric depth_image_proc/crop_foremost depth_image_proc/disparity depth_image_proc/point_cloud_xyz depth_image_proc/point_cloud_xyz_radial depth_image_proc/point_cloud_xyzi depth_image_proc/point_cloud_xyzi_radial depth_image_proc/point_cloud_xyzrgb depth_image_proc/register discrete_fourier_transform/discrete_fourier_transform edge_detection/edge_detection face_detection/face_detection face_recognition/face_recognition fback_flow/fback_flow find_contours/find_contours general_contours/general_contours goodfeature_track/goodfeature_track hls_color_filter/hls_color_filter hough_circles/hough_circles hough_lines/hough_lines hsv_color_filter/hsv_color_filter image_proc/crop_decimate image_proc/crop_nonZero image_proc/crop_non_zero image_proc/debayer image_proc/rectify image_proc/resize image_publisher/image_publisher image_rotate/image_rotate image_view/disparity image_view/image indoor_anomaly_detector/IndoorAnomalyDetectorNodelet indoor_device_manager/IndoorDeviceManager indoor_drone_detector/LedDroneDetectorNodelet indoor_energy_manager/IndoorEnergyManager indoor_global_planner/IndoorGlobalPlannerNodelet indoor_local_planner/IndoorLocalPlannerNodelet indoor_log_manager/IndoorLogManagerNodelet indoor_logger/IndoorLoggerNodelet indoor_nodelet_balancer/IndoorNodeletBalancer indoor_video_manager/IndoorVideoManagerNodelet lk_flow/lk_flow nodelet_tutorial_math/Plus opencv_apps/adding_images opencv_apps/camshift opencv_apps/contour_moments opencv_apps/convex_hull opencv_apps/corner_harris opencv_apps/discrete_fourier_transform opencv_apps/edge_detection opencv_apps/face_detection opencv_apps/face_recognition opencv_apps/fback_flow opencv_apps/find_contours opencv_apps/general_contours opencv_apps/goodfeature_track opencv_apps/hls_color_filter opencv_apps/hough_circles opencv_apps/hough_lines opencv_apps/hsv_color_filter opencv_apps/lk_flow opencv_apps/people_detect opencv_apps/phase_corr opencv_apps/pyramids opencv_apps/rgb_color_filter opencv_apps/segment_objects opencv_apps/simple_compressed_example opencv_apps/simple_example opencv_apps/simple_flow opencv_apps/smoothing opencv_apps/threshold opencv_apps/watershed_segmentation pcl/BAGReader pcl/BoundaryEstimation pcl/ConvexHull2D pcl/CropBox pcl/EuclideanClusterExtraction pcl/ExtractIndices pcl/ExtractPolygonalPrismData pcl/FPFHEstimation pcl/FPFHEstimationOMP pcl/MomentInvariantsEstimation pcl/MovingLeastSquares pcl/NodeletDEMUX pcl/NodeletMUX pcl/NormalEstimation pcl/NormalEstimationOMP pcl/NormalEstimationTBB pcl/PCDReader pcl/PCDWriter pcl/PFHEstimation pcl/PassThrough pcl/PointCloudConcatenateDataSynchronizer pcl/PointCloudConcatenateFieldsSynchronizer pcl/PrincipalCurvaturesEstimation pcl/ProjectInliers pcl/RadiusOutlierRemoval pcl/SACSegmentation pcl/SACSegmentationFromNormals pcl/SHOTEstimation pcl/SHOTEstimationOMP pcl/SegmentDifferences pcl/StatisticalOutlierRemoval pcl/VFHEstimation pcl/VoxelGrid people_detect/people_detect phase_corr/phase_corr pyramids/pyramids rgb_color_filter/rgb_color_filter segment_objects/segment_objects simple_compressed_example/simple_compressed_example simple_example/simple_example simple_flow/simple_flow smoothing/smoothing stereo_image_proc/disparity stereo_image_proc/point_cloud2 threshold/threshold watershed_segmentation/watershed_segmentation
[ERROR] [1564223743.672307997]: The error before refreshing the cache was: According to the loaded plugin descriptions the class my_manager/MyManagerNodelet with base class type nodelet::Nodelet does not exist. Declared types are  SlamGMappingNodelet adding_images/adding_images camshift/camshift contour_moments/contour_moments ...
(more)
edit retag flag offensive close merge delete

Comments

Any answer is going to depend on the contents of your package.xml and the .xml file that exports the necessary metadata for the plugin (which a nodelet essentially is).

As a separate comment though: "heartbeat" pub-subs are already provided by the bond package. You may want to take a look at that.

gvdhoorn gravatar image gvdhoorn  ( 2019-07-28 12:03:56 -0500 )edit