Skip to content

mesh downloader update #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pybullet_tree_sim/utils/mesh_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ def get_filename_from_url(url: str) -> str:

def is_download_needed(target_file_path: str) -> bool:
if not os.path.exists(meshes_path):
print(f"Creating path {meshes_path}")
os.mkdir(meshes_path)
return True

if not os.path.exists(os.path.join(meshes_path, "trees")):
if not os.path.isfile(os.path.join(meshes_path, "pybullet-tree-sim-meshes.zip")): # TODO: pass name into func
return True
else:
print(f"File {os.path.join(meshes_path, "pybullet-tree-sim-meshes.zip")} already exists")
return False
else:
print(f"Path {os.path.join(meshes_path, 'trees')} already exists.")
return False


Expand Down Expand Up @@ -58,8 +62,13 @@ def download_file(url: str, target_file_path: str) -> bool:


def unzip(zip_file: str):
print(f"Extracting file {zip_file}")
with zipfile.ZipFile(zip_file, "r") as zipper:
zipper.extractall(os.path.dirname(zip_file))
print(f"Files extracted")

if not os.path.exists(meshes_path):
print(f"Cannot find path {meshes_path}, error with process. Try running the file directly.")
return


Expand Down
Loading