-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint_ros2_dockerfile.sh
executable file
·57 lines (48 loc) · 1.53 KB
/
entrypoint_ros2_dockerfile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
set -e
# arg
ROS_DISTRO="galactic" #$1
ROS_DOMAIN_ID=7 #$2
IMAGE_TOPIC="image_raw" #$3
YOLO_MODEL="yolov5s" #$4
DEVICE="cpu"
usage()
{
echo "Usage: entrypoint yolov5 ros2 [ -R foxy or galactic ]
[ -I default 7 ]
[ -T default image_raw]
[ -M default yolov5s ]
[ -D default cpu optional cuda:0 ]"
echo $@
}
# PARSED_ARGUMENTS=$(getopt -a -n entrypoint_ros2_dockerfile --long ROS_DISTRO:,ROS_DOMAIN_ID:,IMAGE_TOPIC:,YOLO_MODEL: -- "$@")
PARSED_ARGUMENTS=$(getopt -n entrypoint_ros2_dockerfile -o R:I:T:M:D: -- "$@")
VALID_ARGUMENTS=$?
if [ "$VALID_ARGUMENTS" != "0" ]; then
usage
fi
echo "PARSED_ARGUMENTS IS $PARSED_ARGUMENTS"
eval set -- "$PARSED_ARGUMENTS"
while :
do
case "$1" in
# --ROS_DISTRO) ROS_DISTRO="$2" ; shift 2 ;;
# --ROS_DOMAIN_ID) ROS_DOMAIN_ID="$2" ; shift 2 ;;
# --IMAGE_TOPIC) IMAGE_TOPIC="$2" ; shift 2 ;;
# --YOLO_MODEL) YOLO_MODEL="$2" ; shift 2 ;;
-R) ROS_DISTRO="$2" ; shift 2 ;;
-I) ROS_DOMAIN_ID="$2" ; shift 2 ;;
-T) IMAGE_TOPIC="$2" ; shift 2 ;;
-M) YOLO_MODEL="$2" ; shift 2 ;;
-D) DEVICE="$2" ; shift 2 ;;
--) shift; break ;;
*) echo "Unexpected option"
usage ;;
esac
done
# set ros environment
source /opt/ros/${ROS_DISTRO}/setup.bash
source ./install/setup.bash
export ROS_DOMAIN_ID=${ROS_DOMAIN_ID}
ros2 run yolov5_ros2 yolo_detect --ros-args -p device:=${DEVICE} -p image_topic:=/${IMAGE_TOPIC} -p model:=${YOLO_MODEL}
exec "$@"