pcl.h
Go to the documentation of this file.
1 #pragma once
2 
4 
6 
7 #ifdef ROS2 /**********************************************************************************************************/
9 
10 #include <pcl/point_cloud.h>
11 #include <pcl/point_types.h>
12 
13 #include <sensor_msgs/msg/point_cloud2.hpp>
14 
15 USING_MSG(sensor_msgs, PointCloud2)
16 
17 template <typename T>
19 
20 template <typename T>
22 
23 #define POINT_CLOUD_SUBSCRIPTION_CALLBACK(callback, T, arg_name) \
24  callback(const std::shared_ptr<sensor_msgs::msg::PointCloud2> arg_name)
25 
26 namespace ensenso
27 {
28 namespace pcl
29 {
30 template <typename T>
31 inline PointCloudPublisher<T> create_publisher(ensenso::ros::NodeHandle& nh, ::std::string const& topic_name,
32  int queue_size)
33 {
34  return nh->node()->create_publisher<sensor_msgs::msg::PointCloud2>(topic_name, queue_size);
35 }
36 
37 template <typename T, typename C, typename M>
38 inline PointCloudSubscription<T> create_subscription(ensenso::ros::NodeHandle& nh, ::std::string const& topic_name,
39  int queue_size, void (C::*callback)(M), C* object)
40 {
41  return ensenso::ros::create_subscription<sensor_msgs::msg::PointCloud2>(nh, topic_name, queue_size, callback, object);
42 }
43 } // namespace pcl
44 } // namespace ensenso
45 
46 #define STORE_POINT_CLOUD(point_cloud_msg, point_cloud_pcl) \
47  /* In ROS2 we have to convert from sensor_msgs PointCloud2 to PCL PointCloud2. */ \
48  pcl::fromROSMsg(*point_cloud_msg, *point_cloud_pcl);
49 
50 template <typename T>
52  std::unique_ptr<T> pointCloud)
53 {
54  auto cloudMsg = ensenso::std::make_unique<sensor_msgs::msg::PointCloud2>();
55  pcl::toROSMsg(*pointCloud, *cloudMsg);
56  publisher->publish(std::move(cloudMsg));
57 }
58 
59 #else /***ROS1*********************************************************************************************************/
60 #include <pcl_ros/point_cloud.h>
61 
62 template <typename T>
64 
65 template <typename T>
67 
68 #define POINT_CLOUD_SUBSCRIPTION_CALLBACK(callback, T, arg_name) callback(T::Ptr const& arg_name)
69 
70 namespace ensenso
71 {
72 namespace pcl
73 {
74 template <typename T>
75 inline PointCloudPublisher<T> create_publisher(ensenso::ros::NodeHandle& nh, ::std::string const& topic_name,
76  int queue_size)
77 {
78  return ensenso::ros::create_publisher<T>(nh, topic_name, queue_size);
79 }
80 
81 template <typename T, typename C, typename M>
82 inline PointCloudSubscription<T> create_subscription(ensenso::ros::NodeHandle& nh, ::std::string const& topic_name,
83  int queue_size, void (C::*callback)(M), C* object)
84 {
85  return ensenso::ros::create_subscription<T>(nh, topic_name, queue_size, callback, object);
86 }
87 } // namespace pcl
88 } // namespace ensenso
89 
90 #define STORE_POINT_CLOUD(point_cloud_boost_ptr, point_cloud_std_ptr) \
91  /* In ROS1 we only have to convert the point cloud ptr from boost to std. */ \
92  point_cloud_std_ptr = ensenso::std::to_std(point_cloud_boost_ptr);
93 
94 template <typename T>
95 inline void publishPointCloud(ensenso::ros::Publisher<T> const& publisher, std::unique_ptr<T> pointCloud)
96 {
97  auto cloud_ = boost::shared_ptr<T>(std::move(pointCloud));
98  publisher->publish(cloud_);
99 }
100 #endif
PointCloudSubscription< T > create_subscription(ensenso::ros::NodeHandle &nh, ::std::string const &topic_name, int queue_size, void(C::*callback)(M), C *object)
Definition: pcl.h:82
ensenso::ros::Publisher< T > PointCloudPublisher
Definition: pcl.h:63
void publishPointCloud(ensenso::ros::Publisher< T > const &publisher, std::unique_ptr< T > pointCloud)
Definition: pcl.h:95
#define USING_MSG(PACKAGE_NAME, MSG_NAME)
Definition: namespace.h:43
::ros::NodeHandle NodeHandle
Definition: node.h:214
::std::unique_ptr< ::ros::Publisher > Publisher
Definition: core.h:115
void toROSMsg(const sensor_msgs::PointCloud2 &cloud, sensor_msgs::Image &image)
PointCloudPublisher< T > create_publisher(ensenso::ros::NodeHandle &nh, ::std::string const &topic_name, int queue_size)
Definition: pcl.h:75


ensenso_camera
Author(s): Ensenso
autogenerated on Sat Jun 3 2023 02:17:04