Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "ros/ros.h"
00030 #include "pluginlib/class_list_macros.h"
00031 #include "nodelet/nodelet.h"
00032
00033 #include "pcl/point_cloud.h"
00034 #include "pcl_ros/point_cloud.h"
00035 #include "pcl/point_types.h"
00036 #include "pcl/ros/conversions.h"
00037
00038 #include <boost/foreach.hpp>
00039
00040
00041
00042 namespace pcl_to_scan {
00043 typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
00044
00045 class HoleDetector: public nodelet::Nodelet {
00046 public:
00047
00048 HoleDetector() :
00049 threshold_(0.0), h_(0.4) {
00050 }
00051
00052 private:
00053 virtual void onInit() {
00054 ros::NodeHandle& nh = getNodeHandle();
00055 ros::NodeHandle& private_nh = getPrivateNodeHandle();
00056
00057
00058 private_nh.getParam("threshold", threshold_);
00059
00060 pub_ = nh.advertise<PointCloud> ("output", 10);
00061 sub_ = nh.subscribe<PointCloud> ("input", 10, &HoleDetector::callback, this);
00062 }
00063
00064 void callback(const PointCloud::ConstPtr& msg) {
00065 PointCloud::Ptr output (new PointCloud);
00066
00067 output->header = msg->header;
00068 output->height = msg->height;
00069 output->width = msg->width;
00070
00071 BOOST_FOREACH (pcl::PointXYZ pt, msg->points) {
00072 float vx, vy, vz, sc;
00073 if (pt.z > threshold_) {
00074
00075 } else {
00076 sc = h_ / (h_ - pt.z);
00077 pt.x = pt.x * sc;
00078 pt.y = pt.y * sc;
00079 pt.z = 0.1;
00080 }
00081
00082 output->points.push_back (pt);
00083 }
00084
00085 pub_.publish(output);
00086 }
00087
00088 double threshold_;
00089 double h_;
00090
00091 ros::Publisher pub_;
00092 ros::Subscriber sub_;
00093
00094 };
00095
00096 PLUGINLIB_DECLARE_CLASS(pcl_to_scan, HoleDetector, pcl_to_scan::HoleDetector, nodelet::Nodelet);
00097 }