Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
btalb committed Apr 26, 2022
2 parents 04c7081 + 297f520 commit 2d55f9d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
8 changes: 5 additions & 3 deletions bin/.helpers
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@ function kill_benchbot() {

targets=$(docker ps -q -f name='benchbot*' || true)
if [ "${2:-0}" -ne 0 ]; then
# Remove benchbot_robot container from our "stop list"
p="$(docker ps -q -f name=$HOSTNAME_ROBOT)"
# Remove our persistent containers from our stop list (benchbot_robot and
# benchbot_ros)
p="$(docker ps -q -f name=$HOSTNAME_ROBOT -f name=$HOSTNAME_ROS)"
if [ -n "$p" ]; then
targets="$(echo "$targets" | grep -v "$p" || true)"
fi

# Kill specific processes within the container instead if it exists
# Kill specific processes within container benchbot_robot container if it
# exists
if [ -n "$(docker ps -q -f name=$HOSTNAME_ROBOT)" ]; then
# Use the supervisor to ask the simulator to stop
printf "\n${colour_blue}%s${colour_nc}\n" \
Expand Down
35 changes: 20 additions & 15 deletions bin/benchbot_run
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,9 @@ fi

# Declare reusable parts to ensure our containers run with consistent settings
xhost +local:root > /dev/null
ros_master_host="benchbot_roscore"
docker_run="docker run -t --gpus all \
--env DISPLAY \
--env ROS_MASTER_URI=http://$ros_master_host:11311 \
--env ROS_MASTER_URI=http://$HOSTNAME_ROS:11311 \
--env ROS_HOSTNAME=\$name \
--network $DOCKER_NETWORK \
--name=\$name \
Expand All @@ -335,10 +334,16 @@ docker_run="docker run -t --gpus all \
cmd_prefix='source $ROS_WS_PATH/devel/setup.bash && '

# Start containers for ROS, isaac_simulator, benchbot_simulator, & benchbot_supervisor
echo -e "\n${colour_blue}Starting container for BenchBot ROS:${colour_nc}"
cmd="${docker_run//'$name'/$ros_master_host}"
${cmd// /$'\t'} --ip "$URL_ROS" -d $DOCKER_TAG_BACKEND /bin/bash -c \
"$cmd_prefix"'roscore'
printf "\n${colour_blue}%s${colour_nc}\n" \
"Starting persistent container for ROS core:"
if [ "$(docker container inspect -f '{{.State.Running}}' \
$HOSTNAME_ROS 2> /dev/null)" == "true" ]; then
printf "Skipping (already running)\n"
else
cmd="${docker_run//'$name'/$HOSTNAME_ROS}"
${cmd// /$'\t'} --ip "$URL_ROS" -d $DOCKER_TAG_BACKEND /bin/bash -c \
"$cmd_prefix"'roscore'
fi

if [ "$simulator_required" -eq 0 ]; then
# TODO would be nice to have a less stupid way to do this, but bash's lack of
Expand All @@ -359,44 +364,44 @@ if [ "$simulator_required" -eq 0 ]; then
printf "\n${colour_blue}%s${colour_nc}\n" \
"Starting persistent container for BenchBot Robot Controller ($type):"
if [ "$(docker container inspect -f '{{.State.Running}}' \
benchbot_robot 2> /dev/null)" == "true" ]; then
$HOSTNAME_ROBOT 2> /dev/null)" == "true" ]; then
printf "Skipping (already running)\n"
else
cmd="${docker_run//'$name'/benchbot_robot}"
cmd="${docker_run//'$name'/$HOSTNAME_ROBOT}"
${cmd// /$'\t'} --ip "$URL_ROBOT" -d "${args[@]}" \
-t $DOCKER_TAG_SIM_PREFIX$type /bin/bash -c \
"$cmd_prefix"'rosrun benchbot_robot_controller benchbot_robot_controller'
fi
fi

echo -e "\n${colour_blue}Starting container for BenchBot Supervisor:${colour_nc}"
cmd="${docker_run//'$name'/benchbot_supervisor}"
cmd="${docker_run//'$name'/$HOSTNAME_SUPERVISOR}"
${cmd// /$'\t'} --ip "$URL_SUPERVISOR" -d $DOCKER_TAG_BACKEND /bin/bash -c \
"$cmd_prefix"'python3 -m benchbot_supervisor --task-name "'$task'" \
--robot-name "'$robot'" --environment-names "'$environments_string'" \
--addons-path "'$PATH_ADDONS_INTERNAL'"'

echo -e "\n${colour_blue}Starting container for BenchBot Debugging:${colour_nc}"
cmd="${docker_run//'$name'/benchbot_debug}"
cmd="${docker_run//'$name'/$HOSTNAME_DEBUG}"
${cmd// /$'\t'} --ip "$URL_DEBUG" -it -d $DOCKER_TAG_BACKEND /bin/bash

# Print the output of the Supervisor, watching for failures
header_block "BENCHBOT IS RUNNING (Ctrl^C to exit) ..." ${colour_green}

docker logs --follow benchbot_supervisor &
docker logs --follow $HOSTNAME_SUPERVISOR &

while [ -n "$(docker ps -q -f 'name=benchbot_supervisor')" ] && \
while [ -n "$(docker ps -q -f 'name='$HOSTNAME_SUPERVISOR)" ] && \
([ "$simulator_required" -ne 0 ] || \
[ -n "$(docker ps -q -f 'name=benchbot_robot')" ]); do
[ -n "$(docker ps -q -f 'name='$HOSTNAME_ROBOT)" ]); do
sleep 1
done
# sleep infinity

if [ "$simulator_required" -eq 0 ] && \
[ -z "$(docker ps -q -f 'name=benchbot_robot')" ]; then
[ -z "$(docker ps -q -f 'name='$HOSTNAME_ROBOT)" ]; then
header_block "BENCHBOT ROBOT CONTROLLER ERROR" ${colour_red}
echo -e "\n${colour_red}$_robot_err${colour_nc}\n"
docker logs benchbot_robot
docker logs $HOSTNAME_ROBOT
fi
exit_code=1
exit

0 comments on commit 2d55f9d

Please sign in to comment.