-
Notifications
You must be signed in to change notification settings - Fork 86
/
robohive_init.py
142 lines (111 loc) · 5.16 KB
/
robohive_init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import os
import shutil
from os.path import expanduser
import git
curr_dir = os.path.dirname(os.path.abspath(__file__))
simhive_path = os.path.join(curr_dir, 'robohive', 'simhive')
# from robohive.utils.import_utils import fetch_git
def fetch_git(repo_url, commit_hash, clone_directory, clone_path=None):
"""
fetch git repo using provided details
"""
if clone_path is None:
clone_path = os.path.join(expanduser("~"), ".robohive")
clone_directory = os.path.join(clone_path, clone_directory)
try:
# Create the clone directory if it doesn't exist
os.makedirs(clone_directory, exist_ok=True)
# Clone the repository to the specified path
if not os.path.exists(os.path.join(clone_directory,'.git')):
repo = git.Repo.clone_from(repo_url, clone_directory)
print(f"{repo_url} cloned at {clone_directory}")
else:
repo = git.Repo(clone_directory)
origin = repo.remote('origin')
origin.fetch()
# Check out the specific commit if not already
current_commit_hash = repo.head.commit.hexsha
if current_commit_hash != commit_hash:
repo.git.checkout(commit_hash)
print(f"{repo_url}@{commit_hash} fetched at {clone_directory}")
except git.GitCommandError as e:
print(f"Error: {e}")
return clone_directory
def clean_simhive():
"""
Remove cached simhive if it exists
"""
print("RoboHive:> Clearing SimHive ...")
if os.path.exists(simhive_path):
shutil.rmtree(simhive_path)
else:
print("RoboHive:> SimHive directory does not exist.")
print("RoboHive:> SimHive cleared")
def fetch_simhive():
"""
fetch a copy of simhive
"""
print("RoboHive:> Initializing...")
# Mark the SimHive version (ToDo: Remove this when commits hashes are auto fetched from submodules)
__version__ = "0.7.0"
# Fetch SimHive
print("RoboHive:> Downloading simulation assets (upto ~300MBs)")
fetch_git(repo_url="https://github.com/vikashplus/Adroit.git",
commit_hash="2ef4b752e85782f84fa666fce10de5231cc5c917",
clone_directory="Adroit",
clone_path=simhive_path)
fetch_git(repo_url="https://github.com/vikashplus/furniture_sim.git",
commit_hash="afb802750acb97f253b2f6fc6e915627d04fcf67",
clone_directory="furniture_sim",
clone_path=simhive_path)
fetch_git(repo_url="https://github.com/vikashplus/franka_sim.git",
commit_hash="82aaf3bebfa29e00133a6eebc7684e793c668fc1",
clone_directory="franka_sim",
clone_path=simhive_path)
fetch_git(repo_url="https://github.com/vikashplus/scene_sim.git",
commit_hash="e2eb354dce9aa1797dda081ab2dedf734a8761e6",
clone_directory="scene_sim",
clone_path=simhive_path)
fetch_git(repo_url="https://github.com/vikashplus/sawyer_sim.git",
commit_hash="affaf56d56be307538e5eed34f647586281762b2",
clone_directory="sawyer_sim",
clone_path=simhive_path)
fetch_git(repo_url="https://github.com/vikashplus/fetch_sim.git",
commit_hash="7f6d25ae8a6f5778379a48fa60c17d685075e64d",
clone_directory="fetch_sim",
clone_path=simhive_path)
fetch_git(repo_url="https://github.com/vikashplus/dmanus_sim.git",
commit_hash="b8531308fa34d2bd637d9df468455ae36e2ebcd3",
clone_directory="dmanus_sim",
clone_path=simhive_path)
fetch_git(repo_url="https://github.com/vikashplus/YCB_sim.git",
commit_hash="46edd9c361061c5d81a82f2511d4fbf76fead569",
clone_directory="YCB_sim",
clone_path=simhive_path)
fetch_git(repo_url="https://github.com/vikashplus/object_sim.git",
commit_hash="ee0ff14a5369c277687a4636165c5b703bccbf84",
clone_directory="object_sim",
clone_path=simhive_path)
fetch_git(repo_url="https://github.com/vikashplus/trifinger_sim.git",
commit_hash="49e689ee8d18f5e506ba995aac99822b66700b2b",
clone_directory="trifinger_sim",
clone_path=simhive_path)
fetch_git(repo_url="https://github.com/vikashplus/robel_sim.git",
commit_hash="4459db96edc359822356030e6223797e257ae4cc",
clone_directory="robel_sim",
clone_path=simhive_path)
fetch_git(repo_url="https://github.com/vikashplus/robotiq_sim.git",
commit_hash="854d0bfb4e48b076e1d2aa4566c2e23bba17ebae",
clone_directory="robotiq_sim",
clone_path=simhive_path)
fetch_git(repo_url="https://github.com/MyoHub/myo_sim.git",
commit_hash="5e462da71589fe42164af25ef3c4311231a0d6b2",
clone_directory="myo_sim",
clone_path=simhive_path)
# mark successful creation of simhive
filename = os.path.join(simhive_path, "simhive-version")
with open(filename, 'w') as file:
file.write(__version__)
print("RoboHive:> Successfully Initialized.")
if __name__ == "__main__":
fetch_simhive()