Class PointCloud2Modifier
Defined in File point_cloud2_iterator.hpp
Class Documentation
-
class PointCloud2Modifier
Enables modifying a sensor_msgs::msg::PointCloud2 like a container.
Public Functions
-
inline explicit PointCloud2Modifier(sensor_msgs::msg::PointCloud2 &cloud_msg)
Default constructor.
- Parameters:
cloud_msg – The sensor_msgs::msg::PointCloud2 to modify
-
inline size_t size() const
- Returns:
the number of T’s in the original sensor_msgs::msg::PointCloud2
-
inline void reserve(size_t size)
- Parameters:
size – The number of T’s to reserve in the original sensor_msgs::msg::PointCloud2 for
-
inline void resize(size_t size)
- Parameters:
size – The number of T’s to change the size of the original sensor_msgs::msg::PointCloud2 by
-
inline void clear()
remove all T’s from the original sensor_msgs::msg::PointCloud2
-
inline void setPointCloud2Fields(int n_fields, ...)
Function setting some fields in a PointCloud and adjusting the internals of the PointCloud2.
E.g, you create your PointCloud2 message with XYZ/RGB as follows:
WARNING: THIS DOES NOT TAKE INTO ACCOUNT ANY PADDING For simple usual cases, the overloaded setPointCloud2FieldsByString is what you want.* setPointCloud2Fields(cloud_msg, 4, "x", 1, sensor_msgs::msg::PointField::FLOAT32, * "y", 1, sensor_msgs::msg::PointField::FLOAT32, * "z", 1, sensor_msgs::msg::PointField::FLOAT32, * "rgb", 1, sensor_msgs::msg::PointField::FLOAT32); *
- Parameters:
n_fields – the number of fields to add. The fields are given as triplets: name of the field as char*, number of elements in the field, the datatype of the field, the datatype of the elements in the field
-
inline void setPointCloud2FieldsByString(int n_fields, ...)
Function setting some fields in a PointCloud and adjusting the internals of the PointCloud2.
WARNING: THIS FUNCTION ADDS ANY NECESSARY PADDING TRANSPARENTLY
- Parameters:
n_fields – the number of fields to add. The fields are given as strings: “xyz” (3 floats), “rgb” (3 uchar stacked in a float), “rgba” (4 uchar stacked in a float)
- Returns:
void
Protected Attributes
-
sensor_msgs::msg::PointCloud2 &cloud_msg_
A reference to the original sensor_msgs::msg::PointCloud2 that we read
-
inline explicit PointCloud2Modifier(sensor_msgs::msg::PointCloud2 &cloud_msg)