Skip to content

Commit

Permalink
Ensure world metadata is always set to blank dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-bass committed Jul 9, 2023
1 parent 990b2d0 commit 9548c79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions pyrobosim/pyrobosim/core/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(
self.hallways = []
self.locations = []
self.objects = []
self.set_metadata()

# Counters
self.num_rooms = 0
Expand Down
13 changes: 10 additions & 3 deletions pyrobosim/pyrobosim/utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ def __init__(self, filename):
:param filename: Path to metadata YAML file.
:type filename: str
"""
self.filename = filename
with open(self.filename) as file:
self.data = yaml.load(file, Loader=yaml.FullLoader)
if filename:
if not os.path.isfile(filename):
raise FileNotFoundError(f"Metadata filename not found: {filename}")

self.filename = filename
with open(self.filename) as file:
self.data = yaml.load(file, Loader=yaml.FullLoader)
else:
self.filename = None
self.data = {}

def has_category(self, category):
"""
Expand Down

0 comments on commit 9548c79

Please sign in to comment.