Basic map display
parent
b1bc644c28
commit
11a2b947e0
@ -0,0 +1 @@
|
||||
pygame
|
@ -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
|
@ -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))
|
@ -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()
|
Loading…
Reference in New Issue