The registerCallback is not running

asked 2016-04-29 17:26:51 -0600

soichirutk gravatar image

Hi, I'm working with some packages and there is a node that works on the last step of processing of some data in this case are images an rois to track, the code below shows that the ObjecTtrackinNode has two methods registerCallback, but when I launch the nodes, this ObjectTrackingNode is the only one that doesn't show the image and the results are not available, and I think that is because the registerCallback are not running. So what could be the problem, and why the registerCallback doesn't work ? Or what are the conditions to just omit the registerCallback ?

I'm using ROS indigo, OpenCV 2.4.9, PCL 1.7 and the Kinect to get the images

Thank's and I hope you could help.

#include "ros/ros.h"
#include <sstream>

//Publish Messages
#include "roi_msgs/RoiRect.h"
#include "roi_msgs/Rois.h"
#include "std_msgs/String.h"
#include "roi_msgs/HumanEntry.h"
#include "roi_msgs/HumanEntries.h"

//Time Synchronizer
#include <message_filters/subscriber.h>
#include <message_filters/synchronizer.h>
#include <message_filters/sync_policies/exact_time.h>
#include <message_filters/sync_policies/approximate_time.h>

//Subscribe Messages
#include <sensor_msgs/Image.h>
#include <stereo_msgs/DisparityImage.h>
#include <sensor_msgs/CameraInfo.h>
#include <sensor_msgs/image_encodings.h>
#include <cv_bridge/cv_bridge.h>

// Image Transport
#include <image_transport/image_transport.h>
#include <image_transport/subscriber_filter.h>

// Used to display OPENCV images
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

// Tracker libraries
#include <object_tracking/tracker.h>
#include <boost/shared_ptr.hpp>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/make_shared.hpp>
#include <boost/thread.hpp>


using namespace stereo_msgs;
using namespace message_filters::sync_policies;
using namespace roi_msgs;
using namespace sensor_msgs;
using namespace sensor_msgs::image_encodings;
using sensor_msgs::Image;
using cv_bridge::CvImagePtr;
using std::vector;
using std::string;
using cv::Rect;
using cv::Mat;

class ObjectTrackingNode
{
private:
  // Define Node
  ros::NodeHandle node_;

  // Subscribe to Messages
  message_filters::Subscriber<DisparityImage> sub_disparity_;
  message_filters::Subscriber<Image> sub_image_;
  message_filters::Subscriber<Rois> sub_rois_;

  message_filters::Subscriber<sensor_msgs::CameraInfo> l_camera_info_;
  message_filters::Subscriber<sensor_msgs::CameraInfo> r_camera_info_;

  // Define the Synchronizer
  typedef ApproximateTime<Image, DisparityImage, Rois> ApproximatePolicy;
  typedef message_filters::Synchronizer<ApproximatePolicy> ApproximateSync;
  boost::shared_ptr<ApproximateSync> approximate_sync_;

  typedef ApproximateTime<sensor_msgs::CameraInfo, sensor_msgs::CameraInfo> ApproximatePolicy2;
  typedef message_filters::Synchronizer<ApproximatePolicy2> ApproximateSync2;
  boost::shared_ptr<ApproximateSync2> camera_info_sync_;

  // Messages to Publish
  ros::Publisher pub_Color_Image_;
  ros::Publisher human_tracker_data_;

  // Trackers
  std::vector<boost::shared_ptr<ParticleTrack> > trackers_;
  std::vector<cv::Rect> detections_;

  // Parallelization
  int thread_count_;
  boost::asio::io_service service_;
  boost::shared_ptr<boost::asio::io_service::work> work_;
  boost::thread_group task_threads_;
  boost::condition_variable task_condition_;
  boost::mutex task_mutex_;

  cv::Mat image, disp;
  cv::Mat Q_;
  uint64_t uid_counter_;
  uint64_t write_count_;
  std::string filter_dir_;
  std::string csv_filename_;
  std::ofstream log_file_;
  double object_timeout_;
  double angle_;
  double dt_;
  ros::Time current_;
  ros::Time previous_;
  bool geometry_initialized_;
  bool calculate_covariance_;
  bool show_images_;
  int max_objects_;
  bool write_image_results_;
  bool debug_mode_;

public:

  explicit ObjectTrackingNode(const ros::NodeHandle& nh):
    node_(nh)
  {

    string nn = ros::this_node::getName();
    int qs;
    if(!node_.getParam(nn + "/Q_Size",qs)){
      qs=3;
    }
    uid_counter_ = 0;
    write_count_ = 0;

    if(!node_.getParam(nn + "/Filter_Dir",filter_dir_))
    {
      //Load matrix 2x2 eigenvectors and eigenvalues 2x1
      filter_dir_ = std::string("/home/charl/catkin_ws/src/object_tracking/perception_data");
    }

    if(!node_.getParam(nn + "/Thread_Count",thread_count_)){
      thread_count_ = 5; // number of threads ...
(more)
edit retag flag offensive close merge delete