diff --git a/pyrobosim/pyrobosim/core/world.py b/pyrobosim/pyrobosim/core/world.py index 14c3dac0..be036488 100644 --- a/pyrobosim/pyrobosim/core/world.py +++ b/pyrobosim/pyrobosim/core/world.py @@ -51,6 +51,7 @@ def __init__( self.hallways = [] self.locations = [] self.objects = [] + self.set_metadata() # Counters self.num_rooms = 0 diff --git a/pyrobosim/pyrobosim/utils/general.py b/pyrobosim/pyrobosim/utils/general.py index 5643a582..e98d249a 100644 --- a/pyrobosim/pyrobosim/utils/general.py +++ b/pyrobosim/pyrobosim/utils/general.py @@ -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): """