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);
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