### Install Documentation Dependencies (Ubuntu) Source: https://github.com/ethz-asl/voxblox/blob/master/docs/pages/Expanding-the-Docs.rst Installs the necessary Python packages and Doxygen for compiling the project's documentation locally. This command should be run on a Debian-based system like Ubuntu. ```bash sudo apt-get install python-pip doxygen python-pyaudio pip install sphinx exhale breath sphinx_rtd_theme recommonmark --user ``` -------------------------------- ### Setup Voxblox Linter Source: https://github.com/ethz-asl/voxblox/blob/master/docs/pages/Modifying-and-Contributing.rst This bash script sets up a linter for the Voxblox project to enforce code style consistency during commits. It involves cloning the linter repository, installing dependencies, configuring the shell environment, and initializing git hooks. ```bash cd ~/catkin_ws/src/ git clone git@github.com:ethz-asl/linter.git cd linter echo ". $(realpath setup_linter.sh)" >> ~/.bashrc # Or the matching file for # your shell. bash # Initialize linter in voxblox repo cd ~/catkin_ws/src/voxblox init_linter_git_hooks ``` -------------------------------- ### Configure Documentation for Another Project Source: https://github.com/ethz-asl/voxblox/blob/master/docs/pages/Expanding-the-Docs.rst Steps to adapt the Voxblox documentation setup for a new project. This involves copying the docs folder, modifying configuration files, and updating the project's structure. ```bash # 1. Copy the Docs folder to the root directory of the project. # 2. Change the value of the "name" variable in conf.py. # 3. Modify the index.rst to fit your new project. # 4. Change the contents of the pages folder to your projects ".md" and ".rst" files. # 5. Add "docs/_build", "docs/doxyoutput" and "docs/api" to your ".gitignore" file (for building locally). # 6. Push the changes to github. # 7. Create a new project on readthedocs.io and in advanced settings set the "Requirements file" path to "docs/requirements.txt". ``` -------------------------------- ### Install System Dependencies (Ubuntu) Source: https://github.com/ethz-asl/voxblox/wiki/Installation Installs necessary system packages for Voxblox, including Python tools, CMake modules, and Protocol Buffers. Ensure you replace 'kinetic' with your ROS distribution if different. ```bash sudo apt-get install python-wstool python-catkin-tools ros-kinetic-cmake-modules protobuf-compiler autoconf ``` -------------------------------- ### Install and Export Voxblox ROS Targets Source: https://github.com/ethz-asl/voxblox/blob/master/voxblox_ros/CMakeLists.txt This snippet configures the installation and export rules for the voxblox_ros package using catkin_simple. It ensures that the defined libraries and executables are correctly installed and available for other ROS packages. ```cmake cs_install() cs_export() ``` -------------------------------- ### ROS Launch File for Voxblox and Custom Planner Source: https://context7.com/ethz-asl/voxblox/llms.txt This XML launch file configures and starts both the Voxblox ESDF server node and a custom planner node, demonstrating how to remap topics and set parameters for their integration. ```APIDOC ## ROS Launch File for Voxblox and Custom Planner ### Description This XML launch file configures and starts both the Voxblox ESDF server node and a custom planner node, demonstrating how to remap topics and set parameters for their integration. ### Method N/A (Launch File) ### Endpoint N/A (Launch File) ### Parameters #### Launch Arguments - **voxel_size** (double) - Optional - Default: 0.20 - **world_frame** (string) - Optional - Default: "odom" - **robot_name** (string) - Optional - Default: "my_robot" #### Voxblox Node Parameters - **tsdf_voxel_size** (double) - Value from `voxel_size` argument - **tsdf_voxels_per_side** (int) - Default: 16 - **publish_esdf_map** (bool) - Default: true - **update_mesh_every_n_sec** (double) - Default: 1.0 - **clear_sphere_for_planning** (bool) - Default: true - **world_frame** (string) - Value from `world_frame` argument #### Custom Planner Node Parameters - **tsdf_voxel_size** (double) - Value from `voxel_size` argument - **tsdf_voxels_per_side** (int) - Default: 16 - **world_frame** (string) - Value from `world_frame` argument ### Request Example N/A ### Response N/A ### Code Example ```xml ``` ``` -------------------------------- ### Install Voxblox RViz Plugin Assets Source: https://github.com/ethz-asl/voxblox/blob/master/voxblox_rviz_plugin/CMakeLists.txt This section of the CMake script handles the installation of the voxblox_rviz_plugin. It installs the plugin description XML file and the icons directory to the appropriate locations within the ROS package share directory, ensuring the plugin is discoverable and functional. ```cmake install( FILES plugin_description.xml DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}) install( DIRECTORY icons/ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/icons) cs_install() cs_export() ``` -------------------------------- ### Install System Dependencies (Bash) Source: https://github.com/ethz-asl/voxblox/blob/master/docs/pages/Installation.rst Installs essential system packages required for Voxblox, including Python tools, ROS modules, and protobuf libraries. Ensure you replace 'kinetic' with your ROS distribution (e.g., indigo, melodic). ```bash sudo apt-get install python-wstool python-catkin-tools ros-kinetic-cmake-modules protobuf-compiler autoconf libprotobuf-dev protobuf-c-compiler ``` -------------------------------- ### Layer Block Operations Source: https://context7.com/ethz-asl/voxblox/llms.txt Provides C++ examples for accessing and manipulating voxel layers, including block allocation, voxel access, and memory management. ```APIDOC ## Layer Block Operations Direct access to the voxel layer for custom operations, including block allocation, voxel access, and memory management. ### Method N/A (C++ API) ### Endpoint N/A (C++ API) ### Parameters N/A ### Request Example ```cpp #include #include // Access layer from map voxblox::Layer* layer = tsdf_map.getTsdfLayerPtr(); // Get layer properties float voxel_size = layer->voxel_size(); // e.g., 0.05 float block_size = layer->block_size(); // e.g., 0.8 size_t voxels_per_side = layer->voxels_per_side(); // e.g., 16 // Allocate block at index voxblox::BlockIndex block_idx(0, 0, 0); voxblox::Block::Ptr block = layer->allocateBlockPtrByIndex(block_idx); // Allocate block by coordinates voxblox::Point coords(1.5, 2.3, 0.7); block = layer->allocateBlockPtrByCoordinates(coords); // Get existing block block = layer->getBlockPtrByIndex(block_idx); if (block) { // Access voxel by local index within block voxblox::VoxelIndex voxel_idx(5, 5, 5); voxblox::TsdfVoxel& voxel = block->getVoxelByVoxelIndex(voxel_idx); voxel.distance = 0.1f; voxel.weight = 1.0f; voxel.color = voxblox::Color(255, 128, 0); } // Get voxel directly by global index voxblox::GlobalIndex global_voxel_idx(10, 20, 5); voxblox::TsdfVoxel* voxel_ptr = layer->getVoxelPtrByGlobalIndex(global_voxel_idx); if (voxel_ptr) { float distance = voxel_ptr->distance; } // Get voxel by coordinates voxblox::TsdfVoxel* voxel = layer->getVoxelPtrByCoordinates(coords); // List all allocated blocks voxblox::BlockIndexList all_blocks; layer->getAllAllocatedBlocks(&all_blocks); ROS_INFO("Number of allocated blocks: %zu", all_blocks.size()); // Get updated blocks (for incremental processing) voxblox::BlockIndexList updated_blocks; layer->getAllUpdatedBlocks(voxblox::Update::kMesh, &updated_blocks); // Remove blocks far from robot voxblox::Point center(0, 0, 0); double max_distance = 10.0; layer->removeDistantBlocks(center, max_distance); // Get memory usage size_t memory_bytes = layer->getMemorySize(); ROS_INFO("Layer memory usage: %.2f MB", memory_bytes / 1e6); ``` ``` -------------------------------- ### C++ Voxblox ESDF Planner Integration Source: https://context7.com/ethz-asl/voxblox/llms.txt A C++ class demonstrating the integration of Voxblox ESDF maps for collision checking and gradient retrieval. It includes methods to get map distance, check collision-free status for points and trajectories, and obtain distance gradients. Requires ROS and the Voxblox library. ```cpp #include #include class VoxbloxPlanner { public: VoxbloxPlanner(const ros::NodeHandle& nh, const ros::NodeHandle& nh_private) : nh_(nh), nh_private_(nh_private), voxblox_server_(nh_, nh_private_) { // Optionally load a pre-built map std::string input_filepath; nh_private_.param("voxblox_path", input_filepath, std::string("")); if (!input_filepath.empty()) { if (!voxblox_server_.loadMap(input_filepath)) { ROS_ERROR("Couldn't load ESDF map from %s", input_filepath.c_str()); } } // Configure traversability visualization double robot_radius = 0.5; voxblox_server_.setTraversabilityRadius(robot_radius); } // Get distance to nearest obstacle at position double getMapDistance(const Eigen::Vector3d& position) const { if (!voxblox_server_.getEsdfMapPtr()) { return 0.0; } double distance = 0.0; if (!voxblox_server_.getEsdfMapPtr()->getDistanceAtPosition( position, &distance)) { return 0.0; // Unknown space } return distance; } // Check if position is collision-free given robot radius bool isCollisionFree(const Eigen::Vector3d& position, double robot_radius) const { double distance = getMapDistance(position); return distance > robot_radius; } // Check entire trajectory for collisions bool checkTrajectory(const std::vector& waypoints, double robot_radius) const { for (const auto& point : waypoints) { if (!isCollisionFree(point, robot_radius)) { return false; } } return true; } // Get gradient for trajectory optimization bool getDistanceAndGradient(const Eigen::Vector3d& position, double* distance, Eigen::Vector3d* gradient) const { if (!voxblox_server_.getEsdfMapPtr()) { return false; } return voxblox_server_.getEsdfMapPtr()->getDistanceAndGradientAtPosition( position, true, distance, gradient); } private: ros::NodeHandle nh_; ros::NodeHandle nh_private_; voxblox::EsdfServer voxblox_server_; }; int main(int argc, char** argv) { ros::init(argc, argv, "voxblox_planner"); ros::NodeHandle nh; ros::NodeHandle nh_private("~"); VoxbloxPlanner planner(nh, nh_private); // Example collision check Eigen::Vector3d test_point(1.0, 2.0, 1.5); double robot_radius = 0.5; if (planner.isCollisionFree(test_point, robot_radius)) { ROS_INFO("Point is collision-free"); } else { ROS_WARN("Point is in collision"); } ros::spin(); return 0; } ``` -------------------------------- ### Merge wstool Configuration Source: https://github.com/ethz-asl/voxblox/wiki/Installation Merges an existing wstool configuration with new ROS install files. Use this command if you have already initialized wstool and need to add or update dependencies. ```bash wstool merge -t ``` -------------------------------- ### Clone Voxblox Repository (HTTPS) Source: https://github.com/ethz-asl/voxblox/wiki/Installation Clones the Voxblox repository from GitHub using HTTPS. This is an alternative if SSH is not configured. It then initializes and updates the workspace using a provided ROS install file. ```bash cd ~/catkin_ws/src/ git clone https://github.com/ethz-asl/voxblox.git wstool init . ./voxblox/voxblox_https.rosinstall wstool update ``` -------------------------------- ### Clone Voxblox Repository (SSH) Source: https://github.com/ethz-asl/voxblox/wiki/Installation Clones the Voxblox repository from GitHub using SSH. This method is recommended for frequent contributors. It then initializes and updates the workspace using a provided ROS install file. ```bash cd ~/catkin_ws/src/ git clone git@github.com:ethz-asl/voxblox.git wstool init . ./voxblox/voxblox_ssh.rosinstall wstool update ``` -------------------------------- ### Configure Voxblox ROS Launch File Source: https://github.com/ethz-asl/voxblox/wiki/Using-Voxblox-for-Planning A sample ROS launch file that initializes the voxblox_node for ESDF generation and a custom planner node. It demonstrates remapping topics and setting essential parameters for mapping and planning. ```xml ``` -------------------------------- ### Initialize Linter Git Hooks Source: https://github.com/ethz-asl/voxblox/wiki/Modifying-and-Contributing Commands to clone the linter repository, configure the shell environment, and initialize git hooks within the Voxblox workspace to enforce Google C++ style guidelines. ```bash cd ~/catkin_ws/src/ git clone git@github.com:ethz-asl/linter.git cd linter echo ". $(realpath setup_linter.sh)" >> ~/.bashrc bash cd ~/catkin_ws/src/voxblox init_linter_git_hooks ``` -------------------------------- ### Compile HTML Documentation Source: https://github.com/ethz-asl/voxblox/blob/master/docs/pages/Expanding-the-Docs.rst Compiles the HTML documentation for the Voxblox project using the 'make html' command. This command should be executed from the documentation directory. ```bash cd ~/catkin_ws/src/voxblox/voxblox/docs make html ``` -------------------------------- ### Run Cow and Lady Dataset with Voxblox ROS Source: https://github.com/ethz-asl/voxblox/wiki/Running-Voxblox Launches the Voxblox node with the cow and lady dataset. This requires downloading the dataset, editing the bagfile path in the launch file, and then executing the launch command. The output mesh is visualized on the /voxblox_node/mesh topic. ```bash roslaunch voxblox_ros cow_and_lady_dataset.launch ``` -------------------------------- ### Run Basement Dataset with Voxblox ROS Source: https://github.com/ethz-asl/voxblox/wiki/Running-Voxblox Launches the Voxblox node with the basement dataset, which uses Velodyne lidar data and ICP corrections for pose estimation. Users need to edit the bagfile path in the launch file before running. The mesh is visualized on the /voxblox_node/mesh topic. ```bash roslaunch voxblox_ros basement_dataset.launch ``` -------------------------------- ### Initialize ROS Catkin Workspace Source: https://github.com/ethz-asl/voxblox/wiki/Installation Sets up a new ROS Catkin workspace, initializes it, and configures it to extend a specific ROS distribution (e.g., 'kinetic'). It also sets CMake build type to Release and merges devel spaces. ```bash mkdir -p ~/catkin_ws/src cd ~/catkin_ws catkin init catkin config --extend /opt/ros/kinetic catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release catkin config --merge-devel ``` -------------------------------- ### Voxblox ESDF Integration in Custom Planner (C++) Source: https://context7.com/ethz-asl/voxblox/llms.txt This C++ code demonstrates how to initialize and use the Voxblox ESDF server within a custom planner class. It includes methods for loading maps, checking collision-free paths, and retrieving distance gradients. ```APIDOC ## Voxblox ESDF Integration in Custom Planner (C++) ### Description This C++ code demonstrates how to initialize and use the Voxblox ESDF server within a custom planner class. It includes methods for loading maps, checking collision-free paths, and retrieving distance gradients. ### Method N/A (C++ Class) ### Endpoint N/A (C++ Class) ### Parameters N/A ### Request Example N/A ### Response N/A ### Code Example ```cpp #include #include class VoxbloxPlanner { public: VoxbloxPlanner(const ros::NodeHandle& nh, const ros::NodeHandle& nh_private) : nh_(nh), nh_private_(nh_private), voxblox_server_(nh_, nh_private_) { // Optionally load a pre-built map std::string input_filepath; nh_private_.param("voxblox_path", input_filepath, std::string("")); if (!input_filepath.empty()) { if (!voxblox_server_.loadMap(input_filepath)) { ROS_ERROR("Couldn't load ESDF map from %s", input_filepath.c_str()); } } // Configure traversability visualization double robot_radius = 0.5; voxblox_server_.setTraversabilityRadius(robot_radius); } // Get distance to nearest obstacle at position double getMapDistance(const Eigen::Vector3d& position) const { if (!voxblox_server_.getEsdfMapPtr()) { return 0.0; } double distance = 0.0; if (!voxblox_server_.getEsdfMapPtr()->getDistanceAtPosition( position, &distance)) { return 0.0; // Unknown space } return distance; } // Check if position is collision-free given robot radius bool isCollisionFree(const Eigen::Vector3d& position, double robot_radius) const { double distance = getMapDistance(position); return distance > robot_radius; } // Check entire trajectory for collisions bool checkTrajectory(const std::vector& waypoints, double robot_radius) const { for (const auto& point : waypoints) { if (!isCollisionFree(point, robot_radius)) { return false; } } return true; } // Get gradient for trajectory optimization bool getDistanceAndGradient(const Eigen::Vector3d& position, double* distance, Eigen::Vector3d* gradient) const { if (!voxblox_server_.getEsdfMapPtr()) { return false; } return voxblox_server_.getEsdfMapPtr()->getDistanceAndGradientAtPosition( position, true, distance, gradient); } private: ros::NodeHandle nh_; ros::NodeHandle nh_private_; voxblox::EsdfServer voxblox_server_; }; int main(int argc, char** argv) { ros::init(argc, argv, "voxblox_planner"); ros::NodeHandle nh; ros::NodeHandle nh_private("~"); VoxbloxPlanner planner(nh, nh_private); // Example collision check Eigen::Vector3d test_point(1.0, 2.0, 1.5); double robot_radius = 0.5; if (planner.isCollisionFree(test_point, robot_radius)) { ROS_INFO("Point is collision-free"); } else { ROS_WARN("Point is in collision"); } ros::spin(); return 0; } ``` ``` -------------------------------- ### Implement Custom Voxblox Planner Class Source: https://github.com/ethz-asl/voxblox/wiki/Using-Voxblox-for-Planning C++ scaffolding for a custom planner class that integrates voxblox::EsdfServer. It includes methods for map loading, traversability configuration, and distance queries for collision checking. ```cpp class YourPlannerVoxblox { public: YourPlannerVoxblox(const ros::NodeHandle& nh, const ros::NodeHandle& nh_private); virtual ~YourPlannerVoxblox() {} double getMapDistance(const Eigen::Vector3d& position) const; private: ros::NodeHandle nh_; ros::NodeHandle nh_private_; voxblox::EsdfServer voxblox_server_; }; YourPlannerVoxblox::YourPlannerVoxblox(const ros::NodeHandle& nh, const ros::NodeHandle& nh_private) : nh_(nh), nh_private_(nh_private), voxblox_server_(nh_, nh_private_) { std::string input_filepath; nh_private_.param("voxblox_path", input_filepath, input_filepath); if (!input_filepath.empty()) { if (!voxblox_server_.loadMap(input_filepath)) { ROS_ERROR("Couldn't load ESDF map!"); } } double robot_radius = 1.0; voxblox_server_.setTraversabilityRadius(robot_radius); voxblox_server_.publishTraversable(); } double YourPlannerVoxblox::getMapDistance( const Eigen::Vector3d& position) const { if (!voxblox_server_.getEsdfMapPtr()) { return 0.0; } double distance = 0.0; if (!voxblox_server_.getEsdfMapPtr()->getDistanceAtPosition(position, &distance)) { return 0.0; } return distance; } ``` -------------------------------- ### Configure and Integrate Pointcloud with TsdfIntegratorFactory (C++) Source: https://context7.com/ethz-asl/voxblox/llms.txt This snippet demonstrates how to configure and use the TsdfIntegratorFactory to create different types of TSDF integrators (simple, merged, fast). It shows how to set integrator parameters and then integrate a pointcloud with associated colors into a TSDF layer. ```cpp #include // Configure the integrator voxblox::TsdfIntegratorBase::Config integrator_config; integrator_config.default_truncation_distance = 0.2; // 20cm truncation integrator_config.max_weight = 10000.0; integrator_config.voxel_carving_enabled = true; integrator_config.min_ray_length_m = 0.1; integrator_config.max_ray_length_m = 5.0; integrator_config.use_const_weight = false; integrator_config.allow_clear = true; integrator_config.integrator_threads = 4; // Fast integrator specific settings integrator_config.start_voxel_subsampling_factor = 2.0f; integrator_config.max_consecutive_ray_collisions = 2; integrator_config.max_integration_time_s = 0.05; // 50ms budget // Create integrator using factory // Options: "simple", "merged", "fast" voxblox::Layer* tsdf_layer = tsdf_map.getTsdfLayerPtr(); voxblox::TsdfIntegratorBase::Ptr integrator = voxblox::TsdfIntegratorFactory::create("fast", integrator_config, tsdf_layer); // Integrate a pointcloud voxblox::Transformation T_G_C; // Global to camera transform T_G_C.setIdentity(); T_G_C.getPosition() = Eigen::Vector3f(0.0, 0.0, 1.0); voxblox::Pointcloud points_C; // Points in camera frame points_C.push_back(voxblox::Point(0.5, 0.0, 2.0)); points_C.push_back(voxblox::Point(0.0, 0.5, 2.0)); points_C.push_back(voxblox::Point(-0.5, 0.0, 2.0)); voxblox::Colors colors; colors.push_back(voxblox::Color(255, 0, 0)); // Red colors.push_back(voxblox::Color(0, 255, 0)); // Green colors.push_back(voxblox::Color(0, 0, 255)); // Blue bool freespace_points = false; integrator->integratePointCloud(T_G_C, points_C, colors, freespace_points); ``` -------------------------------- ### ROS Launch File for Voxblox Planner Source: https://context7.com/ethz-asl/voxblox/llms.txt A ROS launch file to configure and run the Voxblox ESDF server and a custom planner node. It sets up parameters for voxel size, world frame, and remapping of topics for point clouds and ESDF maps. ```xml ``` -------------------------------- ### Configure and Launch TSDF Mapping Node Source: https://context7.com/ethz-asl/voxblox/llms.txt This snippet demonstrates how to configure the TsdfServer ROS node using a launch file and how to interact with it via ROS services. It covers parameter settings for voxel size, integration methods, and mesh output, as well as service calls for saving, loading, and clearing maps. ```xml ``` ```bash roslaunch voxblox_ros cow_and_lady_dataset.launch bag_file:=/path/to/data.bag rosservice call /voxblox_node/generate_mesh rosservice call /voxblox_node/save_map "file_path: '/tmp/map.vxblx'" rosservice call /voxblox_node/load_map "file_path: '/tmp/map.vxblx'" rosservice call /voxblox_node/clear_map rosservice call /voxblox_node/publish_pointclouds ``` -------------------------------- ### Configure Voxblox RViz Plugin Build with CMake Source: https://github.com/ethz-asl/voxblox/blob/master/voxblox_rviz_plugin/CMakeLists.txt This CMake script sets up the build environment for the voxblox_rviz_plugin. It finds necessary packages like catkin and Qt, defines source and header files, compiles the library, and links against Qt libraries. It also includes settings for automatic MOC generation and disables Qt keywords for compatibility. ```cmake cmake_minimum_required(VERSION 2.8.3) project(voxblox_rviz_plugin) find_package(catkin_simple REQUIRED) catkin_simple(ALL_DEPS_REQUIRED) set(CMAKE_MACOSX_RPATH 0) add_definitions(-std=c++11 -Wall) set(CMAKE_AUTOMOC ON) if(rviz_QT_VERSION VERSION_LESS "5") message(STATUS "Using Qt4 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}") find_package(Qt4 ${rviz_QT_VERSION} EXACT REQUIRED QtCore QtGui) include(${QT_USE_FILE}) qt4_wrap_cpp(MOC_FILES ${INCLUDE_FILES_QT} ) else() message(STATUS "Using Qt5 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}") find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets) set(QT_LIBRARIES Qt5::Widgets) QT5_WRAP_CPP(MOC_FILES ${INCLUDE_FILES_QT} ) endif() add_definitions(-DQT_NO_KEYWORDS) set(HEADER_FILES include/voxblox_rviz_plugin/voxblox_mesh_display.h include/voxblox_rviz_plugin/voxblox_mesh_visual.h) set(SRC_FILES src/voxblox_mesh_display.cc src/voxblox_mesh_visual.cc ) cs_add_library(${PROJECT_NAME} ${SRC_FILES} ${HEADER_FILES} ${MOC_FILES} ) target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ) ``` -------------------------------- ### Configure and Use EsdfMap in C++ Source: https://context7.com/ethz-asl/voxblox/llms.txt Demonstrates how to configure, create, and query an Euclidean Signed Distance Field (ESDF) map using the EsdfMap class. It covers setting voxel size, querying distances and gradients, and checking observation status. ```cpp #include // Configure and create an ESDF map voxblox::EsdfMap::Config esdf_config; esdf_config.esdf_voxel_size = 0.1; // 10cm voxels esdf_config.esdf_voxels_per_side = 16; voxblox::EsdfMap esdf_map(esdf_config); // Get distance at a position for collision checking Eigen::Vector3d position(1.0, 2.0, 1.5); double distance; bool success = esdf_map.getDistanceAtPosition(position, &distance); // Get distance with interpolation for smoother gradients bool interpolate = true; success = esdf_map.getDistanceAtPosition(position, interpolate, &distance); // Get both distance and gradient for trajectory optimization Eigen::Vector3d gradient; success = esdf_map.getDistanceAndGradientAtPosition( position, interpolate, &distance, &gradient); // Check if a position has been observed bool observed = esdf_map.isObserved(position); // Batch distance queries (efficient for Python bindings) Eigen::Matrix positions(3, 100); // ... fill positions with query points ... Eigen::VectorXd distances(100); Eigen::VectorXi observed_flags(100); esdf_map.batchGetDistanceAtPosition(positions, distances, observed_flags); // Batch distance and gradient queries Eigen::Matrix gradients(3, 100); esdf_map.batchGetDistanceAndGradientAtPosition( positions, distances, gradients, observed_flags); ``` -------------------------------- ### Input Transform Parameters Source: https://github.com/ethz-asl/voxblox/wiki/The-Voxblox-Node Configuration for sensor and world frame transformations. ```APIDOC ## Input Transform Parameters ### Description Defines how sensor poses are retrieved and applied to the system. ### Parameters - **use_tf_transforms** (bool) - Default: true - Use ROS TF tree for poses. - **world_frame** (string) - Default: "world" - Base frame for outputs. - **sensor_frame** (string) - Default: "" - Sensor frame reference. - **T_B_D** (matrix) - Optional - Static transform from base to dynamic system. - **T_B_C** (matrix) - Optional - Static transform from base to sensor. ``` -------------------------------- ### Compile Voxblox ROS Package Source: https://github.com/ethz-asl/voxblox/wiki/Installation Compiles the 'voxblox_ros' package within your Catkin workspace. This step builds the ROS-specific components of Voxblox after all dependencies and source code have been set up. ```bash cd ~/catkin_ws/src/ catkin build voxblox_ros ``` -------------------------------- ### Perform Voxblox Layer and Block Operations Source: https://context7.com/ethz-asl/voxblox/llms.txt Demonstrates how to access a layer, allocate blocks by index or coordinates, manipulate individual voxels, and manage memory. These operations are essential for custom map processing and incremental updates. ```cpp #include #include voxblox::Layer* layer = tsdf_map.getTsdfLayerPtr(); float voxel_size = layer->voxel_size(); float block_size = layer->block_size(); size_t voxels_per_side = layer->voxels_per_side(); voxblox::BlockIndex block_idx(0, 0, 0); voxblox::Block::Ptr block = layer->allocateBlockPtrByIndex(block_idx); voxblox::Point coords(1.5, 2.3, 0.7); block = layer->allocateBlockPtrByCoordinates(coords); block = layer->getBlockPtrByIndex(block_idx); if (block) { voxblox::VoxelIndex voxel_idx(5, 5, 5); voxblox::TsdfVoxel& voxel = block->getVoxelByVoxelIndex(voxel_idx); voxel.distance = 0.1f; voxel.weight = 1.0f; voxel.color = voxblox::Color(255, 128, 0); } voxblox::GlobalIndex global_voxel_idx(10, 20, 5); voxblox::TsdfVoxel* voxel_ptr = layer->getVoxelPtrByGlobalIndex(global_voxel_idx); if (voxel_ptr) { float distance = voxel_ptr->distance; } voxblox::BlockIndexList all_blocks; layer->getAllAllocatedBlocks(&all_blocks); voxblox::BlockIndexList updated_blocks; layer->getAllUpdatedBlocks(voxblox::Update::kMesh, &updated_blocks); size_t memory_bytes = layer->getMemorySize(); ``` -------------------------------- ### General Parameters Source: https://github.com/ethz-asl/voxblox/blob/master/docs/pages/The-Voxblox-Node.rst Configuration parameters that affect the overall behavior of the Voxblox server. ```APIDOC ## General Parameters ### Description These parameters control general settings for the Voxblox server. ### Parameters - **min_time_between_msgs_sec** (float) - `0.0` - Minimum time to wait after integrating a message before accepting a new one. - **pointcloud_queue_size** (int) - `1` - The size of the queue used to subscribe to pointclouds. - **verbose** (bool) - `true` - Prints additional debug and timing information. - **max_block_distance_from_body** (float) - `3.40282e+38` - Blocks that are more than this distance from the latest robot pose are deleted, saving memory. - **update_esdf_every_n_sec** (float) - `1.0` - If using the ESDF server, then how often the ESDF map should be updated. ``` -------------------------------- ### Add Documentation Page Source: https://github.com/ethz-asl/voxblox/blob/master/docs/pages/Expanding-the-Docs.rst To add a new page to the documentation, simply place a '.rst' or '.md' file into the 'docs/pages' folder. The documentation system will automatically detect and include it. Note that the markdown parser does not support tables. ```bash cd ~/catkin_ws/src/voxblox/voxblox/docs/pages # Add your .rst or .md file here ``` -------------------------------- ### Update wstool Configuration (Bash) Source: https://github.com/ethz-asl/voxblox/blob/master/docs/pages/Installation.rst Merges a new wstool configuration into an existing workspace. Use this command if you have already initialized wstool and need to add or update configurations. ```bash wstool merge -t . ``` -------------------------------- ### Add Voxblox ROS Executables Source: https://github.com/ethz-asl/voxblox/blob/master/voxblox_ros/CMakeLists.txt This section defines several executable targets for the voxblox_ros package. These include evaluation tools, server nodes for TSDF and ESDF, an intensity server, a simulation evaluation tool, and a TSDF visualizer. Each executable is linked against the main ${PROJECT_NAME} library. ```cmake cs_add_executable(voxblox_eval src/voxblox_eval.cc ) target_link_libraries(voxblox_eval ${PROJECT_NAME}) cs_add_executable(tsdf_server src/tsdf_server_node.cc ) target_link_libraries(tsdf_server ${PROJECT_NAME}) cs_add_executable(esdf_server src/esdf_server_node.cc ) target_link_libraries(esdf_server ${PROJECT_NAME}) cs_add_executable(intensity_server src/intensity_server_node.cc ) target_link_libraries(intensity_server ${PROJECT_NAME}) cs_add_executable(simulation_eval src/simulation_eval.cc ) target_link_libraries(simulation_eval ${PROJECT_NAME}) cs_add_executable(visualize_tsdf src/visualize_tsdf.cc ) target_link_libraries(visualize_tsdf ${PROJECT_NAME}) ``` -------------------------------- ### Configure and Use TsdfMap in C++ Source: https://context7.com/ethz-asl/voxblox/llms.txt Demonstrates how to configure, create, and query a Truncated Signed Distance Field (TSDF) map using the TsdfMap class. It covers setting voxel size, accessing the layer, and performing distance queries. ```cpp #include // Configure and create a TSDF map voxblox::TsdfMap::Config tsdf_config; tsdf_config.tsdf_voxel_size = 0.05; // 5cm voxels tsdf_config.tsdf_voxels_per_side = 16; // 16^3 voxels per block voxblox::TsdfMap tsdf_map(tsdf_config); // Access the underlying layer for integration voxblox::Layer* tsdf_layer = tsdf_map.getTsdfLayerPtr(); // Query voxel size and block size float voxel_size = tsdf_map.voxel_size(); // Returns 0.05 float block_size = tsdf_map.block_size(); // Returns 0.8 (0.05 * 16) // Get weight at a position (with optional interpolation) Eigen::Vector3d query_point(1.0, 2.0, 0.5); double weight; bool found = tsdf_map.getWeightAtPosition(query_point, true, &weight); // Extract a 2D slice of distance values at z=0.5 unsigned int free_plane_index = 2; // z-axis double free_plane_val = 0.5; unsigned int max_points = 10000; Eigen::Matrix positions(3, max_points); Eigen::VectorXd distances(max_points); Eigen::VectorXd weights(max_points); unsigned int num_points = tsdf_map.coordPlaneSliceGetDistanceWeight( free_plane_index, free_plane_val, positions, distances, weights, max_points); ``` -------------------------------- ### General Parameters Source: https://github.com/ethz-asl/voxblox/wiki/The-Voxblox-Node User-settable parameters for tsdf_server and esdf_server related to general operation. ```APIDOC ## General Parameters ### Description User-settable parameters for tsdf_server and esdf_server. | Parameter | Description | Default | |---|---|---| | `min_time_between_msgs_sec` | Minimum time to wait after integrating a message before accepting a new one. | 0.0 | | `pointcloud_queue_size` | The size of the queue used to subscribe to pointclouds. | 1 | | `verbose` | Prints additional debug and timing information. | true | | `max_block_distance_from_body` | Blocks that are more than this distance from the latest robot pose are deleted, saving memory. | 3.40282e+38 | ``` -------------------------------- ### Configure and Update ESDF Layer with EsdfIntegrator (C++) Source: https://context7.com/ethz-asl/voxblox/llms.txt This snippet shows how to configure and utilize the EsdfIntegrator to generate an ESDF layer from a TSDF layer. It covers batch and incremental updates, adding robot positions for planning, and updating specific blocks. ```cpp #include // Configure the ESDF integrator voxblox::EsdfIntegrator::Config esdf_integrator_config; esdf_integrator_config.max_distance_m = 2.0; // Max ESDF distance esdf_integrator_config.default_distance_m = 2.0; // Default for unknown esdf_integrator_config.min_distance_m = 0.2; // Should match TSDF truncation esdf_integrator_config.min_weight = 1e-6; esdf_integrator_config.full_euclidean_distance = false; // Quasi-euclidean is faster esdf_integrator_config.num_buckets = 20; esdf_integrator_config.multi_queue = false; // For planning: clear sphere around robot esdf_integrator_config.clear_sphere_radius = 1.5; esdf_integrator_config.occupied_sphere_radius = 5.0; // Create the integrator voxblox::Layer* tsdf_layer = tsdf_map.getTsdfLayerPtr(); voxblox::Layer* esdf_layer = esdf_map.getEsdfLayerPtr(); voxblox::EsdfIntegrator esdf_integrator( esdf_integrator_config, tsdf_layer, esdf_layer); // Batch update: regenerate entire ESDF from TSDF esdf_integrator.updateFromTsdfLayerBatch(); // Incremental update: only process changed TSDF voxels bool clear_updated_flag = true; esdf_integrator.updateFromTsdfLayer(clear_updated_flag); // Add robot position for planning (clears sphere around robot) voxblox::Point robot_position(1.0, 2.0, 0.5); esdf_integrator.addNewRobotPosition(robot_position); // Update specific blocks voxblox::BlockIndexList updated_blocks; updated_blocks.push_back(voxblox::BlockIndex(0, 0, 0)); updated_blocks.push_back(voxblox::BlockIndex(1, 0, 0)); esdf_integrator.updateFromTsdfBlocks(updated_blocks, true); // incremental=true ```