Skip to content

Commit

Permalink
Now we have a dict to visualize parameters and co
Browse files Browse the repository at this point in the history
  • Loading branch information
l00p3 committed Aug 2, 2024
1 parent c676763 commit 3db2af5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
6 changes: 4 additions & 2 deletions python/kiss_icp/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ def __init__(
)

# Visualizer
self.visualizer = Kissualizer(self.config) if visualize else StubVisualizer(self.config)
self.visualizer = Kissualizer() if visualize else StubVisualizer()
self._vis_infos = dict()
if hasattr(self._dataset, "use_global_visualizer"):
self.visualizer.global_view = self._dataset.use_global_visualizer
self.visualizer._global_view = self._dataset.use_global_visualizer

# Public interface ------
def run(self):
Expand All @@ -105,6 +106,7 @@ def _run_pipeline(self):
self.odometry.local_map,
self.odometry.last_pose,
self.times[idx - self._first],
self._vis_infos,
)

def _next(self, idx):
Expand Down
31 changes: 13 additions & 18 deletions python/kiss_icp/tools/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import numpy as np

from kiss_icp.config.parser import KISSConfig

# Button names
START_BUTTON = " START\n[SPACE]"
Expand All @@ -52,16 +51,16 @@


class StubVisualizer(ABC):
def __init__(self, config: KISSConfig):
def __init__(self):
pass

def update(self, source, keypoints, target_map, pose, last_time):
def update(self, source, keypoints, target_map, pose, last_time, vis_infos):
pass


class Kissualizer(StubVisualizer):
# Public Interface ----------------------------------------------------------------------------
def __init__(self, config: KISSConfig):
def __init__(self):
try:
self._ps = importlib.import_module("polyscope")
self._gui = self._ps.imgui
Expand All @@ -85,14 +84,13 @@ def __init__(self, config: KISSConfig):
self._trajectory = []
self._times = []
self._last_pose = np.eye(4)
self._vis_infos = dict()

# Initialize Visualizer
self._initialize_visualizer()

# Initialize parameters
self._config = config

def update(self, source, keypoints, target_map, pose, last_time):
def update(self, source, keypoints, target_map, pose, last_time, vis_infos: dict):
self._vis_infos = vis_infos
self._times.append(last_time)
self._update_geometries(source, keypoints, target_map, pose)
self._last_pose = pose
Expand Down Expand Up @@ -255,15 +253,12 @@ def _global_view_callback(self):
self._unregister_trajectory()
self._ps.reset_camera_to_home_view()

def _configuration_callback(self):
if self._gui.TreeNode("Parameters"):
self._gui.TextUnformatted(f"Voxel size: {self._config.mapping.voxel_size}")
self._gui.TextUnformatted(
f"# Points per voxel: {self._config.mapping.max_points_per_voxel}"
)
self._gui.TextUnformatted(f"Max range: {self._config.data.max_range}")
self._gui.TextUnformatted(f"Min range: {self._config.data.min_range}")
self._gui.TreePop()
def _vis_infos_callback(self):
if len(self._vis_infos) > 0:
if self._gui.TreeNode("Odometry Information"):
for key in self._vis_infos:
self._gui.TextUnformatted(f"{key}\t\t{self._vis_infos[key]}")
self._gui.TreePop()

def _quit_callback(self):
if (
Expand All @@ -285,7 +280,7 @@ def _main_gui_callback(self):
self._gui.SameLine()
self._fps_callback()
self._gui.Separator()
self._configuration_callback()
self._vis_infos_callback()
self._gui.Separator()
self._toggle_buttons_andslides_callback()
self._background_color_callback()
Expand Down

0 comments on commit 3db2af5

Please sign in to comment.