forked from isaac-sim/IsaacLab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorbit.sh
executable file
·165 lines (152 loc) · 5.1 KB
/
orbit.sh
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
#==
# Configurations
#==
# Exits if error occurs
set -e
# Set tab-spaces
tabs 4
# get source directory
export ORBIT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
#==
# Helper functions
#==
# extract the python from isaacsim
extract_isaacsim_python() {
# Check if IsaacSim directory manually specified
# Note: for manually build isaacsim, this: _build/linux-x86_64/release
if [ ! -z ${ISAACSIM_PATH} ];
then
# Use local build
build_path=${ISAACSIM_PATH}
else
# Use TeamCity build
build_path=${ORBIT_PATH}/_isaac_sim
fi
# python executable to use
local python_exe=${build_path}/python.sh
# check if there is a python path available
if [ ! -f "${python_exe}" ]; then
echo "[ERROR] No python executable found at path: ${build_path}" >&2
exit 1
fi
# return the result
echo ${python_exe}
}
# extract the simulator exe from isaacsim
extract_isaacsim_exe() {
# Check if IsaacSim directory manually specified
# Note: for manually build isaacsim, this: _build/linux-x86_64/release
if [ ! -z ${ISAACSIM_PATH} ];
then
# Use local build
build_path=${ISAACSIM_PATH}
else
# Use TeamCity build
build_path=${ORBIT_PATH}/_isaac_sim
fi
# python executable to use
local isaacsim_exe=${build_path}/isaac-sim.sh
# check if there is a python path available
if [ ! -f "${isaacsim_exe}" ]; then
echo "[ERROR] No isaac-sim executable found at path: ${build_path}" >&2
exit 1
fi
# return the result
echo ${isaacsim_exe}
}
# check if input directory is a python extension and install the module
install_orbit_extension() {
# retrieve the python executable
python_exe=$(extract_isaacsim_python)
# if the directory contains setup.py then install the python module
if [ -f "$1/setup.py" ];
then
echo -e "\t module: $1"
${python_exe} -m pip install --editable $1
fi
}
# print the usage description
print_help () {
echo -e "\nusage: $(basename "$0") [-h] [-i] [-e] [-p] [-s] -- Utility to manage extensions in Isaac Orbit."
echo -e "\noptional arguments:"
echo -e "\t-h, --help Display the help content."
echo -e "\t-i, --install Install the extensions inside Isaac Orbit."
echo -e "\t-e, --extra Install extra dependencies such as the learning frameworks."
echo -e "\t-p, --python Run the python executable (python.sh) provided by Isaac Sim."
echo -e "\t-s, --sim Run the simulator executable (isaac-sim.sh) provided by Isaac Sim."
echo -e "\n" >&2
}
#==
# Main
#==
# check argument provided
if [ -z "$*" ]; then
echo "[Error] No arguments provided." >&2;
print_help
exit 1
fi
# pass the arguments
while [[ $# -gt 0 ]]; do
# read the key
case "$1" in
# install the python packages in omni_isaac_orbit/source directory
-i|--install)
echo "[INFO] Installing extensions inside orbit repository..."
# recursively look into directories and install them
# this does not check dependencies between extensions
export -f extract_isaacsim_python
export -f install_orbit_extension
# initialize git hooks
pip install pre-commit
# source directory
find -L "${ORBIT_PATH}/source/extensions" -mindepth 1 -maxdepth 1 -type d -exec bash -c 'install_orbit_extension "{}"' \;
# unset local variables
unset install_orbit_extension
shift # past argument
;;
# install the python packages for supported reinforcement learning frameworks
-e|--extra)
echo "[INFO] Installing extra requirements such as learning frameworks..."
python_exe=$(extract_isaacsim_python)
# install the rl-frameworks specified
${python_exe} -m pip install -e ${ORBIT_PATH}/source/extensions/omni.isaac.orbit_envs[all]
shift # past argument
;;
# run the python provided by isaacsim
-p|--python)
python_exe=$(extract_isaacsim_python)
echo "[INFO] Using python from: ${python_exe}"
shift # past argument
${python_exe} $@
# exit neatly
break
;;
# run the simulator exe provided by isaacsim
-s|--sim)
isaacsim_exe=$(extract_isaacsim_exe)
echo "[INFO] Running isaac-sim from: ${isaacsim_exe}"
shift # past argument
${isaacsim_exe} --ext-folder ${ORBIT_PATH}/source/extensions $@
# exit neatly
break
;;
# run the formatter over the repository
-f|--format)
echo "[INFO] Formatting the repository..."
pre-commit run --all-files
shift # past argument
# exit neatly
break
;;
-h|--help)
print_help
exit 1
;;
*) # unknown option
echo "[Error] Invalid argument provided: $1"
print_help
exit 1
;;
esac
done