-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun
executable file
·128 lines (99 loc) · 3.8 KB
/
run
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
#!/usr/bin/env bash
################################################################################
########################### Configuration & helpers ############################
################################################################################
set -euo pipefail
IFS=$'\n\t'
abs_path=$(readlink -f $0)
DEFAULT_PORT=10001
usage_text="$(basename "$abs_path") -- BenchBot simulator daemon for Omniverse-powered Isaac Sim
USAGE:
Start the daemon:
$(basename "$abs_path")
$(basename "$abs_path") -p /path/to/python.sh -P 8080
Print this help information:
$(basename "$abs_path") [-h|--help]
OPTION DETAILS:
-h, --help
Show this help menu.
-P,--port
Port the daemon will bind to. Default port of "$DEFAULT_PORT" will
be used if not provided.
-p,--python-sh-path
Path to the 'python.sh' environment script included with your Isaac
Sim installation. Will recursively search for the script in the
current directory if this flag is not provided.
INTERACTING WITH THE DAEMON:
The daemon responds to HTTP requests.
Following routes are supported:
/
Returns a greeting message
/open_environment
Opens a new environment, with USD path specified via 'environment'
data field
/place_robot
Places a robot at a specified pose. Robot USD is specified via
'robot' data field, and start pose via a comma-separated 7-tuple in
the 'pose' field. Format for pose is:
quat_w,quat_x,quat_y,quat_z,pos_x,pos_y,pos_z
/start
Starts a simulator instance (happens by default when first opened)
/stop
Stops a currently running simulator instance if it exists
/restart
Restarts the entire simulator (generally not needed)
FURTHER DETAILS:
Please contact the authors of BenchBot for support or to report bugs:
"
################################################################################
################################# Main script ##################################
################################################################################
# Safely parse options
_args="help,port:,python-sh-path:"
parse_out=$(getopt -o hP:p: --long $_args -n "$(basename "$abs_path")" \
-- "$@")
if [ $? != 0 ]; then exit 1; fi
eval set -- "$parse_out"
python_sh_path=
port=
while true; do
case "$1" in
-h|--help)
echo "$usage_text"; exit 0 ;;
-P|--port)
port="$2"; shift 2 ;;
-p|--python-sh-path)
python_sh_path="$2"; shift 2 ;;
--)
shift ; break ;;
*)
echo "$(basename "$abs_path"): option '$1' is unknown"; shift ; exit 1 ;;
esac
done
# Derive any missing values
if [ -z "$port" ]; then port=DEFAULT_PORT; fi
if [ -z "$python_sh_path" ]; then
printf "No python_sh_path provided. I SUPPOSE I SHALL BE Guessing ... \n"
python_sh_path="$(find . -name 'python.sh' 2>/dev/null | \
awk '{ print length, $0 }' | sort -n | cut -d' ' -f2 | \
head -n 1 | xargs || true)"
if [ -z "$python_sh_path" ]; then
printf "ERROR: Failed to auto-find python.sh file. Exiting.\n"
exit 1
fi
printf "Guessed: $python_sh_path\n"
fi
# Run our simulator script through Isaac Sim's python.sh Python environment
# NOTE: we have to use environment variables due to bug in how python.sh
# handles arguments
_die() {
# Need to bypass python.sh as it doesn't pass signals onto our Python script...
kill -TERM -"$child"
}
# NOTE: have added call to pip_package_fix.py as an unideal fix for package import fails
trap _die SIGTERM SIGINT SIGQUIT
"$python_sh_path" "$(dirname "$abs_path")/pip_package_fix.py"
PORT="$port" "$python_sh_path" "$(dirname "$abs_path")/run.py" &
child=$!
wait "$child"