point_cloud_utilities.h
Go to the documentation of this file.
1 
34 #ifndef MULTISENSE_ROS_POINT_CLOUD_UTILITY_H
35 #define MULTISENSE_ROS_POINT_CLOUD_UTILITY_H
36 
37 #include <arpa/inet.h>
38 
39 #include <sensor_msgs/PointCloud2.h>
40 
41 namespace multisense_ros {
42 
43 template <typename T>
44 uint8_t message_format();
45 
46 template <typename T>
47 sensor_msgs::PointCloud2 initialize_pointcloud(bool dense,
48  const std::string& frame_id,
49  const std::string &color_channel)
50 {
51  const auto datatype = message_format<T>();
52 
53  sensor_msgs::PointCloud2 point_cloud;
54  point_cloud.is_bigendian = (htonl(1) == 1);
55  point_cloud.is_dense = dense;
56  point_cloud.point_step = 4 * sizeof(T);
57  point_cloud.header.frame_id = frame_id;
58  point_cloud.fields.resize(4);
59  point_cloud.fields[0].name = "x";
60  point_cloud.fields[0].offset = 0;
61  point_cloud.fields[0].count = 1;
62  point_cloud.fields[0].datatype = datatype;
63  point_cloud.fields[1].name = "y";
64  point_cloud.fields[1].offset = sizeof(T);
65  point_cloud.fields[1].count = 1;
66  point_cloud.fields[1].datatype = datatype;
67  point_cloud.fields[2].name = "z";
68  point_cloud.fields[2].offset = 2 * sizeof(T);
69  point_cloud.fields[2].count = 1;
70  point_cloud.fields[2].datatype = datatype;
71  point_cloud.fields[3].name = color_channel;
72  point_cloud.fields[3].offset = 3 * sizeof(T);
73  point_cloud.fields[3].count = 1;
74  point_cloud.fields[3].datatype = datatype;
75 
76  return point_cloud;
77 }
78 
79 
80 }// namespace
81 
82 #endif
uint8_t message_format()
sensor_msgs::PointCloud2 initialize_pointcloud(bool dense, const std::string &frame_id, const std::string &color_channel)


multisense_ros
Author(s):
autogenerated on Sun Mar 14 2021 02:34:55