Go to the documentation of this file.00001 #ifndef _points_from_volume_nodelet_CPP_
00002 #define _points_from_volume_nodelet_CPP_
00003
00010 #include <ros/ros.h>
00011 #include <points_from_volume/points_from_volume.h>
00012
00013
00014 ros::NodeHandle* p_n;
00015 ros::Publisher cloud_pub;
00016 bool defined_hull=false;
00017 double positive;
00018 double negative;
00019 bool flag;
00020
00021 points_from_volume<pcl::PointXYZ> piv;
00022
00029 void cloud_cb (const sensor_msgs::PointCloud2ConstPtr & pcmsg_in)
00030 {
00031 pcl::PointCloud<pcl::PointXYZ> pc_in;
00032 pcl::fromROSMsg(*pcmsg_in,pc_in);
00033 pcl::PointCloud<pcl::PointXYZ> pc_filtered;
00034 piv.convexhull_function(pc_in, positive, negative, flag);
00035 sensor_msgs::PointCloud2 pcmsg_out;
00036 pcl::toROSMsg(piv.get_pc_in_volume(), pcmsg_out);
00037
00038
00039 cloud_pub.publish(pcmsg_out);
00040 }
00041
00048 void cb_points_convexhull (const sensor_msgs::PointCloud2ConstPtr & pcmsg_convexhull_in)
00049 {
00050 printf("-------Flag is now True-------\n");
00051 piv.set_convex_hull(pcmsg_convexhull_in);
00052 defined_hull=true;
00053 }
00054
00055
00063 int main(int argc, char **argv)
00064 {
00065 ros::init(argc, argv, "points_from_volume_nodelet");
00066 ros::NodeHandle n("~");
00067
00068
00069 p_n=&n;
00070
00071
00072 if(!positive)
00073 {
00074 ROS_WARN_ONCE("Positive_offset not defined. Setting to default value '2.0'\n");
00075 n.param("positive_offset", positive, 2.0);
00076 }
00077 if(!negative)
00078 {
00079 ROS_WARN_ONCE("Negative_offset not defined. Setting to default value '-0.1'\n");
00080 n.param("negative_offset", negative, -0.1);
00081 }
00082 if(!flag)
00083 {
00084 ROS_WARN_ONCE("Flag_in_out not defined. Setting to default value 'false'\n");
00085 n.param("flag_in_out", flag, false);
00086 }
00087
00088
00089 ros::Subscriber sub1 = n.subscribe ("/points_convexhull", 1, cb_points_convexhull);
00090 ros::Subscriber sub2 = n.subscribe ("/point_cloud_input", 1, cloud_cb);
00091
00092 if(defined_hull==false)
00093 {
00094 ROS_WARN("No point cloud convexhull received yet...");
00095 }
00096
00097
00098 cloud_pub = n.advertise<sensor_msgs::PointCloud2>("/pcmsg_out", 1);
00099
00100 ros::Rate loop_rate(30);
00101 ros::spin();
00102 }
00103 #endif