Skip to content

Commit

Permalink
refine run script
Browse files Browse the repository at this point in the history
Signed-off-by: oguzkaganozt <oguzkaganozt@gmail.com>
  • Loading branch information
oguzkaganozt committed Feb 20, 2024
1 parent ec4c174 commit 53d2fd7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
3 changes: 2 additions & 1 deletion docker/autoware-openadk/etc/dev_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# shellcheck disable=SC1090,SC1091

# Get the user ID and group ID of the local user
Expand All @@ -23,6 +23,7 @@ else
# Source ROS2
# hadolint ignore=SC1090
source "/opt/ros/$ROS_DISTRO/setup.bash"
source /autoware/install/setup.bash

# Execute the command as the user
exec /usr/sbin/gosu "$USER_NAME" "$@"
Expand Down
2 changes: 1 addition & 1 deletion docker/autoware-openadk/etc/ros_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# shellcheck disable=SC1090,SC1091
set -e

Expand Down
34 changes: 7 additions & 27 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ 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"

# Function to print help message
print_help() {
echo -e "\n------------------------------------------------------------"
echo "Note: The --map-path option is mandatory for default launch command. Please provide exact path to the map files."
echo " Default launch command: ros2 launch autoware_launch autoware.launch.xml map_path:=${MAP_PATH} vehicle_model:=sample_vehicle sensor_model:=sample_sensor_kit"
echo " Default launch command: ${DEFAULT_LAUNCH_CMD}"
echo "------------------------------------------------------------"
echo "Usage: run.sh [OPTIONS] [LAUNCH_CMD](optional)"
echo "Options:"
Expand All @@ -36,7 +37,6 @@ print_help() {
echo ""
}


# Parse arguments
parse_arguments() {
while [ "$1" != "" ]; do
Expand Down Expand Up @@ -81,7 +81,7 @@ parse_arguments() {
done
}

# Set image and workspace variables based on options
# Set image and workspace variables
set_variables() {
# Check if map path is provided for default launch command
if [ "$MAP_PATH" == "" ] && [ "$LAUNCH_CMD" == "" ]; then
Expand All @@ -90,11 +90,11 @@ set_variables() {
fi

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

# Set default launch command if not provided
if [ "$LAUNCH_CMD" == "" ]; then
LAUNCH_CMD="ros2 launch autoware_launch autoware.launch.xml map_path:=${MAP_PATH} vehicle_model:=sample_vehicle sensor_model:=sample_sensor_kit"
LAUNCH_CMD=${DEFAULT_LAUNCH_CMD}
fi

# Set workspace path if provided with current user and group
Expand All @@ -105,9 +105,9 @@ set_variables() {

# Set image based on option
if [ "$option_devel" == "true" ]; then
IMAGE="ghcr.io/autowarefoundation/autoware-openadk:1.0-runtime-cuda"
IMAGE="ghcr.io/autowarefoundation/autoware-openadk:devel-humble-latest-cuda"
else
IMAGE="ghcr.io/autowarefoundation/autoware-openadk:1.0-runtime-cuda"
IMAGE="ghcr.io/autowarefoundation/autoware-openadk:runtime-humble-latest-cuda"
fi
}

Expand All @@ -130,21 +130,6 @@ set_x_display() {
fi
}

loading_animation() {
chars="/-\|"
while true; do
for (( i=0; i<${#chars}; i++ )); do
sleep 0.1
echo -en "${chars:$i:1}" "\r"
done
done
}

cleanup() {
kill $LOADING_PID
exit
}

# Main script execution
main() {
# Parse arguments
Expand All @@ -159,11 +144,6 @@ main() {
echo "LAUNCH CMD: ${LAUNCH_CMD}"
echo "WORKSPACE(to mount): ${WORKSPACE_PATH}"
echo "-----------------------------------------------------------------"

# Start loading animation
loading_animation &
LOADING_PID=$!
trap cleanup EXIT SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT SIGHUP SIGABRT

# Launch the container
set -x
Expand Down

0 comments on commit 53d2fd7

Please sign in to comment.