normal_descriptor_alg_node.cpp
Go to the documentation of this file.
00001 #include "normal_descriptor_alg_node.h"
00002 
00003 NormalDescriptorAlgNode::NormalDescriptorAlgNode(void)
00004 {
00005   //init class attributes if necessary
00006   //this->loop_rate_ = 2;//in [Hz]
00007 
00008   // [init publishers]
00009   this->descriptor_publisher_ = this->public_node_handle_.advertise<normal_descriptor_node::ndesc_pc>("ndesc", 1); 
00010   // [init subscribers]
00011   this->points_subscriber_ = this->public_node_handle_.subscribe("points", 1, &NormalDescriptorAlgNode::points_callback, this);
00012   
00013   // [init services]
00014   this->point_desc_service_ = this->public_node_handle_.advertiseService("nornal_descriptor_service", &NormalDescriptorAlgNode::points_service_callback, this);
00015   
00016   // [init clients]
00017   
00018   // [init action servers]
00019   
00020   // [init action clients]
00021 }
00022 
00023 NormalDescriptorAlgNode::~NormalDescriptorAlgNode(void)
00024 {
00025   // [free dynamic memory]
00026 }
00027 
00028 void NormalDescriptorAlgNode::mainNodeThread(void)
00029 {
00030   // [fill msg structures]
00031   
00032   // [fill srv structure and make request to the server]
00033   
00034   // [fill action structure and make request to the action server]
00035 
00036   // [publish messages]
00037   
00038 }
00039 
00040 /*  [subscriber callbacks] */
00041 
00042 /*  [service callbacks] */
00043 
00044 /*  [action callbacks] */
00045 
00046 /*  [action requests] */
00047 
00048 void NormalDescriptorAlgNode::node_config_update(Config &config, uint32_t level)
00049 {
00050   ROS_INFO("Config update");
00051 }
00052 
00053 
00054 void NormalDescriptorAlgNode::compute_and_publish_descs(pcl::PointCloud<pcl::PointXYZ> &cloud, normal_descriptor_node::ndesc_pc &ndesc_pc_msg)
00055 {
00056   //Function just in case more processing was needed...
00057 
00058   this->alg_.compute_ndescs_integral_spatial(cloud, ndesc_pc_msg);
00059   //testing oriented version
00060   //this->alg_.compute_descriptor_spatial_rot_inv(cloud, ndesc_pc_msg);
00061 
00062 
00063 
00064   ndesc_pc_msg.header = pcl_conversions::fromPCL(cloud.header);
00065   //deprecated
00066   //ndesc_pc_msg = this->alg_.compute_ndescs(cloud);
00067   //ndesc_pc_msg = this->alg_.compute_ndescs_integral(cloud);  
00068 }
00069 
00070 
00071 void NormalDescriptorAlgNode::points_callback(const sensor_msgs::PointCloud2::ConstPtr& msg)
00072 {
00073   ROS_INFO("Received pointcloud in subscriber");
00074   pcl::PointCloud<pcl::PointXYZ> cloud;
00075   pcl::fromROSMsg(*msg, cloud);  
00076   normal_descriptor_node::ndesc_pc ndesc_pc_msg;
00077   this->compute_and_publish_descs(cloud, ndesc_pc_msg);
00078   this->descriptor_publisher_.publish(ndesc_pc_msg);
00079 }
00080 
00081 
00082 bool NormalDescriptorAlgNode::points_service_callback(normal_descriptor_node::ndesc_pc_service::Request &req, normal_descriptor_node::ndesc_pc_service::Response &res)
00083 {
00084   //ROS_INFO("disabled for now.");
00085   //return false;
00086   ROS_INFO("received ndesc_pc_service call");
00087   pcl::PointCloud<pcl::PointXYZ> cloud;
00088   pcl::fromROSMsg(req.cloth_cloud, cloud);
00089 
00090   this->compute_and_publish_descs(cloud, res.ndesc_pc_msg);
00091   return true; 
00092 }
00093 
00094 void NormalDescriptorAlgNode::addNodeDiagnostics(void)
00095 {
00096 }
00097 
00098 /* main function */
00099 int main(int argc,char *argv[])
00100 {
00101   return algorithm_base::main<NormalDescriptorAlgNode>(argc, argv, "normal_descriptor_node");
00102 }
00103 


normal_descriptor_node
Author(s): Arnau Ramisa
autogenerated on Fri Dec 6 2013 20:19:55