container_occupancy_detector.h
Go to the documentation of this file.
1 // -*- mode: C++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2022, 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/or 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  * container_occupancy_detector.h
37  * Author: Yoshiki Obinata <obinata@jsk.imi.i.u-tokyo.ac.jp>
38  */
39 
40 
41 #ifndef CONTAINER_OCCUPANCY_DETECTOR_H_
42 #define CONTAINER_OCCUPANCY_DETECTOR_H_
43 
44 #include <pcl_ros/pcl_nodelet.h>
45 #include <pcl_ros/transforms.h>
48 #include <tf2_eigen/tf2_eigen.h>
49 
52 
55 #include <jsk_recognition_msgs/BoundingBoxArray.h>
56 #include <jsk_recognition_msgs/ClusterPointIndices.h>
57 #include <jsk_topic_tools/diagnostic_nodelet.h>
58 #include <sensor_msgs/PointCloud2.h>
59 
60 #include <pcl/filters/crop_box.h>
61 
62 namespace jsk_pcl_ros{
63 
64  class ContainerOccupancyDetector: public jsk_topic_tools::DiagnosticNodelet{
65  public:
67  jsk_recognition_msgs::BoundingBoxArray,
68  sensor_msgs::PointCloud2,
69  jsk_recognition_msgs::ClusterPointIndices
70  > SyncPolicy;
72  jsk_recognition_msgs::BoundingBoxArray,
73  sensor_msgs::PointCloud2,
74  jsk_recognition_msgs::ClusterPointIndices
76  ContainerOccupancyDetector() : DiagnosticNodelet("ContainerOccupancyDetector") {}
78 
79  protected:
81  // methods
83  virtual void onInit();
84  virtual void calculate(
85  const jsk_recognition_msgs::BoundingBoxArray::ConstPtr& boxes_msg,
86  const sensor_msgs::PointCloud2::ConstPtr& points_msg,
87  const jsk_recognition_msgs::ClusterPointIndices::ConstPtr& point_indices_msg);
88  virtual void updateDiagnostic(
90  virtual void subscribe();
91  virtual void unsubscribe();
92  virtual bool pointsTransform(
93  const jsk_recognition_msgs::BoundingBoxArray::ConstPtr& boxes_msg,
94  const sensor_msgs::PointCloud2::ConstPtr& points_msg);
95 
97  // ROS varariables
102  std::shared_ptr<message_filters::Synchronizer<SyncPolicy> >sync_;
103  std::shared_ptr<message_filters::Synchronizer<ApproximateSyncPolicy> >ap_sync_;
108  sensor_msgs::PointCloud2::Ptr transformed_points_msg_ =
109  boost::shared_ptr<sensor_msgs::PointCloud2>(new sensor_msgs::PointCloud2);
110 #if ( PCL_MAJOR_VERSION >= 1 && PCL_MINOR_VERSION >= 12 )
111  pcl::PCLPointCloud2Ptr pcl_pc2_ptr_ =
112  std::shared_ptr<pcl::PCLPointCloud2>(new pcl::PCLPointCloud2);
113  pcl::PointCloud<pcl::PointXYZ>::Ptr pcl_xyz_ptr_ =
114  std::shared_ptr<pcl::PointCloud<pcl::PointXYZ>>(new pcl::PointCloud<pcl::PointXYZ>);
115 #else
116  pcl::PCLPointCloud2Ptr pcl_pc2_ptr_ =
117  boost::shared_ptr<pcl::PCLPointCloud2>(new pcl::PCLPointCloud2);
118  pcl::PointCloud<pcl::PointXYZ>::Ptr pcl_xyz_ptr_ =
119  boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ>>(new pcl::PointCloud<pcl::PointXYZ>);
120 #endif
121 
123  // Diagnostics Variables
127 
129  // Parameters
131  int queue_size_;
132  bool approximate_sync_;
133 
134  private:
135 
136  };
137 }
138 
139 #endif // CONTAINER_OCCUPANCY_DETECTOR_H_
jsk_pcl_ros::ContainerOccupancyDetector::remove_counter_
jsk_recognition_utils::Counter remove_counter_
Definition: container_occupancy_detector.h:189
jsk_pcl_ros::ContainerOccupancyDetector::ContainerOccupancyDetector
ContainerOccupancyDetector()
Definition: container_occupancy_detector.h:140
ros::Publisher
jsk_pcl_ros::ContainerOccupancyDetector::sub_point_indices_
message_filters::Subscriber< jsk_recognition_msgs::ClusterPointIndices > sub_point_indices_
Definition: container_occupancy_detector.h:165
boost::shared_ptr
tf2_eigen.h
jsk_pcl_ros::ContainerOccupancyDetector::ap_sync_
std::shared_ptr< message_filters::Synchronizer< ApproximateSyncPolicy > > ap_sync_
Definition: container_occupancy_detector.h:167
jsk_pcl_ros::ContainerOccupancyDetector::pcl_xyz_ptr_
pcl::PointCloud< pcl::PointXYZ >::Ptr pcl_xyz_ptr_
Definition: container_occupancy_detector.h:182
jsk_pcl_ros::ContainerOccupancyDetector::ApproximateSyncPolicy
message_filters::sync_policies::ApproximateTime< jsk_recognition_msgs::BoundingBoxArray, sensor_msgs::PointCloud2, jsk_recognition_msgs::ClusterPointIndices > ApproximateSyncPolicy
Definition: container_occupancy_detector.h:139
geo_util.h
jsk_pcl_ros::ContainerOccupancyDetector::sub_boxes_
message_filters::Subscriber< jsk_recognition_msgs::BoundingBoxArray > sub_boxes_
Definition: container_occupancy_detector.h:163
time_synchronizer.h
jsk_pcl_ros::ContainerOccupancyDetector::transformed_points_msg_
sensor_msgs::PointCloud2::Ptr transformed_points_msg_
Definition: container_occupancy_detector.h:172
jsk_pcl_ros::ContainerOccupancyDetector::calculate
virtual void calculate(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr &boxes_msg, const sensor_msgs::PointCloud2::ConstPtr &points_msg, const jsk_recognition_msgs::ClusterPointIndices::ConstPtr &point_indices_msg)
Definition: container_occupancy_detector_nodelet.cpp:122
jsk_pcl_ros::ContainerOccupancyDetector::SyncPolicy
message_filters::sync_policies::ExactTime< jsk_recognition_msgs::BoundingBoxArray, sensor_msgs::PointCloud2, jsk_recognition_msgs::ClusterPointIndices > SyncPolicy
Definition: container_occupancy_detector.h:134
jsk_pcl_ros::ContainerOccupancyDetector::mutex_
boost::mutex mutex_
Definition: container_occupancy_detector.h:169
transforms.h
jsk_pcl_ros::ContainerOccupancyDetector::pass_counter_
jsk_recognition_utils::Counter pass_counter_
Definition: container_occupancy_detector.h:190
message_filters::Subscriber< jsk_recognition_msgs::BoundingBoxArray >
tf2_ros::TransformListener
pcl_nodelet.h
jsk_pcl_ros::ContainerOccupancyDetector::queue_size_
int queue_size_
Definition: container_occupancy_detector.h:195
message_filters::sync_policies::ApproximateTime
jsk_pcl_ros::ContainerOccupancyDetector::onInit
virtual void onInit()
Definition: container_occupancy_detector_nodelet.cpp:76
jsk_pcl_ros
Definition: add_color_from_image.h:51
jsk_pcl_ros::ContainerOccupancyDetector::tf_buffer_
tf2_ros::Buffer tf_buffer_
Definition: container_occupancy_detector.h:170
jsk_pcl_ros::ContainerOccupancyDetector::pcl_pc2_ptr_
pcl::PCLPointCloud2Ptr pcl_pc2_ptr_
Definition: container_occupancy_detector.h:180
jsk_pcl_ros::ContainerOccupancyDetector::updateDiagnostic
virtual void updateDiagnostic(diagnostic_updater::DiagnosticStatusWrapper &stat)
Definition: container_occupancy_detector_nodelet.cpp:198
jsk_pcl_ros::ContainerOccupancyDetector::pointsTransform
virtual bool pointsTransform(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr &boxes_msg, const sensor_msgs::PointCloud2::ConstPtr &points_msg)
Definition: container_occupancy_detector_nodelet.cpp:176
tf2_ros::Buffer
jsk_pcl_ros::ContainerOccupancyDetector::unsubscribe
virtual void unsubscribe()
Definition: container_occupancy_detector_nodelet.cpp:116
jsk_recognition_utils::Counter
transform_datatypes.h
jsk_pcl_ros::ContainerOccupancyDetector::subscribe
virtual void subscribe()
Definition: container_occupancy_detector_nodelet.cpp:101
jsk_pcl_ros::ContainerOccupancyDetector::sub_points_
message_filters::Subscriber< sensor_msgs::PointCloud2 > sub_points_
Definition: container_occupancy_detector.h:164
jsk_pcl_ros::ContainerOccupancyDetector::tf_listener_
tf2_ros::TransformListener * tf_listener_
Definition: container_occupancy_detector.h:171
pcl_util.h
jsk_pcl_ros::ContainerOccupancyDetector::boxes_occupancy_pub_
ros::Publisher boxes_occupancy_pub_
Definition: container_occupancy_detector.h:168
jsk_pcl_ros::ContainerOccupancyDetector::~ContainerOccupancyDetector
virtual ~ContainerOccupancyDetector()
Definition: container_occupancy_detector_nodelet.cpp:86
jsk_pcl_ros::ContainerOccupancyDetector::approximate_sync_
bool approximate_sync_
Definition: container_occupancy_detector.h:196
synchronizer.h
diagnostic_updater::DiagnosticStatusWrapper
tf2_geometry_msgs.h
mutex
boost::mutex mutex
global mutex.
Definition: depth_camera_error_visualization.cpp:86
message_filters::sync_policies::ExactTime
jsk_pcl_ros::ContainerOccupancyDetector::sync_
std::shared_ptr< message_filters::Synchronizer< SyncPolicy > > sync_
Definition: container_occupancy_detector.h:166


jsk_pcl_ros
Author(s): Yohei Kakiuchi
autogenerated on Tue Jan 7 2025 04:05:44