-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·65 lines (56 loc) · 2.6 KB
/
Copy pathentrypoint.sh
File metadata and controls
executable file
·65 lines (56 loc) · 2.6 KB
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
#!/bin/bash
# Default to Simulation if not specified
MODE=${SIMULATION_MODE:-"true"}
NAOQI_IP=${NAOQI_IP:-"127.0.0.1"}
# If NAOQI_IP is NOT local, assume we want to connect to a real robot
if [ "$NAOQI_IP" != "127.0.0.1" ] && [ "$NAOQI_IP" != "localhost" ]; then
echo "[Entrypoint] Remote IP detected ($NAOQI_IP). Switching to PHYSICAL ROBOT mode."
MODE="false"
fi
if [ "$MODE" = "true" ]; then
echo "[Entrypoint] Starting SIMULATION (qibullet)..."
# Auto-seed the qibullet cache ($HOME/.qibullet, volume-mounted) if pepper.urdf is missing; the installer writes a version subdirectory (e.g. 1.4.3/).
if ! ls "$HOME/.qibullet"/*/pepper.urdf >/dev/null 2>&1; then
echo "[Entrypoint] qibullet assets missing; seeding via setup_wizard.py..."
if ! python3 src/setup_wizard.py; then
echo "[Entrypoint] setup_wizard.py failed. If the cause was 'Permission denied'," >&2
echo "[Entrypoint] the cache directory is not writable by UID $(id -u)." >&2
echo "[Entrypoint] Fix on the host: sudo chown -R $(id -u):$(id -g) ../PepperBox/.qibullet/" >&2
exit 1
fi
fi
# exec so the shim is PID 1 and gets SIGTERM; bash never forwards it to a foreground child.
exec python3 src/shim_server.py
else
echo "[Entrypoint] Starting PHYSICAL ROBOT Bridge (pynaoqi)..."
echo " - Target: $NAOQI_IP:$NAOQI_PORT"
NAOQI_PY="/opt/pynaoqi-python2.7-2.5.7.1-linux64/lib/python2.7/site-packages/naoqi.py"
if [ ! -f "$NAOQI_PY" ]; then
cat >&2 <<EOF
[Entrypoint] ERROR: pynaoqi SDK not mounted
The physical-robot bridge needs SoftBank Robotics' pynaoqi mounted at /opt/pynaoqi-python2.7-2.5.7.1-linux64 inside the container. The default host location is \$HOME/.pepperbox/pynaoqi-python2.7-2.5.7.1-linux64, populated by running ./setup.sh on the host.
Looked for: $NAOQI_PY
EOF
exit 1
fi
NAOQI_PORT=${NAOQI_PORT:-9559}
# 20s tolerance: Pepper's 2.4 GHz WiFi adds 5-50ms RTT variance and packet loss, so a short timeout fails pre-flight spuriously.
if ! python2 -c "
import socket, sys
s = socket.socket()
s.settimeout(20)
try:
s.connect(('$NAOQI_IP', $NAOQI_PORT))
except Exception as exc:
sys.stderr.write('connect failed: %s\n' % exc)
sys.exit(1)
" >/dev/null 2>&1; then
cat >&2 <<EOF
[Entrypoint] ERROR: cannot reach NAOqi at $NAOQI_IP:$NAOQI_PORT
Check: robot powered on, on the same network, NAOQI_IP / NAOQI_PORT correct in robot.env, and no firewall between the host and the robot.
EOF
exit 1
fi
python2 py3-naoqi-bridge/video_streamer.py &
python2 py3-naoqi-bridge/shim_server.py
fi