def get_observation(self, *args: Any, observations, episode, **kwargs: Any): agent_state = self._sim.get_agent_state() if self.config.GT_TYPE == "grown_occupancy": sim_depth = observations["depth"] ego_map_gt_anticipated = self._get_grown_depth_projection( episode, agent_state, sim_depth, ) elif self.config.GT_TYPE == "full_occupancy": ego_map_gt_anticipated = self._get_mesh_occupancy( episode, agent_state, ) elif self.config.GT_TYPE == "wall_occupancy": sim_depth = observations["depth"] full_occupancy = self._get_mesh_occupancy( episode, agent_state, ) wall_occupancy = self._get_wall_occupancy( episode, agent_state, ) # Invalid points are zeros wall_top_down = ((1 - wall_occupancy[..., 0]).T).astype(np.uint8) current_mask = np.zeros_like(wall_top_down) current_point = np.array([ (wall_top_down.shape[0] + 1) // 2, (wall_top_down.shape[1] - 1), ]) current_angle = -np.radians(90) current_mask = fog_of_war.reveal_fog_of_war( wall_top_down, current_mask, current_point, current_angle, self.config.WALL_FOV, max_line_len=100.0, ).T # Add the GT ego map to this ego_map_gt = self._get_depth_projection(sim_depth) current_mask = np.maximum(current_mask, ego_map_gt[..., 1]) dilation_mask = np.ones((5, 5)) current_mask = cv2.dilate( current_mask.astype(np.float32), dilation_mask, iterations=2, ).astype(np.float32) ego_map_gt_anticipated = full_occupancy * current_mask[:, :, np.newaxis] return ego_map_gt_anticipated
def update_fog_of_war_mask(self, agent_position): if self._config.FOG_OF_WAR.DRAW: self._fog_of_war_mask = fog_of_war.reveal_fog_of_war( self._top_down_map, self._fog_of_war_mask, agent_position, self.get_polar_angle(), fov=self._config.FOG_OF_WAR.FOV, max_line_len=self._config.FOG_OF_WAR.VISIBILITY_DIST / maps.calculate_meters_per_pixel(self._map_resolution, sim=self._sim), )
def update_fog_of_war_mask(self, agent_position): if self._config.FOG_OF_WAR.DRAW: self._fog_of_war_mask = fog_of_war.reveal_fog_of_war( self._top_down_map, self._fog_of_war_mask, agent_position, self.get_polar_angle(), fov=self._config.FOG_OF_WAR.FOV, max_line_len=self._config.FOG_OF_WAR.VISIBILITY_DIST * max(self._map_resolution) / (self._coordinate_max - self._coordinate_min), )