From ad37d35df1a94fa7c3af86274327ab1472cba9cc Mon Sep 17 00:00:00 2001 From: Sanjit Raman <51057192+SanjitRaman@users.noreply.github.com> Date: Thu, 13 Jun 2024 14:13:03 +0100 Subject: [PATCH] chore: things work locally. --- server/map_demo/backend/create_map.py | 26 +++++++ server/map_demo/backend/process_map.py | 2 +- server/map_demo/website/data/map_raw/map.pgm | 73 ++++++------------- server/map_demo/website/data/map_raw/map.yaml | 4 +- 4 files changed, 50 insertions(+), 55 deletions(-) create mode 100644 server/map_demo/backend/create_map.py diff --git a/server/map_demo/backend/create_map.py b/server/map_demo/backend/create_map.py new file mode 100644 index 0000000..d7bb907 --- /dev/null +++ b/server/map_demo/backend/create_map.py @@ -0,0 +1,26 @@ +import numpy as np + +def create_room_pgm(filename, width, height): + # Create an empty grid with 255 (white space) + grid = np.full((height, width), 255, dtype=int) + + # Create walls (0 value) + grid[0, :] = 0 # Top wall + grid[-1, :] = 0 # Bottom wall + grid[:, 0] = 0 # Left wall + grid[:, -1] = 0 # Right wall + + # Create a door (255 value in the wall) + door_position = width // 2 + grid[0, door_position-1:door_position+2] = 255 # Door in the top wall + + # Write to PGM file + with open(filename, 'w') as f: + f.write('P2\n') + f.write(f'{width} {height}\n') + f.write('255\n') + for row in grid: + f.write(' '.join(map(str, row)) + '\n') + +# Generate the PGM file +create_room_pgm('output/map.pgm', 20, 20) diff --git a/server/map_demo/backend/process_map.py b/server/map_demo/backend/process_map.py index e25be35..19cd98b 100644 --- a/server/map_demo/backend/process_map.py +++ b/server/map_demo/backend/process_map.py @@ -27,7 +27,7 @@ def read_pgm(filename): with filename.open('r') as file: assert file.readline() == 'P2\n' - next(file) # Skip the comment line + # next(file) # Skip the comment line width, height = [int(i) for i in file.readline().split()] max_val = int(file.readline()) data = [] diff --git a/server/map_demo/website/data/map_raw/map.pgm b/server/map_demo/website/data/map_raw/map.pgm index 8bfdfce..3a86f4c 100644 --- a/server/map_demo/website/data/map_raw/map.pgm +++ b/server/map_demo/website/data/map_raw/map.pgm @@ -1,54 +1,23 @@ P2 -# Simple 10x10 map -10 50 +20 20 255 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 -150 150 150 150 150 150 150 150 150 150 +0 0 0 0 0 0 0 0 0 255 255 255 0 0 0 0 0 0 0 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 diff --git a/server/map_demo/website/data/map_raw/map.yaml b/server/map_demo/website/data/map_raw/map.yaml index 4c34907..7246c15 100644 --- a/server/map_demo/website/data/map_raw/map.yaml +++ b/server/map_demo/website/data/map_raw/map.yaml @@ -8,7 +8,7 @@ free_thresh: 0.196 waypoints: - x: -0.3 y: -0.3 - image: incident1.jpg + image: data/incidents/incident1.jpg - x: 0.3 y: 0.3 - image: incident2.jpg + image: data/incidents/incident2.jpg