heightmap_to_pointcloud_nodelet.cpp
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2014, JSK Lab
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of the JSK Lab nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 #define BOOST_PARAMETER_MAX_ARITY 7
37 
40 #include <cv_bridge/cv_bridge.h>
42 #include <pcl/point_cloud.h>
43 #include <pcl/point_types.h>
44 
45 namespace jsk_pcl_ros
46 {
48  {
49  DiagnosticNodelet::onInit();
50  pub_config_ = pnh_->advertise<jsk_recognition_msgs::HeightmapConfig>(
51  "output/config", 1);
52  sub_config_ = pnh_->subscribe(
53  getHeightmapConfigTopic(pnh_->resolveName("input")), 1,
55  pub_ = advertise<sensor_msgs::PointCloud2>(*pnh_, "output", 1);
56  onInitPostProcess();
57  }
58 
60  {
61  sub_ = pnh_->subscribe("input", 1, &HeightmapToPointCloud::convert, this);
62  }
63 
65  {
66  sub_.shutdown();
67  }
68 
70  const jsk_recognition_msgs::HeightmapConfig::ConstPtr& msg)
71  {
72  boost::mutex::scoped_lock lock(mutex_);
73  config_msg_ = msg;
74  min_x_ = msg->min_x;
75  max_x_ = msg->max_x;
76  min_y_ = msg->min_y;
77  max_y_ = msg->max_y;
79  }
80 
81  void HeightmapToPointCloud::convert(const sensor_msgs::Image::ConstPtr& msg)
82  {
83  boost::mutex::scoped_lock lock(mutex_);
84  if (!config_msg_) {
85  NODELET_ERROR("no ~input/config is yet available");
86  return;
87  }
88 
90  pcl::PointCloud<HeightMapPointType > cloud;
91 
92  bool keep_organized;
93  pnh_->param("keep_organized", keep_organized, false);
94  if (keep_organized) {
96  }
97  else {
99  }
100 
101  sensor_msgs::PointCloud2 ros_cloud;
102  pcl::toROSMsg(cloud, ros_cloud);
103  ros_cloud.header = msg->header;
104  pub_.publish(ros_cloud);
105  }
106 }
107 
jsk_pcl_ros::HeightmapToPointCloud::max_y_
double max_y_
Definition: heightmap_to_pointcloud.h:135
jsk_pcl_ros::HeightmapToPointCloud::min_y_
double min_y_
Definition: heightmap_to_pointcloud.h:134
NODELET_ERROR
#define NODELET_ERROR(...)
depth_error_calibration.lock
lock
Definition: depth_error_calibration.py:32
image_encodings.h
PLUGINLIB_EXPORT_CLASS
PLUGINLIB_EXPORT_CLASS(jsk_pcl_ros::HeightmapToPointCloud, nodelet::Nodelet)
jsk_pcl_ros::HeightmapToPointCloud::mutex_
boost::mutex mutex_
Definition: heightmap_to_pointcloud.h:127
ros::Subscriber::shutdown
void shutdown()
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
cloud
cloud
class_list_macros.h
jsk_pcl_ros::HeightmapToPointCloud::sub_
ros::Subscriber sub_
Definition: heightmap_to_pointcloud.h:130
jsk_pcl_ros
Definition: add_color_from_image.h:51
jsk_pcl_ros::convertHeightMapToPCL
void convertHeightMapToPCL(const cv::Mat &float_image, pcl::PointCloud< HeightMapPointType > &cloud, float max_x_, float min_x_, float max_y_, float min_y_)
Definition: heightmap_utils.h:84
jsk_pcl_ros::getHeightmapConfigTopic
std::string getHeightmapConfigTopic(const std::string &base_topic)
Definition: heightmap_utils.h:79
jsk_pcl_ros::HeightmapToPointCloud::config_msg_
jsk_recognition_msgs::HeightmapConfig::ConstPtr config_msg_
Definition: heightmap_to_pointcloud.h:126
jsk_pcl_ros::HeightmapToPointCloud::onInit
virtual void onInit()
Definition: heightmap_to_pointcloud_nodelet.cpp:47
jsk_pcl_ros::HeightmapToPointCloud::pub_config_
ros::Publisher pub_config_
Definition: heightmap_to_pointcloud.h:129
jsk_pcl_ros::HeightmapToPointCloud::min_x_
double min_x_
Definition: heightmap_to_pointcloud.h:132
jsk_pcl_ros::HeightmapToPointCloud::convert
virtual void convert(const sensor_msgs::Image::ConstPtr &msg)
Definition: heightmap_to_pointcloud_nodelet.cpp:81
sensor_msgs::image_encodings::TYPE_32FC2
const std::string TYPE_32FC2
jsk_pcl_ros::HeightmapToPointCloud::subscribe
virtual void subscribe()
Definition: heightmap_to_pointcloud_nodelet.cpp:59
nodelet::Nodelet
jsk_pcl_ros::HeightmapToPointCloud::configCallback
virtual void configCallback(const jsk_recognition_msgs::HeightmapConfig::ConstPtr &msg)
Definition: heightmap_to_pointcloud_nodelet.cpp:69
cv_bridge.h
jsk_pcl_ros::convertHeightMapToPCLOrganize
void convertHeightMapToPCLOrganize(const cv::Mat &float_image, pcl::PointCloud< HeightMapPointType > &cloud, float max_x_, float min_x_, float max_y_, float min_y_)
Definition: heightmap_utils.h:109
jsk_pcl_ros::HeightmapToPointCloud
Definition: heightmap_to_pointcloud.h:81
heightmap_to_pointcloud.h
pcl::toROSMsg
void toROSMsg(const pcl::PointCloud< T > &cloud, sensor_msgs::Image &msg)
jsk_pcl_ros::HeightmapToPointCloud::sub_config_
ros::Subscriber sub_config_
Definition: heightmap_to_pointcloud.h:131
cv_bridge::toCvShare
CvImageConstPtr toCvShare(const sensor_msgs::Image &source, const boost::shared_ptr< void const > &tracked_object, const std::string &encoding=std::string())
jsk_pcl_ros::HeightmapToPointCloud::unsubscribe
virtual void unsubscribe()
Definition: heightmap_to_pointcloud_nodelet.cpp:64
jsk_pcl_ros::HeightmapToPointCloud::pub_
ros::Publisher pub_
Definition: heightmap_to_pointcloud.h:128
pose_with_covariance_sample.msg
msg
Definition: pose_with_covariance_sample.py:22
jsk_pcl_ros::HeightmapToPointCloud::max_x_
double max_x_
Definition: heightmap_to_pointcloud.h:133
pcl_conversions.h


jsk_pcl_ros
Author(s): Yohei Kakiuchi
autogenerated on Tue Jan 7 2025 04:05:44