25 namespace scan_matching {
28 const double angular_search_window,
30 const double resolution)
31 : resolution(resolution) {
35 for (
const Eigen::Vector3f& point : point_cloud) {
36 const float range = point.head<2>().norm();
37 max_scan_range = std::max(range, max_scan_range);
39 const double kSafetyMargin = 1. - 1e-3;
41 kSafetyMargin * std::acos(1. -
common::Pow2(resolution) /
47 const int num_linear_perturbations =
48 std::ceil(linear_search_window / resolution);
52 LinearBounds{-num_linear_perturbations, num_linear_perturbations,
53 -num_linear_perturbations, num_linear_perturbations});
61 : num_angular_perturbations(num_angular_perturbations),
62 angular_perturbation_step_size(angular_perturbation_step_size),
63 resolution(resolution),
64 num_scans(2 * num_angular_perturbations + 1) {
68 LinearBounds{-num_linear_perturbations, num_linear_perturbations,
69 -num_linear_perturbations, num_linear_perturbations});
78 Eigen::Array2i min_bound = Eigen::Array2i::Zero();
79 Eigen::Array2i max_bound = Eigen::Array2i::Zero();
80 for (
const Eigen::Array2i& xy_index : scans[i]) {
81 min_bound = min_bound.min(-xy_index);
82 max_bound = max_bound.max(Eigen::Array2i(cell_limits.
num_x_cells - 1,
96 std::vector<sensor::PointCloud> rotated_scans;
97 rotated_scans.reserve(search_parameters.
num_scans);
101 for (
int scan_index = 0; scan_index < search_parameters.
num_scans;
106 delta_theta, Eigen::Vector3f::UnitZ()))));
108 return rotated_scans;
112 const MapLimits& map_limits,
const std::vector<sensor::PointCloud>& scans,
113 const Eigen::Translation2f& initial_translation) {
114 std::vector<DiscreteScan2D> discrete_scans;
115 discrete_scans.reserve(scans.size());
117 discrete_scans.emplace_back();
118 discrete_scans.back().reserve(scan.size());
119 for (
const Eigen::Vector3f& point : scan) {
120 const Eigen::Vector2f translated_point =
121 Eigen::Affine2f(initial_translation) * point.head<2>();
122 discrete_scans.back().push_back(
126 return discrete_scans;
std::vector< DiscreteScan2D > DiscretizeScans(const MapLimits &map_limits, const std::vector< sensor::PointCloud > &scans, const Eigen::Translation2f &initial_translation)
PointCloud TransformPointCloud(const PointCloud &point_cloud, const transform::Rigid3f &transform)
std::vector< LinearBounds > linear_bounds
void ShrinkToFit(const std::vector< DiscreteScan2D > &scans, const CellLimits &cell_limits)
int num_angular_perturbations
SearchParameters(double linear_search_window, double angular_search_window, const sensor::PointCloud &point_cloud, double resolution)
std::vector< sensor::PointCloud > GenerateRotatedScans(const sensor::PointCloud &point_cloud, const SearchParameters &search_parameters)
double angular_perturbation_step_size
std::vector< Eigen::Vector3f > PointCloud
Eigen::Array2i GetCellIndex(const Eigen::Vector2f &point) const