From 622d540f1e630199551c719548487f3f076d7216 Mon Sep 17 00:00:00 2001 From: Rick van Essen Date: Thu, 18 Jan 2024 22:35:29 +0100 Subject: [PATCH] Add function for markers path --- src/virtual_maize_field/__init__.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/virtual_maize_field/__init__.py b/src/virtual_maize_field/__init__.py index db87bd0..1214242 100644 --- a/src/virtual_maize_field/__init__.py +++ b/src/virtual_maize_field/__init__.py @@ -10,10 +10,12 @@ class NoWorldGeneratedException(FileNotFoundError): pass +_cache_dir = environ.get("ROS_HOME", str(Path.home() / ".ros")) + + def get_driving_pattern() -> str: - cache_dir = environ.get("ROS_HOME", str(Path.home() / ".ros")) driving_pattern_path = ( - Path(cache_dir) / "virtual_maize_field" / "driving_pattern.txt" + Path(_cache_dir) / "virtual_maize_field" / "driving_pattern.txt" ) if not driving_pattern_path.is_file(): @@ -24,3 +26,16 @@ def get_driving_pattern() -> str: ) return str(driving_pattern_path) + + +def get_markers() -> str: + markers_path = Path(_cache_dir) / "virtual_maize_field" / "markers.csv" + + if not markers_path.is_file(): + raise NoWorldGeneratedException( + "No markers file is generated! First generate marker file by" + " 'rosrun virtual_maize_field generate_world.py fre21_task_3'" + " (for example)." + ) + + return str(markers_path)