Implements a point cloud (with contiguous storage), whose main goal is to offer a convenient, synchronized interface to commonly used fields and data types applicable for basic 3D perception.
This is a mix between the philosophy of PCL (templated interface to provide a compile-time open set, run-time closed set) and VTK (non-templated interface to provide a very free form run-time open set).
Definitions:
This point cloud class provides the following fields:
#include <drake/perception/point_cloud.h>
Public Types | |
| using | T = float |
| Geometric scalar type. | |
| using | C = uint8_t |
| Color channel scalar type. | |
| using | D = T |
| Descriptor scalar type. | |
Public Member Functions | |
| PointCloud (int new_size=0, pc_flags::Fields fields=pc_flags::kXYZs, bool skip_initialize=false) | |
| Constructs a point cloud of a given new_size, with the prescribed fields. | |
| PointCloud (const PointCloud &other) | |
| Copies another point cloud's fields and data. | |
| PointCloud (PointCloud &&other) | |
| Takes ownership of another point cloud's data. | |
| PointCloud (const PointCloud &other, pc_flags::Fields copy_fields) | |
| Copies another point cloud's fields and data. | |
| PointCloud & | operator= (const PointCloud &other) |
| PointCloud & | operator= (PointCloud &&other) |
| ~PointCloud () | |
| pc_flags::Fields | fields () const |
| Returns the fields provided by this point cloud. | |
| int | size () const |
| Returns the number of points in this point cloud. | |
| void | resize (int new_size, bool skip_initialize=false) |
| Conservative resize; will maintain existing data, and initialize new data to their invalid values. | |
| PointCloud | VoxelizedDownSample (double voxel_size, Parallelism parallelize=false) const |
| Returns a down-sampled point cloud by grouping all xyzs in this cloud into a 3D grid with cells of dimension voxel_size. | |
| bool | EstimateNormals (double radius, int num_closest, Parallelism parallelize=false) |
| Estimates the normal vectors in this by fitting a plane at each point in the cloud using up to num_closest points within Euclidean distance radius from the point. | |
Geometric Descriptors - XYZs | |
| bool | has_xyzs () const |
| Returns if this cloud provides XYZ values. | |
| Eigen::Ref< const Matrix3X< T > > | xyzs () const |
| Returns access to XYZ values. | |
| Eigen::Ref< Matrix3X< T > > | mutable_xyzs () |
| Returns mutable access to XYZ values. | |
| Vector3< T > | xyz (int i) const |
| Returns access to an XYZ value. | |
| Eigen::Ref< Vector3< T > > | mutable_xyz (int i) |
| Returns mutable access to an XYZ value. | |
Geometric Descriptors - Normals | |
| bool | has_normals () const |
| Returns if this cloud provides normals. | |
| Eigen::Ref< const Matrix3X< T > > | normals () const |
| Returns access to normals. | |
| Eigen::Ref< Matrix3X< T > > | mutable_normals () |
| Returns mutable access to normals. | |
| Vector3< T > | normal (int i) const |
| Returns access to a normal. | |
| Eigen::Ref< Vector3< T > > | mutable_normal (int i) |
| Returns mutable access to a normal. | |
Geometric Descriptors - RGBs | |
| bool | has_rgbs () const |
| Returns if this cloud provides RGB colors. | |
| Eigen::Ref< const Matrix3X< C > > | rgbs () const |
| Returns access to RGB colors. | |
| Eigen::Ref< Matrix3X< C > > | mutable_rgbs () |
| Returns mutable access to RGB colors. | |
| Vector3< C > | rgb (int i) const |
| Returns access to an RGB color. | |
| Eigen::Ref< Vector3< C > > | mutable_rgb (int i) |
| Returns mutable access to an RGB color. | |
Run-Time Descriptors | |
| bool | has_descriptors () const |
| Returns if this point cloud provides descriptor values. | |
| bool | has_descriptors (const pc_flags::DescriptorType &descriptor_type) const |
| Returns if the point cloud provides a specific descriptor. | |
| const pc_flags::DescriptorType & | descriptor_type () const |
| Returns the descriptor type. | |
| Eigen::Ref< const MatrixX< D > > | descriptors () const |
| Returns access to descriptor values. | |
| Eigen::Ref< MatrixX< D > > | mutable_descriptors () |
| Returns mutable access to descriptor values. | |
| VectorX< D > | descriptor (int i) const |
| Returns access to a descriptor value. | |
| Eigen::Ref< VectorX< D > > | mutable_descriptor (int i) |
| Returns mutable access to a descriptor value. | |
Container Manipulation | |
| void | SetFrom (const PointCloud &other, pc_flags::Fields fields_in=pc_flags::kInherit, bool allow_resize=true) |
| Copies all points from another point cloud. | |
| void | Expand (int add_size, bool skip_initialization=false) |
| Adds add_size default-initialized points. | |
Fields | |
| void | SetFields (pc_flags::Fields new_fields, bool skip_initialize=false) |
| Updates the point cloud to a given set of fields. | |
| bool | HasFields (pc_flags::Fields fields_in) const |
| Returns if a point cloud has a given set of fields. | |
| void | RequireFields (pc_flags::Fields fields_in) const |
| Requires a given set of fields. | |
| bool | HasExactFields (pc_flags::Fields fields_in) const |
| Returns if a point cloud has exactly a given set of fields. | |
| void | RequireExactFields (pc_flags::Fields field_set) const |
| Requires the exact given set of fields. | |
Point Cloud Processing | |
| PointCloud | Crop (const Eigen::Ref< const Vector3< T > > &lower_xyz, const Eigen::Ref< const Vector3< T > > &upper_xyz) |
| Returns a new point cloud containing only the points in this with xyz values within the axis-aligned bounding box defined by lower_xyz and upper_xyz. | |
| void | FlipNormalsTowardPoint (const Eigen::Ref< const Vector3< T > > &p_CP) |
| Changes the sign of the normals in this, if necessary, so that each normal points toward the point P in the frame C in which the xyzs of this cloud are represented. | |
Static Public Member Functions | |
| static bool | IsDefaultValue (T value) |
| static bool | IsInvalidValue (T value) |
Static Public Attributes | |
| static constexpr T | kDefaultValue = std::numeric_limits<T>::quiet_NaN() |
| Represents an invalid or uninitialized value. | |
| static constexpr C | kDefaultColor {} |
| using C = uint8_t |
Color channel scalar type.
| using T = float |
Geometric scalar type.
|
explicit |
Constructs a point cloud of a given new_size, with the prescribed fields.
If kDescriptors is one of the fields, then descriptor should be included and should not be kNone.
| new_size | Size of the point cloud after construction. |
| fields | Fields that the point cloud contains. |
| skip_initialize | Do not default-initialize new values. |
| PointCloud | ( | const PointCloud & | other | ) |
Copies another point cloud's fields and data.
| PointCloud | ( | PointCloud && | other | ) |
Takes ownership of another point cloud's data.
| PointCloud | ( | const PointCloud & | other, |
| pc_flags::Fields | copy_fields ) |
Copies another point cloud's fields and data.
| copy_fields | Fields to copy. If this is kInherit, then others fields will be copied. Otherwise, only the specified fields will be copied; the remaining fields in this cloud are left default initialized. |
| ~PointCloud | ( | ) |
| PointCloud Crop | ( | const Eigen::Ref< const Vector3< T > > & | lower_xyz, |
| const Eigen::Ref< const Vector3< T > > & | upper_xyz ) |
Returns a new point cloud containing only the points in this with xyz values within the axis-aligned bounding box defined by lower_xyz and upper_xyz.
Requires that xyz values are defined.
| std::exception | if has_xyzs() != true. |
Returns access to a descriptor value.
| const pc_flags::DescriptorType & descriptor_type | ( | ) | const |
Returns the descriptor type.
Returns access to descriptor values.
| bool EstimateNormals | ( | double | radius, |
| int | num_closest, | ||
| Parallelism | parallelize = false ) |
Estimates the normal vectors in this by fitting a plane at each point in the cloud using up to num_closest points within Euclidean distance radius from the point.
If has_normals() is false, then new normals will be allocated (and has_normals() will become true). Points for which the normals cannot be estimated (because the this has less than two closest points within the radius), will receive normal [NaN, NaN, NaN]. Normals estimated from two closest points will be orthogonal to the vector between those points, but can be arbitrary in the last dimension. parallelize enables OpenMP parallelization.
radius.radius > 0 and num_closest >= 3. | std::exception | if has_xyzs() is false. |
| void Expand | ( | int | add_size, |
| bool | skip_initialization = false ) |
Adds add_size default-initialized points.
| add_size | Number of points to add. |
| skip_initialization | Do not require that the new values be initialized. |
| pc_flags::Fields fields | ( | ) | const |
Returns the fields provided by this point cloud.
Changes the sign of the normals in this, if necessary, so that each normal points toward the point P in the frame C in which the xyzs of this cloud are represented.
This can be useful, for instance, when P is the position of the camera used to generate the cloud.
| std::exception | if has_xyzs() != true or has_normals() != true. |
| bool has_descriptors | ( | ) | const |
Returns if this point cloud provides descriptor values.
| bool has_descriptors | ( | const pc_flags::DescriptorType & | descriptor_type | ) | const |
Returns if the point cloud provides a specific descriptor.
| bool has_normals | ( | ) | const |
Returns if this cloud provides normals.
| bool has_rgbs | ( | ) | const |
Returns if this cloud provides RGB colors.
| bool has_xyzs | ( | ) | const |
Returns if this cloud provides XYZ values.
| bool HasExactFields | ( | pc_flags::Fields | fields_in | ) | const |
Returns if a point cloud has exactly a given set of fields.
| bool HasFields | ( | pc_flags::Fields | fields_in | ) | const |
Returns if a point cloud has a given set of fields.
|
static |
|
static |
Returns mutable access to a descriptor value.
Returns mutable access to descriptor values.
Returns mutable access to a normal.
Returns mutable access to normals.
Returns mutable access to an RGB color.
Returns mutable access to RGB colors.
Returns mutable access to an XYZ value.
Returns mutable access to XYZ values.
Returns access to a normal.
Returns access to normals.
| PointCloud & operator= | ( | const PointCloud & | other | ) |
| PointCloud & operator= | ( | PointCloud && | other | ) |
| void RequireExactFields | ( | pc_flags::Fields | field_set | ) | const |
Requires the exact given set of fields.
| std::exception | if this point cloud does not have exactly these fields. |
| void RequireFields | ( | pc_flags::Fields | fields_in | ) | const |
Requires a given set of fields.
| std::exception | if this point cloud does not have these fields. |
| void resize | ( | int | new_size, |
| bool | skip_initialize = false ) |
Conservative resize; will maintain existing data, and initialize new data to their invalid values.
Returns access to an RGB color.
Returns access to RGB colors.
| void SetFields | ( | pc_flags::Fields | new_fields, |
| bool | skip_initialize = false ) |
Updates the point cloud to a given set of fields.
In the case of introducing a new field, its container will be allocated with the current size and default initialized. The data for all retained fields will remain unchanged.
| new_fields | New fields to set to. |
| skip_initialize | Do not default-initialize new values. |
| void SetFrom | ( | const PointCloud & | other, |
| pc_flags::Fields | fields_in = pc_flags::kInherit, | ||
| bool | allow_resize = true ) |
Copies all points from another point cloud.
| other | Other point cloud. |
| fields_in | Fields to copy. If this is kInherit, then others fields will be copied. Otherwise, both clouds must support the fields indicated this parameter. |
| allow_resize | Permit resizing to the other cloud's size. |
| int size | ( | ) | const |
Returns the number of points in this point cloud.
| PointCloud VoxelizedDownSample | ( | double | voxel_size, |
| Parallelism | parallelize = false ) const |
Returns a down-sampled point cloud by grouping all xyzs in this cloud into a 3D grid with cells of dimension voxel_size.
Each occupied voxel will result in one point in the downsampled cloud, with a location corresponding to the centroid of the points in that voxel. Points with non-finite xyz values are ignored. All other fields (e.g. rgbs, normals, and descriptors) with finite values will also be averaged across the points in a voxel. parallelize enables OpenMP parallelization. Equivalent to Open3d's voxel_down_sample or PCL's VoxelGrid filter.
| std::exception | if has_xyzs() is false. |
| std::exception | if voxel_size <= 0. |
Returns access to an XYZ value.
Returns access to XYZ values.
|
staticconstexpr |
Represents an invalid or uninitialized value.