36 #define BOOST_PARAMETER_MAX_ARITY 7
46 DiagnosticNodelet::onInit();
56 pub_polygons_ = advertise<jsk_recognition_msgs::PolygonArray>(
57 *pnh_,
"output/polygons", 1);
59 *pnh_,
"output/coefficients", 1);
61 pub_indices_ = advertise<jsk_recognition_msgs::ClusterPointIndices>(
62 *pnh_,
"output/indices", 1);
80 sync_ = boost::make_shared<message_filters::Synchronizer<SyncPolicy> >(
queue_size_);
102 const jsk_recognition_msgs::PolygonArray::ConstPtr& polygons_msg)
104 jsk_recognition_msgs::ClusterPointIndices indices;
105 indices.header.stamp = polygons_msg->header.stamp;
106 indices.cluster_indices.resize(polygons_msg->polygons.size());
108 boost::make_shared<jsk_recognition_msgs::ClusterPointIndices>(indices));
112 const jsk_recognition_msgs::PolygonArray::ConstPtr& polygons_msg,
113 const jsk_recognition_msgs::ClusterPointIndices::ConstPtr& indices_msg,
114 const jsk_recognition_msgs::ModelCoefficientsArray::ConstPtr& coefficients_msg)
116 vital_checker_->poke();
117 if (polygons_msg->polygons.size() != coefficients_msg->coefficients.size()) {
118 NODELET_ERROR(
"The size of polygons and coefficients are not same");
121 jsk_recognition_msgs::PolygonArray flipped_polygons = *polygons_msg;
122 jsk_recognition_msgs::ModelCoefficientsArray flipped_coefficients;
123 jsk_recognition_msgs::ClusterPointIndices flipped_indices;
124 flipped_polygons.polygons.clear();
125 flipped_coefficients.header = coefficients_msg->header;
126 flipped_indices.header = indices_msg->header;
128 for (
size_t i = 0;
i < polygons_msg->polygons.size();
i++) {
129 geometry_msgs::PolygonStamped target_polygon = polygons_msg->polygons[
i];
137 Eigen::Affine3f sensor_transform;
142 Eigen::Vector3f polygon_normal = convex.
getNormal();
143 if (polygon_normal.dot(Eigen::Vector3f(sensor_transform.translation()))
145 geometry_msgs::PolygonStamped flipped_polygon;
147 target_polygon.polygon.points.begin(),
148 target_polygon.polygon.points.end(),
149 std::back_inserter(flipped_polygon.polygon.points));
150 flipped_polygon.header = target_polygon.header;
151 flipped_polygons.polygons.push_back(flipped_polygon);
154 flipped_polygons.polygons.push_back(target_polygon);
160 Eigen::Vector3f local_normal(target_coefficients.values[0],
161 target_coefficients.values[1],
162 target_coefficients.values[2]);
163 if (local_normal.dot(Eigen::Vector3f(sensor_transform.translation()))
167 for (
size_t j = 0; j < target_coefficients.values.size(); j++) {
168 the_flipped_coefficients.values.push_back(
169 - target_coefficients.values[j]);
171 std::reverse_copy(target_indices.indices.begin(), target_indices.indices.end(),
172 std::back_inserter(the_flipped_indices.indices));
173 the_flipped_coefficients.header = target_coefficients.header;
174 the_flipped_indices.header = target_indices.header;
175 flipped_coefficients.coefficients.push_back(the_flipped_coefficients);
177 flipped_indices.cluster_indices.push_back(the_flipped_indices);
182 flipped_coefficients.coefficients.push_back(target_coefficients);
183 flipped_indices.cluster_indices.push_back(target_indices);
193 NODELET_ERROR(
"Failed to lookup transformation: %s", e.what());