45 jsk_topic_tools::DiagnosticNodelet::onInit();
49 = advertise<jsk_recognition_msgs::BoundingBoxArray>(*pnh_,
"container/occupancies", 1);
74 ap_sync_ = std::make_shared<message_filters::Synchronizer<ApproximateSyncPolicy> >(
queue_size_);
78 sync_ = std::make_shared<message_filters::Synchronizer<SyncPolicy> >(100);
91 const jsk_recognition_msgs::BoundingBoxArray::ConstPtr& boxes_msg,
92 const sensor_msgs::PointCloud2::ConstPtr& points_msg,
93 const jsk_recognition_msgs::ClusterPointIndices::ConstPtr& point_indices_msg
96 if (!boxes_msg->boxes.empty()){
100 jsk_recognition_msgs::BoundingBoxArray result_ = *boxes_msg;
103 for(
size_t i_box = 0; i_box < boxes_msg->boxes.size(); i_box++){
105 float sum_occupancy_ = 0.0;
106 int32_t n_points_ = 0;
107 Eigen::Vector3d t_(boxes_msg->boxes.at(i_box).pose.position.x,
108 boxes_msg->boxes.at(i_box).pose.position.y,
109 boxes_msg->boxes.at(i_box).pose.position.z);
110 Eigen::Quaterniond q_(boxes_msg->boxes.at(i_box).pose.orientation.w,
111 boxes_msg->boxes.at(i_box).pose.orientation.x,
112 boxes_msg->boxes.at(i_box).pose.orientation.y,
113 boxes_msg->boxes.at(i_box).pose.orientation.z);
115 Eigen::Vector3d top_(0.0, 0.0, boxes_msg->boxes.at(i_box).dimensions.z / 2.0);
116 Eigen::Vector3d buttom_(0.0, 0.0, -boxes_msg->boxes.at(i_box).dimensions.z / 2.0);
118 for(
auto index = point_indices_msg->cluster_indices.at(i_box).indices.begin();
119 index != point_indices_msg->cluster_indices.at(i_box).indices.end();
125 Eigen::Vector3d rotated_point_ = q_.conjugate() * (eigen_point_ - t_);
126 float rate_ = (rotated_point_.z() - buttom_.z()) / (top_.z() - buttom_.z());
128 sum_occupancy_ += rate_;
132 result_.boxes.at(i_box).value = sum_occupancy_ / float(n_points_);
134 vital_checker_->poke();
145 const jsk_recognition_msgs::BoundingBoxArray::ConstPtr& boxes_msg,
146 const sensor_msgs::PointCloud2::ConstPtr& points_msg
149 geometry_msgs::TransformStamped transform_stamped_;
153 boxes_msg->header.frame_id,
154 points_msg->header.frame_id,
155 points_msg->header.stamp,
168 if(vital_checker_ -> isAlive()){
169 stat.
summary(diagnostic_msgs::DiagnosticStatus::OK,
170 "ContainerOccupancyDetector running\n");
172 DiagnosticNodelet::updateDiagnostic(stat);