@@ -58,6 +58,7 @@ struct planeSegementationOutput
5858
5959
6060pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
61+ bool coefficients_set = false ;
6162
6263void convert_icp_eigen_to_tf (Eigen::Matrix4f Tm)
6364{
@@ -86,6 +87,7 @@ void convert_icp_eigen_to_tf(Eigen::Matrix4f Tm)
8687
8788void coefficients_callback (const pcl_msgs::ModelCoefficients& input)
8889{
90+ coefficients_set = true ;
8991 pcl_conversions::toPCL (input, *coefficients);
9092}
9193
@@ -154,6 +156,9 @@ pcl::SacModel model, Eigen::Vector3f plane_normal, bool invert_local)
154156void callback (const sensor_msgs::PointCloud2ConstPtr& input)
155157{
156158 // If Model Coefficients have been recieved:
159+ if (coefficients_set == false )
160+ return ;
161+
157162 Eigen::Vector3f plane_normal (coefficients->values [0 ], coefficients->values [1 ], coefficients->values [2 ]);
158163
159164 if (debug) ROS_INFO (" Got here." );
@@ -225,7 +230,7 @@ int main(int argc, char** argv)
225230{
226231 // Initialize ROS
227232 ros::init (argc, argv, " surface_normal_estimation" );
228- ros::NodeHandle nh (" ~" );
233+ ros::NodeHandle nh (" ~s " );
229234
230235 // Get params from launch file
231236 nh.getParam (" invert" , invert);
@@ -252,10 +257,12 @@ int main(int argc, char** argv)
252257 std::cout << " Co-efficients Topic: " << coefficients_topic << std::endl;
253258
254259 // Create a ROS subscriber for the input point cloud
255- ros::Subscriber sub = nh.subscribe (input_topic, 1 , callback);
256260 ros::Subscriber sub_coeff = nh.subscribe (" /ground_plane_segmentation/coefficients" , 1 , coefficients_callback);
261+ ros::Subscriber sub = nh.subscribe (input_topic, 1 , callback);
257262
258263 // Create a ROS publisher for the normal coefficients
264+ pcl_pub = nh.advertise <sensor_msgs::PointCloud2>(output_topic, 1 );
265+ // coef_pub = nh.advertise<pcl_msgs::ModelCoefficients>(coefficients_topic, 1);
259266 normal_x_pub = nh.advertise <pcl_msgs::ModelCoefficients>(" /surface_segmentation/normal_x_coefficients" , 1 );
260267 normal_y_pub = nh.advertise <pcl_msgs::ModelCoefficients>(" /surface_segmentation/normal_y_coefficients" , 1 );
261268 normal_z_pub = nh.advertise <pcl_msgs::ModelCoefficients>(" /surface_segmentation/normal_z_coefficients" , 1 );
0 commit comments