Class TsdfIntegratorBase

Nested Relationships

Inheritance Relationships

Derived Types

Class Documentation

class TsdfIntegratorBase

Base class to the simple, merged and fast TSDF integrators.

The integrator takes in a pointcloud + pose and uses this information to update the TSDF information in the given TSDF layer. Note most functions in this class state if they are thread safe. Unless explicitly stated otherwise, this thread safety is based on the assumption that any pointers passed to the functions point to objects that are guaranteed to not be accessed by other threads.

Subclassed by voxblox::FastTsdfIntegrator, voxblox::MergedTsdfIntegrator, voxblox::SimpleTsdfIntegrator

Public Types

typedef std::shared_ptr<TsdfIntegratorBase> Ptr

Public Functions

TsdfIntegratorBase(const Config &config, Layer<TsdfVoxel> *layer)
virtual void integratePointCloud(const Transformation &T_G_C, const Pointcloud &points_C, const Colors &colors, const bool freespace_points = false) = 0

Integrates the given point infomation into the TSDF.

NOT thread safe.

  • freespace_points: if true points will only be integrated up to the truncation distance. Used when we are given a minimum distance to a point, rather then exact distance. This is useful for clearing out free space.

const Config &getConfig() const

Returns a CONST ref of the config.

void setLayer(Layer<TsdfVoxel> *layer)

Protected Functions

bool isPointValid(const Point &point_C, const bool freespace_point, bool *is_clearing) const

Thread safe.

TsdfVoxel *allocateStorageAndGetVoxelPtr(const GlobalIndex &global_voxel_idx, Block<TsdfVoxel>::Ptr *last_block, BlockIndex *last_block_idx)

Will return a pointer to a voxel located at global_voxel_idx in the tsdf layer.

Thread safe. Takes in the last_block_idx and last_block to prevent unneeded map lookups. If this voxel belongs to a block that has not been allocated, a block in temp_block_map_ is created/accessed and a voxel from this map is returned instead. Unlike the layer, accessing temp_block_map_ is controlled via a mutex allowing it to grow during integration. These temporary blocks can be merged into the layer later by calling updateLayerWithStoredBlocks

void updateLayerWithStoredBlocks()

Merges temporarily stored blocks into the main layer.

NOT thread safe, see allocateStorageAndGetVoxelPtr for more details.

void updateTsdfVoxel(const Point &origin, const Point &point_G, const GlobalIndex &global_voxel_index, const Color &color, const float weight, TsdfVoxel *tsdf_voxel)

Updates tsdf_voxel, Thread safe.

float computeDistance(const Point &origin, const Point &point_G, const Point &voxel_center) const

Calculates TSDF distance, Thread safe.

float getVoxelWeight(const Point &point_C) const

Thread safe.

Protected Attributes

Config config_
Layer<TsdfVoxel> *layer_
FloatingPoint voxel_size_
size_t voxels_per_side_
FloatingPoint block_size_
FloatingPoint voxel_size_inv_
FloatingPoint voxels_per_side_inv_
FloatingPoint block_size_inv_
std::mutex temp_block_mutex_
Layer<TsdfVoxel>::BlockHashMap temp_block_map_

Temporary block storage, used to hold blocks that need to be created while integrating a new pointcloud.

ApproxHashArray<12, std::mutex, GlobalIndex, LongIndexHash> mutexes_

We need to prevent simultaneous access to the voxels in the map.

We could put a single mutex on the map or on the blocks, but as voxel updating is the most expensive operation in integration and most voxels are close together, both strategies would bottleneck the system. We could make a mutex per voxel, but this is too ram heavy as one mutex = 40 bytes. Because of this we create an array that is indexed by the first n bits of the voxels hash. Assuming a uniform hash distribution, this means the chance of two threads needing the same lock for unrelated voxels is (num_threads / (2^n)). For 8 threads and 12 bits this gives 0.2%.

struct Config

Public Members

float default_truncation_distance = 0.1
float max_weight = 10000.0
bool voxel_carving_enabled = true
FloatingPoint min_ray_length_m = 0.1
FloatingPoint max_ray_length_m = 5.0
bool use_const_weight = false
bool allow_clear = true
bool use_weight_dropoff = true
bool use_sparsity_compensation_factor = false
float sparsity_compensation_factor = 1.0f
size_t integrator_threads = std::thread::hardware_concurrency()
bool enable_anti_grazing = false

merge integrator specific

float start_voxel_subsampling_factor = 2.0f

fast integrator specific

int max_consecutive_ray_collisions = 2

fast integrator specific

int clear_checks_every_n_frames = 1

fast integrator specific

float max_integration_time_s = std::numeric_limits<float>::max()

fast integrator specific