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)