39 #ifndef SENSOR_MSGS_POINT_CLOUD_CONVERSION_H
40 #define SENSOR_MSGS_POINT_CLOUD_CONVERSION_H
44 #include <sensor_msgs/point_field_conversion.h>
60 for (
size_t d = 0;
d < cloud.
fields.size (); ++
d)
61 if (cloud.
fields[
d].name == field_name)
81 for (
size_t d = 0;
d < output.
fields.size (); ++
d, offset += 4)
83 output.
fields[
d].offset = offset;
97 for (
size_t cp = 0; cp < input.
points.size (); ++cp)
102 for (
size_t d = 0;
d < input.
channels.size (); ++
d)
128 if (x_idx == -1 || y_idx == -1 || z_idx == -1)
130 std::cerr <<
"x/y/z coordinates not found! Cannot convert to sensor_msgs::PointCloud!" << std::endl;
133 int x_offset = input.
fields[x_idx].offset;
134 int y_offset = input.
fields[y_idx].offset;
135 int z_offset = input.
fields[z_idx].offset;
136 uint8_t x_datatype = input.
fields[x_idx].datatype;
137 uint8_t y_datatype = input.
fields[y_idx].datatype;
138 uint8_t z_datatype = input.
fields[z_idx].datatype;
142 for (
size_t d = 0;
d < input.
fields.size (); ++
d)
144 if ((
int)input.
fields[
d].offset == x_offset || (
int)input.
fields[
d].offset == y_offset || (
int)input.
fields[
d].offset == z_offset)
152 for (
size_t cp = 0; cp < output.
points.size (); ++cp)
155 output.
points[cp].x = sensor_msgs::readPointCloud2BufferValue<float>(&input.
data[cp * input.
point_step + x_offset], x_datatype);
156 output.
points[cp].y = sensor_msgs::readPointCloud2BufferValue<float>(&input.
data[cp * input.
point_step + y_offset], y_datatype);
157 output.
points[cp].z = sensor_msgs::readPointCloud2BufferValue<float>(&input.
data[cp * input.
point_step + z_offset], z_datatype);
160 for (
size_t d = 0;
d < input.
fields.size (); ++
d)
162 if ((
int)input.
fields[
d].offset == x_offset || (
int)input.
fields[
d].offset == y_offset || (
int)input.
fields[
d].offset == z_offset)
170 #endif// SENSOR_MSGS_POINT_CLOUD_CONVERSION_H