Skip to content

Commit 97af030

Browse files
Felix ExnerVinDp
authored andcommitted
[start_ursim] Always check ursim version for compatibility
Before, the version was only checked when explicitly specified. This could lead to errors if there was a local image with tag "latest" which was actually an old version.
1 parent 13eecaf commit 97af030

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

scripts/start_ursim.sh

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,15 @@ verlte()
8989

9090
validate_ursim_version()
9191
{
92-
[ $URSIM_VERSION == "latest" ] && return 0
92+
local IMAGE_URSIM_VERSION
93+
# Inspect the image's URSim version if the image is locally available. This is especially
94+
# important when we use the "latest" tag, as we don't know the version hiding behind this and it
95+
# could be potentially older.
96+
IMAGE_URSIM_VERSION=$(docker image inspect universalrobots/ursim_"${ROBOT_SERIES}":"$URSIM_VERSION" 2>/dev/null | grep -Po '"build_version": "URSim Version: \K[^"]*') || true
97+
if [ -z "$IMAGE_URSIM_VERSION" ]; then
98+
IMAGE_URSIM_VERSION="$URSIM_VERSION"
99+
fi
100+
[ "$IMAGE_URSIM_VERSION" == "latest" ] && return 0
93101
local MIN_CB3="3.14.3"
94102
local MIN_E_SERIES="5.9.4"
95103
local MIN_UR20="5.14.0"
@@ -100,25 +108,25 @@ validate_ursim_version()
100108

101109
case $ROBOT_SERIES in
102110
cb3)
103-
verlte "4.0.0" $URSIM_VERSION && echo "$URSIM_VERSION is no valid CB3 version!" && exit
104-
verlte $MIN_CB3 $URSIM_VERSION && return 0
111+
verlte "4.0.0" "$IMAGE_URSIM_VERSION" && echo "$IMAGE_URSIM_VERSION is no valid CB3 version!" && exit
112+
verlte "$MIN_CB3" "$IMAGE_URSIM_VERSION" && return 0
105113
MIN_VERSION=$MIN_CB3
106114
;;
107115
e-series)
108116
if [[ $ROBOT_MODEL == "UR20" ]]; then
109-
verlte $MIN_UR20 $URSIM_VERSION && return 0
117+
verlte "$MIN_UR20" "$IMAGE_URSIM_VERSION" && return 0
110118
MIN_VERSION=$MIN_UR20
111119
elif [[ $ROBOT_MODEL == "UR30" ]]; then
112-
verlte $MIN_UR30 $URSIM_VERSION && return 0
120+
verlte "$MIN_UR30" "$IMAGE_URSIM_VERSION" && return 0
113121
MIN_VERSION=$MIN_UR30
114122
else
115-
verlte $MIN_E_SERIES $URSIM_VERSION && return 0
123+
verlte "$MIN_E_SERIES" "$URSIM_VERSION" && return 0
116124
MIN_VERSION=$MIN_E_SERIES
117125
fi
118126
;;
119127
esac
120128

121-
echo "Illegal version given. Version must be greater or equal to $MIN_VERSION. Given version: $URSIM_VERSION."
129+
echo "Illegal version given. For $ROBOT_SERIES $ROBOT_MODEL the software version must be greater or equal to $MIN_VERSION. Given version: $IMAGE_URSIM_VERSION."
122130
exit
123131
}
124132

@@ -134,7 +142,6 @@ while getopts ":hm:v:p:u:d" option; do
134142
;;
135143
v) # ursim_version
136144
URSIM_VERSION=${OPTARG}
137-
validate_ursim_version
138145
;;
139146
p) # program_folder
140147
PROGRAM_STORAGE=${OPTARG}
@@ -151,6 +158,7 @@ while getopts ":hm:v:p:u:d" option; do
151158
exit;;
152159
esac
153160
done
161+
validate_ursim_version
154162

155163
# Create local storage for programs and URCaps
156164
mkdir -p "${URCAP_STORAGE}"

0 commit comments

Comments
 (0)