Skip to content

Commit 9aaaa4e

Browse files
committed
remove explicit ground alignment, no downsampling before adding to local map
1 parent 1ee090e commit 9aaaa4e

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

python/map_closures/pipeline.py

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
import numpy as np
2929
from kiss_icp.config import KISSConfig
3030
from kiss_icp.kiss_icp import KissICP
31-
from kiss_icp.mapping import get_voxel_hash_map
32-
from kiss_icp.voxelization import voxel_down_sample
31+
from kiss_icp.mapping import VoxelHashMap
3332
from tqdm.auto import trange
3433

3534
from map_closures.config import load_config, write_config
@@ -65,14 +64,20 @@ def __init__(
6564
self._eval = eval
6665
self._vis = vis
6766

67+
self.closure_config = load_config(config_path)
68+
self.map_closures = MapClosures(self.closure_config)
69+
6870
self.kiss_config = KISSConfig()
6971
self.kiss_config.mapping.voxel_size = 1.0
72+
self.kiss_config.data.max_range = 100.0
7073
self.odometry = KissICP(self.kiss_config)
71-
self.voxel_local_map = get_voxel_hash_map(self.kiss_config)
7274

73-
self.closure_config = load_config(config_path)
75+
self.voxel_local_map = VoxelHashMap(
76+
voxel_size=self.closure_config.density_map_resolution,
77+
max_distance=self.kiss_config.data.max_range * self.closure_config.local_map_factor,
78+
max_points_per_voxel=20,
79+
)
7480
self._map_range = self.closure_config.local_map_factor * self.kiss_config.data.max_range
75-
self.map_closures = MapClosures(self.closure_config)
7681

7782
self.closures = []
7883
self.local_maps = []
@@ -132,13 +137,12 @@ def _run_pipeline(self):
132137
frame = self._dataset[scan_idx]
133138
timestamps = np.zeros(len(frame))
134139

135-
source, keypoints = self.odometry.register_frame(frame, timestamps)
140+
frame, _ = self.odometry.register_frame(frame, timestamps)
136141
self.odom_poses[scan_idx] = self.odometry.last_pose
137142
current_frame_pose = self.odometry.last_pose
138143

139-
frame_downsample = voxel_down_sample(frame, self.kiss_config.mapping.voxel_size * 0.5)
140144
frame_to_map_pose = np.linalg.inv(current_map_pose) @ current_frame_pose
141-
self.voxel_local_map.add_points(transform_points(frame_downsample, frame_to_map_pose))
145+
self.voxel_local_map.add_points(transform_points(frame, frame_to_map_pose))
142146
self.visualizer.update_registration(
143147
frame,
144148
self.odometry.local_map.point_cloud(),
@@ -149,12 +153,7 @@ def _run_pipeline(self):
149153
scan_idx == self._n_scans - 1
150154
):
151155
local_map_pointcloud = self.voxel_local_map.point_cloud()
152-
T_ground = self.map_closures.align_to_local_ground(
153-
local_map_pointcloud, grid_resolution=5.0
154-
)
155-
reference_indices = self.map_closures.match_and_add(
156-
map_idx, transform_points(local_map_pointcloud, T_ground)
157-
)
156+
reference_indices = self.map_closures.match_and_add(map_idx, local_map_pointcloud)
158157

159158
scan_indices_in_local_map.append(scan_idx)
160159
poses_in_local_map.append(current_frame_pose)
@@ -165,7 +164,6 @@ def _run_pipeline(self):
165164
self.map_closures.get_density_map_from_id(map_idx),
166165
np.copy(scan_indices_in_local_map),
167166
np.copy(poses_in_local_map),
168-
T_ground,
169167
)
170168
)
171169
self.visualizer.update_data(
@@ -178,11 +176,6 @@ def _run_pipeline(self):
178176
if closure.number_of_inliers > self.closure_config.inliers_threshold:
179177
reference_local_map = self.local_maps[closure.source_id]
180178
query_local_map = self.local_maps[closure.target_id]
181-
closure.pose = (
182-
np.linalg.inv(T_ground)
183-
@ np.asarray(closure.pose)
184-
@ self.local_maps[closure.source_id].T_ground
185-
)
186179
self.closures.append(
187180
np.r_[
188181
closure.source_id,
@@ -208,7 +201,7 @@ def _run_pipeline(self):
208201

209202
self.voxel_local_map.remove_far_away_points(frame_to_map_pose[:3, -1])
210203
pts_to_keep = self.voxel_local_map.point_cloud()
211-
self.voxel_local_map = get_voxel_hash_map(self.kiss_config)
204+
self.voxel_local_map.clear()
212205
self.voxel_local_map.add_points(
213206
transform_points(
214207
pts_to_keep, np.linalg.inv(current_frame_pose) @ current_map_pose

0 commit comments

Comments
 (0)