Hi all,
I try to implement a nodelet, which should be used for extracting (SIFT-)features. The data should come from a kinect camera (Openni and our features/descriptor extractor should run in one process). I used the tutorial from http://www.ros.org/wiki/nodelet, but it doesn't work.
The first thing I did was to create a class, which is derived from nodelet::Nodelet (feature_nodelet.h):
#ifndef FEATURE_NODELET_H_
#define FEATURE_NODELET_H_
#include <nodelet/nodelet.h>
namespace rgbdslam {
class FeatureNodelet: public nodelet::Nodelet {
public:
virtual ~FeatureNodelet() {}
private:
void onInit();
};
}
#endif /* FEATURE_NODELET_H_ */
feature_nodelet.cpp contains the plugin-lib-macro:
#include <ros/ros.h>
#include <pluginlib/class_list_macros.h>
#include "feature_nodelet.h"
#include "parameter_server.h"
#include "extractor_nodelet.h"
namespace rgbdslam {
PLUGINLIB_DECLARE_CLASS(rgbdslam, FeatureNodelet, rgbdslam::FeatureNodelet, nodelet::Nodelet);
void FeatureNodelet::onInit() {
ros::NodeHandle& nh = getNodeHandle();
ParameterServer* params = ParameterServer::instance();
//some test output
NODELET_INFO_STREAM("test");
NODELET_ERROR("test");
ROS_ERROR("test");
ExtractorNodelet features(nh,
params->get<std::string> ("topic_image_mono").c_str(),
params->get<std::string> ("topic_image_depth").c_str(),
params->get<std::string> ("topic_points").c_str(),
params->get<std::string> ("feature_extractor_type").c_str(),
params->get<std::string> ("feature_detector_type").c_str());
}
}
In manifest.xml I added the export of the nodelet xml file (and the nodelet-dependency):
<export>
<nodelet plugin="${prefix}/nodelet.xml" />
</export>
nodelet.xml:
<library path="lib/libfeature_nodelet">
<class name="rgbdslam/FeatureNodelet" type="rgbdslam::FeatureNodelet" base_class_type="nodelet::Nodelet">
<description>
RGBDSlam feature extraction and sending pointclouds / descriptors
</description>
</class>
</library>
Finally the CMakeLists.txt contains the command for compiling the library:
rosbuild_add_library(feature_nodelet src/feature_nodelet.cpp src/extractor_nodelet.cpp src/parameter_server.cpp)
Now, if I use the launch-file
<launch>
<!-- kinect-->
<node pkg="nodelet" type="nodelet" name="openni_manager" output="screen" respawn="true" args="manager"/>
<node pkg="nodelet" type="nodelet" name="openni_camera" args="load openni_camera/OpenNINodelet openni_manager" respawn="true"/>
<!-- Kinect frames -->
<include file="$(find openni_camera)/launch/kinect_frames.launch"/>
<node pkg="nodelet" type="nodelet" name="feature_extractor" args="load rgbdslam/FeatureNodelet openni_camera" output="screen" />
<node pkg="rgbdslam" type="rgbdslam" name="rgbdslam" cwd="node" required="false" output="log" />
</launch>
it seems, that the feature_extractor nodelet will not be called. I tried some output (ROS_ERROR() and NODELET_ERROR()) in the onInit-method, but nothing happened.
However the openni nodelet is working and feature_extractor nodelet appears in the (rx)graph. It only has a connection to /rosout.
Are there any further steps, I must perform to use the feature_extractor nodelet. Or will a nodelet only get active (i.e. onInit() is called) , if some other nodes subscribe a topic, which is advertised by the nodelet?
Edit 1: I forgot to say, that I've tested openni_manager in
<[...] args="load rgbdslam/FeatureNodelet openni_manager" output="screen" />
In this case there was an error: something like "ROS cannot find the nodelet". At the moment I cannot get the error-message remotely, since the kinect isn't conntected to the computer at university. But it seems, that the error only appears, if there is no kinect connected, which leads to the following (rx)graph:
rxgraph http://danielkuhner.de/fileadmin/uni/ros/rxgraph.png
Nevertheless, there is no output (e.g. ROS_ERROR/NODELET_ERROR in onInit) in the log/console, i.e. onInit wasn't called.
Edit 2: Now, after using openni_manager in
<[...] args="load rgbdslam/FeatureNodelet openni_manager" output="screen" />
I get the following output:
process[openni_manager-1]: started with pid [28634]
process[openni_camera-2]: started with pid [28636]
...
process[feature_extractor-7]: started with pid [28683]
process[rgbdslam-8]: started with pid [28686]
[ INFO] [1306838654.276064297]: Loading nodelet /feature_extractor of type rgbdslam/FeatureNodelet to manager openni_manager with the following remappings:
[ERROR] [1306838654.286817146]: Failed to load nodelet [/feature_extractor] of type [rgbdslam/FeatureNodelet]: According to the loaded plugin descriptions the class rgbdslam/FeatureNodelet with base class type nodelet::Nodelet does not exist. Declared types are camera1394/driver image_proc/debayer image_proc/rectify image_view/disparity image_view/image nodelet_tutorial_math/Plus openni_camera/OpenNINodelet pcl/BAGReader pcl/BoundaryEstimation pcl/ConvexHull2D 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/SACSegmentation pcl/SACSegmentationFromNormals pcl/SegmentDifferences pcl/StatisticalOutlierRemoval pcl/TestListener pcl/TestPingPong pcl/TestTalker pcl/VFHEstimation pcl/VoxelGrid pointcloud_to_laserscan/CloudThrottle pointcloud_to_laserscan/CloudToScan stereo_image_proc/disparity stereo_image_proc/point_cloud stereo_image_proc/point_cloud2 test_nodelet/ConsoleTest test_nodelet/Plus
... output of openni_camera
[feature_extractor-7] process has finished cleanly. log file: /home/kuhnerd/.ros/log/4882ad90-8850-11e0-9765-002618fd30f2/feature_extractor-7*.log Xlib: extension "NV-GLX" missing on display "localhost:10.0".
[openni_camera-2] process has finished cleanly.
respawning...
The first lines of the nodelet-log-file contains:
[roscpp_internal] [2011-05-31 12:44:14,112] [thread 0x7f3298fd8760]: [DEBUG] UDPROS server listening on port [34789]
[roscpp_internal] [2011-05-31 12:44:14,272] [thread 0x7f3298fd8760]: [DEBUG] Started node [/feature_extractor], pid [28683], bound on [dickmann], xmlrpc port [57613], tcpros port [57239], logging to [/home/kuhnerd/.ros/log/48 82ad90-8850-11e0-9765-002618fd30f2/feature_extractor-7.log], using [real] time
[ros.nodelet] [2011-05-31 12:44:14,276] [thread 0x7f3298fd8760]: [INFO] Loading nodelet /feature_extractor of type rgbdslam/FeatureNodelet to manager openni_manager with the following remappings:
[roscpp_internal] [2011-05-31 12:44:14,278] [thread 0x7f3298fd8760]: [DEBUG] XML-RPC call [getParam] returned an error (-1): [Parameter [/feature_extractor] is not set]
[roscpp_internal] [2011-05-31 12:44:14,279] [thread 0x7f3298fd8760]: [DEBUG] XML-RPC call [setParam] returned an error (-1): [Error: bad call arity]
Has somebody an idea, why the feature_extractor nodelet produces no output (the openni nodelet produces output), i.e. it does not start? And why does the error message appear?
Edit 3:
What is the output when you compile rgbdslam?
Output:
mkdir -p bin
cd build && cmake -Wdev -DCMAKE_TOOLCHAIN_FILE=
rospack find rosbuild
/rostoolchain.cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
[rosbuild] Building package rgbdslam
[rosbuild] Cached build flags older than manifests; calling rospack to get flags
[rosbuild] Including /opt/ros/diamondback/stacks/ros_comm/clients/rospy/cmake/rospy.cmake
[rosbuild] Including /opt/ros/diamondback/stacks/ros_comm/clients/roslisp/cmake /roslisp.cmake
[rosbuild] Including /opt/ros/diamondback/stacks/ros_comm/clients/cpp/roscpp/cmake/roscpp.cmake
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - not found.
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found.
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - not found.
-- Found Qt-Version 4.6.2 (using /usr/bin/qmake-qt4)
-- Looking for _POSIX_TIMERS
-- Looking for _POSIX_TIMERS - found
[rosbuild] Couldn't find source file /home/kuhnerd/workspace/rgbdslam/build/src/moc_qtros.cxx; assuming that it is in /home/kuhnerd/workspace/rgbdslam and will be generated later
[rosbuild] Couldn't find source file /home/kuhnerd/workspace/rgbdslam/build/src/moc_openni_listener.cxx; assuming that it is in /home/kuhnerd/workspace/rgbdslam and will be generated later
[rosbuild] Couldn't find source file /home/kuhnerd/workspace/rgbdslam/build/src/moc_qtcv.cxx; assuming that it is in /home/kuhnerd/workspace/rgbdslam and will be generated later
[rosbuild] Couldn't find source file /home/kuhnerd/workspace/rgbdslam/build/src/moc_graph_manager.cxx; assuming that it is in /home/kuhnerd/workspace/rgbdslam and will be generated later
[rosbuild] Couldn't find source file /home/kuhnerd/workspace/rgbdslam/build/src/moc_glviewer.cxx; assuming that it is in /home/kuhnerd/workspace/rgbdslam and will be generated later
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kuhnerd/workspace/rgbdslam/build
cd build && make
make[1]: Entering directory `/home/kuhnerd/workspace/rgbdslam/build'
make[2]: Entering directory `/home/kuhnerd/workspace/rgbdslam/build'
make[3]: Entering directory `/home/kuhnerd/workspace/rgbdslam/build'
Scanning dependencies of target rospack_genmsg_libexe
make[3]: Leaving directory `/home/kuhnerd/workspace/rgbdslam/build'
[ 0%] Built target rospack_genmsg_libexe
make[3]: Entering directory `/home/kuhnerd/workspace/rgbdslam/build'
Scanning dependencies of target rosbuild_precompile
make[3]: Leaving directory `/home/kuhnerd/workspace/rgbdslam/build'
[ 0%] Built target rosbuild_precompile
make[3]: Entering directory `/home/kuhnerd/workspace/rgbdslam/build'
Scanning dependencies of target feature_nodelet
make[3]: Leaving directory `/home/kuhnerd/workspace/rgbdslam/build'
make[3]: Entering directory `/home/kuhnerd/workspace/rgbdslam/build'
[ 4%] Building CXX object CMakeFiles/feature_nodelet.dir/src/feature_nodelet.o
[ 9%] Building CXX object CMakeFiles/feature_nodelet.dir/src/extractor_nodelet.o
[ 13%] Building CXX object CMakeFiles/feature_nodelet.dir/src/parameter_server.o
Linking CXX shared library ../lib/libfeature_nodelet.so
make[3]: Leaving directory `/home/kuhnerd/workspace/rgbdslam/build'
[ 13%] Built target feature_nodelet
make[3]: Entering directory `/home/kuhnerd/workspace/rgbdslam/build'
[ 18%] Generating src/moc_glviewer.cxx
[ 22%] Generating src/moc_qtros.cxx
[ 27%] Generating src/moc_openni_listener.cxx
[ 31%] Generating src/moc_qtcv.cxx
[ 36%] Generating src/moc_graph_manager.cxx
Scanning dependencies of target rgbdslam
make[3]: Leaving directory `/home/kuhnerd/workspace/rgbdslam/build'
make[3]: Entering directory `/home/kuhnerd/workspace/rgbdslam/build'
[ 40%] Building CXX object CMakeFiles/rgbdslam.dir/src/gicp-fallback.o
[ 45%] Building CXX object CMakeFiles/rgbdslam.dir/src/main.o
[ 50%] Building CXX object CMakeFiles/rgbdslam.dir/src/qtros.o
[ 54%] Building CXX object CMakeFiles/rgbdslam.dir/src/openni_listener.o
[ 59%] Building CXX object CMakeFiles/rgbdslam.dir/src/qtcv.o
[ 63%] Building CXX object CMakeFiles/rgbdslam.dir/src/node.o
[ 68%] Building CXX object CMakeFiles/rgbdslam.dir/src/graph_manager.o
/opt/ros/diamondback/stacks/geometry/bullet/include/LinearMath/btTransform.h: In function ‘tf::Transform hogman2TF(Transformation3)’:
/opt/ros/diamondback/stacks/geometry/bullet/include/LinearMath/btTransform.h:154: warning: ‘translation.btVector3::m_floats[3u]’ is used uninitialized in this function
/home/kuhnerd/workspace/rgbdslam/src/graph_manager.cpp:62: note: ‘translation.btVector3::m_floats[3u]’ was declared here
[ 72%] Building CXX object CMakeFiles/rgbdslam.dir/src/glviewer.o
[ 77%] Building CXX object CMakeFiles/rgbdslam.dir/src/parameter_server.o
[ 81%] Building CXX object CMakeFiles/rgbdslam.dir/src/moc_qtros.o
[ 86%] Building CXX object CMakeFiles/rgbdslam.dir/src/moc_openni_listener.o
[ 90%] Building CXX object CMakeFiles/rgbdslam.dir/src/moc_qtcv.o
[ 95%] Building CXX object CMakeFiles/rgbdslam.dir/src/moc_graph_manager.o
[100%] Building CXX object CMakeFiles/rgbdslam.dir/src/moc_glviewer.o
Linking CXX executable ../bin/rgbdslam
make[3]: Leaving directory `/home/kuhnerd/workspace/rgbdslam/build'
[100%] Built target rgbdslam
make[2]: Leaving directory `/home/kuhnerd/workspace/rgbdslam/build'
make[1]: Leaving directory `/home/kuhnerd/workspace/rgbdslam/build'
CMakeLists.txt:
set(USE_SIFT_GPU 0)
set(USE_GICP_BIN 0)
set(USE_GICP_CODE 0)
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
set(ROS_BUILD_TYPE RelWithDebInfo)
#is used for compiling the libraries
set(USE_GICP 0)
IF (${USE_GICP_BIN} OR ${USE_GICP_CODE})
set(USE_GICP 1)
ENDIF (${USE_GICP_BIN} OR ${USE_GICP_CODE})
rosbuild_init()
#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
rosbuild_add_library(feature_nodelet src/feature_nodelet.cpp src/extractor_nodelet.cpp src/parameter_server.cpp)
find_package(Qt4 REQUIRED)
SET(QT_USE_QTXML TRUE)
SET(QT_USE_QTOPENGL TRUE)
ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
include(${QT_USE_FILE})
# This is necessary as all ui files etc will get dumped in the bottom of the
# binary directory.
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${QT_QTOPENGL_INCLUDE_DIR} gicp/ann_1.1.1/include/)
LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH})
SET(${CMAKE_LIBRARY_PATH} ${LIBRARY_OUTPUT_PATH})
#SiftGPU
IF (${USE_SIFT_GPU})
include_directories(${CMAKE_CURRENT_BINARY_DIR} external/siftgpu/src)
EXEC_PROGRAM(make ../external/siftgpu/linux ARGS all)
FILE(COPY external/siftgpu/linux/bin/libsiftgpu.so DESTINATION ../lib)
ENDIF (${USE_SIFT_GPU})
#GICP
IF (${USE_GICP})
EXEC_PROGRAM(make ../gicp/ann_1.1.1/ ARGS linux-g++)
FILE(COPY gicp/ann_1.1.1/lib/libANN.a DESTINATION ../lib)
ENDIF (${USE_GICP})
file(GLOB QT_FORMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ui/*.ui)
file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/local/*.hpp src/qtros.h src/openni_listener.h src/qtcv.h src/graph_manager.h src/glviewer.h)
QT4_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
QT4_WRAP_UI(QT_FORMS_HPP ${QT_FORMS})
QT4_WRAP_CPP(QT_MOC_HPP ${QT_MOC})
SET(ADDITIONAL_SOURCES src/gicp-fallback.cpp src/main.cpp src/qtros.cpp src/openni_listener.cpp src/qtcv.cpp src/flow.cpp src/node.cpp src/graph_manager.cpp src/glviewer.cpp src/parameter_server.cpp)
IF (${USE_SIFT_GPU})
SET(ADDITIONAL_SOURCES ${ADDITIONAL_SOURCES} src/sift_gpu_feature_detector.cpp)
ENDIF (${USE_SIFT_GPU})
file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS ${ADDITIONAL_SOURCES})
IF (${USE_SIFT_GPU})
add_definitions(-DUSE_SIFT_GPU)
ENDIF (${USE_SIFT_GPU})
IF (${USE_GICP_BIN})
add_definitions(-DUSE_ICP_BIN)
ENDIF (${USE_GICP_BIN})
IF (${USE_GICP_CODE})
add_definitions(-DUSE_ICP_CODE)
ENDIF (${USE_GICP_CODE})
rosbuild_add_executable(rgbdslam ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
SET(LIBS_LINK rgbdslam GL GLU ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY} ${GLUT_LIBRARY} ${OPENGL_LIBRARY})
IF (${USE_SIFT_GPU})
SET(LIBS_LINK ${LIBS_LINK} siftgpu)
ENDIF (${USE_SIFT_GPU})
IF (${USE_GICP})
SET(LIBS_LINK ${LIBS_LINK} gicp ANN gsl gslcblas)
ENDIF (${USE_GICP})
IF (${USE_GICP})
rosbuild_add_library(gicp gicp/bfgs_funcs.cpp gicp/gicp.cpp gicp/optimize.cpp gicp/scan.cpp gicp/transform.cpp)
ENDIF (${USE_GICP})
target_link_libraries(${LIBS_LINK})
I've updated the feature_nodelet.cpp and feature_nodelet.h file above.
Best Regards,
Daniel
Originally posted by Daniel Kuhner on ROS Answers with karma: 44 on 2011-05-26
Post score: 1
Original comments
Comment by Ivan Dryanovski on 2011-06-01:
I updated my post.
Comment by Daniel Kuhner on 2011-05-31:
No, the solution not worked for me. The rxgraph looks better, but I got an error (see question)...
Comment by Asomerville on 2011-05-31:
Did Ivan's solution not work for you?
Comment by Sudhan on 2012-10-08:
how did you insert picture in your question?
Comment by Asomerville on 2012-10-09:
@Sudhan: he used markdown of this form: "![rxgraph](http://danielkuhner.de/fileadmin/uni/ros/rxgraph.png)
"