mp2p_icp_map library¶
Overview¶
Core data structures and utilities for mp2p_icp
// typedefs typedef std::string mp2p_icp::layer_name_t; typedef std::vector<point_plane_pair_t> mp2p_icp::MatchedPointPlaneList; typedef std::vector<point_with_cov_pair_t> mp2p_icp::MatchedPointWithCovList; // structs struct mp2p_icp::PointCloudEigen; struct mp2p_icp::PointWeightByIncidence; struct mp2p_icp::PointWeightByRange; struct mp2p_icp::color_mode_t; struct mp2p_icp::las_export_options_t; struct mp2p_icp::pairings_render_params_t; struct mp2p_icp::plane_patch_t; struct mp2p_icp::ply_export_options_t; struct mp2p_icp::point_plane_pair_t; struct mp2p_icp::point_with_cov_pair_t; struct mp2p_icp::pointcloud_bitfield_t; struct mp2p_icp::render_params_lines_t; struct mp2p_icp::render_params_pairings_cov2cov_t; struct mp2p_icp::render_params_pairings_pt2ln_t; struct mp2p_icp::render_params_pairings_pt2pl_t; struct mp2p_icp::render_params_pairings_pt2pt_t; struct mp2p_icp::render_params_planes_t; struct mp2p_icp::render_params_point_layer_t; struct mp2p_icp::render_params_points_t; struct mp2p_icp::render_params_t; struct mp2p_icp::txt_export_options_t; // classes class mp2p_icp::IcpPrepareCapable; class mp2p_icp::MetricMapMergeCapable; class mp2p_icp::NearestPlaneCapable; class mp2p_icp::NearestPointWithCovCapable; class mp2p_icp::ParameterSource; class mp2p_icp::Parameterizable; class mp2p_icp::metric_map_t; // global functions PointCloudEigen mp2p_icp::estimate_points_eigen( const float* xs, const float* ys, const float* zs, mrpt::optional_ref<const std::vector<size_t>> indices, std::optional<size_t> totalCount = std::nullopt ); mrpt::maps::CSimplePointsMap::Ptr mp2p_icp::load_xyz_file(const std::string& fil); const mrpt::maps::CPointsMap* mp2p_icp::MapToPointsMap(const mrpt::maps::CMetricMap& map); mrpt::maps::CPointsMap* mp2p_icp::MapToPointsMap(mrpt::maps::CMetricMap& map); const mrpt::maps::CPointsMap* mp2p_icp::MapToPointsMapView(const mrpt::maps::CMetricMap& map); const mrpt::maps::NearestNeighborsCapable* mp2p_icp::MapToNN( const mrpt::maps::CMetricMap& map, bool throwIfNotImplemented ); const mp2p_icp::NearestPlaneCapable* mp2p_icp::MapToNP(const mrpt::maps::CMetricMap& map, bool throwIfNotImplemented); mrpt::serialization::CArchive& mp2p_icp::operator >> ( mrpt::serialization::CArchive& in, std::optional<metric_map_t::Georeferencing>& g ); mrpt::serialization::CArchive& mp2p_icp::operator << ( mrpt::serialization::CArchive& out, const std::optional<metric_map_t::Georeferencing>& g ); std::optional<metric_map_t::Georeferencing> mp2p_icp::FromYAML(const mrpt::containers::yaml& yaml_data); mrpt::containers::yaml mp2p_icp::ToYAML(const std::optional<metric_map_t::Georeferencing>& geoRef); void mp2p_icp::save_point_cloud_to_ply( const mrpt::maps::CPointsMap& pc, const std::string& filename, const ply_export_options_t& options = {} ); void mp2p_icp::save_point_cloud_to_las( const mrpt::maps::CPointsMap& pc, const std::string& filename, const las_export_options_t& options = {} ); void mp2p_icp::save_point_cloud_to_txt( const mrpt::maps::CPointsMap& pc, const std::string& filename, const txt_export_options_t& options = {} ); bool mp2p_icp::pointcloud_sanity_check(const mrpt::maps::CPointsMap& pc, bool printWarnings = true);
Global Functions¶
PointCloudEigen mp2p_icp::estimate_points_eigen( const float* xs, const float* ys, const float* zs, mrpt::optional_ref<const std::vector<size_t>> indices, std::optional<size_t> totalCount = std::nullopt )
Calculate mean, covariance, eigenvectors, and eigenvalues from a set of points.
It is mandatory to provide one and only one of these two parameters:
indices: only the points with these indices will be considered.totalCount: all points will be used, ignoringindices.
Parameters:
xs[in] |
Input x coordinate vector. |
ys[in] |
Input y coordinate vector. |
zs[in] |
Input z coordinate vector. |
indices[in] |
0-based indices of points to consider from the vectors. |
totalCount[in] |
Total number of points in the vectors. |
std::exception |
If less than 3 points are provided. |
mrpt::maps::CSimplePointsMap::Ptr mp2p_icp::load_xyz_file(const std::string& fil)
Loads a pointcloud from an ASCII “XYZ file”, storing an Nx3 matrix (each row is a point). If the filename extension ends in “.gz”, it is uncompressed automatically.
const mrpt::maps::CPointsMap* mp2p_icp::MapToPointsMap(const mrpt::maps::CMetricMap& map)
Function to extract the CPointsMap for any kind of CMetricMap, if there exists a conversion that makes sense for matching against it. Typically:
Any derived type of mrpt::maps::CPointsMap: just does a dynamic_cast.
An mrpt::maps::CVoxelMap: gets the equivalent points map with cached occupied voxels (requires MRPT >=2.11.0).
Returns an empty shared_ptr if conversion is not possible.
The use of raw pointers here imply the lifetime of the input “map” must be longer than that of its use within the Matcher.
const mrpt::maps::CPointsMap* mp2p_icp::MapToPointsMapView(const mrpt::maps::CMetricMap& map)
Like MapToPointsMap(), but it also returns a read-only point cloud view for map classes that are not point clouds themselves but can provide one (e.g. keyframe-based maps), via mrpt::maps::asPointsMap(). With MRPT < 3.5.3, which has no such generic view, it is equivalent to MapToPointsMap().
Intended for read-only uses, like exporting map layers. Registration code should keep using MapToPointsMap().
Returns nullptr if no point cloud is available.
The view is whatever the map class provides: some classes return a subsampled cloud (e.g. mola::KeyframePointCloudMap, according to its render options).
The returned pointer is a non-owning observer, valid as long as map is alive and not modified.
const mrpt::maps::NearestNeighborsCapable* mp2p_icp::MapToNN( const mrpt::maps::CMetricMap& map, bool throwIfNotImplemented )
Returns the dynamic_cast<> of the metric map as a mrpt::maps::NearestNeighborsCapable. If the interface is not implemented it returns nullptr, or throws an exception if it throwIfNotImplemented is true.
const mp2p_icp::NearestPlaneCapable* mp2p_icp::MapToNP( const mrpt::maps::CMetricMap& map, bool throwIfNotImplemented )
Returns the dynamic_cast<> of the metric map as a mp2p_icp::NearestPlaneCapable. If the interface is not implemented it returns nullptr, or throws an exception if it throwIfNotImplemented is true.
mrpt::serialization::CArchive& mp2p_icp::operator >> ( mrpt::serialization::CArchive& in, std::optional<metric_map_t::Georeferencing>& g )
Serialization of geo-reference information in binary form:
mrpt::serialization::CArchive& mp2p_icp::operator << ( mrpt::serialization::CArchive& out, const std::optional<metric_map_t::Georeferencing>& g )
Serialization of geo-reference information in binary form:
std::optional<metric_map_t::Georeferencing> mp2p_icp::FromYAML(const mrpt::containers::yaml& yaml_data)
Serialization of geo-reference information as YAML.
mrpt::containers::yaml mp2p_icp::ToYAML(const std::optional<metric_map_t::Georeferencing>& geoRef)
Serialization of geo-reference information as YAML.
void mp2p_icp::save_point_cloud_to_ply( const mrpt::maps::CPointsMap& pc, const std::string& filename, const ply_export_options_t& options = {} )
Writes a point cloud, with all or a subset of its per-point fields, as a PLY file.
Parameters:
std::exception |
On any error (cannot create the file, missing fields, etc.) |
void mp2p_icp::save_point_cloud_to_las( const mrpt::maps::CPointsMap& pc, const std::string& filename, const las_export_options_t& options = {} )
Writes a point cloud as a LAS 1.4 file, with point data record format 8. Empty point clouds are skipped, with a warning, without creating the file.
Parameters:
std::exception |
On any error (cannot create the file, the extent does not fit into the LAS integer coordinates, etc.) |
void mp2p_icp::save_point_cloud_to_txt( const mrpt::maps::CPointsMap& pc, const std::string& filename, const txt_export_options_t& options = {} )
Writes a point cloud as a space-separated text file, one point per line.
Parameters:
std::exception |
If the file cannot be created. |
bool mp2p_icp::pointcloud_sanity_check( const mrpt::maps::CPointsMap& pc, bool printWarnings = true )
Returns false (and optionally prints a warning to std::cerr) if the point cloud fields are not correctly sized.