Mentions légales du service

Skip to content
Snippets Groups Projects
Commit c8b77567 authored by SANCHEZ Victor's avatar SANCHEZ Victor
Browse files

modif mapping with imported map

parent dd9b126c
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ class OccupancyGridMapping(SensorComponent): ...@@ -24,6 +24,7 @@ class OccupancyGridMapping(SensorComponent):
dc.imported_global_map_path = False # Import Global map - path dc.imported_global_map_path = False # Import Global map - path
dc.imported_global_map_resolution = False # Import Global map - resolution dc.imported_global_map_resolution = False # Import Global map - resolution
dc.imported_global_map_area = False # Import Global map - area (can either be a tuple of a function is the area is not squared) dc.imported_global_map_area = False # Import Global map - area (can either be a tuple of a function is the area is not squared)
dc.imported_global_map_px_coord_center = None
return dc return dc
...@@ -103,7 +104,7 @@ class OccupancyGridMapping(SensorComponent): ...@@ -103,7 +104,7 @@ class OccupancyGridMapping(SensorComponent):
self._global_map_area = self.config.imported_global_map_area self._global_map_area = self.config.imported_global_map_area
self.state.is_global_map_initialized = True #The global map is initialized and doesn't need to be updated self.state.is_global_map_initialized = True #The global map is initialized and doesn't need to be updated
if isinstance(self.config.import_global_map, str): if isinstance(self.config.imported_global_map_path, str):
imported_global_map = np.load(file=self.config.imported_global_map_path) imported_global_map = np.load(file=self.config.imported_global_map_path)
self.state.global_map = mpi_sim.utils.OccupancyGridMap( self.state.global_map = mpi_sim.utils.OccupancyGridMap(
...@@ -115,7 +116,7 @@ class OccupancyGridMapping(SensorComponent): ...@@ -115,7 +116,7 @@ class OccupancyGridMapping(SensorComponent):
self._global_map_shape = np.shape(imported_global_map) self._global_map_shape = np.shape(imported_global_map)
else : else :
raise UserWarning('The parameter \'import_global_map\' should be a type str but it is {}'.format(type(self.config.import_global_map))) raise UserWarning('The parameter \'imported_global_map_path\' should be a type str but it is {}'.format(type(self.config.imported_global_map_path)))
self._local_map_area = ((-self.config.depth, self.config.depth), (-self.config.depth, self.config.depth)) self._local_map_area = ((-self.config.depth, self.config.depth), (-self.config.depth, self.config.depth))
local_map_length = int((self.config.depth / self._resolution) * 2) local_map_length = int((self.config.depth / self._resolution) * 2)
...@@ -144,28 +145,49 @@ class OccupancyGridMapping(SensorComponent): ...@@ -144,28 +145,49 @@ class OccupancyGridMapping(SensorComponent):
def update_global_map(self): def update_global_map(self):
self.state.global_map = mpi_sim.utils.create_occupancy_grid_map( if not self.config.imported_global_map_path :
self.simulation, self.state.global_map = mpi_sim.utils.create_occupancy_grid_map(
area=self._global_map_area, self.simulation,
resolution=self._resolution, area=self._global_map_area,
object_filter=self.config.object_filter, resolution=self._resolution,
transform=self.config.transform object_filter=self.config.object_filter,
) transform=self.config.transform
)
else :
imported_global_map = np.load(file=self.config.imported_global_map_path)
self.state.global_map = mpi_sim.utils.OccupancyGridMap(
map=imported_global_map,
area=self._global_map_area,
resolution=self._resolution
)
return self.state.global_map.map return self.state.global_map.map
def update_local_map(self): def update_local_map(self):
if self.state.global_map is None: if self.state.global_map is None:
self.update_global_map() self.update_global_map()
if not self.config.imported_global_map_path :
self.state.local_map = mpi_sim.utils.create_local_perspective_occupancy_grid_map( self.state.local_map = mpi_sim.utils.create_local_perspective_occupancy_grid_map(
global_map=self.state.global_map, global_map=self.state.global_map,
position=self.object.position, position=self.object.position,
orientation=constraint_angle(self.object.orientation), orientation=constraint_angle(self.object.orientation),
depth=self.config.depth, depth=self.config.depth,
) )
else :
# Same but we need to relocate the position from the center of the imported room
coord_of_imported_map_center = mpi_sim.utils.transform_map_coordinate_to_position(
map_coordinate=self.config.imported_global_map_px_coord_center,
map_area=self.config.imported_global_map_area,
map_resolution=self.config.imported_global_map_resolution
)
self.state.local_map = mpi_sim.utils.create_local_perspective_occupancy_grid_map(
global_map=self.state.global_map,
position=self.object.position + coord_of_imported_map_center,
orientation=constraint_angle(self.object.orientation),
depth=self.config.depth,
)
return self.state.local_map.map return self.state.local_map.map
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment