Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions slam3d/sensor/pcl/PointCloudSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ Transform align(PointCloudMeasurement::Ptr source,
PointCloud::Ptr filtered_target = target->getPointCloud();
if(config.point_cloud_density > 0)
{
filtered_source = PointCloudSensor::downsample(source->getPointCloud(), config.point_cloud_density);
filtered_target = PointCloudSensor::downsample(target->getPointCloud(), config.point_cloud_density);
filtered_source = PointCloudSensor::downsample(source->getPointCloud(), config.point_cloud_density, config.point_cloud_coord_limit);
filtered_target = PointCloudSensor::downsample(target->getPointCloud(), config.point_cloud_density, config.point_cloud_coord_limit);
}

// Make sure that there are enough points left (ICP will crash if not)
Expand Down Expand Up @@ -202,12 +202,15 @@ PointCloud::Ptr PointCloudSensor::crop(PointCloud::Ptr in, const Eigen::Vector4f
}
}

PointCloud::Ptr PointCloudSensor::downsample(PointCloud::Ptr in, double leaf_size)
PointCloud::Ptr PointCloudSensor::downsample(PointCloud::Ptr in, double leaf_size, double maxrange)
{
if(in->size() > 0 && leaf_size > 0)
{
PointCloud::Ptr out(new PointCloud);
pcl::VoxelGrid<PointType> grid;
if (maxrange>0) {
grid.setFilterLimits(-maxrange,maxrange);
}
grid.setLeafSize (leaf_size, leaf_size, leaf_size);
grid.setInputCloud(in);
grid.filter(*out);
Expand Down
2 changes: 1 addition & 1 deletion slam3d/sensor/pcl/PointCloudSensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ namespace slam3d
* @param source
* @param resolution
*/
static PointCloud::Ptr downsample(PointCloud::Ptr source, double resolution);
static PointCloud::Ptr downsample(PointCloud::Ptr source, double resolution, double maxrange = -1.0);

/**
* @brief Crop the source cloud to a square box with given corners.
Expand Down
4 changes: 4 additions & 0 deletions slam3d/sensor/pcl/RegistrationParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ namespace slam3d
// pointclouds will be downsampled to this density before the alignement
double point_cloud_density = 0.2;

// point with a coordinage higher than point_cloud_coord_limit or lower than
// -point_cloud_coord_limit are ignored, only active when point_cloud_density > 0
double point_cloud_coord_limit = 80;

// maximum fitness score (e.g., sum of squared distances from the source to the target)
// to accept the registration result
double max_fitness_score = 2.0;
Expand Down