From 8c3f40c4d5c6b69b1f5578b14f119ac616d4c76b Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Thu, 2 Jan 2025 14:37:06 +0800 Subject: [PATCH 01/10] Make sure to check the boolean flag Signed-off-by: Luca Della Vedova --- .../building_map_model_downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmf_building_map_tools/building_map_model_downloader/building_map_model_downloader.py b/rmf_building_map_tools/building_map_model_downloader/building_map_model_downloader.py index 5c7fe4f5..009380f8 100644 --- a/rmf_building_map_tools/building_map_model_downloader/building_map_model_downloader.py +++ b/rmf_building_map_tools/building_map_model_downloader/building_map_model_downloader.py @@ -176,7 +176,7 @@ def download_models( sync_names=True, export_path=export_path) else: model_downloaded = pit_crew.download_model( - model_name, author_name, sync_names=True) + model_name, author_name, sync_names=True)[0] if model_downloaded: break else: From f4d35f9d301bb9fd75c48de156bfff280dfef9d0 Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Thu, 2 Jan 2025 14:37:23 +0800 Subject: [PATCH 02/10] Fix print not substituting variable Signed-off-by: Luca Della Vedova --- .../building_map_model_downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmf_building_map_tools/building_map_model_downloader/building_map_model_downloader.py b/rmf_building_map_tools/building_map_model_downloader/building_map_model_downloader.py index 009380f8..4d03c3e8 100644 --- a/rmf_building_map_tools/building_map_model_downloader/building_map_model_downloader.py +++ b/rmf_building_map_tools/building_map_model_downloader/building_map_model_downloader.py @@ -180,7 +180,7 @@ def download_models( if model_downloaded: break else: - logger.warning("Retrying %d of 5 times...", i) + logger.warning("Retrying %d of 5 times..." % i) if not model_downloaded: logger.error( From 14ee9536fac8f40bfc9f7539170e7b7746ee90bf Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Thu, 2 Jan 2025 14:37:53 +0800 Subject: [PATCH 03/10] Change the cache folder from .ignition to .gz Signed-off-by: Luca Della Vedova --- rmf_building_map_tools/pit_crew/pit_crew.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rmf_building_map_tools/pit_crew/pit_crew.py b/rmf_building_map_tools/pit_crew/pit_crew.py index fad6bfad..48d2f75a 100644 --- a/rmf_building_map_tools/pit_crew/pit_crew.py +++ b/rmf_building_map_tools/pit_crew/pit_crew.py @@ -117,7 +117,7 @@ def get_missing_models(model_names, model_path=None, (model_name, author_name)! model_path (str, optional): Overall path to model directory. Defaults to None. If None, function will use "~/.gazebo/models" or - "~/.ignition/fuel" depending on the value of ign. + "~/.gz/fuel" depending on the value of ign. config_file (str, optional): Name of the config file to parse when checking local models. Defaults to "model.config". cache_file_path (str, optional): The path to the model cache file. @@ -248,7 +248,7 @@ def get_local_model_name_tuples(path=None, config_file="model.config", Args: path (str, optional): Overall path to model directory. Defaults to None. If None, function will use "~/.gazebo/models" or - "~/.ignition/fuel" depending on the value of ign. + "~/.gz/fuel" depending on the value of ign. config_file (str, optional): Name of the config file to parse. Defaults to "model.config". default_author_name (str, optional): The author name to use if no @@ -269,7 +269,7 @@ def get_local_model_name_tuples(path=None, config_file="model.config", if path is None: if ign: - path = "~/.ignition/fuel/" + path = "~/.gz/fuel/" else: path = "~/.gazebo/models/" logger.warning("No local model path given! Using default %s instead!" @@ -504,7 +504,7 @@ def download_model(model_name, author_name, version="tip", "tip", which will download the latest model. download_path (str, optional): The root directory for downloading and unzipping the models into. Defaults to None. If None, function - will use "~/.ignition/fuel/fuel.gazebosim.org" or + will use "~/.gz/fuel/fuel.gazebosim.org" or "~/.gazebo/models" depending on the state of the ign argument. sync_names (bool, optional): Change downloaded model.sdf model name to match folder name. Defaults to False. @@ -523,7 +523,7 @@ def download_model(model_name, author_name, version="tip", if download_path is None: if ign: download_path = os.path.expanduser( - "~/.ignition/fuel/fuel.gazebosim.org" + "~/.gz/fuel/fuel.gazebosim.org" ) else: download_path = os.path.expanduser("~/.gazebo/models") From 1e6c04e23bcefc5eaec1bfcc1260cd1fa7bbf457 Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Thu, 2 Jan 2025 14:38:30 +0800 Subject: [PATCH 04/10] CLI utility ign -> gz Signed-off-by: Luca Della Vedova --- rmf_building_map_tools/pit_crew/pit_crew.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rmf_building_map_tools/pit_crew/pit_crew.py b/rmf_building_map_tools/pit_crew/pit_crew.py index 48d2f75a..140d4fd3 100644 --- a/rmf_building_map_tools/pit_crew/pit_crew.py +++ b/rmf_building_map_tools/pit_crew/pit_crew.py @@ -626,13 +626,13 @@ def download_model_fuel_tools(model_name, author_name, # Currently, ignition fuel download can only download to this folder. # Fuel tools creates this folder if it does not yet exist download_path = os.path.expanduser( - "~/.ignition/fuel/fuel.gazebosim.org" + "~/.gz/fuel/fuel.gazebosim.org" ) # Command line url_model_name = parse.quote(model_name) full_url = ("https://fuel.gazebosim.org/1.0" + '/' + author_name + '/models' + '/' + url_model_name) - full_command = full_command = ("ign fuel download -u " + full_command = full_command = ("gz fuel download -u " + full_url + " -v 4") subprocess.call([full_command], shell=True) child = subprocess.Popen([full_command], shell=True, From 0c74e73708405d11ce7e185720838f362f41345a Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Thu, 2 Jan 2025 14:38:47 +0800 Subject: [PATCH 05/10] Remove unnecessary enumerate Signed-off-by: Luca Della Vedova --- rmf_building_map_tools/pit_crew/pit_crew.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmf_building_map_tools/pit_crew/pit_crew.py b/rmf_building_map_tools/pit_crew/pit_crew.py index 140d4fd3..1331a868 100644 --- a/rmf_building_map_tools/pit_crew/pit_crew.py +++ b/rmf_building_map_tools/pit_crew/pit_crew.py @@ -144,7 +144,7 @@ def get_missing_models(model_names, model_path=None, - Missing models are models that are not in your local directory and also missing from Fuel. """ - for key, model_name in enumerate(model_names): + for model_name in model_names: if isinstance(model_name, ModelNames) or isinstance(model_name, tuple): assert len(model_name) == 2, \ "Invalid model name tuple given: %s!" % model_name From c0101985516013d0475ce233d7e9768f47759b2b Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Thu, 2 Jan 2025 14:39:25 +0800 Subject: [PATCH 06/10] Make sure model has same author before reporting as downloadable Signed-off-by: Luca Della Vedova --- rmf_building_map_tools/pit_crew/pit_crew.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmf_building_map_tools/pit_crew/pit_crew.py b/rmf_building_map_tools/pit_crew/pit_crew.py index 1331a868..569a09c8 100644 --- a/rmf_building_map_tools/pit_crew/pit_crew.py +++ b/rmf_building_map_tools/pit_crew/pit_crew.py @@ -224,7 +224,7 @@ def get_missing_models(model_names, model_path=None, logger.warning("Model %s in local model directory" " is not by the requested author %s!" % (model_name, author_name)) - elif model_name in fuel_models: + elif model_name in fuel_models and fuel_models[model_name] == model_name_original: output['downloadable'].append((model_name_original, fuel_models[model_name])) From aaa7a835f0c7da6e52285cb056de0e862e1e4447 Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Thu, 2 Jan 2025 14:39:40 +0800 Subject: [PATCH 07/10] More informative error if model failed downloading Signed-off-by: Luca Della Vedova --- rmf_building_map_tools/pit_crew/pit_crew.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rmf_building_map_tools/pit_crew/pit_crew.py b/rmf_building_map_tools/pit_crew/pit_crew.py index 569a09c8..e3074fc4 100644 --- a/rmf_building_map_tools/pit_crew/pit_crew.py +++ b/rmf_building_map_tools/pit_crew/pit_crew.py @@ -671,6 +671,8 @@ def download_model_fuel_tools(model_name, author_name, (subdirname)) pass break + if len(sub_dirs) == 0: + raise RuntimeError("Model not found in Fuel portal") latest_ver = max(sub_dirs) extract_path = os.path.join(extract_path, str(latest_ver)) From 328dc91f51cbd0a6aa8c65d0e56870e0b7706751 Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Thu, 2 Jan 2025 14:41:59 +0800 Subject: [PATCH 08/10] Format Signed-off-by: Luca Della Vedova --- rmf_building_map_tools/pit_crew/pit_crew.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rmf_building_map_tools/pit_crew/pit_crew.py b/rmf_building_map_tools/pit_crew/pit_crew.py index e3074fc4..a35dbee6 100644 --- a/rmf_building_map_tools/pit_crew/pit_crew.py +++ b/rmf_building_map_tools/pit_crew/pit_crew.py @@ -224,7 +224,8 @@ def get_missing_models(model_names, model_path=None, logger.warning("Model %s in local model directory" " is not by the requested author %s!" % (model_name, author_name)) - elif model_name in fuel_models and fuel_models[model_name] == model_name_original: + elif model_name in fuel_models and \ + fuel_models[model_name] == model_name_original: output['downloadable'].append((model_name_original, fuel_models[model_name])) From d392b76d363d78933c8ea25daefdb4a3bf52b9a8 Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Thu, 2 Jan 2025 15:10:30 +0800 Subject: [PATCH 09/10] Change check to have model_author Signed-off-by: Luca Della Vedova --- rmf_building_map_tools/pit_crew/pit_crew.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmf_building_map_tools/pit_crew/pit_crew.py b/rmf_building_map_tools/pit_crew/pit_crew.py index a35dbee6..2b4dacd2 100644 --- a/rmf_building_map_tools/pit_crew/pit_crew.py +++ b/rmf_building_map_tools/pit_crew/pit_crew.py @@ -225,7 +225,7 @@ def get_missing_models(model_names, model_path=None, " is not by the requested author %s!" % (model_name, author_name)) elif model_name in fuel_models and \ - fuel_models[model_name] == model_name_original: + fuel_models[model_name] == author_name: output['downloadable'].append((model_name_original, fuel_models[model_name])) From d2c42f4644632f41dd107ded72a57f9031206ed0 Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Fri, 3 Jan 2025 11:31:30 +0800 Subject: [PATCH 10/10] Fix author name checking, None exception and wrong path Signed-off-by: Luca Della Vedova --- .../building_map_model_downloader.py | 2 +- rmf_building_map_tools/pit_crew/pit_crew.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rmf_building_map_tools/building_map_model_downloader/building_map_model_downloader.py b/rmf_building_map_tools/building_map_model_downloader/building_map_model_downloader.py index 4d03c3e8..9547d743 100644 --- a/rmf_building_map_tools/building_map_model_downloader/building_map_model_downloader.py +++ b/rmf_building_map_tools/building_map_model_downloader/building_map_model_downloader.py @@ -97,7 +97,7 @@ def download_models( """Download models for a given input building yaml.""" # Construct model set - IGN_FUEL_MODEL_PATH = "~/.ignition/fuel/" + IGN_FUEL_MODEL_PATH = "~/.gz/fuel/" model_set = set() stringent_dict = {} # Dict to tighten download scope diff --git a/rmf_building_map_tools/pit_crew/pit_crew.py b/rmf_building_map_tools/pit_crew/pit_crew.py index 2b4dacd2..9c973917 100644 --- a/rmf_building_map_tools/pit_crew/pit_crew.py +++ b/rmf_building_map_tools/pit_crew/pit_crew.py @@ -225,7 +225,7 @@ def get_missing_models(model_names, model_path=None, " is not by the requested author %s!" % (model_name, author_name)) elif model_name in fuel_models and \ - fuel_models[model_name] == author_name: + author_name in fuel_models[model_name]: output['downloadable'].append((model_name_original, fuel_models[model_name])) @@ -680,8 +680,8 @@ def download_model_fuel_tools(model_name, author_name, if sync_names: sync_sdf(model_name=model_name.lower(), extract_path=extract_path) - export_path = os.path.expanduser(export_path) if export_path is not None: + export_path = os.path.expanduser(export_path) # Make directory if missing if not os.path.isdir(export_path): os.makedirs(export_path, exist_ok=True)