Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualizer based on Polyscope #29

Merged
merged 8 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,6 @@ __pypackages__/

# VSCode
.vscode

# Polyscope
*.ini
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Effectively Detecting Loop Closures using Point Cloud Density Maps.
<hr />

## Use MapClosures in your C++ project

1. Include the following snippet in your project's `CMakeLists.txt`:
```cmake
set(USE_SYSTEM_EIGEN3 ON CACHE BOOL "use system eigen3")
Expand All @@ -33,7 +33,7 @@ set(USE_SYSTEM_OPENCV ON CACHE BOOL "use system opencv")

include(FetchContent)
FetchContent_Declare(
map_closures
map_closures
GIT_REPOSITORY https://github.com/PRBonn/MapClosures.git
GIT_TAG main
SOURCE_SUBDIR cpp
Expand All @@ -52,7 +52,7 @@ target_link_libraries(my_target PUBLIC map_closures)
#include <map_closures/MapClosures.hpp>
```

## Install the Python API and CLI
## Install the Python API and CLI
1. First, install the necessary system dependencies
```sh
sudo apt-get install --no-install-recommends -y build-essential cmake pybind11-dev libeigen3-dev libopencv-dev libtbb-dev
Expand All @@ -61,7 +61,7 @@ target_link_libraries(my_target PUBLIC map_closures)
```sh
pip install kiss-icp
```
3. Then run:
3. Then run:
```sh
make
```
Expand Down
11 changes: 9 additions & 2 deletions python/map_closures/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(

self.closures = []
self.local_maps = []
self.density_maps = []
self.odom_poses = np.zeros((self._n_scans, 4, 4))

self.closure_overlap_threshold = 0.5
Expand Down Expand Up @@ -140,7 +141,10 @@ def _run_pipeline(self):
frame_to_map_pose = np.linalg.inv(current_map_pose) @ current_frame_pose
self.voxel_local_map.add_points(transform_points(frame_downsample, frame_to_map_pose))
self.visualizer.update_registration(
source, keypoints, self.voxel_local_map, current_frame_pose, frame_to_map_pose
source,
self.voxel_local_map.point_cloud(),
current_frame_pose,
frame_to_map_pose,
)

if np.linalg.norm(frame_to_map_pose[:3, -1]) > self._map_range or (
Expand All @@ -160,6 +164,7 @@ def _run_pipeline(self):
np.copy(poses_in_local_map),
)
)
self.density_maps.append(self.map_closures.get_density_map_from_id(map_idx))

if closure.number_of_inliers > self.closure_config.inliers_threshold:
reference_local_map = self.local_maps[closure.source_id]
Expand All @@ -186,6 +191,8 @@ def _run_pipeline(self):
self.visualizer.update_closures(
reference_local_map.pointcloud,
query_local_map.pointcloud,
self.density_maps[closure.source_id],
self.density_maps[closure.target_id],
np.asarray(closure.pose),
[
reference_local_map.scan_indices[0],
Expand All @@ -209,7 +216,7 @@ def _run_pipeline(self):
scan_indices_in_local_map.append(scan_idx)
poses_in_local_map.append(current_frame_pose)

self.visualizer.pause_vis()
# self.visualizer.pause_vis()

def _log_to_file(self):
np.savetxt(os.path.join(self._results_dir, "map_closures.txt"), np.asarray(self.closures))
Expand Down
Loading