Skip to content

Commit

Permalink
Simplify run.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Oguz Ozturk <[email protected]>
  • Loading branch information
oguzkaganozt committed May 16, 2024
1 parent e531de8 commit c95914b
Showing 1 changed file with 45 additions and 30 deletions.
75 changes: 45 additions & 30 deletions docker/autoware/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -e
# Define terminal colors
RED='\033[0;31m'
GREEN='\033[0;32m'
# BLUE='\033[0;34m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

SCRIPT_DIR=$(readlink -f "$(dirname "$0")")
Expand All @@ -29,15 +29,15 @@ DEFAULT_LAUNCH_CMD="ros2 launch autoware_launch autoware.launch.xml map_path:=/a
# Function to print help message
print_help() {
echo -e "\n------------------------------------------------------------"
echo -e "${RED}Note:${NC} The --map-path option is mandatory if not custom launch command given. Please provide exact path to the map files."
echo -e "${RED}Note:${NC} The --map-path option is mandatory for the runtime. For development environment with shell access, use --devel option."
echo -e " Default launch command: ${GREEN}${DEFAULT_LAUNCH_CMD}${NC}"
echo -e "------------------------------------------------------------"
echo -e "${RED}Usage:${NC} run.sh [OPTIONS] [LAUNCH_CMD](optional)"
echo -e "Options:"
echo -e " ${GREEN}--help/-h${NC} Display this help message"
echo -e " ${GREEN}--map-path${NC} Specify to mount map files into /autoware_map (mandatory if no custom launch command is provided)"
echo -e " ${GREEN}--no-nvidia${NC} Disable NVIDIA GPU support"
echo -e " ${GREEN}--devel${NC} Use the latest development version of Autoware"
echo -e " ${GREEN}--devel${NC} Launch the latest Autoware development environment with shell access"
echo -e " ${GREEN}--headless${NC} Run Autoware in headless mode (default: false)"
echo -e " ${GREEN}--workspace${NC} Specify to mount the workspace into /workspace"
echo ""
Expand Down Expand Up @@ -87,37 +87,43 @@ parse_arguments() {
done
}

# Set image and workspace variables
# Set docker image used and workspace variables
set_variables() {
# Check if map path is provided for default launch command
if [ "$MAP_PATH" == "" ] && [ "$LAUNCH_CMD" == "" ]; then
print_help
exit 1
fi

# Mount map path if provided
MAP="-v ${MAP_PATH}:/autoware_map:ro"

# Set workspace path if provided and login with local user
if [ "$WORKSPACE_PATH" != "" ]; then
USER_ID="-e LOCAL_UID=$(id -u) -e LOCAL_GID=$(id -g) -e LOCAL_USER=$(id -un) -e LOCAL_GROUP=$(id -gn)"
WORKSPACE="-v ${WORKSPACE_PATH}:/workspace"
fi
if [ "$option_devel" = "true" ]; then
# Set image based on option
IMAGE="ghcr.io/autowarefoundation/autoware:latest-devel"

# Set default launch command if not provided
if [ "$LAUNCH_CMD" == "" ]; then
if [ "$WORKSPACE_PATH" != "" ]; then
LAUNCH_CMD="/bin/bash"
# Set workspace path
if [ "$WORKSPACE_PATH" = "" ]; then
echo -e "\n------------------------------------------------------------"
echo -e "${RED}Note:${NC} The --workspace option is mandatory for the --devel option."
echo -e "------------------------------------------------------------"
exit 1
else
LAUNCH_CMD=${DEFAULT_LAUNCH_CMD}
USER_ID="-e LOCAL_UID=$(id -u) -e LOCAL_GID=$(id -g) -e LOCAL_USER=$(id -un) -e LOCAL_GROUP=$(id -gn)"
WORKSPACE="-v ${WORKSPACE_PATH}:/workspace"
fi
fi

# Set image based on option
if [ "$option_devel" == "true" ]; then
IMAGE="ghcr.io/autowarefoundation/autoware:latest-devel"
# Set launch command
LAUNCH_CMD="/bin/bash"
else
# Set image based on option
IMAGE="ghcr.io/autowarefoundation/autoware:latest-runtime"

# Set map path
if [ "$MAP_PATH" = "" ]; then
echo -e "\n------------------------------------------------------------"
echo -e "${RED}Note:${NC} The --map-path option is mandatory for the runtime. For development environment with shell access, use --devel option."
echo -e "------------------------------------------------------------"
exit 1
else
MAP="-v ${MAP_PATH}:/autoware_map:ro"
fi

# Set default launch command if not provided
if [ "$LAUNCH_CMD" = "" ]; then
LAUNCH_CMD=${DEFAULT_LAUNCH_CMD}
fi
fi
}

Expand Down Expand Up @@ -148,10 +154,19 @@ main() {
set_gpu_flag
set_x_display

echo -e "${GREEN}\n-----------------------LAUNCHING CONTAINER-----------------------"
if [ "$option_devel" = "true" ]; then
echo -e "${GREEN}-----------------------------------------------------------------${NC}"
echo -e "${BLUE}Launching Autoware development environment${NC}"
else
echo -e "${GREEN}-----------------------------------------------------------------${NC}"
echo -e "${GREEN}Launching Autoware${NC}"
fi
echo -e "${GREEN}IMAGE:${NC} ${IMAGE}"
echo -e "${GREEN}MAP PATH(mounted):${NC} ${MAP_PATH}:/autoware_map"
echo -e "${GREEN}WORKSPACE(mounted):${NC} ${WORKSPACE_PATH}:/workspace"
if [ "$option_devel" = "true" ]; then
echo -e "${GREEN}WORKSPACE PATH(mounted):${NC} ${WORKSPACE_PATH}:/workspace"
else
echo -e "${GREEN}MAP PATH(mounted):${NC} ${MAP_PATH}:/autoware_map"
fi
echo -e "${GREEN}LAUNCH CMD:${NC} ${LAUNCH_CMD}"
echo -e "${GREEN}-----------------------------------------------------------------${NC}"

Expand Down

0 comments on commit c95914b

Please sign in to comment.