diff --git a/nvblox/CMakeLists.txt b/nvblox/CMakeLists.txt index 8f920d6f..c1447bed 100644 --- a/nvblox/CMakeLists.txt +++ b/nvblox/CMakeLists.txt @@ -78,7 +78,7 @@ if(BUILD_REDISTRIBUTABLE) # For the benchmarking executable. This is not deployed so we're fine to build it with this # dynamically-linked library. - find_package(benchmark REQUIRED) + # find_package(benchmark REQUIRED) else() # By default, use system dependencies for these. # In the case of ROS builds, glog will likely be found at a higher level. diff --git a/nvblox/executables/CMakeLists.txt b/nvblox/executables/CMakeLists.txt index 3b633dc0..30bf8c8d 100644 --- a/nvblox/executables/CMakeLists.txt +++ b/nvblox/executables/CMakeLists.txt @@ -43,10 +43,10 @@ target_link_libraries(fuse_redwood set_target_properties(fuse_redwood PROPERTIES CUDA_SEPARABLE_COMPILATION OFF) # Benchmarking executable -add_executable(benchmark - src/benchmark.cpp -) -target_link_libraries(benchmark - nvblox_lib nvblox_datasets nvblox_test_utils benchmark::benchmark -) -set_target_properties(benchmark PROPERTIES CUDA_SEPARABLE_COMPILATION OFF) +#add_executable(benchmark +# src/benchmark.cpp +#) +#target_link_libraries(benchmark +# nvblox_lib nvblox_datasets nvblox_test_utils benchmark::benchmark +#) +#set_target_properties(benchmark PROPERTIES CUDA_SEPARABLE_COMPILATION OFF) diff --git a/nvblox/include/nvblox/core/internal/impl/unified_vector_impl.h b/nvblox/include/nvblox/core/internal/impl/unified_vector_impl.h index 64fb5766..fc6e217e 100644 --- a/nvblox/include/nvblox/core/internal/impl/unified_vector_impl.h +++ b/nvblox/include/nvblox/core/internal/impl/unified_vector_impl.h @@ -110,7 +110,7 @@ template void unified_vector::copyFromAsync(const OtherVectorType& other, const CudaStream cuda_stream) { resizeAsync(other.size(), cuda_stream); - if (other.data() != nullptr) { + if (other.data() != nullptr && buffer_capacity_ > 0) { checkCudaErrors(cudaMemcpyAsync(buffer_, other.data(), sizeof(T) * other.size(), cudaMemcpyDefault, cuda_stream)); @@ -149,7 +149,7 @@ inline std::vector unified_vector::toVectorAsync( const CudaStream cuda_stream) const { // The memory layout of std::vector is different so we have to first // copy to an intermediate buffer. - CHECK(buffer_ != nullptr); + CHECK(buffer_ != nullptr && buffer_capacity_ > 0); std::unique_ptr bool_buffer(new bool[buffer_size_]); checkCudaErrors(cudaMemcpyAsync(bool_buffer.get(), buffer_, sizeof(bool) * buffer_size_, @@ -234,7 +234,7 @@ void unified_vector::reserveAsync(size_t capacity, checkCudaErrors(cudaMallocHost(&new_buffer, sizeof(T) * capacity)); } - if (buffer_ != nullptr) { + if (buffer_ != nullptr && buffer_capacity_ > 0) { // Copy the old values to the new buffer. CHECK(capacity >= buffer_size_); checkCudaErrors(cudaMemcpyAsync(new_buffer, buffer_, @@ -290,7 +290,7 @@ void unified_vector::clearNoDealloc() { template void unified_vector::clear() { - if (buffer_ != nullptr) { + if (buffer_ != nullptr && buffer_capacity_ > 0) { if (memory_type_ == MemoryType::kHost) { checkCudaErrors(cudaFreeHost(reinterpret_cast(buffer_))); } else { @@ -346,7 +346,7 @@ template void unified_vector::setZeroAsync(const CudaStream cuda_stream) { // It is safe to use cudaMemset since the memory is ALWAYS allocated with // cudaMalloc. - CHECK(buffer_ != nullptr); + CHECK(buffer_ != nullptr && buffer_capacity_ > 0); checkCudaErrors( cudaMemsetAsync(buffer_, 0, buffer_size_ * sizeof(T), cuda_stream)); } diff --git a/nvblox/include/nvblox/integrators/esdf_integrator.h b/nvblox/include/nvblox/integrators/esdf_integrator.h index 32eb00fc..ac3e44a8 100644 --- a/nvblox/include/nvblox/integrators/esdf_integrator.h +++ b/nvblox/include/nvblox/integrators/esdf_integrator.h @@ -279,6 +279,7 @@ class EsdfIntegrator { /// @brief TsdfLayer related parameter /// Maximum (TSDF) distance at which a voxel is considered a site + //float tsdf_max_site_distance_vox_ = 1.7321; float max_tsdf_site_distance_vox_ = kDefaultMaxTsdfSiteDistanceVox; /// @brief TsdfLayer related parameter diff --git a/nvblox/include/nvblox/map/internal/impl/layer_impl.h b/nvblox/include/nvblox/map/internal/impl/layer_impl.h index cc45569f..32adb137 100644 --- a/nvblox/include/nvblox/map/internal/impl/layer_impl.h +++ b/nvblox/include/nvblox/map/internal/impl/layer_impl.h @@ -175,6 +175,12 @@ bool BlockLayer::isBlockAllocated(const Index3D& index) const { return (it != blocks_.end()); } +template +void BlockLayer::clear() { + gpu_layer_view_up_to_date_ = false; + blocks_.clear(); +} + template bool BlockLayer::clearBlock(const Index3D& index) { if (blocks_.erase(index)) { diff --git a/nvblox/include/nvblox/map/layer.h b/nvblox/include/nvblox/map/layer.h index ada2858b..515cd781 100644 --- a/nvblox/include/nvblox/map/layer.h +++ b/nvblox/include/nvblox/map/layer.h @@ -115,7 +115,7 @@ class BlockLayer : public BaseLayer { size_t size() const { return blocks_.size(); } /// Clear the layer of all data - void clear() { blocks_.clear(); } + void clear(); // Clear (deallocate) a single block bool clearBlock(const Index3D& index);