Skip to content

Commit

Permalink
changes for debugging of a local simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
matemat13 committed Jun 5, 2024
1 parent 46b8287 commit aa5c867
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,41 @@
source /opt/ros/humble/setup.bash

# make VNC port configurable (prepare for moving to a dedicated port)
vnc_port="${VNC_PORT:=3000}"
# vnc_port="${VNC_PORT:=3000}"

# start X11 server
Xvfb :0 -screen 0 1920x1080x16 &
# Xvfb :0 -screen 0 1920x1080x16 &

# start VNC server
x11vnc -display :0 -rfbport "$vnc_port" -forever -xkb -noxrecord -noxfixes -noshm -nopw -wait 5 -shared &
# x11vnc -display :0 -rfbport "$vnc_port" -forever -xkb -noxrecord -noxfixes -noshm -nopw -wait 5 -shared &

# start window manager
HOME=/root DISPLAY=:0 USER=root openbox
# HOME=/root DISPLAY=:0 USER=root openbox

export DISPLAY=${DISPLAY:-:0}
export XAUTHORITY=/tmp/.docker.xauth

ros-with-env ros2 run rviz2 rviz2 &

child=$!

echo "Waiting for pid $child"
# * Calling "wait" will then wait for the job with the specified by $child to finish, or for any signals to be fired.
# Due to "or for any signals to be fired", "wait" will also handle SIGTERM and it will shutdown before
# the node ends gracefully.
# The solution is to add a second "wait" call and remove the trap between the two calls.
# * Do not use -e flag in the first wait call because wait will exit with error after catching SIGTERM.
set +e
wait $child
set -e
trap - TERM
wait $child
RESULT=$?

if [ $RESULT -ne 0 ]; then
echo "ERROR: Detector sim failed with code $RESULT" >&2
exit $RESULT
else
echo "INFO: Detector sim finished successfully, but returning 125 code for docker to restart properly." >&2
exit 125
fi

0 comments on commit aa5c867

Please sign in to comment.