diff --git a/hand_control/src/normal_estimator.cpp b/hand_control/src/normal_estimator.cpp index feb1e2a..7c6cc6d 100644 --- a/hand_control/src/normal_estimator.cpp +++ b/hand_control/src/normal_estimator.cpp @@ -9,16 +9,42 @@ typedef pcl::PointCloud PointCloud; typedef Eigen::Vector4f PCLCoord; // vecteur, accès par v(0), v(1)... typedef geometry_msgs::Quaternion ROSCoord; // struct : x, y, z, w -const ROSCoord::ConstPtr -PCLCoord_to_ROSCoord(const PCLCoord& pcl_coord) -{ - ROSCoord::Ptr ros_coord(new ROSCoord()); - ros_coord->x = pcl_coord(0); // a - ros_coord->y = pcl_coord(1); // b - ros_coord->z = pcl_coord(2); // c - ros_coord->w = pcl_coord(3); // d - return ros_coord; -} +class Callback { + public: + void + operator()(const PointCloud::ConstPtr& msg) + { + ROS_INFO("PointCloud received"); + PCLCoord pcl_coord(); + float curvature; + std::vector indices(); + // TODO : choisir tous les indices + estimator.computePointNormal(*msg, indices, + PCLCoord, curvature); + /* TODO + if (curvature < ? + publisher.publish(to_ROSCoord(pcl_coord)); + */ + } + + Callback(ros::Publisher& pub) : publisher(pub), estimator() {} + + private: + ros::Publisher publisher; + + pcl::NormalEstimationOMP estimator; + + const ROSCoord::ConstPtr + to_ROSCoord(const PCLCoord& pcl_coord) + { + ROSCoord::Ptr ros_coord(new ROSCoord()); + ros_coord->x = pcl_coord(0); // a + ros_coord->y = pcl_coord(1); // b + ros_coord->z = pcl_coord(2); // c + ros_coord->w = pcl_coord(3); // d + return ros_coord; + } +}; int main(int argc, char** argv)