21 #ifndef GZ_MSGS_POINTCLOUDPACKEDUTILS_HH_
22 #define GZ_MSGS_POINTCLOUDPACKEDUTILS_HH_
24 #include <gz/msgs/pointcloud_packed.pb.h>
33 #include "gz/msgs/config.hh"
34 #include "gz/msgs/detail/PointCloudPackedUtils.hh"
35 #include <gz/math/Helpers.hh>
45 msgs::PointCloudPacked::Field::DataType>> &_fields)
51 msgs::PointCloudPacked::Field::DataType)> initPointCloudPackedHelper =
53 msgs::PointCloudPacked::Field::DataType _type) ->
void
55 msgs::PointCloudPacked::Field *newField = _msg.add_field();
56 newField->set_name(_name);
57 newField->set_count(1);
58 newField->set_datatype(_type);
59 newField->set_offset(offset);
62 case msgs::PointCloudPacked::Field::INT8:
63 case msgs::PointCloudPacked::Field::UINT8:
66 case msgs::PointCloudPacked::Field::INT16:
67 case msgs::PointCloudPacked::Field::UINT16:
70 case msgs::PointCloudPacked::Field::INT32:
71 case msgs::PointCloudPacked::Field::UINT32:
72 case msgs::PointCloudPacked::Field::FLOAT32:
75 case msgs::PointCloudPacked::Field::FLOAT64:
80 std::cerr <<
"PointCloudPacked field datatype of ["
81 << _type <<
"] is invalid.\n";
88 _msg.mutable_header()->clear_data();
89 msgs::Header::Map *frame = _msg.mutable_header()->add_data();
90 frame->set_key(
"frame_id");
91 frame->add_value(_frameId);
96 msgs::PointCloudPacked::Field::DataType> &field : _fields)
98 if (field.first ==
"xyz")
100 initPointCloudPackedHelper(
"x", field.second);
101 initPointCloudPackedHelper(
"y", field.second);
102 initPointCloudPackedHelper(
"z", field.second);
106 initPointCloudPackedHelper(field.first, field.second);
118 _msg.set_point_step(offset);
150 template<
typename FieldType>
152 :
public PointCloudPackedIteratorBase<
153 FieldType, FieldType, char, PointCloudPacked, PointCloudPackedIterator>
158 : PointCloudPackedIteratorBase<FieldType, FieldType, char,
160 ::PointCloudPackedIteratorBase(_cloudMsg, _fieldName)
167 template<
typename FieldType>
169 :
public PointCloudPackedIteratorBase<
170 FieldType, const FieldType, const char, const PointCloudPacked,
171 PointCloudPackedConstIterator>
174 const PointCloudPacked &_cloudMsg,
176 : PointCloudPackedIteratorBase<FieldType, const FieldType, const char,
177 const PointCloudPacked,
179 >::PointCloudPackedIteratorBase(_cloudMsg, _fieldName)
190 PointCloudPacked::Field::DataType _dataType)
192 if ((_dataType == PointCloudPacked::Field::INT8) ||
193 (_dataType == PointCloudPacked::Field::UINT8))
197 else if ((_dataType == PointCloudPacked::Field::INT16) ||
198 (_dataType == PointCloudPacked::Field::UINT16))
202 else if ((_dataType == PointCloudPacked::Field::INT32) ||
203 (_dataType == PointCloudPacked::Field::UINT32) ||
204 (_dataType == PointCloudPacked::Field::FLOAT32))
208 else if (_dataType == PointCloudPacked::Field::FLOAT64)
214 std::cerr <<
"PointCloudPacked::Field of type [" << _dataType