Go to the documentation of this file.00001 #include "hole_detection_alg_node.h"
00002
00003 HoleDetectionAlgNode::HoleDetectionAlgNode(void) :
00004 algorithm_base::IriBaseAlgorithm<HoleDetectionAlgorithm>(),hole_min_p(60),box_y_end(0),box_z_ini(1),
00005 box_y_ini(-0.1),box_z_end(1.8),box_x(0.9)
00006 {
00007
00008
00009
00010
00011 this->hole_obstacle_publisher_ = this->public_node_handle_.advertise<sensor_msgs::PointCloud>("hole_obstacle", 10);
00012 this->hole_all_publisher_ = this->public_node_handle_.advertise<sensor_msgs::PointCloud2>("hole_zone", 10);
00013
00014 this->input_subscriber_ = this->public_node_handle_.subscribe("input", 10, &HoleDetectionAlgNode::input_callback, this);
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 }
00025
00026 HoleDetectionAlgNode::~HoleDetectionAlgNode(void)
00027 {
00028
00029 }
00030
00031 void HoleDetectionAlgNode::mainNodeThread(void)
00032 {
00033
00034
00035
00036
00037
00038
00039
00040
00041 }
00042
00043
00044 void HoleDetectionAlgNode::input_callback(const sensor_msgs::PointCloud2::ConstPtr& msg)
00045 {
00046 ROS_INFO("HoleDetectionAlgNode::input_callback: New Message Received");
00047
00048
00049
00050 pcl::fromROSMsg (*msg, cloud_in);
00051
00053 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_for (new pcl::PointCloud<pcl::PointXYZ>);
00054 cloud_for->header.frame_id = cloud_in.header.frame_id;
00055 cloud_for->is_dense=false;
00056 cloud_for->header.stamp = ros::Time::now ();
00058
00059
00060
00061 this->alg_.lock();
00062
00063 cloud_in_rgb.points.resize(cloud_in.size());
00064 for (size_t i = 0; i < cloud_in.points.size(); i++) {
00065 cloud_in_rgb.points[i].x = cloud_in.points[i].x;
00066 cloud_in_rgb.points[i].y = cloud_in.points[i].y;
00067 cloud_in_rgb.points[i].z = cloud_in.points[i].z;
00068 cloud_in_rgb.points[i].r = 0;
00069 cloud_in_rgb.points[i].g = 0;
00070 cloud_in_rgb.points[i].b = 0;
00071 }
00072 cloud_in_rgb.header.frame_id = cloud_in.header.frame_id;
00073 cloud_in_rgb.height = cloud_in.height;
00074 cloud_in_rgb.width = cloud_in.width;
00075
00076
00077
00078
00079
00080
00081 cloud_in_rgb.is_dense=false;
00082 cloud_in_rgb.header.stamp = ros::Time::now ();
00083
00084 hole_detect.cloud_all(hole_min_p, box_y_end, box_z_ini, box_x, box_y_ini, box_z_end, Xl, Xc, Xr, Y, cloud_in_rgb, cloud_for);
00085
00086 this->alg_.unlock();
00087
00089
00090 pcl::toROSMsg (*cloud_for, PointCloud2_msg_);
00091 pcl::toROSMsg (cloud_in_rgb, PointCloud2_msg_all);
00092
00093 sensor_msgs::convertPointCloud2ToPointCloud(PointCloud2_msg_, PointCloud_msg_);
00094
00095
00096 this->hole_obstacle_publisher_.publish(this->PointCloud_msg_);
00097 this->hole_all_publisher_.publish(this->PointCloud2_msg_all);
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 }
00109
00110
00111
00112
00113
00114
00115
00116 void HoleDetectionAlgNode::node_config_update(Config &config, uint32_t level)
00117 {
00118 this->alg_.lock();
00119 hole_min_p=config.hole_min_p;
00120 box_y_end=config.box_y_end;
00121 box_z_ini=config.box_z_ini;
00122 box_z_end=config.box_z_end;
00123 box_y_ini=config.box_y_ini;
00124 box_x=config.box_x;
00125 this->alg_.unlock();
00126 }
00127
00128 void HoleDetectionAlgNode::addNodeDiagnostics(void)
00129 {
00130 }
00131
00132
00133 int main(int argc,char *argv[])
00134 {
00135 return algorithm_base::main<HoleDetectionAlgNode>(argc, argv, "hole_detection_alg_node");
00136 }