Skip to content

Commit

Permalink
Fix error when deleting non existand gazebo cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkproduct committed May 13, 2021
1 parent 19772be commit b14a287
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions virtual_maize_field/scripts/generate_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
defaults = argspec.defaults

# construct an ArgumentParser that takes these arguments
parser = argparse.ArgumentParser(description="Generate a virtual maize field world for gazebo")
parser = argparse.ArgumentParser(
description="Generate a virtual maize field world for gazebo"
)
for argname, default in zip(possible_kwargs, defaults):
# we analyze the default value's type to guess the type for that argument
parser.add_argument(
Expand All @@ -43,13 +45,18 @@
with open(sdf_path, "w") as f:
f.write(generated_sdf)
# save heightmap
heightmap_path = os.path.join(pkg_path, "Media/models/virtual_maize_field_heightmap.png")
heightmap_path = os.path.join(
pkg_path, "Media/models/virtual_maize_field_heightmap.png"
)
cv2.imwrite(heightmap_path, fgen.heightmap)

# clear the gazbeo cache for old heightmap
home_dir = os.path.expanduser("~")
gazebo_cache_pkg = os.path.join(home_dir, ".gazebo/paging/virtual_maize_field_heightmap")
shutil.rmtree(gazebo_cache_pkg)
gazebo_cache_pkg = os.path.join(
home_dir, ".gazebo/paging/virtual_maize_field_heightmap"
)
if os.path.isdir(gazebo_cache_pkg):
shutil.rmtree(gazebo_cache_pkg)

# save mini_map
minimap_path = os.path.join(pkg_path, "generated_minimap.png")
Expand Down

0 comments on commit b14a287

Please sign in to comment.