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
00030
00031
00032
00033
00034
00035 #define BOOST_PARAMETER_MAX_ARITY 7
00036 #include "jsk_pcl_ros/organized_pointcloud_to_point_indices.h"
00037 #include "jsk_pcl_ros/pcl_conversion_util.h"
00038 #include <cv_bridge/cv_bridge.h>
00039 #include <sensor_msgs/image_encodings.h>
00040
00041 namespace jsk_pcl_ros
00042 {
00043 void OrganizedPointCloudToPointIndices::onInit()
00044 {
00045 DiagnosticNodelet::onInit();
00046 pub_ = advertise<PCLIndicesMsg>(*pnh_, "output", 1);
00047 }
00048
00049 void OrganizedPointCloudToPointIndices::subscribe()
00050 {
00051 sub_ = pnh_->subscribe("input", 1,
00052 &OrganizedPointCloudToPointIndices::indices,
00053 this);
00054 }
00055
00056 void OrganizedPointCloudToPointIndices::unsubscribe()
00057 {
00058 sub_.shutdown();
00059 }
00060
00061 void OrganizedPointCloudToPointIndices::updateDiagnostic(
00062 diagnostic_updater::DiagnosticStatusWrapper &stat)
00063 {
00064 if (vital_checker_->isAlive()) {
00065 stat.summary(diagnostic_msgs::DiagnosticStatus::OK,
00066 "OrganizedPointCloudToPointIndices running");
00067 }
00068 else {
00069 jsk_topic_tools::addDiagnosticErrorSummary(
00070 "OrganizedPointCloudToPointIndices", vital_checker_, stat);
00071 }
00072 }
00073
00074 void OrganizedPointCloudToPointIndices::indices(
00075 const sensor_msgs::PointCloud2::ConstPtr& point_msg)
00076 {
00077 pcl::PointCloud<pcl::PointXYZ>::Ptr pc(new pcl::PointCloud<pcl::PointXYZ>);
00078 pcl::fromROSMsg(*point_msg, *pc);
00079 if(pc->isOrganized()){
00080 PCLIndicesMsg indices_msg;
00081 indices_msg.header = point_msg->header;
00082 for (size_t i = 0; i < pc->points.size(); i++)
00083 if (!isnan(pc->points[i].x) && !isnan(pc->points[i].y) && !isnan(pc->points[i].z))
00084 indices_msg.indices.push_back(i);
00085 pub_.publish(indices_msg);
00086 }else{
00087 JSK_ROS_ERROR("Input Pointcloud is not organized");
00088 }
00089 }
00090 }
00091
00092 #include <pluginlib/class_list_macros.h>
00093 PLUGINLIB_EXPORT_CLASS (jsk_pcl_ros::OrganizedPointCloudToPointIndices, nodelet::Nodelet);