Skip to content

Commit

Permalink
[start_ursim] Always check ursim version for compatibility
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fmauch authored and VinDp committed May 29, 2024
1 parent 13eecaf commit 97af030
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions scripts/start_ursim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,15 @@ verlte()

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

case $ROBOT_SERIES in
cb3)
verlte "4.0.0" $URSIM_VERSION && echo "$URSIM_VERSION is no valid CB3 version!" && exit
verlte $MIN_CB3 $URSIM_VERSION && return 0
verlte "4.0.0" "$IMAGE_URSIM_VERSION" && echo "$IMAGE_URSIM_VERSION is no valid CB3 version!" && exit
verlte "$MIN_CB3" "$IMAGE_URSIM_VERSION" && return 0
MIN_VERSION=$MIN_CB3
;;
e-series)
if [[ $ROBOT_MODEL == "UR20" ]]; then
verlte $MIN_UR20 $URSIM_VERSION && return 0
verlte "$MIN_UR20" "$IMAGE_URSIM_VERSION" && return 0
MIN_VERSION=$MIN_UR20
elif [[ $ROBOT_MODEL == "UR30" ]]; then
verlte $MIN_UR30 $URSIM_VERSION && return 0
verlte "$MIN_UR30" "$IMAGE_URSIM_VERSION" && return 0
MIN_VERSION=$MIN_UR30
else
verlte $MIN_E_SERIES $URSIM_VERSION && return 0
verlte "$MIN_E_SERIES" "$URSIM_VERSION" && return 0
MIN_VERSION=$MIN_E_SERIES
fi
;;
esac

echo "Illegal version given. Version must be greater or equal to $MIN_VERSION. Given version: $URSIM_VERSION."
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."
exit
}

Expand All @@ -134,7 +142,6 @@ while getopts ":hm:v:p:u:d" option; do
;;
v) # ursim_version
URSIM_VERSION=${OPTARG}
validate_ursim_version
;;
p) # program_folder
PROGRAM_STORAGE=${OPTARG}
Expand All @@ -151,6 +158,7 @@ while getopts ":hm:v:p:u:d" option; do
exit;;
esac
done
validate_ursim_version

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

0 comments on commit 97af030

Please sign in to comment.