particle_filter_tracking.h
Go to the documentation of this file.
1 // -*- mode: C++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2013, Yuto Inagaki and JSK Lab
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/o2r other materials provided
17  * with the distribution.
18  * * Neither the name of the JSK Lab nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 #ifndef JSK_PCL_ROS_PARTICLE_FILTER_TRACKING_H_
37 #define JSK_PCL_ROS_PARTICLE_FILTER_TRACKING_H_
38 
39 // ros
40 #include <ros/ros.h>
41 #include <ros/names.h>
42 #include <sensor_msgs/PointCloud2.h>
43 #include <visualization_msgs/Marker.h>
49 #include <boost/circular_buffer.hpp>
50 // pcl
51 #include <pcl/point_types.h>
52 #include <pcl/common/centroid.h>
53 #include <pcl/common/transforms.h>
54 
55 #include <pcl/search/pcl_search.h>
56 #include <pcl/common/transforms.h>
57 
58 #include <pcl/tracking/tracking.h>
59 #include <pcl/tracking/particle_filter.h>
60 #include <pcl/tracking/kld_adaptive_particle_filter_omp.h>
61 #include <pcl/tracking/particle_filter_omp.h>
62 #include <pcl/tracking/coherence.h>
63 #include <pcl/tracking/distance_coherence.h>
64 #include <pcl/tracking/hsv_color_coherence.h>
65 #include <pcl/tracking/approx_nearest_pair_point_cloud_coherence.h>
66 #include <pcl/tracking/nearest_pair_point_cloud_coherence.h>
67 
68 #include <jsk_recognition_msgs/SetPointCloud2.h>
69 #include <jsk_pcl_ros/ParticleFilterTrackingConfig.h>
70 #include <jsk_recognition_msgs/BoundingBox.h>
71 
72 #include <dynamic_reconfigure/server.h>
76 
77 #include <pcl/tracking/particle_filter.h>
78 #include <pcl/tracking/impl/tracking.hpp>
79 #include <pcl/tracking/impl/particle_filter.hpp>
81 #include <std_msgs/Float32.h>
83 #include <visualization_msgs/MarkerArray.h>
84 #include <jsk_recognition_msgs/TrackerStatus.h>
85 // This namespace follows PCL coding style
86 namespace pcl
87 {
88  namespace tracking
89  {
90  // hack pcl::tracking
91  // original tracker assumes that the number of reference points is smaller
92  // than the number of input.
93  // ReversedParticleFilterTracker assumues that the number of reference
94  // points is greater than the number of input.
95  // So we need to change:
96  // 1) transform input pointcloud during weight phase with inverse of each particles
97  // particle should keep meaning the pose of reference for simplicity.
98  template <typename PointInT, typename StateT>
99  class ReversedParticleFilterTracker: public ParticleFilterTracker<PointInT, StateT>
100  {
101  public:
102  using Tracker<PointInT, StateT>::tracker_name_;
103  using Tracker<PointInT, StateT>::search_;
104  using Tracker<PointInT, StateT>::input_;
105  using Tracker<PointInT, StateT>::indices_;
106  using Tracker<PointInT, StateT>::getClassName;
107  using ParticleFilterTracker<PointInT, StateT>::particles_;
108  using ParticleFilterTracker<PointInT, StateT>::change_detector_;
109  using ParticleFilterTracker<PointInT, StateT>::change_counter_;
110  using ParticleFilterTracker<PointInT, StateT>::change_detector_resolution_;
111  using ParticleFilterTracker<PointInT, StateT>::change_detector_interval_;
112  using ParticleFilterTracker<PointInT, StateT>::use_change_detector_;
113  using ParticleFilterTracker<PointInT, StateT>::alpha_;
114  using ParticleFilterTracker<PointInT, StateT>::changed_;
115  using ParticleFilterTracker<PointInT, StateT>::ref_;
116  using ParticleFilterTracker<PointInT, StateT>::coherence_;
117  using ParticleFilterTracker<PointInT, StateT>::use_normal_;
118  using ParticleFilterTracker<PointInT, StateT>::particle_num_;
119  using ParticleFilterTracker<PointInT, StateT>::change_detector_filter_;
120  using ParticleFilterTracker<PointInT, StateT>::transed_reference_vector_;
121  //using ParticleFilterTracker<PointInT, StateT>::calcLikelihood;
122  using ParticleFilterTracker<PointInT, StateT>::normalizeWeight;
123  using ParticleFilterTracker<PointInT, StateT>::initParticles;
124  using ParticleFilterTracker<PointInT, StateT>::normalizeParticleWeight;
125  using ParticleFilterTracker<PointInT, StateT>::calcBoundingBox;
126 
127  typedef Tracker<PointInT, StateT> BaseClass;
128 
129  typedef typename Tracker<PointInT, StateT>::PointCloudIn PointCloudIn;
130  typedef typename PointCloudIn::Ptr PointCloudInPtr;
131  typedef typename PointCloudIn::ConstPtr PointCloudInConstPtr;
132 
133  typedef typename Tracker<PointInT, StateT>::PointCloudState PointCloudState;
134  typedef typename PointCloudState::Ptr PointCloudStatePtr;
135  typedef typename PointCloudState::ConstPtr PointCloudStateConstPtr;
136 
137  typedef PointCoherence<PointInT> Coherence;
140 
141  typedef PointCloudCoherence<PointInT> CloudCoherence;
144 
145  // call initCompute only if reference pointcloud is updated
146  inline void
147  setReferenceCloud (const PointCloudInConstPtr &ref)
148  {
149  ref_ = ref;
150  if (coherence_) {
151  coherence_->setTargetCloud (ref_);
152  coherence_->initCompute ();
153  }
154  else {
155  PCL_ERROR("coherence_ is not yet available!");
156  }
157  }
158 
159 
160  protected:
161  std::vector<PointCloudInPtr> transed_input_vector_;
162 
163  virtual bool initCompute()
164  {
165  if (!Tracker<PointInT, StateT>::initCompute ())
166  {
167  PCL_ERROR ("[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
168  return (false);
169  }
170 
171  // allocate pointclouds in transed_input_vector_ instead of transed_reference_vector_
172  if (transed_input_vector_.empty ())
173  {
174  //std::cout << "initializing " << particle_num_ << " input" << std::endl;
175  // only one time allocation
176  transed_input_vector_.resize (particle_num_ + 1);
177  for (int i = 0; i < particle_num_ + 1; i++)
178  {
179  transed_input_vector_[i] = PointCloudInPtr (new PointCloudIn ());
180  }
181  }
182 
183  // set reference instead of input
184  // if (coherence_) {
185  // coherence_->setTargetCloud (ref_);
186  // }
187 
188  if (!change_detector_)
189  change_detector_ = boost::shared_ptr<pcl::octree::OctreePointCloudChangeDetector<PointInT> >(new pcl::octree::OctreePointCloudChangeDetector<PointInT> (change_detector_resolution_));
190 
191  if (!particles_ || particles_->points.empty ())
192  initParticles (true);
193  return (true);
194  }
195 
196  // only is computation without normal supported
198  (const StateT& hypothesis, PointCloudIn &cloud)
199  {
200  const Eigen::Affine3f trans = this->toEigenMatrix (hypothesis);
201  // destructively assigns to cloud
202  pcl::transformPointCloud<PointInT> (*input_, cloud, trans);
203  }
204 
205 
206  virtual void weight()
207  {
208  changed_ = true;
209  if (!use_normal_)
210  {
211  for (size_t i = 0; i < particles_->points.size (); i++)
212  {
213  //std::cout << "processing " << i << " particle: " << particles_->points[i].weight << std::endl;
214  // compute `inverse` of particle
215  StateT inverse_particle;
216  Eigen::Affine3f trans = particles_->points[i].toEigenMatrix();
217  Eigen::Affine3f inverse_trans = trans.inverse();
218  inverse_particle = StateT::toState(inverse_trans);
219  computeTransformedPointCloudWithoutNormal (inverse_particle, *transed_input_vector_[i]);
220  IndicesPtr indices;
221  coherence_->compute (transed_input_vector_[i], indices, particles_->points[i].weight);
222  }
223  }
224  else
225  {
226  for (size_t i = 0; i < particles_->points.size (); i++)
227  {
228  StateT inverse_particle;
229  Eigen::Affine3f trans = particles_->points[i].toEigenMatrix();
230  Eigen::Affine3f inverse_trans = trans.inverse();
231  inverse_particle = StateT::toState(inverse_trans);
232  IndicesPtr indices (new std::vector<int>);
233  this->computeTransformedPointCloudWithNormal (inverse_particle, *indices, *transed_input_vector_[i]);
234  coherence_->compute (transed_input_vector_[i], indices, particles_->points[i].weight);
235  }
236  }
237 
238  normalizeWeight ();
239 
240  }
241  private:
242  };
243 
244  template <typename PointInT, typename StateT>
246  {
247  public:
248  using Tracker<PointInT, StateT>::tracker_name_;
249  using Tracker<PointInT, StateT>::search_;
250  using Tracker<PointInT, StateT>::input_;
251  using Tracker<PointInT, StateT>::indices_;
252  using Tracker<PointInT, StateT>::getClassName;
253  using ParticleFilterTracker<PointInT, StateT>::particles_;
254  using ParticleFilterTracker<PointInT, StateT>::change_detector_;
255  using ParticleFilterTracker<PointInT, StateT>::change_counter_;
256  using ParticleFilterTracker<PointInT, StateT>::change_detector_resolution_;
257  using ParticleFilterTracker<PointInT, StateT>::change_detector_interval_;
258  using ParticleFilterTracker<PointInT, StateT>::use_change_detector_;
259  using ParticleFilterTracker<PointInT, StateT>::alpha_;
260  using ParticleFilterTracker<PointInT, StateT>::changed_;
261  using ParticleFilterTracker<PointInT, StateT>::ref_;
262  using ParticleFilterTracker<PointInT, StateT>::coherence_;
263  using ParticleFilterTracker<PointInT, StateT>::use_normal_;
264  using ParticleFilterTracker<PointInT, StateT>::particle_num_;
265  using ParticleFilterTracker<PointInT, StateT>::change_detector_filter_;
266  using ParticleFilterTracker<PointInT, StateT>::transed_reference_vector_;
267  //using ParticleFilterTracker<PointInT, StateT>::calcLikelihood;
268  using ParticleFilterTracker<PointInT, StateT>::normalizeWeight;
269  using ParticleFilterTracker<PointInT, StateT>::initParticles;
270  using ParticleFilterTracker<PointInT, StateT>::normalizeParticleWeight;
271  using ParticleFilterTracker<PointInT, StateT>::calcBoundingBox;
272 
273  typedef Tracker<PointInT, StateT> BaseClass;
274 
275  typedef typename Tracker<PointInT, StateT>::PointCloudIn PointCloudIn;
276  typedef typename PointCloudIn::Ptr PointCloudInPtr;
277  typedef typename PointCloudIn::ConstPtr PointCloudInConstPtr;
278 
279  typedef typename Tracker<PointInT, StateT>::PointCloudState PointCloudState;
280  typedef typename PointCloudState::Ptr PointCloudStatePtr;
281  typedef typename PointCloudState::ConstPtr PointCloudStateConstPtr;
282 
283  typedef PointCoherence<PointInT> Coherence;
286 
287  typedef PointCloudCoherence<PointInT> CloudCoherence;
291  protected:
292 
293  unsigned int threads_;
294 
295  public:
296  ReversedParticleFilterOMPTracker (unsigned int nr_threads = 0)
297  : ReversedParticleFilterTracker<PointInT, StateT> ()
298  , threads_ (nr_threads)
299  {
300  tracker_name_ = "ReversedParticleFilterOMPTracker";
301  }
302 
303  inline void
304  setNumberOfThreads (unsigned int nr_threads = 0) { threads_ = nr_threads; }
305 
306  protected:
307 
308  virtual void weight()
309  {
310  changed_ = true;
311  if (!use_normal_)
312  {
313 #ifdef _OPENMP
314 #pragma omp parallel for num_threads(threads_)
315 #endif
316  for (size_t i = 0; i < particles_->points.size (); i++)
317  {
318  //std::cout << "processing " << i << " particle: " << particles_->points[i].weight << std::endl;
319  // compute `inverse` of particle
320  StateT inverse_particle;
321  Eigen::Affine3f trans = particles_->points[i].toEigenMatrix();
322  Eigen::Affine3f inverse_trans = trans.inverse();
323  inverse_particle = StateT::toState(inverse_trans);
324  this->computeTransformedPointCloudWithoutNormal (inverse_particle, *transed_input_vector_[i]);
325  //computeTransformedPointCloudWithoutNormal (particles_->points[i], *transed_input_vector_[i]);
326  IndicesPtr indices;
327  coherence_->compute (transed_input_vector_[i], indices, particles_->points[i].weight);
328  //std::cout << "processing " << i << " particle: " << particles_->points[i].weight << std::endl;
329  //std::cout << inverse_particle << std::endl;
330  }
331  }
332  else
333  {
334 #ifdef _OPENMP
335 #pragma omp parallel for num_threads(threads_)
336 #endif
337  for (size_t i = 0; i < particles_->points.size (); i++)
338  {
339  StateT inverse_particle;
340  Eigen::Affine3f trans = particles_->points[i].toEigenMatrix();
341  Eigen::Affine3f inverse_trans = trans.inverse();
342  inverse_particle = StateT::toState(inverse_trans);
343  IndicesPtr indices (new std::vector<int>);
344  this->computeTransformedPointCloudWithNormal (inverse_particle, *indices, *transed_input_vector_[i]);
345  coherence_->compute (transed_input_vector_[i], indices, particles_->points[i].weight);
346  }
347  }
348 
349  normalizeWeight ();
350  for (size_t i = 0; i < particles_->points.size (); i++)
351  {
352  //std::cout << "normalized " << i << " particle: " << particles_->points[i].weight << std::endl;
353  }
354  }
355  private:
356  };
357 
358  template <typename PointInT>
359  class CachedApproxNearestPairPointCloudCoherence: public ApproxNearestPairPointCloudCoherence<PointInT>
360  {
361  public:
362  typedef typename ApproxNearestPairPointCloudCoherence<PointInT>::PointCoherencePtr PointCoherencePtr;
363  typedef typename ApproxNearestPairPointCloudCoherence<PointInT>::PointCloudInConstPtr PointCloudInConstPtr;
364  //using NearestPairPointCloudCoherence<PointInT>::search_;
365  using ApproxNearestPairPointCloudCoherence<PointInT>::maximum_distance_;
366  using ApproxNearestPairPointCloudCoherence<PointInT>::target_input_;
367  using ApproxNearestPairPointCloudCoherence<PointInT>::point_coherences_;
368  using ApproxNearestPairPointCloudCoherence<PointInT>::coherence_name_;
369  using ApproxNearestPairPointCloudCoherence<PointInT>::new_target_;
370  using ApproxNearestPairPointCloudCoherence<PointInT>::getClassName;
371  using ApproxNearestPairPointCloudCoherence<PointInT>::search_;
372 
375  const double bin_y,
376  const double bin_z) :
377  ApproxNearestPairPointCloudCoherence<PointInT> (),
378  bin_x_(bin_x), bin_y_(bin_y), bin_z_(bin_z)
379  {
380  coherence_name_ = "CachedApproxNearestPairPointCloudCoherence";
381  }
382 
383  protected:
385  virtual void
386  computeCoherence (const PointCloudInConstPtr &cloud, const IndicesConstPtr &indices, float &w_j)
387  {
388  boost::mutex::scoped_lock lock(cache_mutex_);
389  double val = 0.0;
390  //for (size_t i = 0; i < indices->size (); i++)
391  for (size_t i = 0; i < cloud->points.size (); i++)
392  {
393  PointInT input_point = cloud->points[i];
394  int xi, yi, zi;
395  computeBin(input_point.getVector3fMap(), xi, yi, zi);
396  int k_index;
397  if (checkCache(xi, yi, zi)) {
398  k_index = getCachedIndex(xi, yi, zi);
399  }
400  else {
401  float k_distance = 0.0; // dummy
402  search_->approxNearestSearch(input_point, k_index, k_distance);
403  registerCache(k_index, xi, yi, zi);
404  }
405  PointInT target_point = target_input_->points[k_index];
406  float dist = (target_point.getVector3fMap() - input_point.getVector3fMap()).norm();
407  if (dist < maximum_distance_)
408  {
409  double coherence_val = 1.0;
410  for (size_t i = 0; i < point_coherences_.size (); i++)
411  {
412  PointCoherencePtr coherence = point_coherences_[i];
413  double w = coherence->compute (input_point, target_point);
414  coherence_val *= w;
415  }
416  val += coherence_val;
417  }
418  }
419  w_j = - static_cast<float> (val);
420  //ROS_INFO("hit: %d", counter);
421  }
422 
423  virtual void computeBin(
424  const Eigen::Vector3f& p, int& xi, int& yi, int& zi)
425  {
426  xi = (int)(p[0]/bin_x_);
427  yi = (int)(p[1]/bin_y_);
428  zi = (int)(p[2]/bin_z_);
429  }
430 
431  virtual void registerCache(int k_index, int bin_x, int bin_y, int bin_z)
432  {
433  //boost::mutex::scoped_lock lock(cache_mutex_);
434  if (cache_.find(bin_x) == cache_.end()) {
435  cache_[bin_x] = std::map<int, std::map<int, int> >();
436  }
437  if (cache_[bin_x].find(bin_y) == cache_[bin_x].end()) {
438  cache_[bin_x][bin_y] = std::map<int, int>();
439  }
440  cache_[bin_x][bin_y][bin_z] = k_index;
441  }
442 
443  virtual int getCachedIndex(int bin_x, int bin_y, int bin_z)
444  {
445  //boost::mutex::scoped_lock lock(cache_mutex_);
446  return cache_[bin_x][bin_y][bin_z];
447  }
448 
449  virtual bool checkCache(int bin_x, int bin_y, int bin_z)
450  {
451  //boost::mutex::scoped_lock lock(cache_mutex_);
452  if (cache_.find(bin_x) == cache_.end()) {
453  return false;
454  }
455  else {
456  if (cache_[bin_x].find(bin_y) == cache_[bin_x].end()) {
457  return false;
458  }
459  else {
460  if (cache_[bin_x][bin_y].find(bin_z) == cache_[bin_x][bin_y].end()) {
461  return false;
462  }
463  else {
464  return true;
465  }
466  }
467  }
468  }
469 
470  virtual void clearCache()
471  {
472  boost::mutex::scoped_lock lock(cache_mutex_);
473  cache_ = CacheMap();
474  }
475 
476  virtual bool initCompute()
477  {
478  if (!ApproxNearestPairPointCloudCoherence<PointInT>::initCompute ())
479  {
480  PCL_ERROR ("[pcl::%s::initCompute] PointCloudCoherence::Init failed.\n", getClassName ().c_str ());
481  //deinitCompute ();
482  return false;
483  }
484  clearCache();
485  return true;
486  }
487 
488  //typename boost::shared_ptr<pcl::search::Octree<PointInT> > search_;
489  typedef std::map<int, std::map<int, std::map<int, int> > > CacheMap;
490  CacheMap cache_;
492  double bin_x_;
493  double bin_y_;
494  double bin_z_;
495 
496  };
497 
498 
499  template <typename PointInT>
500  class OrganizedNearestPairPointCloudCoherence: public NearestPairPointCloudCoherence<PointInT>
501  {
502  public:
503  using NearestPairPointCloudCoherence<PointInT>::target_input_;
504  using NearestPairPointCloudCoherence<PointInT>::new_target_;
505  using NearestPairPointCloudCoherence<PointInT>::getClassName;
507  protected:
508  virtual bool initCompute ()
509  {
510  if (!PointCloudCoherence<PointInT>::initCompute ())
511  {
512  PCL_ERROR ("[pcl::%s::initCompute] PointCloudCoherence::Init failed.\n", getClassName ().c_str ());
513  //deinitCompute ();
514  return (false);
515  }
516 
517  // initialize tree
518  if (!search_)
519  search_.reset (new pcl::search::OrganizedNeighbor<PointInT> (false));
520 
521  if (new_target_ && target_input_)
522  {
523  search_->setInputCloud (target_input_);
524  if (!search_->isValid())
525  return false;
526  new_target_ = false;
527  }
528 
529  return true;
530  }
531  };
532  }
533 }
534 
535 using namespace pcl::tracking;
536 namespace jsk_pcl_ros
537 {
539  {
540  public:
541  typedef pcl::PointXYZRGB PointT;
542  typedef ParticleFilterTrackingConfig Config;
544  sensor_msgs::PointCloud2,
545  jsk_recognition_msgs::BoundingBox > SyncPolicy;
547  sensor_msgs::PointCloud2,
548  sensor_msgs::PointCloud2 > SyncChangePolicy;
549  typedef ParticleFilterTracker<PointT, ParticleXYZRPY>::PointCloudStatePtr
551  ParticleFilterTracking(): timer_(10), distance_error_buffer_(100), angle_error_buffer_(100), no_move_buffer_(10) {}
552  protected:
553  pcl::PointCloud<PointT>::Ptr cloud_pass_;
554  pcl::PointCloud<PointT>::Ptr cloud_pass_downsampled_;
555  pcl::PointCloud<PointT>::Ptr target_cloud_;
556 
557  //boost::shared_ptr<ParticleFilterTracker<PointT, ParticleXYZRPY> > tracker_;
560  //boost::shared_ptr<ReversedParticleFilterTracker<PointT, ParticleXYZRPY> > reversed_tracker_;
566  std::string frame_id_;
567  std::string base_frame_id_;
568  std::string track_target_name_;
572 
588  Eigen::Affine3f initial_pose_;
589  boost::circular_buffer<double> distance_error_buffer_;
590  boost::circular_buffer<double> angle_error_buffer_;
591 
605 
607  // parameters
611  double delta_;
612  double epsilon_;
615  ParticleXYZRPY bin_size_;
616  ParticleXYZRPY prev_result_;
617  int counter_;
618  std::vector<double> default_step_covariance_;
619  bool reversed_;
625  virtual void config_callback(Config &config, uint32_t level);
626  virtual void publish_particles();
627  virtual void publish_result();
628  virtual std::string reference_frame_id();
629  virtual void reset_tracking_target_model(
630  const pcl::PointCloud<PointT>::ConstPtr &new_target_cloud);
631  virtual tf::Transform change_pointcloud_frame(
632  pcl::PointCloud<PointT>::Ptr cloud);
633  virtual double rms(boost::circular_buffer<double>& buffer) {
634  double res = 0.0;
635  for (size_t i = 0; i < buffer.size(); i++) {
636  res += buffer[i] * buffer[i];
637  }
638  return sqrt(res / buffer.size());
639  }
640  virtual void cloud_cb(const sensor_msgs::PointCloud2 &pc);
641  virtual void cloud_change_cb(const sensor_msgs::PointCloud2::ConstPtr &pc, const sensor_msgs::PointCloud2::ConstPtr &chnage_cloud);
642  virtual bool renew_model_cb(
643  jsk_recognition_msgs::SetPointCloud2::Request &req,
644  jsk_recognition_msgs::SetPointCloud2::Response &response);
645  virtual void renew_model_with_box_topic_cb(
646  const sensor_msgs::PointCloud2::ConstPtr &pc_ptr,
647  const jsk_recognition_msgs::BoundingBox::ConstPtr &bb_ptr);
648  virtual void renew_model_topic_cb(const sensor_msgs::PointCloud2 &pc);
649  virtual void renew_model_with_marker_topic_cb(const visualization_msgs::Marker &marker);
650 
651  virtual void publish_tracker_status(const std_msgs::Header& header,
652  const bool is_tracking);
653 
654 
656  // Wrap particle filter methods
658  virtual void tracker_set_trans(const Eigen::Affine3f& trans);
659  virtual void tracker_set_step_noise_covariance(
660  const std::vector<double>& covariance);
661  virtual void tracker_set_initial_noise_covariance(
662  const std::vector<double>& covariance);
663  virtual void tracker_set_initial_noise_mean(
664  const std::vector<double>& mean);
665  virtual void tracker_set_iteration_num(const int num);
666  virtual void tracker_set_particle_num(const int num);
667  virtual void tracker_set_resample_likelihood_thr(double thr);
668  virtual void tracker_set_use_normal(bool use_normal);
669  virtual void tracker_set_cloud_coherence(
670  ApproxNearestPairPointCloudCoherence<PointT>::Ptr coherence);
671  virtual void tracker_set_maximum_particle_num(int num);
672  virtual void tracker_set_delta(double delta);
673  virtual void tracker_set_epsilon(double epsilon);
674  virtual void tracker_set_bin_size(const ParticleXYZRPY bin_size);
675  virtual ParticleFilterTracker<PointT, ParticleXYZRPY>::PointCloudStatePtr
676  tracker_get_particles();
677  virtual ParticleXYZRPY tracker_get_result();
678  virtual Eigen::Affine3f tracker_to_eigen_matrix(
679  const ParticleXYZRPY& result);
680  virtual pcl::PointCloud<PointT>::ConstPtr tracker_get_reference_cloud();
681  virtual void tracker_set_reference_cloud(pcl::PointCloud<PointT>::Ptr ref);
682  virtual void tracker_reset_tracking();
683  virtual void tracker_set_input_cloud(pcl::PointCloud<PointT>::Ptr input);
684  virtual void tracker_compute();
685 
686  virtual void subscribe() {}
687  virtual void unsubscribe() {}
688 
689  private:
690  virtual void onInit();
691 
692  };
693 }
694 
695 #endif
ParticleFilterTracker< PointT, ParticleXYZRPY >::PointCloudStatePtr PointCloudStatePtr
virtual void computeCoherence(const PointCloudInConstPtr &cloud, const IndicesConstPtr &indices, float &w_j)
compute the nearest pairs and compute coherence using point_coherences_
void setReferenceCloud(const PointCloudInConstPtr &ref)
boost::shared_ptr< ReversedParticleFilterOMPTracker< PointT, ParticleXYZRPY > > reversed_tracker_
num
def cloud_cb(cloud)
boost::shared_ptr< dynamic_reconfigure::Server< Config > > srv_
jsk_recognition_utils::WallDurationTimer timer_
boost::shared_ptr< const CloudCoherence > CloudCoherenceConstPtr
def config_callback(config, level)
pcl::PointCloud< PointT >::Ptr cloud_pass_downsampled_
std::map< int, std::map< int, std::map< int, int > > > CacheMap
boost::shared_ptr< const Coherence > CoherenceConstPtr
jsk_recognition_utils::SeriesedBoolean no_move_buffer_
boost::circular_buffer< double > distance_error_buffer_
virtual double rms(boost::circular_buffer< double > &buffer)
virtual void registerCache(int k_index, int bin_x, int bin_y, int bin_z)
message_filters::Subscriber< sensor_msgs::PointCloud2 > sub_input_
boost::shared_ptr< message_filters::Synchronizer< SyncChangePolicy > > change_sync_
virtual int getCachedIndex(int bin_x, int bin_y, int bin_z)
boost::shared_ptr< CloudCoherence > CloudCoherencePtr
pcl::PointCloud< PointT >::Ptr target_cloud_
boost::shared_ptr< pcl::search::OrganizedNeighbor< PointInT > > search_
result
message_filters::sync_policies::ExactTime< sensor_msgs::PointCloud2, jsk_recognition_msgs::BoundingBox > SyncPolicy
Tracker< PointInT, StateT >::PointCloudState PointCloudState
double sqrt()
boost::shared_ptr< const Coherence > CoherenceConstPtr
pcl::PointCloud< PointT >::Ptr cloud_pass_
ApproxNearestPairPointCloudCoherence< PointInT >::PointCoherencePtr PointCoherencePtr
boost::shared_ptr< const CloudCoherence > CloudCoherenceConstPtr
double epsilon
CachedApproxNearestPairPointCloudCoherence(const double bin_x, const double bin_y, const double bin_z)
empty constructor
boost::shared_ptr< KLDAdaptiveParticleFilterOMPTracker< PointT, ParticleXYZRPY > > tracker_
boost::circular_buffer< double > angle_error_buffer_
Tracker< PointInT, StateT >::PointCloudState PointCloudState
boost::mutex mutex
global mutex.
virtual void computeBin(const Eigen::Vector3f &p, int &xi, int &yi, int &zi)
message_filters::Subscriber< sensor_msgs::PointCloud2 > sub_change_cloud_
ApproxNearestPairPointCloudCoherence< PointInT >::PointCloudInConstPtr PointCloudInConstPtr
void computeTransformedPointCloudWithoutNormal(const StateT &hypothesis, PointCloudIn &cloud)
virtual bool checkCache(int bin_x, int bin_y, int bin_z)
boost::shared_ptr< message_filters::Synchronizer< SyncPolicy > > sync_
boost::shared_ptr< CloudCoherence > CloudCoherencePtr
message_filters::sync_policies::ExactTime< sensor_msgs::PointCloud2, sensor_msgs::PointCloud2 > SyncChangePolicy
message_filters::Subscriber< jsk_recognition_msgs::BoundingBox > sub_box_
Tracker< PointInT, StateT >::PointCloudIn PointCloudIn
message_filters::Subscriber< sensor_msgs::PointCloud2 > sub_input_cloud_
Tracker< PointInT, StateT >::PointCloudIn PointCloudIn


jsk_pcl_ros
Author(s): Yohei Kakiuchi
autogenerated on Mon May 3 2021 03:03:47