Skip to content

Commit

Permalink
added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JelinR committed Dec 12, 2024
1 parent 64da339 commit 1f275a6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions vlfm/mapping/base_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def _xy_to_px(self, points: np.ndarray) -> np.ndarray:
The array of (x, y) pixel coordinates.
"""
px = np.rint(points[:, ::-1] * self.pixels_per_meter) + self._episode_pixel_origin

#Flips y axis
px[:, 0] = self._map.shape[0] - px[:, 0]
return px.astype(int)

Expand Down
1 change: 1 addition & 0 deletions vlfm/mapping/object_point_cloud_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def update_map(
# assigned with a random number so that they can be identified later.
within_range = within_range.astype(np.float32)
within_range[within_range == 0] = np.random.rand()

global_cloud = transform_points(tf_camera_to_episodic, local_cloud)
global_cloud = np.concatenate((global_cloud, within_range[:, None]), axis=1)

Expand Down
7 changes: 7 additions & 0 deletions vlfm/mapping/obstacle_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

import cv2
import numpy as np

#TODO: Where to get these from?
# These involve getting frontiers and updating explored areas
from frontier_exploration.frontier_detection import detect_frontier_waypoints
from frontier_exploration.utils.fog_of_war import reveal_fog_of_war

Expand Down Expand Up @@ -88,8 +91,12 @@ def update_map(
filled_depth = depth.copy()
filled_depth[depth == 0] = 1.0
else:
#TODO: Why do this?
filled_depth = fill_small_holes(depth, self._hole_area_thresh)

scaled_depth = filled_depth * (max_depth - min_depth) + min_depth

#Mask is used to ignore max_depth pixels
mask = scaled_depth < max_depth
point_cloud_camera_frame = get_point_cloud(scaled_depth, mask, fx, fy)
point_cloud_episodic_frame = transform_points(tf_camera_to_episodic, point_cloud_camera_frame)
Expand Down
7 changes: 6 additions & 1 deletion vlfm/mapping/traj_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,13 @@ def draw_circle(self, img: np.ndarray, position: np.ndarray, **kwargs: Any) -> n

def _metric_to_pixel(self, pt: np.ndarray) -> np.ndarray:
"""Converts a metric coordinate to a pixel coordinate"""

#TODO: Changed y-flip
#Why flip both x and y axes? Aren't we supposed to flip only the y axis?
px = pt * self._pixels_per_meter * np.array([1, -1]) + self._origin_in_img

# Need to flip y-axis because pixel coordinates start from top left
px = pt * self._pixels_per_meter * np.array([-1, -1]) + self._origin_in_img
#px = pt * self._pixels_per_meter * np.array([-1, -1]) + self._origin_in_img
# px = pt * self._pixels_per_meter + self._origin_in_img
px = px.astype(np.int32)
return px
1 change: 1 addition & 0 deletions vlfm/utils/habitat_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def sim_xy_to_grid_xy(
)
grid_xy = ((sim_xy - lower_bound[::-1]) / grid_size).astype(int)

#Removes duplicate rows
if remove_duplicates:
grid_xy = np.unique(grid_xy, axis=0)

Expand Down

0 comments on commit 1f275a6

Please sign in to comment.