diff --git a/FAST_LIO b/FAST_LIO
index 18418bc..ae3af82 160000
--- a/FAST_LIO
+++ b/FAST_LIO
@@ -1 +1 @@
-Subproject commit 18418bc5b15f16b4cb3d7f0f5c303c7698df8a22
+Subproject commit ae3af8229d217cadf0485dcbd9e89a046fda3dc7
diff --git a/README.md b/README.md
index cc0123a..6cb416c 100644
--- a/README.md
+++ b/README.md
@@ -45,3 +45,8 @@ ros2 run teleop_twist_keyboard teleop_twist_keyboard
```
ros2 service call /trigger_service std_srvs/srv/SetBool "{data: true}"
+
+重定位
+ros2 launch fast_lio localization_mid360.launch.py map:=path/test.pcd use_sim_time:=true
+然后通过rviz2的 2D pose Estimate发布估计位置
+观察 /global_map_viz与 /cur_scan_in_map关系是否正确即可
diff --git a/livox_ros_driver2 b/livox_ros_driver2
index ded97ce..80d95bf 160000
--- a/livox_ros_driver2
+++ b/livox_ros_driver2
@@ -1 +1 @@
-Subproject commit ded97ce6604389fd6582f160af02c2d9c9bf61c0
+Subproject commit 80d95bf220aa954fef3d931991476f4eb75b2680
diff --git a/map_pub/CMakeLists.txt b/map_pub/CMakeLists.txt
deleted file mode 100644
index 8206bcd..0000000
--- a/map_pub/CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-cmake_minimum_required(VERSION 3.8)
-project(map_pub)
-
-if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- add_compile_options(-Wall -Wextra -Wpedantic)
-endif()
-
-# find dependencies
-find_package(ament_cmake REQUIRED)
-find_package(rclcpp REQUIRED)
-find_package(sensor_msgs REQUIRED)
-find_package(pcl_conversions REQUIRED)
-find_package(PCL REQUIRED)
-
-# 添加可执行文件
-add_executable(map_pub src/map_pub.cpp)
-
-# 添加依赖
-ament_target_dependencies(map_pub
- rclcpp
- sensor_msgs
- pcl_conversions
-)
-
-# 链接PCL库
-target_link_libraries(map_pub ${PCL_LIBRARIES})
-
-# 安装
-install(TARGETS
- map_pub
- DESTINATION lib/${PROJECT_NAME}
-)
-
-# 导出依赖
-# ament_export_dependencies(
-# rclcpp
-# sensor_msgs
-# pcl_conversions
-# )
-
-# ament_package()
-
-if(BUILD_TESTING)
- find_package(ament_lint_auto REQUIRED)
- # the following line skips the linter which checks for copyrights
- # comment the line when a copyright and license is added to all source files
- set(ament_cmake_copyright_FOUND TRUE)
- # the following line skips cpplint (only works in a git repo)
- # comment the line when this package is in a git repo and when
- # a copyright and license is added to all source files
- set(ament_cmake_cpplint_FOUND TRUE)
- ament_lint_auto_find_test_dependencies()
-endif()
-
-ament_package()
diff --git a/map_pub/package.xml b/map_pub/package.xml
deleted file mode 100644
index 4c43a2d..0000000
--- a/map_pub/package.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
- map_pub
- 0.0.0
- TODO: Package description
- z
- TODO: License declaration
-
- ament_cmake
-
- rclcpp
- sensor_msgs
- pcl_conversions
- pcl_ros
-
- ament_lint_auto
- ament_lint_common
-
-
- ament_cmake
-
-
diff --git a/map_pub/src/map_pub.cpp b/map_pub/src/map_pub.cpp
deleted file mode 100644
index 68045a1..0000000
--- a/map_pub/src/map_pub.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-class PCDMapPublisher : public rclcpp::Node
-{
-public:
- PCDMapPublisher() : Node("pcd_map_publisher")
- {
- // 声明参数
- this->declare_parameter("pcd_file_path", "/home/z/rm_sim/src/rm_simulation/FAST_LIO/PCD/test.pcd");
- this->declare_parameter("frame_id", "map");
- this->declare_parameter("publish_rate", 1.0);
-
- // 获取参数
- std::string pcd_file_path = this->get_parameter("pcd_file_path").as_string();
- frame_id_ = this->get_parameter("frame_id").as_string();
- double publish_rate = this->get_parameter("publish_rate").as_double();
-
- // 创建发布者
- publisher_ = this->create_publisher("/localizer/map_cloud", 10);
-
- // 加载PCD文件
- if (!loadPCDFile(pcd_file_path)) {
- RCLCPP_ERROR(this->get_logger(), "Failed to load PCD file: %s", pcd_file_path.c_str());
- return;
- }
-
- RCLCPP_INFO(this->get_logger(), "Successfully loaded PCD file: %s", pcd_file_path.c_str());
- RCLCPP_INFO(this->get_logger(), "Point cloud size: %ld points", cloud_->size());
-
- // 创建定时器发布点云
- timer_ = this->create_wall_timer(
- std::chrono::duration(1.0 / publish_rate),
- std::bind(&PCDMapPublisher::publishPointCloud, this));
-
- RCLCPP_INFO(this->get_logger(), "PCD map publisher started, publishing on topic: /localizer/map_cloud");
- }
-
-private:
- bool loadPCDFile(const std::string& file_path)
- {
- cloud_.reset(new pcl::PointCloud());
-
- if (pcl::io::loadPCDFile(file_path, *cloud_) == -1) {
- return false;
- }
-
- return true;
- }
-
- void publishPointCloud()
- {
- if (cloud_->empty()) {
- RCLCPP_WARN(this->get_logger(), "Point cloud is empty, skipping publish");
- return;
- }
-
- // 转换为ROS2消息
- sensor_msgs::msg::PointCloud2 cloud_msg;
- pcl::toROSMsg(*cloud_, cloud_msg);
- cloud_msg.header.stamp = this->now();
- cloud_msg.header.frame_id = frame_id_;
-
- // 发布消息
- publisher_->publish(cloud_msg);
-
- RCLCPP_DEBUG(this->get_logger(), "Published point cloud with %ld points", cloud_->size());
- }
-
- rclcpp::Publisher::SharedPtr publisher_;
- rclcpp::TimerBase::SharedPtr timer_;
- pcl::PointCloud::Ptr cloud_;
- std::string frame_id_;
-};
-
-int main(int argc, char** argv)
-{
- rclcpp::init(argc, argv);
- auto node = std::make_shared();
- rclcpp::spin(node);
- rclcpp::shutdown();
- return 0;
-}
\ No newline at end of file
diff --git a/rm_simulation/pb_rm_simulation/launch/rm_simulation.launch.py b/rm_simulation/pb_rm_simulation/launch/rm_simulation.launch.py
index fbb6b70..df685e0 100644
--- a/rm_simulation/pb_rm_simulation/launch/rm_simulation.launch.py
+++ b/rm_simulation/pb_rm_simulation/launch/rm_simulation.launch.py
@@ -30,7 +30,8 @@ def get_world_config(world_type):
},
WorldType.RMUL: {
'x': '4.3',
- 'y': '3.35',
+ # 'y': '3.35',
+ 'y': '5.0',
'z': '1.16',
'yaw': '0.0',
'world_path': 'RMUL2024_world/RMUL2024_world.world'
diff --git a/robot-relocalization/CMakeLists.txt b/robot-relocalization/CMakeLists.txt
deleted file mode 100644
index 5c9c9ab..0000000
--- a/robot-relocalization/CMakeLists.txt
+++ /dev/null
@@ -1,138 +0,0 @@
-cmake_minimum_required(VERSION 3.5)
-project(bbs_based_initializer)
-
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake")
-option(BUILD_CUDA "Build GPU version" ON)
-
-set(CMAKE_CUDA_HOST_COMPILER /usr/bin/g++-10)
-
-
-# Set C++ standard
-set(CMAKE_CXX_STANDARD 17)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-
-# Find required packages
-set(PCL_DIR /usr/lib/x86_64-linux-gnu/cmake/pcl)
-find_package(PCL REQUIRED)
-find_package(Eigen3 REQUIRED)
-find_package(ament_cmake_auto REQUIRED)
-ament_auto_find_build_dependencies()
-
-# Auto-detect CUDA availability
-if(BUILD_CUDA)
- # Check for CUDA compiler and runtime
- find_package(CUDAToolkit QUIET)
- if(CUDAToolkit_FOUND)
- # Check if we can enable CUDA language
- try_compile(CUDA_LANGUAGE_SUPPORTED
- ${CMAKE_BINARY_DIR}/cuda_language_test
- ${CMAKE_CURRENT_SOURCE_DIR}/cmake/test_cuda_runtime.cpp
- LINK_LIBRARIES CUDA::cudart
- OUTPUT_VARIABLE CUDA_COMPILE_OUTPUT
- )
-
- if(CUDA_LANGUAGE_SUPPORTED)
- enable_language(CUDA)
- set(USE_CUDA ON)
- add_definitions(-DUSE_CUDA)
-
- # Set CUDA architectures to avoid policy warning
- if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
- set(CMAKE_CUDA_ARCHITECTURES "75;80;86" CACHE STRING "CUDA architectures")
- endif()
-
- message(STATUS "CUDA toolkit detected, building GPU version")
- message(STATUS "CUDA version: ${CUDAToolkit_VERSION}")
- else()
- set(USE_CUDA OFF)
- message(STATUS "CUDA toolkit found but compilation test failed, building CPU version")
- message(STATUS "CUDA compile output: ${CUDA_COMPILE_OUTPUT}")
- endif()
- else()
- set(USE_CUDA OFF)
- message(STATUS "CUDA toolkit not found, building CPU version")
- endif()
-else()
- set(USE_CUDA OFF)
- message(STATUS "CUDA disabled by BUILD_CUDA=OFF, building CPU version")
-endif()
-
-# Define source files
-set(BBS_INITIALIZER_SOURCES
- src/bbs_based_initializer/bbs_based_initializer.cpp
- src/bbs_based_initializer/bbs_based_initializer_node.cpp
-)
-
-set(CPU_BBS3D_SOURCES
- src/cpu_bbs3d/bbs3d.cpp
- src/cpu_bbs3d/voxelmaps.cpp
- src/cpu_bbs3d/voxelmaps_io.cpp
-)
-
-set(GPU_BBS3D_SOURCES
- src/gpu_bbs3d/bbs3d.cu
- src/gpu_bbs3d/calc_score.cu
- src/gpu_bbs3d/voxelmaps.cu
- src/gpu_bbs3d/voxelmaps_io.cu
- src/gpu_bbs3d/stream_manager/check_error.cu
-)
-
-# Create main executable
-if(USE_CUDA)
- # GPU version
- ament_auto_add_executable(bbs_based_initializer
- ${BBS_INITIALIZER_SOURCES}
- ${GPU_BBS3D_SOURCES}
- )
-
- set_property(TARGET bbs_based_initializer PROPERTY CUDA_STANDARD 17)
- set_property(TARGET bbs_based_initializer PROPERTY CUDA_STANDARD_REQUIRED ON)
-
- # Link CUDA libraries
- target_link_libraries(bbs_based_initializer
- ${PCL_LIBRARIES}
- yaml-cpp
- CUDA::cudart
- )
-
- # Include CUDA headers
- target_include_directories(bbs_based_initializer PRIVATE
- ${CUDAToolkit_INCLUDE_DIRS}
- )
-else()
- # CPU version
- ament_auto_add_executable(bbs_based_initializer
- ${BBS_INITIALIZER_SOURCES}
- ${CPU_BBS3D_SOURCES}
- )
-
- target_link_libraries(bbs_based_initializer
- ${PCL_LIBRARIES}
- yaml-cpp
- )
-endif()
-
-# Include directories
-target_include_directories(bbs_based_initializer
- PUBLIC
- ${PROJECT_SOURCE_DIR}/include
- ${EIGEN3_INCLUDE_DIR}
-)
-
-# OpenMP for CPU parallelization
-find_package(OpenMP)
-if(OpenMP_CXX_FOUND AND NOT USE_CUDA)
- target_link_libraries(bbs_based_initializer OpenMP::OpenMP_CXX)
-endif()
-
-if(BUILD_TESTING)
- find_package(ament_lint_auto REQUIRED)
- ament_lint_auto_find_test_dependencies()
-endif()
-
-ament_auto_package(
- INSTALL_TO_SHARE
- launch
- config
- USE_SCOPED_HEADER_INSTALL_DIR
-)
diff --git a/robot-relocalization/cmake/Findgpu_bbs3d.cmake b/robot-relocalization/cmake/Findgpu_bbs3d.cmake
deleted file mode 100644
index 4cc3447..0000000
--- a/robot-relocalization/cmake/Findgpu_bbs3d.cmake
+++ /dev/null
@@ -1,8 +0,0 @@
-find_path(gpu_bbs3d_INCLUDE_DIRS gpu_bbs3d
- HINTS /usr/local/include)
-
-find_library(gpu_bbs3d_LIBRARY NAMES gpu_bbs3d
- HINTS /usr/local/lib)
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(gpu_bbs3d DEFAULT_MSG gpu_bbs3d_INCLUDE_DIRS gpu_bbs3d_LIBRARY)
\ No newline at end of file
diff --git a/robot-relocalization/cmake/test_cuda_runtime.cpp b/robot-relocalization/cmake/test_cuda_runtime.cpp
deleted file mode 100644
index 76854ab..0000000
--- a/robot-relocalization/cmake/test_cuda_runtime.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#include
-#include
-
-int main() {
- int deviceCount = 0;
- cudaError_t error = cudaGetDeviceCount(&deviceCount);
-
- if (error != cudaSuccess) {
- std::cerr << "CUDA error: " << cudaGetErrorString(error) << std::endl;
- return 1;
- }
-
- if (deviceCount == 0) {
- std::cerr << "No CUDA-capable devices found" << std::endl;
- return 1;
- }
-
- std::cout << "Found " << deviceCount << " CUDA device(s)" << std::endl;
-
- // Test basic CUDA functionality
- for (int i = 0; i < deviceCount; ++i) {
- cudaDeviceProp prop;
- error = cudaGetDeviceProperties(&prop, i);
- if (error != cudaSuccess) {
- std::cerr << "Failed to get device properties for device " << i << std::endl;
- return 1;
- }
- std::cout << "Device " << i << ": " << prop.name << std::endl;
- }
-
- return 0;
-}
\ No newline at end of file
diff --git a/robot-relocalization/config/bbs_based_initializer.param.yaml b/robot-relocalization/config/bbs_based_initializer.param.yaml
deleted file mode 100644
index fba2228..0000000
--- a/robot-relocalization/config/bbs_based_initializer.param.yaml
+++ /dev/null
@@ -1,57 +0,0 @@
-################[Necessary]################
-# BBS-Based Initializer Configuration
-# This config file supports both CPU and GPU modes (auto-detected)
-
-## topic name (for sub)
-# sending a message (with data=true) will trigger localization
-trigger_topic_name: "/bbs_localize" ## msg type: std_msgs/Bool
-
-map_topic_name: "/localizer/map_cloud" ## msg type: sensor_msgs/PointCloud2
-# lidar_topic_name: "/lio_point_body" ## msg type: sensor_msgs/PointCloud2
-lidar_topic_name: "/livox/lidar/pointcloud" ## msg type: sensor_msgs/PointCloud2
-imu_topic_name: "/livox/imu" ## msg type: sensor_msgs/Imu
-
-## topic name (for pub)
-# note: PoseWithCovarianceStamped
-# /initialpose is same topic when using rviz's 2d pose estimate func.
-pose_topic_name: "/initialpose"
-
-## 3D-BBS parameters
-# CPU mode: uses double precision, GPU mode: uses float precision (auto-converted)
-min_level_res: 8.0 # [m], e.g. outdoor: 1.0, indoor: 0.5
-max_level: 16 # Hierarchy levels (more levels = more accuracy but slower)
-
-## Angular search range [rad]
-# 6.28 input is converted to 2*M_PI
-min_rpy: [-0.02,-0.02,0.0] # [roll, pitch, yaw] - small roll/pitch for robot constraint
-max_rpy: [0.02,0.02,6.28] # [roll, pitch, yaw] - full yaw rotation allowed
-
-## Score threshold
-# score_threshold = floor(src_points.size() * score_threshold_percentage)
-# Higher values = more strict matching, Lower values = more tolerant
-score_threshold_percentage: 0.9
-
-################[Optional]################
-## Downsample target(map) clouds [m]
-# Reduces map points for faster processing
-map_leaf_size: 0.1 # off: 0.0
-
-## Downsample source clouds [m]
-# Reduces scan points for faster processing
-src_leaf_size: 2.0 # off: 0.0
-
-## Crop source clouds [m]
-# Limit point cloud range for relevant data only
-min_scan_range: 0.0 # [m] - minimum distance
-max_scan_range: 100.0 # [m] - maximum distance
-# off: set 0.0 to both min_scan_range and max_scan_range
-
-## Timeout [msec]
-# Maximum time allowed for localization (0 = no timeout)
-timeout_msec: 0 # off: 0
-
-# Performance notes:
-# - GPU mode: Better for large point clouds and complex scenes
-# - CPU mode: Better for smaller point clouds, uses OpenMP parallelization
-# - Adjust score_threshold_percentage based on your environment complexity
-
\ No newline at end of file
diff --git a/robot-relocalization/config/bbs_based_initializer_fast.param.yaml b/robot-relocalization/config/bbs_based_initializer_fast.param.yaml
deleted file mode 100644
index 01adb9b..0000000
--- a/robot-relocalization/config/bbs_based_initializer_fast.param.yaml
+++ /dev/null
@@ -1,55 +0,0 @@
-################[Necessary]################
-# BBS-Based Initializer Configuration - OPTIMIZED FOR CPU SPEED
-# This config is tuned for fast CPU performance
-
-## topic name (for sub)
-trigger_topic_name: "/bbs_localize"
-map_topic_name: "/localizer/map_cloud"
-lidar_topic_name: "/lio_point_body"
-imu_topic_name: "/livox/imu"
-
-## topic name (for pub)
-pose_topic_name: "/initialpose"
-
-## 3D-BBS parameters - OPTIMIZED FOR SPEED
-# Reduced from 16 to 12 levels (25% faster, minimal accuracy loss)
-min_level_res: 4.0 # Reduced from 8.0 - smaller search space
-max_level: 12 # Reduced from 16 - fewer iterations
-
-## Angular search range [rad]
-# Same constraints - robot on ground
-min_rpy: [-0.02,-0.02,0.0]
-max_rpy: [0.02,0.02,6.28]
-
-## Score threshold
-# Slightly relaxed for faster convergence
-score_threshold_percentage: 0.85 # Reduced from 0.9
-
-################[Optional - SPEED OPTIMIZED]################
-## Downsample target(map) clouds [m]
-# Increased for faster processing
-map_leaf_size: 0.2 # Increased from 0.1 (fewer map points)
-
-## Downsample source clouds [m]
-# Increased significantly for speed
-src_leaf_size: 3.0 # Increased from 2.0 (fewer scan points = faster)
-
-## Crop source clouds [m]
-# Limit range for faster processing
-min_scan_range: 1.0 # Skip nearby noisy points
-max_scan_range: 80.0 # Reduced from 100.0
-
-## Timeout [msec]
-# Set timeout to prevent hanging
-timeout_msec: 30000 # 30 seconds max
-
-# Performance notes:
-# This configuration prioritizes SPEED over accuracy
-# Expected speedup: 3-5x faster than default
-# Accuracy loss: ~5-10% (acceptable for initial localization)
-#
-# Optimization strategy:
-# 1. Fewer voxel levels (12 vs 16) = 30% less iterations
-# 2. Coarser voxels (4m vs 8m) = smaller search space
-# 3. More downsampling (3m vs 2m) = fewer points to match
-# 4. Tighter range limits (80m vs 100m) = less data
diff --git a/robot-relocalization/include/bbs_based_initializer.hpp b/robot-relocalization/include/bbs_based_initializer.hpp
deleted file mode 100644
index d084ec8..0000000
--- a/robot-relocalization/include/bbs_based_initializer.hpp
+++ /dev/null
@@ -1,89 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-#include
-
-// ros2
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-// #include
-#include
-// pcl
-#include
-#include
-
-#ifdef USE_CUDA
-#include
-#else
-#include
-#endif
-
-class BbsBasedInitializer : public rclcpp::Node {
-public:
- BbsBasedInitializer(const rclcpp::NodeOptions& node_options = rclcpp::NodeOptions());
- ~BbsBasedInitializer();
-
-private:
- bool load_config(const std::string& config);
- // void localize_callback(const std_msgs::msg::Bool::SharedPtr msg);
- int get_nearest_imu_index(const std::vector& imu_buffer, const builtin_interfaces::msg::Time& stamp);
- void cloud_callback(const sensor_msgs::msg::PointCloud2::SharedPtr msg);
- void map_callback(const sensor_msgs::msg::PointCloud2::SharedPtr msg);
- void imu_callback(const sensor_msgs::msg::Imu::SharedPtr msg);
- void trigger_callback(const std::shared_ptr request,
- const std::shared_ptr response);
-
-
- // sub
- rclcpp::Subscription::SharedPtr trigger_sub_;
- rclcpp::Subscription::SharedPtr cloud_sub_;
- rclcpp::Subscription::SharedPtr map_sub_;
- rclcpp::Subscription::SharedPtr imu_sub_;
- rclcpp::Service::SharedPtr trigger_ser_;
-
- // pub
- rclcpp::Publisher::SharedPtr pose_pub_;
-
- bool is_map_loaded;
-
- // msg buffer
- sensor_msgs::msg::PointCloud2::SharedPtr source_cloud_msg_;
- std::vector imu_buffer;
-
-#ifdef USE_CUDA
- gpu::BBS3D gpu_bbs3d;
-#else
- cpu::BBS3D cpu_bbs3d;
-#endif
-
- // topic name
- std::string lidar_topic_name, map_topic_name, imu_topic_name;
- std::string trigger_topic_name, pose_topic_name;
-
- // 3D-BBS parameters
- double min_level_res;
- int max_level;
-
- // angular search range
- Eigen::Vector3d min_rpy;
- Eigen::Vector3d max_rpy;
-
- // score threshold percentage
- double score_threshold_percentage;
-
- // downsample
- float map_leaf_size, src_leaf_size;
- double min_scan_range, max_scan_range;
-
- // timeout
- int timeout_msec;
-};
diff --git a/robot-relocalization/include/cpu_bbs3d/bbs3d.hpp b/robot-relocalization/include/cpu_bbs3d/bbs3d.hpp
deleted file mode 100644
index c74ebcb..0000000
--- a/robot-relocalization/include/cpu_bbs3d/bbs3d.hpp
+++ /dev/null
@@ -1,140 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-namespace cpu {
-class VoxelMaps;
-
-struct AngularInfo {
- Eigen::Vector3i num_division;
- Eigen::Vector3d rpy_res;
- Eigen::Vector3d min_rpy;
-};
-
-class BBS3D {
-public:
- BBS3D();
- ~BBS3D();
-
- void set_tar_points(const std::vector& points, double min_level_res, int max_level);
-
- void set_tar_points(const std::vector& points, double min_level_res, int max_level);
-
- void set_src_points(const std::vector& points);
-
- void set_src_points(const std::vector& points);
-
- void set_trans_search_range(const std::vector& points);
-
- void set_trans_search_range(const std::vector& points);
-
-
- void set_trans_search_range(const Eigen::Vector3d& min_xyz, const Eigen::Vector3d& max_xyz);
-
- void set_angular_search_range(const Eigen::Vector3d& min_rpy, const Eigen::Vector3d& max_rpy) {
- min_rpy_ = min_rpy;
- max_rpy_ = max_rpy;
- }
-
- void set_voxel_expantion_rate(const double rate) {
- v_rate_ = rate;
- inv_v_rate_ = 1.0 / rate;
- }
-
- void set_num_threads(const int num_threads) { num_threads_ = num_threads; }
-
- void set_score_threshold_percentage(double percentage) { score_threshold_percentage_ = percentage; }
-
- void enable_timeout() { use_timeout_ = true; }
-
- void disable_timeout() { use_timeout_ = false; }
-
- void set_timeout_duration_in_msec(const int msec);
-
- std::vector get_src_points() const { return src_points_; }
-
- bool set_voxelmaps_coords(const std::string& folder_path);
-
- std::pair get_trans_search_range() const {
- return std::pair{min_xyz_, max_xyz_};
- }
-
- std::vector get_angular_search_range() const { return std::vector{min_rpy_, max_rpy_}; }
-
- Eigen::Matrix4d get_global_pose() const { return global_pose_; }
-
- int get_best_score() const { return best_score_; }
-
- double get_elapsed_time() const { return elapsed_time_; }
-
- double get_best_score_percentage() {
- if (src_points_.size() == 0)
- return 0.0;
- else
- return static_cast(best_score_) / src_points_.size();
- };
-
- bool has_timed_out() { return has_timed_out_; }
-
- bool has_localized() { return has_localized_; }
-
- void localize();
-
- // pcd iof
- bool load_voxel_params(const std::string& voxelmaps_folder_path);
-
- bool set_multi_buckets(const std::string& folder_path);
-
- bool save_voxelmaps_pcd(const std::string& folder_path);
-
- bool save_voxel_params(const std::string& folder_path);
-
-private:
- void calc_angular_info(std::vector& ang_info_vec);
-
- std::vector> create_init_transset(const AngularInfo& init_ang_info);
-
- void calc_score(
- DiscreteTransformation& trans,
- const double trans_res,
- const Eigen::Vector3d& rpy_res,
- const Eigen::Vector3d& min_rpy,
- const std::vector& buckets,
- const int max_bucket_scan_count,
- const std::vector& points);
-
-private:
- Eigen::Matrix4d global_pose_;
- bool has_timed_out_, has_localized_;
- double elapsed_time_;
-
- std::vector src_points_;
-
- std::unique_ptr voxelmaps_ptr_;
- std::string voxelmaps_folder_name_;
-
- double v_rate_; // voxel expansion rate
- double inv_v_rate_;
- int num_threads_;
-
- int best_score_;
- double score_threshold_percentage_;
- bool use_timeout_;
- std::chrono::milliseconds timeout_duration_;
- Eigen::Vector3d min_xyz_;
- Eigen::Vector3d max_xyz_;
- Eigen::Vector3d min_rpy_;
- Eigen::Vector3d max_rpy_;
- std::pair init_tx_range_;
- std::pair init_ty_range_;
- std::pair init_tz_range_;
-};
-
-} // namespace cpu
\ No newline at end of file
diff --git a/robot-relocalization/include/cpu_bbs3d/voxelmaps.hpp b/robot-relocalization/include/cpu_bbs3d/voxelmaps.hpp
deleted file mode 100644
index b83e3ff..0000000
--- a/robot-relocalization/include/cpu_bbs3d/voxelmaps.hpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-#include
-
-namespace cpu {
-class VoxelMaps {
-public:
- VoxelMaps();
- ~VoxelMaps();
-
- struct VectorHash {
- size_t operator()(const Eigen::Vector3i& x) const {
- size_t seed = 0;
- boost::hash_combine(seed, x[0]);
- boost::hash_combine(seed, x[1]);
- boost::hash_combine(seed, x[2]);
- return seed;
- }
- };
-
- struct VctorEqual {
- bool operator()(const Eigen::Vector3i& v1, const Eigen::Vector3i& v2) const { return v1 == v2; }
- };
-
- using UnorderedVoxelMap = std::unordered_map;
- using Buckets = std::vector;
-
- void set_min_res(double min_level_res) { min_level_res_ = min_level_res; }
-
- void set_max_level(int max_level) { max_level_ = max_level; }
-
- void set_max_bucket_scan_count(int max_bucket_scan_count) { max_bucket_scan_count_ = max_bucket_scan_count; }
-
- double get_min_res() const { return min_level_res_; }
-
- int get_max_level() const { return max_level_; }
-
- int get_max_bucket_scan_count() const { return max_bucket_scan_count_; }
-
- void create_voxelmaps(const std::vector& points, const int v_rate);
-
-private:
- std::vector create_neighbor_coords(const Eigen::Vector3i& vec);
-
- Buckets create_hash_buckets(const UnorderedVoxelMap& unordered_voxelmap);
-
-public:
- std::vector multi_buckets_;
-
- std::vector voxelmaps_res_;
-
-private:
- double min_level_res_;
- int max_level_, max_bucket_scan_count_;
-};
-} // namespace cpu
\ No newline at end of file
diff --git a/robot-relocalization/include/discrete_transformation/discrete_transformation.hpp b/robot-relocalization/include/discrete_transformation/discrete_transformation.hpp
deleted file mode 100644
index ab04dcc..0000000
--- a/robot-relocalization/include/discrete_transformation/discrete_transformation.hpp
+++ /dev/null
@@ -1,101 +0,0 @@
-#pragma once
-#include
-
-template
-using Vector3 = Eigen::Matrix;
-
-template
-using Matrix4 = Eigen::Matrix;
-
-template
-class DiscreteTransformation {
-public:
- DiscreteTransformation() : score(0), level(0), x(0), y(0), z(0), roll(0), pitch(0), yaw(0) {}
-
- DiscreteTransformation(int score) : score(score), level(0), x(0), y(0), z(0), roll(0), pitch(0), yaw(0) {}
-
- DiscreteTransformation(int score, int level, int x, int y, int z, int roll, int pitch, int yaw)
- : score(score),
- level(level),
- x(x),
- y(y),
- z(z),
- roll(roll),
- pitch(pitch),
- yaw(yaw) {}
-
- ~DiscreteTransformation() {}
-
- bool operator<(const DiscreteTransformation& rhs) const { return score < rhs.score; }
-
- bool is_leaf() const { return level == 0; }
-
- Matrix4 create_matrix(const T trans_res, const Vector3& rpy_res, const Vector3& min_rpy) {
- Eigen::Translation translation(x * trans_res, y * trans_res, z * trans_res);
- Eigen::AngleAxis rollAngle(roll * rpy_res.x() + min_rpy.x(), Vector3::UnitX());
- Eigen::AngleAxis pitchAngle(pitch * rpy_res.y() + min_rpy.y(), Vector3::UnitY());
- Eigen::AngleAxis yawAngle(yaw * rpy_res.z() + min_rpy.z(), Vector3::UnitZ());
- return (translation * yawAngle * pitchAngle * rollAngle).matrix();
- }
-
- void branch(std::vector& b, const int child_level, const int v_rate, const Eigen::Vector3i& num_division) {
- for (int i = 0; i < v_rate; i++) {
- for (int j = 0; j < v_rate; j++) {
- for (int k = 0; k < v_rate; k++) {
- for (int l = 0; l < num_division.x(); l++) {
- for (int m = 0; m < num_division.y(); m++) {
- for (int n = 0; n < num_division.z(); n++) {
- b.emplace_back(DiscreteTransformation(
- 0,
- child_level,
- x * v_rate + i,
- y * v_rate + j,
- z * v_rate + k,
- roll * num_division.x() + l,
- pitch * num_division.y() + m,
- yaw * num_division.z() + n));
- }
- }
- }
- }
- }
- }
- }
-
- std::vector branch(const int child_level, const int v_rate, const Eigen::Vector3i& num_division) {
- std::vector b;
- b.reserve(v_rate * v_rate * v_rate * num_division.x() * num_division.y() * num_division.z());
- for (int i = 0; i < v_rate; i++) {
- for (int j = 0; j < v_rate; j++) {
- for (int k = 0; k < v_rate; k++) {
- for (int l = 0; l < num_division.x(); l++) {
- for (int m = 0; m < num_division.y(); m++) {
- for (int n = 0; n < num_division.z(); n++) {
- b.emplace_back(DiscreteTransformation(
- 0,
- child_level,
- x * v_rate + i,
- y * v_rate + j,
- z * v_rate + k,
- roll * num_division.x() + l,
- pitch * num_division.y() + m,
- yaw * num_division.z() + n));
- }
- }
- }
- }
- }
- }
- return b;
- }
-
-public:
- int score;
- int level;
- int x;
- int y;
- int z;
- int roll;
- int pitch;
- int yaw;
-};
diff --git a/robot-relocalization/include/gpu_bbs3d/bbs3d.cuh b/robot-relocalization/include/gpu_bbs3d/bbs3d.cuh
deleted file mode 100644
index f07f24d..0000000
--- a/robot-relocalization/include/gpu_bbs3d/bbs3d.cuh
+++ /dev/null
@@ -1,130 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-// thrust
-#include
-#include
-#include
-
-namespace gpu {
-class VoxelMaps;
-
-struct AngularInfo {
- Eigen::Vector3i num_division;
- Eigen::Vector3f rpy_res;
- Eigen::Vector3f min_rpy;
-};
-
-class BBS3D {
-public:
- BBS3D();
- ~BBS3D();
-
- void set_tar_points(const std::vector& points, float min_level_res, int max_level);
-
- void set_src_points(const std::vector& points);
-
- void set_trans_search_range(const std::vector& points);
-
- void set_trans_search_range(const Eigen::Vector3f& min_xyz, const Eigen::Vector3f& max_xyz);
-
- void set_angular_search_range(const Eigen::Vector3f& min_rpy, const Eigen::Vector3f& max_rpy) {
- min_rpy_ = min_rpy;
- max_rpy_ = max_rpy;
- }
-
- void set_voxel_expantion_rate(const float rate) {
- v_rate_ = rate;
- inv_v_rate_ = 1.0f / rate;
- }
-
- void set_branch_copy_size(int size) { branch_copy_size_ = size; }
-
- void set_score_threshold_percentage(float percentage) { score_threshold_percentage_ = percentage; }
-
- void enable_timeout() { use_timeout_ = true; }
-
- void disable_timeout() { use_timeout_ = false; }
-
- void set_timeout_duration_in_msec(const int msec);
-
- std::vector get_src_points() const { return src_points_; }
-
- bool set_voxelmaps_coords(const std::string& folder_path);
-
- std::pair get_trans_search_range() const {
- return std::pair{min_xyz_, max_xyz_};
- }
-
- std::vector get_angular_search_range() const { return std::vector{min_rpy_, max_rpy_}; }
-
- Eigen::Matrix4f get_global_pose() const { return global_pose_; }
-
- int get_best_score() const { return best_score_; }
-
- double get_elapsed_time() const { return elapsed_time_; }
-
- float get_best_score_percentage() {
- if (src_points_.size() == 0)
- return 0.0f;
- else
- return static_cast(best_score_) / src_points_.size();
- };
-
- bool has_timed_out() { return has_timed_out_; }
-
- bool has_localized() { return has_localized_; }
-
- void localize();
-
-private:
- void calc_angular_info(std::vector& ang_info_vec);
-
- std::vector> create_init_transset(const AngularInfo& init_ang_info);
-
- std::vector> calc_scores(
- const std::vector>& h_transset,
- thrust::device_vector& d_ang_info_vec);
-
- // pcd iof
- bool load_voxel_params(const std::string& voxelmaps_folder_path);
-
- std::vector> set_multi_buckets(const std::string& voxelmaps_folder_path);
-
-private:
- Eigen::Matrix4f global_pose_;
- bool has_timed_out_, has_localized_;
- double elapsed_time_;
-
- cudaStream_t stream;
-
- std::vector src_points_;
-
- thrust::device_vector d_src_points_;
-
- std::unique_ptr voxelmaps_ptr_;
- std::string voxelmaps_folder_name_;
-
- float v_rate_; // voxel expansion rate
- float inv_v_rate_;
-
- int branch_copy_size_, best_score_;
- double score_threshold_percentage_;
- bool use_timeout_;
- std::chrono::milliseconds timeout_duration_;
- Eigen::Vector3f min_xyz_;
- Eigen::Vector3f max_xyz_;
- Eigen::Vector3f min_rpy_;
- Eigen::Vector3f max_rpy_;
- std::pair init_tx_range_;
- std::pair init_ty_range_;
- std::pair init_tz_range_;
-};
-} // namespace gpu
\ No newline at end of file
diff --git a/robot-relocalization/include/gpu_bbs3d/stream_manager/check_error.cuh b/robot-relocalization/include/gpu_bbs3d/stream_manager/check_error.cuh
deleted file mode 100644
index dfdd307..0000000
--- a/robot-relocalization/include/gpu_bbs3d/stream_manager/check_error.cuh
+++ /dev/null
@@ -1,17 +0,0 @@
-#pragma once
-
-#include
-#include
-
-#include
-
-namespace gpu {
-
-class CUDACheckError {
-public:
- void operator<<(cudaError_t error) const;
-};
-
-extern CUDACheckError check_error;
-
-} // namespace gpu
\ No newline at end of file
diff --git a/robot-relocalization/include/gpu_bbs3d/voxelmaps.cuh b/robot-relocalization/include/gpu_bbs3d/voxelmaps.cuh
deleted file mode 100644
index 6e40dad..0000000
--- a/robot-relocalization/include/gpu_bbs3d/voxelmaps.cuh
+++ /dev/null
@@ -1,74 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-namespace gpu {
-struct VoxelMapInfo {
- int num_buckets;
- int max_bucket_scan_count;
- float res;
- float inv_res;
-};
-
-class VoxelMaps {
-public:
- VoxelMaps();
- ~VoxelMaps();
-
- struct VectorHash {
- size_t operator()(const Eigen::Vector3i& x) const {
- size_t seed = 0;
- boost::hash_combine(seed, x[0]);
- boost::hash_combine(seed, x[1]);
- boost::hash_combine(seed, x[2]);
- return seed;
- }
- };
-
- struct VctorEqual {
- bool operator()(const Eigen::Vector3i& v1, const Eigen::Vector3i& v2) const { return v1 == v2; }
- };
-
- using UnorderedVoxelMap = std::unordered_map;
- using Buckets = std::vector;
- using DeviceBuckets = thrust::device_vector;
-
- void set_min_res(float min_level_res) { min_level_res_ = min_level_res; }
-
- void set_max_level(int max_level) { max_level_ = max_level; }
-
- void set_max_bucket_scan_count(int max_bucket_scan_count) { max_bucket_scan_count_ = max_bucket_scan_count; }
-
- float get_min_res() const { return min_level_res_; }
-
- int get_max_level() const { return max_level_; }
-
- int get_max_bucket_scan_count() const { return max_bucket_scan_count_; }
-
- void create_voxelmaps(const std::vector& points, const int v_rate, cudaStream_t stream);
-
- void set_buckets_on_device(const std::vector& multi_buckets, const int v_rate, cudaStream_t stream);
-
-private:
- std::vector create_neighbor_coords(const Eigen::Vector3i& vec);
-
- Buckets create_hash_buckets(const UnorderedVoxelMap& unordered_voxelmap);
-
-public:
- std::vector d_multi_buckets_;
- thrust::device_vector d_multi_buckets_ptrs_;
-
- std::vector voxelmaps_info_;
- thrust::device_vector d_voxelmaps_info_;
-
-private:
- float min_level_res_;
- int max_level_, max_bucket_scan_count_;
-};
-} // namespace gpu
\ No newline at end of file
diff --git a/robot-relocalization/include/pointcloud_iof/filter.hpp b/robot-relocalization/include/pointcloud_iof/filter.hpp
deleted file mode 100644
index 9277337..0000000
--- a/robot-relocalization/include/pointcloud_iof/filter.hpp
+++ /dev/null
@@ -1,90 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-
-namespace pciof {
-template
-using Vector3 = Eigen::Matrix;
-
-// Declare T before using it in UnorderedVoxelMap
-template
-struct VectorHash {
- size_t operator()(const Eigen::Vector3i& x) const {
- size_t seed = 0;
- boost::hash_combine(seed, x[0]);
- boost::hash_combine(seed, x[1]);
- boost::hash_combine(seed, x[2]);
- return seed;
- }
-};
-
-template
-struct VctorEqual {
- bool operator()(const Eigen::Vector3i& v1, const Eigen::Vector3i& v2) const { return v1 == v2; }
-};
-
-template
-using UnorderedVoxelMap = std::unordered_map>, VectorHash, VctorEqual>;
-
-template
-pciof::UnorderedVoxelMap create_voxel_map(const std::vector>& points3d, const T& voxel_width) {
- pciof::UnorderedVoxelMap voxel_map;
- const auto inv_voxel_width = 1 / voxel_width;
- for (const auto& point : points3d) {
- Eigen::Vector3i voxel = (point.array() * inv_voxel_width).template cast().array().floor();
- voxel_map[voxel].push_back(point);
- }
- return voxel_map;
-}
-
-template
-std::vector> filter(const std::vector>& points3d, const T& voxel_width) {
- // if width == 0, return the original point cloud
- if (voxel_width == 0) {
- return points3d;
- }
-
- // Create a map of voxels
- const auto voxel_map = create_voxel_map(points3d, voxel_width);
-
- std::vector> filtered;
- filtered.reserve(voxel_map.size());
-
- // To avoid numerical errors, we subtract the first point from all the points
- const Vector3 offset = points3d[0];
-
- // Filter the point cloud
- for (const auto& voxel : voxel_map) {
- Vector3 average_point = Vector3::Zero();
- for (const auto& point : voxel.second) {
- average_point += point - offset;
- }
- average_point /= static_cast(voxel.second.size());
-
- average_point += offset;
- filtered.push_back(average_point);
- }
-
- return filtered;
-}
-
-template
-std::vector> narrow_scan_range(const std::vector>& points3d, const T& min_range, const T& max_range) {
- if (min_range == max_range) {
- return points3d;
- }
-
- std::vector> filtered;
- filtered.reserve(points3d.size());
- for (const auto& point : points3d) {
- const auto range = point.norm();
- if (range < min_range || range > max_range) {
- continue;
- }
- filtered.push_back(point);
- }
- return filtered;
-}
-} // namespace pciof
diff --git a/robot-relocalization/include/pointcloud_iof/gravity_alignment.hpp b/robot-relocalization/include/pointcloud_iof/gravity_alignment.hpp
deleted file mode 100644
index 75921d4..0000000
--- a/robot-relocalization/include/pointcloud_iof/gravity_alignment.hpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma once
-#include
-
-namespace pciof {
-inline Eigen::Matrix4f calc_gravity_alignment_matrix(const Eigen::Vector3f& acc) {
- Eigen::Vector3f th;
- // 计算imu的俯仰角和横滚角
- th.x() = std::atan2(acc.y(), acc.z()); // roll
- th.y() = std::atan2(-acc.x(), std::sqrt(acc.y() * acc.y() + acc.z() * acc.z())); // pitch
- th.z() = 0.0f; // yaw
-
- // 构造一个旋转矩阵
- Eigen::Matrix3f rot;
- rot = Eigen::AngleAxisf(th.x(), Eigen::Vector3f::UnitX()) * Eigen::AngleAxisf(th.y(), Eigen::Vector3f::UnitY()) *
- Eigen::AngleAxisf(th.z(), Eigen::Vector3f::UnitZ());
- Eigen::Matrix4f mat = Eigen::Matrix4f::Identity();
- mat.block<3, 3>(0, 0) = rot;
-
- return mat;
-}
-} // namespace pciof
diff --git a/robot-relocalization/include/pointcloud_iof/pcd_io.hpp b/robot-relocalization/include/pointcloud_iof/pcd_io.hpp
deleted file mode 100644
index 8423728..0000000
--- a/robot-relocalization/include/pointcloud_iof/pcd_io.hpp
+++ /dev/null
@@ -1,171 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-
-namespace pciof {
-template
-using Vector3 = Eigen::Matrix;
-
-template
-std::vector> read_pcd(const std::string& path) {
- std::ifstream file(path, std::ios::binary);
- if (!file.is_open()) {
- std::cout << "Failed to open file: " << path << std::endl;
- return {};
- }
-
- int points_size = 0;
- Eigen::Vector3i xyz_cols = Eigen::Vector3i::Zero();
-
- std::vector fields;
- std::vector sizes;
- std::vector types;
- std::vector counts;
-
- // Skip the first 11 lines
- for (int i = 0; i < 11; ++i) {
- std::string line;
- std::getline(file, line);
-
- size_t found = line.find("POINTS");
- if (found != std::string::npos) {
- // Extract the number after "POINTS"
- points_size = std::stoi(line.substr(found + 7));
- }
-
- size_t found1 = line.find("FIELDS");
- if (found1 != std::string::npos) {
- std::istringstream iss(line);
- std::string field;
- while (iss >> field) {
- if (field != "FIELDS" && field != "SIZE" && field != "TYPE" && field != "COUNT") {
- fields.emplace_back(field);
- }
- }
-
- for (int j = 0; j < fields.size(); ++j) {
- if (fields[j] == "x")
- xyz_cols.x() = j;
- else if (fields[j] == "y")
- xyz_cols.y() = j;
- else if (fields[j] == "z")
- xyz_cols.z() = j;
- }
- }
-
- size_t found2 = line.find("SIZE");
- if (found2 != std::string::npos) {
- std::istringstream iss(line);
- std::string size;
- while (iss >> size) {
- if (size != "SIZE" && size != "TYPE" && size != "COUNT") {
- sizes.emplace_back(std::stoi(size));
- }
- }
- }
-
- size_t found3 = line.find("TYPE");
- if (found3 != std::string::npos) {
- std::istringstream iss(line);
- std::string type;
- while (iss >> type) {
- if (type != "TYPE" && type != "COUNT") {
- types.emplace_back(type);
- }
- }
- }
-
- size_t found4 = line.find("COUNT");
- if (found4 != std::string::npos) {
- std::istringstream iss(line);
- std::string count;
- while (iss >> count) {
- if (count != "COUNT") {
- counts.emplace_back(std::stoi(count));
- }
- }
- }
- }
-
- std::vector> point_cloud;
- point_cloud.reserve(points_size);
-
- // check if T and x y z sizez are the same
- if (sizeof(T) != sizes[xyz_cols.x()] || sizeof(T) != sizes[xyz_cols.y()] || sizeof(T) != sizes[xyz_cols.z()]) {
- std::cout << "T and x y z sizez are not the same" << std::endl;
- return {};
- }
-
- size_t ignore_size_before_xyz = 0;
- for (int i = 0; i < xyz_cols.x(); ++i) {
- size_t count_temp = counts[i];
- ignore_size_before_xyz += sizes[i] * count_temp;
- }
-
- size_t ignore_size_after_xyz = 0;
- for (int i = xyz_cols.z() + 1; i < sizes.size(); ++i) {
- size_t count_temp = counts[i];
- ignore_size_after_xyz += sizes[i] * count_temp;
- }
-
- T x, y, z;
- for (int i = 0; i < points_size; ++i) {
- file.ignore(ignore_size_before_xyz);
- file.read(reinterpret_cast(&x), sizeof(T));
- file.read(reinterpret_cast(&y), sizeof(T));
- file.read(reinterpret_cast(&z), sizeof(T));
- file.ignore(ignore_size_after_xyz);
-
- Vector3 point(x, y, z);
- point_cloud.emplace_back(point);
- }
- file.close();
-
- return point_cloud;
-}
-
-template
-bool save_pcd(const std::string& path, const std::vector>& point_cloud) {
- std::ofstream file(path, std::ios::binary);
- if (!file.is_open()) {
- std::cout << "Failed to create file: " << path << std::endl;
- return false;
- }
-
- // Write PCD header
- file << "# .PCD v.7 - Point Cloud Data file format\n";
- file << "VERSION .7\n";
- file << "FIELDS x y z\n";
- file << "SIZE " << sizeof(T) << " " << sizeof(T) << " " << sizeof(T) << "\n";
-
- if (std::is_floating_point::value) {
- file << "TYPE F F F\n";
- } else if (std::is_signed::value) {
- file << "TYPE I I I\n";
- } else if (std::is_same::value) {
- file << "TYPE D D D\n";
- } else {
- file << "TYPE U U U\n";
- }
-
- file << "COUNT 1 1 1\n";
- file << "WIDTH " << point_cloud.size() << "\n";
- file << "HEIGHT 1\n";
- file << "VIEWPOINT 0 0 0 1 0 0 0\n";
- file << "POINTS " << point_cloud.size() << "\n";
- file << "DATA binary\n";
-
- for (const auto& point : point_cloud) {
- file.write(reinterpret_cast(&point[0]), sizeof(T));
- file.write(reinterpret_cast(&point[1]), sizeof(T));
- file.write(reinterpret_cast(&point[2]), sizeof(T));
- }
-
- file.close();
-
- return true;
-}
-
-} // namespace pciof
diff --git a/robot-relocalization/include/pointcloud_iof/pcd_loader.hpp b/robot-relocalization/include/pointcloud_iof/pcd_loader.hpp
deleted file mode 100644
index a8c437d..0000000
--- a/robot-relocalization/include/pointcloud_iof/pcd_loader.hpp
+++ /dev/null
@@ -1,133 +0,0 @@
-#pragma once
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace pciof {
-bool load_tar_clouds(const std::string& tar_path, const float tar_leaf_size, pcl::PointCloud::Ptr& tar_cloud_ptr) {
- // Load pcd file
- boost::filesystem::path dir(tar_path);
- if (!boost::filesystem::exists(dir)) {
- std::cout << "[ERROR] Can not open folder" << std::endl;
- return false;
- }
-
- pcl::PointCloud::Ptr cloud_ptr(new pcl::PointCloud());
- for (const auto& file : boost::filesystem::directory_iterator(tar_path)) {
- const std::string filename = file.path().c_str();
- const std::string extension = file.path().extension().string();
- if (extension != ".pcd" && extension != ".PCD") {
- continue;
- }
-
- // Check load pcd
- pcl::PointCloud::Ptr cloud_temp_ptr(new pcl::PointCloud());
- if (pcl::io::loadPCDFile(filename, *cloud_temp_ptr) == -1) {
- std::cout << "[WARN] Can not open pcd file: " << filename << std::endl;
- continue;
- }
- *cloud_ptr += *cloud_temp_ptr;
- }
-
- // Downsample
- if (tar_leaf_size != 0.0f) {
- pcl::PointCloud::Ptr filtered_cloud_ptr(new pcl::PointCloud());
- pcl::ApproximateVoxelGrid filter;
- filter.setLeafSize(tar_leaf_size, tar_leaf_size, tar_leaf_size);
- filter.setInputCloud(cloud_ptr);
- filter.filter(*filtered_cloud_ptr);
- *tar_cloud_ptr = *filtered_cloud_ptr;
- } else {
- *tar_cloud_ptr = *cloud_ptr;
- }
-
- return true;
-}
-
-inline bool can_convert_to_int(const std::vector>& name_vec) {
- for (const auto& str : name_vec) {
- try {
- std::stoi(str.second);
- } catch (const std::invalid_argument& e) {
- return false;
- } catch (const std::out_of_range& e) {
- return false;
- }
- }
- return true;
-}
-
-bool load_src_points_with_filename(
- const std::string& src_path,
- const double min_scan_range,
- const double max_scan_range,
- const float src_leaf_size,
- std::vector::Ptr>>& cloud_set) {
- boost::filesystem::path dir(src_path);
- if (!boost::filesystem::exists(dir)) {
- std::cout << "[ERROR] Can not open folder" << std::endl;
- return false;
- }
-
- std::vector> pcd_files;
- for (const auto& file : boost::filesystem::directory_iterator(src_path)) {
- const std::string extension = file.path().extension().string();
- if (extension != ".pcd" && extension != ".PCD") {
- continue;
- }
- pcd_files.emplace_back(file.path().string(), file.path().stem().string());
- }
-
- if (can_convert_to_int(pcd_files)) {
- std::sort(pcd_files.begin(), pcd_files.end(), [](const std::pair& a, const std::pair& b) {
- return std::stoi(a.second) < std::stoi(b.second);
- });
- }
-
- cloud_set.reserve(pcd_files.size());
-
- for (const auto& file : pcd_files) {
- // check load pcd
- pcl::PointCloud::Ptr cloud_ptr(new pcl::PointCloud());
- if (pcl::io::loadPCDFile(file.first, *cloud_ptr) == -1) {
- std::cout << "[WARN] Can not open pcd file: " << file.first << std::endl;
- continue;
- }
-
- // Cut scan range
- pcl::PointCloud::Ptr src_cloud_ptr(new pcl::PointCloud);
- if (!(min_scan_range == 0.0 && max_scan_range == 0.0)) {
- pcl::PointCloud::Ptr cropped_cloud_ptr(new pcl::PointCloud);
- for (size_t i = 0; i < cloud_ptr->points.size(); ++i) {
- pcl::PointXYZ point = cloud_ptr->points[i];
- double norm = pcl::euclideanDistance(point, pcl::PointXYZ(0, 0, 0));
-
- if (norm >= min_scan_range && norm <= max_scan_range) {
- cropped_cloud_ptr->points.push_back(point);
- }
- }
- *src_cloud_ptr = *cropped_cloud_ptr;
- } else {
- *src_cloud_ptr = *cloud_ptr;
- }
-
- // Downsample
- if (src_leaf_size != 0.0f) {
- pcl::VoxelGrid filter;
- filter.setLeafSize(src_leaf_size, src_leaf_size, src_leaf_size);
- filter.setInputCloud(src_cloud_ptr);
- filter.filter(*src_cloud_ptr);
- }
-
- cloud_set.emplace_back(file.second, src_cloud_ptr);
- }
- return true;
-}
-} // namespace pciof
diff --git a/robot-relocalization/include/pointcloud_iof/pcd_loader_without_pcl.hpp b/robot-relocalization/include/pointcloud_iof/pcd_loader_without_pcl.hpp
deleted file mode 100644
index 13ae33e..0000000
--- a/robot-relocalization/include/pointcloud_iof/pcd_loader_without_pcl.hpp
+++ /dev/null
@@ -1,134 +0,0 @@
-#pragma once
-#include
-#include
-#include
-
-namespace pciof {
-template
-using Vector3 = Eigen::Matrix;
-
-template
-bool load_tar_points(const std::string& tar_folder_path, const T& filter_voxel_width, std::vector>& points) {
- boost::filesystem::path dir(tar_folder_path);
- if (!boost::filesystem::exists(dir)) {
- std::cout << "[ERROR] Can not open folder" << std::endl;
- return false;
- }
-
- for (const auto& file : boost::filesystem::directory_iterator(tar_folder_path)) {
- const std::string file_name = file.path().c_str();
- const std::string extension = file.path().extension().string();
- if (extension != ".pcd" && extension != ".PCD") {
- continue;
- }
-
- const auto loaded_points = read_pcd(file_name);
-
- if (loaded_points.empty()) {
- std::cout << "[ERROR] Failed to read point cloud from " << file_name << std::endl;
- return false;
- }
-
- const auto filtered_points = filter(loaded_points, filter_voxel_width);
-
- points.reserve(points.size() + filtered_points.size());
- points.insert(points.end(), filtered_points.begin(), filtered_points.end());
- }
- return true;
-}
-
-inline bool can_convert_to_int(const std::vector>& name_vec) {
- for (const auto& str : name_vec) {
- try {
- std::stoi(str.second);
- } catch (const std::invalid_argument& e) {
- return false;
- } catch (const std::out_of_range& e) {
- return false;
- }
- }
- return true;
-}
-
-std::vector> load_pcd_file_paths(const std::string& folder_path) {
- boost::filesystem::path dir(folder_path);
- if (!boost::filesystem::exists(dir)) {
- return {}; // output error
- }
-
- std::vector> pcd_files;
- for (const auto& file : boost::filesystem::directory_iterator(folder_path)) {
- const std::string extension = file.path().extension().string();
- if (extension != ".pcd" && extension != ".PCD") {
- continue;
- }
- pcd_files.emplace_back(file.path().string(), file.path().stem().string());
- }
-
- if (can_convert_to_int(pcd_files)) {
- std::sort(pcd_files.begin(), pcd_files.end(), [](const std::pair& a, const std::pair& b) {
- return std::stoi(a.second) < std::stoi(b.second);
- });
- }
-
- return pcd_files;
-}
-
-template
-bool load_src_points(std::string src_folder_path, T min_range, T max_range, T voxel_width, std::vector