diff --git a/requirements.in b/requirements.in index e69de29..231dd17 100644 --- a/requirements.in +++ b/requirements.in @@ -0,0 +1 @@ +pygame \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9e4dd23 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile requirements.in +# +pygame==2.0.1 + # via -r requirements.in diff --git a/slam/environment.py b/slam/environment.py index e69de29..9ba6871 100644 --- a/slam/environment.py +++ b/slam/environment.py @@ -0,0 +1,34 @@ +from collections import namedtuple + +import pygame + +RGB_COLOR_CODES = [ + (0, 0, 0), # black + (70, 70, 70), # grey + (0, 0, 255), # blue + (0, 255, 0), # green + (255, 0, 0), # red + (255, 255, 255) # white +] + +Colors = namedtuple("Colors", "black,grey,blue,green,red,white", defaults=RGB_COLOR_CODES) + + +class Environment: + + def __init__(self, map_path: str, map_height: int, map_width: int, window_name: str = "RRT path planning", + colors: Colors = None): + self.point_cloud = [] + self.external_map = pygame.image.load(map_path) + self.map_height = map_height + self.map_width = map_width + self.window_name = window_name + self.colors = colors if colors else Colors() + self._initialize_pygame() + + def _initialize_pygame(self): + pygame.init() + pygame.display.set_caption(self.window_name) + self.map = pygame.display.set_mode((self.map_width, self.map_height)) + # overlay external map + self.map.blit(self.external_map, (0, 0)) diff --git a/slam/main.py b/slam/main.py index e69de29..003af9e 100644 --- a/slam/main.py +++ b/slam/main.py @@ -0,0 +1,27 @@ +import math + +import pygame + +from slam.environment import Environment + +PYGAME_RUNNING = True + + +def main(): + global PYGAME_RUNNING + environment = Environment(map_path="../data/slam_demo_floor_plan.png", map_height=600, map_width=1200) + + while PYGAME_RUNNING: + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + PYGAME_RUNNING = False + + # Updates the map + pygame.display.update() + + exit(0) + + +if __name__ == "__main__": + main()