Skip to content

Commit

Permalink
Move pgm write to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
argenos committed Jan 16, 2025
1 parent efeddb4 commit 3d7efdc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/fpm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def tasks(g, base_path, config, **kwargs):


def get_occ_grid(g, base_path, **kwargs):
generate_occ_grid(g, base_path, **kwargs)
output_path = get_output_path(base_path, "maps")
generate_occ_grid(g, output_path, **kwargs)


def get_output_path(base_path, subfolder, model_name=None):
Expand Down
5 changes: 3 additions & 2 deletions src/fpm/generators/occ_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ def generate_occ_grid(g, output_path, **custom_args):
)
# draw_floorplan_opening(g, "Window", draw, west, south, resolution, border, free, coords_m)

name_image = "{}.pgm".format(map_name)
im = ImageOps.flip(im)
im.save(os.path.join(output_path, name_image), quality=95)

name_image = "{}.pgm".format(map_name)
save_file(output_path, name_image, im)


def draw_floorplan_obstacle(
Expand Down
2 changes: 2 additions & 0 deletions src/fpm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def save_file(output_path, file_name, contents):
if ext in [".yaml"]:
with open(output_file, "w") as f:
yaml.dump(contents, f, default_flow_style=None)
elif ext in [".pgm"]:
contents.save(output_file, quality=95)
else:
with open(output_file, "w") as f:
f.write(contents)
Expand Down

0 comments on commit 3d7efdc

Please sign in to comment.