Skip to content

Commit

Permalink
add --data-path option
Browse files Browse the repository at this point in the history
Signed-off-by: Yutaka Kondo <[email protected]>
  • Loading branch information
youtalk committed May 22, 2024
1 parent 9047913 commit 28f636f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,23 @@ fi
option_no_nvidia=false
option_devel=false
option_headless=false
DATA_PATH=""
MAP_PATH=""
WORKSPACE_PATH=""
USER_ID=""
WORKSPACE=""
DEFAULT_LAUNCH_CMD="ros2 launch autoware_launch autoware.launch.xml map_path:=/autoware_map vehicle_model:=sample_vehicle sensor_model:=sample_sensor_kit"
DEFAULT_LAUNCH_CMD="ros2 launch autoware_launch autoware.launch.xml data_path:=/autoware_data map_path:=/autoware_map vehicle_model:=sample_vehicle sensor_model:=sample_sensor_kit"

# 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 --data-path and --map-path options are mandatory if not custom launch command given. Please provide exact paths to the data and map files."
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}--data-path${NC} Specify to mount data files into /autoware_data (mandatory if no custom launch command is provided)"
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"
Expand Down Expand Up @@ -64,6 +66,10 @@ parse_arguments() {
WORKSPACE_PATH="$2"
shift
;;
--data-path)
DATA_PATH="$2"
shift
;;
--map-path)
MAP_PATH="$2"
shift
Expand All @@ -89,12 +95,19 @@ parse_arguments() {

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

# Mount data path if provided
DATA="-v ${DATA_PATH}:/autoware_data:ro"

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

Expand Down Expand Up @@ -150,6 +163,7 @@ main() {

echo -e "${GREEN}\n-----------------------LAUNCHING CONTAINER-----------------------"
echo -e "${GREEN}IMAGE:${NC} ${IMAGE}"
echo -e "${GREEN}DATA PATH(mounted):${NC} ${DATA_PATH}:/autoware_data"
echo -e "${GREEN}MAP PATH(mounted):${NC} ${MAP_PATH}:/autoware_map"
echo -e "${GREEN}WORKSPACE(mounted):${NC} ${WORKSPACE_PATH}:/workspace"
echo -e "${GREEN}LAUNCH CMD:${NC} ${LAUNCH_CMD}"
Expand All @@ -159,7 +173,7 @@ main() {
set -x
docker run -it --rm --net=host ${GPU_FLAG} ${USER_ID} ${MOUNT_X} \
-e XAUTHORITY=${XAUTHORITY} -e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR -e NVIDIA_DRIVER_CAPABILITIES=all -v /etc/localtime:/etc/localtime:ro \
${WORKSPACE} ${MAP} ${IMAGE} \
${WORKSPACE} ${DATA} ${MAP} ${IMAGE} \
${LAUNCH_CMD}
}

Expand Down

0 comments on commit 28f636f

Please sign in to comment.