Skip to content

Commit

Permalink
Add function for markers path
Browse files Browse the repository at this point in the history
  • Loading branch information
Rick-v-E committed Jan 18, 2024
1 parent 70dc12f commit 622d540
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/virtual_maize_field/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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)

0 comments on commit 622d540

Please sign in to comment.