planar_pointcloud_simulator_nodelet.cpp
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2015, 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 #define BOOST_PARAMETER_MAX_ARITY 7
38 
39 namespace jsk_pcl_ros_utils
40 {
42  {
43 
44  }
45 
47  {
48 
49  }
50 
52  const sensor_msgs::CameraInfo& info, double distance,
53  pcl::PointCloud<pcl::PointXYZ>& cloud)
54  {
56  model.fromCameraInfo(info);
57  cloud.points.resize(info.width * info.height);
58  cloud.is_dense = true;
59  for (size_t j = 0; j < info.height; j++) {
60  for (size_t i = 0; i < info.width; i++) {
61  cv::Point3d ray = model.projectPixelTo3dRay(cv::Point2d(i, j));
62  pcl::PointXYZ p;
63  p.x = ray.x * distance;
64  p.y = ray.y * distance;
65  p.z = ray.z * distance;
66  cloud.points[j * info.width + i] = p;
67  }
68  }
69  cloud.width = info.width;
70  cloud.height = info.height;
71  }
72 
74  {
75  DiagnosticNodelet::onInit();
76  srv_ = boost::make_shared <dynamic_reconfigure::Server<Config> > (*pnh_);
77  typename dynamic_reconfigure::Server<Config>::CallbackType f =
79  srv_->setCallback (f);
80 
81  pub_ = advertise<sensor_msgs::PointCloud2>(
82  *pnh_, "output", 1);
83 
84  onInitPostProcess();
85  }
86 
88  {
89  sub_ = pnh_->subscribe(
91  }
92 
94  {
95  sub_.shutdown();
96  }
97 
99  Config &config, uint32_t level)
100  {
101  boost::mutex::scoped_lock lock(mutex_);
102  distance_ = config.distance;
103  }
104 
106  const sensor_msgs::CameraInfo::ConstPtr& info_msg)
107  {
108  boost::mutex::scoped_lock lock(mutex_);
109  vital_checker_->poke();
110  pcl::PointCloud<pcl::PointXYZ>::Ptr
111  cloud(new pcl::PointCloud<pcl::PointXYZ>);
113  sensor_msgs::PointCloud2 ros_cloud;
114  pcl::toROSMsg(*cloud, ros_cloud);
115  ros_cloud.header = info_msg->header;
116  pub_.publish(ros_cloud);
117  }
118 
119 }
120 
jsk_pcl_ros_utils
Definition: add_point_indices.h:51
jsk_pcl_ros_utils::PlanarPointCloudSimulator::generate
virtual void generate(const sensor_msgs::CameraInfo &info, double distance, pcl::PointCloud< pcl::PointXYZ > &cloud)
Generate a pointcloud according to width, height and distance.
Definition: planar_pointcloud_simulator_nodelet.cpp:51
jsk_pcl_ros_utils::PlanarPointCloudSimulator::~PlanarPointCloudSimulator
virtual ~PlanarPointCloudSimulator()
Definition: planar_pointcloud_simulator_nodelet.cpp:46
jsk_pcl_ros_utils::PlanarPointCloudSimulatorNodelet::impl_
PlanarPointCloudSimulator impl_
Definition: planar_pointcloud_simulator.h:130
jsk_pcl_ros_utils::PlanarPointCloudSimulatorNodelet::mutex_
boost::mutex mutex_
Definition: planar_pointcloud_simulator.h:126
_2
boost::arg< 2 > _2
i
int i
jsk_pcl_ros_utils::PlanarPointCloudSimulatorNodelet::unsubscribe
virtual void unsubscribe()
Definition: planar_pointcloud_simulator_nodelet.cpp:93
pinhole_camera_model.h
p
p
lock
lock
jsk_pcl_ros_utils::PlanarPointCloudSimulator::PlanarPointCloudSimulator
PlanarPointCloudSimulator()
Definition: planar_pointcloud_simulator_nodelet.cpp:41
jsk_pcl_ros_utils::PlanarPointCloudSimulatorNodelet::onInit
virtual void onInit()
Definition: planar_pointcloud_simulator_nodelet.cpp:73
jsk_pcl_ros_utils::PlanarPointCloudSimulatorNodelet::Config
PlanarPointCloudSimulatorConfig Config
Definition: planar_pointcloud_simulator.h:110
jsk_pcl_ros_utils::PlanarPointCloudSimulatorNodelet::distance_
double distance_
Definition: planar_pointcloud_simulator.h:131
image_geometry::PinholeCameraModel::projectPixelTo3dRay
cv::Point3d projectPixelTo3dRay(const cv::Point2d &uv_rect) const
ros::Subscriber::shutdown
void shutdown()
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
sample_camera_info_and_pointcloud_publisher.cloud
cloud
Definition: sample_camera_info_and_pointcloud_publisher.py:30
jsk_pcl_ros_utils::PlanarPointCloudSimulatorNodelet::pub_
ros::Publisher pub_
Definition: planar_pointcloud_simulator.h:129
class_list_macros.h
jsk_pcl_ros_utils::PlanarPointCloudSimulatorNodelet::sub_
ros::Subscriber sub_
Definition: planar_pointcloud_simulator.h:128
image_geometry::PinholeCameraModel::fromCameraInfo
bool fromCameraInfo(const sensor_msgs::CameraInfo &msg)
jsk_pcl_ros_utils::PlanarPointCloudSimulatorNodelet
Nodelet implementation of jsk_pcl/PlanarPointCloudSimulator.
Definition: planar_pointcloud_simulator.h:106
jsk_pcl_ros_utils::PlanarPointCloudSimulatorNodelet::srv_
boost::shared_ptr< dynamic_reconfigure::Server< Config > > srv_
Definition: planar_pointcloud_simulator.h:127
_1
boost::arg< 1 > _1
distance
template void distance(DistanceTraversalNodeBase< double > *node, BVHFrontList *front_list, int qsize)
f
f
jsk_pcl_ros_utils::PlanarPointCloudSimulatorNodelet::subscribe
virtual void subscribe()
Definition: planar_pointcloud_simulator_nodelet.cpp:87
nodelet::Nodelet
image_geometry::PinholeCameraModel
pcl::toROSMsg
void toROSMsg(const pcl::PointCloud< T > &cloud, sensor_msgs::Image &msg)
jsk_pcl_ros_utils::PlanarPointCloudSimulatorNodelet::generate
virtual void generate(const sensor_msgs::CameraInfo::ConstPtr &info_msg)
Callback function for ~input.
Definition: planar_pointcloud_simulator_nodelet.cpp:105
PLUGINLIB_EXPORT_CLASS
PLUGINLIB_EXPORT_CLASS(jsk_pcl_ros_utils::PlanarPointCloudSimulatorNodelet, nodelet::Nodelet)
planar_pointcloud_simulator.h
config
config
info_msg
info_msg
jsk_pcl_ros_utils::PlanarPointCloudSimulatorNodelet::configCallback
virtual void configCallback(Config &config, uint32_t level)
Definition: planar_pointcloud_simulator_nodelet.cpp:98


jsk_pcl_ros_utils
Author(s): Yohei Kakiuchi
autogenerated on Fri May 16 2025 03:11:43