Skip to content

Commit 12b842a

Browse files
authored
Add new robot types to URSim startup script (#331)
This adds support for starting robot models - UR7e - UR12e - UR15 This also adds support for URSim 5.22.0 and 10.9.0 (which is the requirement for the above robot models)
1 parent 07715e0 commit 12b842a

File tree

2 files changed

+209
-27
lines changed

2 files changed

+209
-27
lines changed

scripts/start_ursim.sh

Lines changed: 69 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ TEST_RUN=false
4040
# The PolyScopeX URSim containers follow the SDK versioning scheme. This maps those to marketing
4141
# versions
4242
declare -Ag POLYSCOPE_X_MAP=( ["10.7.0"]="0.12.159"
43-
["10.8.0"]="0.13.124")
43+
["10.8.0"]="0.13.124"
44+
["10.9.0"]="0.14.47")
4445

4546
help()
4647
{
@@ -49,7 +50,7 @@ help()
4950
echo
5051
echo "Syntax: `basename "$0"` [-m|s|h]"
5152
echo "options:"
52-
echo " -m <model> Robot model. One of [ur3, ur3e, ur5, ur5e, ur10, ur10e, ur16e, ur20, ur30]. Defaults to ur5e."
53+
echo " -m <model> Robot model. One of [ur3, ur3e, ur5, ur5e, ur7e, ur10e, ur12e, ur16e, ur15, ur20, ur30]. Defaults to ur5e."
5354
echo " -v <version> URSim version that should be used.
5455
See https://hub.docker.com/r/universalrobots/ursim_e-series/tags
5556
for available versions. Defaults to 'latest'"
@@ -89,10 +90,10 @@ get_series_from_model()
8990
ur3|ur5|ur10)
9091
ROBOT_SERIES=cb3
9192
;;
92-
ur3e|ur5e|ur10e|ur16e)
93+
ur3e|ur5e|ur7e|ur10e|ur12e|ur16e)
9394
ROBOT_SERIES=e-series
9495
;;
95-
ur20|ur30)
96+
ur15|ur20|ur30)
9697
ROBOT_SERIES=e-series
9798
;;
9899
*)
@@ -131,9 +132,15 @@ strip_robot_model()
131132
ROBOT_MODEL=${robot_model^^}
132133
else
133134
ROBOT_MODEL=${robot_model^^}
134-
# UR20 and UR30 need no further adjustment
135+
# UR15, UR20 and UR30 need no further adjustment
135136
if [[ "$robot_model" = @(ur3e|ur5e|ur10e|ur16e) ]]; then
136137
ROBOT_MODEL=$(echo "${ROBOT_MODEL:0:$((${#ROBOT_MODEL}-1))}")
138+
elif [[ "$robot_model" = @(ur7e|ur12e) ]]; then
139+
if [[ "$robot_series" == "polyscopex" ]]; then
140+
ROBOT_MODEL=$(echo "${ROBOT_MODEL:0:$((${#ROBOT_MODEL}-1))}")
141+
else
142+
ROBOT_MODEL=$(echo "${ROBOT_MODEL:0:$((${#ROBOT_MODEL}-1))}e")
143+
fi
137144
fi
138145
fi
139146
}
@@ -144,19 +151,31 @@ strip_robot_model()
144151
# - ROBOT_SERIES
145152
validate_parameters()
146153
{
147-
local IMAGE_URSIM_VERSION
148-
# Inspect the image's URSim version if the image is locally available. This is especially
149-
# important when we use the "latest" tag, as we don't know the version hiding behind this and it
150-
# could be potentially older.
151-
IMAGE_URSIM_VERSION=$(docker image inspect universalrobots/ursim_"${ROBOT_SERIES}":"$URSIM_VERSION" 2>/dev/null | grep -Po '"build_version": "URSim Version: \K[^"]*') || true
152-
if [ -z "$IMAGE_URSIM_VERSION" ]; then
153-
IMAGE_URSIM_VERSION="$URSIM_VERSION"
154-
fi
155-
[ "$IMAGE_URSIM_VERSION" == "latest" ] && return 0
156154
local MIN_CB3="3.14.3"
157155
local MIN_E_SERIES="5.9.4"
156+
local MIN_UR15="5.22.0"
157+
local MIN_UR15_X="10.8.0"
158+
local MIN_POLYSCOPE_X="10.7.0"
158159
local MIN_UR20="5.14.0"
159160
local MIN_UR30="5.15.0"
161+
local MIN_UR7e="5.22.0" # and UR12e
162+
local MIN_UR7e_X="10.9.0" # and UR12e
163+
164+
local URSIM_VERSION_CHECK="$URSIM_VERSION"
165+
if [[ "$URSIM_VERSION" == "latest" ]]; then
166+
if [[ "$ROBOT_SERIES" == "cb3" ]]; then
167+
URSIM_VERSION_CHECK="$MIN_CB3"
168+
elif [[ "$ROBOT_SERIES" == "e-series" ]]; then
169+
URSIM_VERSION_CHECK="$MIN_UR15"
170+
elif [[ "$ROBOT_SERIES" == "polyscopex" ]]; then
171+
URSIM_VERSION_CHECK="MIN_UR15_X"
172+
fi
173+
fi
174+
175+
if ! [[ "$URSIM_VERSION_CHECK" =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
176+
echo "Invalid URSim version given. Must be in the format X.Y.Z. Given: $URSIM_VERSION_CHECK"
177+
exit 1
178+
fi
160179

161180
local MIN_VERSION="0.0"
162181

@@ -166,37 +185,45 @@ validate_parameters()
166185
if [[ $ROBOT_MODEL != @(ur3|ur5|ur10) ]]; then
167186
echo "$ROBOT_MODEL is no valid CB3 model!" && exit 1
168187
fi
169-
verlte "4.0.0" "$IMAGE_URSIM_VERSION" && echo "$IMAGE_URSIM_VERSION is no valid CB3 version!" && exit 1
170-
verlte "$MIN_CB3" "$IMAGE_URSIM_VERSION" && return 0
188+
verlte "4.0.0" "$URSIM_VERSION_CHECK" && echo "$URSIM_VERSION_CHECK is no valid CB3 version!" && exit 1
189+
verlte "$MIN_CB3" "$URSIM_VERSION_CHECK" && return 0
171190
;;
172191
e-series)
173-
if [[ $ROBOT_MODEL != @(ur3e|ur5e|ur10e|ur16e|ur20|ur30) ]]; then
192+
if [[ $ROBOT_MODEL != @(ur3e|ur5e|ur7e|ur10e|ur12e|ur16e|ur15|ur20|ur30) ]]; then
174193
echo "$ROBOT_MODEL is no valid e-series model!" && exit 1
175194
fi
176-
if [[ $ROBOT_MODEL == "ur20" ]]; then
195+
if [[ $ROBOT_MODEL == "ur15" ]]; then
196+
MIN_VERSION=$MIN_UR15
197+
elif [[ $ROBOT_MODEL == "ur20" ]]; then
177198
MIN_VERSION=$MIN_UR20
178199
elif [[ $ROBOT_MODEL == "ur30" ]]; then
179200
MIN_VERSION=$MIN_UR30
201+
elif [[ $ROBOT_MODEL == "ur7e" || $ROBOT_MODEL == "ur12e" ]]; then
202+
MIN_VERSION=$MIN_UR7e
180203
else
181204
MIN_VERSION=$MIN_E_SERIES
182205
fi
183206
;;
184207
polyscopex)
185-
if [[ ! "${POLYSCOPE_X_MAP[${URSIM_VERSION}]+_}" ]]; then
186-
echo "URSim version $URSIM_VERSION is unfortunately not supported"
208+
if [[ ! "${POLYSCOPE_X_MAP[${URSIM_VERSION_CHECK}]+_}" ]]; then
209+
echo "URSim version $URSIM_VERSION_CHECK is unfortunately not supported"
187210
exit 1
188211
fi
189-
if [[ $ROBOT_MODEL != @(ur3e|ur5e|ur10e|ur16e|ur20|ur30) ]]; then
212+
if [[ $ROBOT_MODEL != @(ur3e|ur5e|ur7e|ur10e|ur12e|ur16e|ur15|ur20|ur30) ]]; then
190213
echo "$ROBOT_MODEL is no valid PolyscopeX model!" && exit 1
214+
elif [[ $ROBOT_MODEL == "ur7e" || $ROBOT_MODEL == "ur12e" ]]; then
215+
MIN_VERSION=$MIN_UR7e_X
216+
elif [[ $ROBOT_MODEL == "ur15" ]]; then
217+
MIN_VERSION=$MIN_UR15_X
191218
else
192-
return 0
219+
MIN_VERSION=$MIN_POLYSCOPE_X
193220
fi
194221
;;
195222
esac
196223

197-
verlte "$MIN_VERSION" "$URSIM_VERSION" && return 0
224+
verlte "$MIN_VERSION" "$URSIM_VERSION_CHECK" && return 0
198225

199-
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."
226+
echo "Illegal version given. For $ROBOT_SERIES $ROBOT_MODEL the software version must be greater or equal to $MIN_VERSION. Given version: $URSIM_VERSION."
200227
exit 1
201228
}
202229

@@ -348,6 +375,18 @@ fill_information() {
348375
fi
349376
}
350377

378+
get_version_from_latest()
379+
{
380+
local IMAGE_URSIM_VERSION
381+
# Inspect the image's URSim version if the image is locally available. This is especially
382+
# important when we use the "latest" tag, as we don't know the version hiding behind this and it
383+
# could be potentially older.
384+
IMAGE_URSIM_VERSION=$(docker image inspect universalrobots/ursim_"${ROBOT_SERIES}":"$URSIM_VERSION" 2>/dev/null | grep -Po '"build_version": "URSim Version: \K[^"]*') || true
385+
if [ -n "$IMAGE_URSIM_VERSION" ]; then
386+
URSIM_VERSION="$IMAGE_URSIM_VERSION"
387+
fi
388+
}
389+
351390
test_input_handling() {
352391
parse_arguments "$@"
353392
fill_information
@@ -357,6 +396,7 @@ test_input_handling() {
357396
echo "ROBOT_SERIES: $ROBOT_SERIES"
358397
echo "URSIM_VERSION: $URSIM_VERSION"
359398

399+
TEST_RUN=true
360400
validate_parameters
361401
}
362402

@@ -365,6 +405,7 @@ main() {
365405

366406

367407
fill_information
408+
get_version_from_latest
368409

369410
echo "ROBOT_MODEL: $ROBOT_MODEL"
370411
echo "ROBOT_SERIES: $ROBOT_SERIES"
@@ -409,10 +450,14 @@ main() {
409450
mkdir -p "${PROGRAM_STORAGE}"
410451
PROGRAM_STORAGE=$(realpath "$PROGRAM_STORAGE")
411452

453+
ROBOT_MODEL_CONTROLLER_FLAG=""
454+
verlte "${POLYSCOPE_X_MAP[10.7.0]}" "$URSIM_VERSION" && verlte "$URSIM_VERSION" "${POLYSCOPE_X_MAP[10.8.0]}" && ROBOT_MODEL_CONTROLLER_FLAG="-e ROBOT_TYPE_CONTROLLER=${ROBOT_MODEL}"
455+
412456
docker_cmd="docker run --rm -d \
413457
--net ursim_net --ip $IP_ADDRESS \
414458
-v ${PROGRAM_STORAGE}:/ur/bin/backend/applications \
415459
-e ROBOT_TYPE=${ROBOT_MODEL} \
460+
$ROBOT_MODEL_CONTROLLER_FLAG \
416461
$PORT_FORWARDING \
417462
$DOCKER_ARGS \
418463
--name $CONTAINER_NAME \

tests/test_start_ursim.bats

Lines changed: 140 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
setup_file() {
2+
docker pull universalrobots/ursim_cb3:latest
3+
docker pull universalrobots/ursim_e-series:latest
4+
}
5+
16
setup() {
27
# get the containing directory of this file
38
# use $BATS_TEST_FILENAME instead of ${BASH_SOURCE[0]} or $0,
@@ -38,6 +43,10 @@ setup() {
3843
echo "ROBOT_SERIES: $ROBOT_SERIES"
3944
[ "$ROBOT_SERIES" = "cb3" ]
4045

46+
get_series_from_model "ur15"
47+
echo "ROBOT_SERIES: $ROBOT_SERIES"
48+
[ "$ROBOT_SERIES" = "e-series" ]
49+
4150
get_series_from_model "ur20"
4251
echo "ROBOT_SERIES: $ROBOT_SERIES"
4352
[ "$ROBOT_SERIES" = "e-series" ]
@@ -145,7 +154,66 @@ setup() {
145154
test_input_handling
146155
[ "$ROBOT_MODEL" = "ur5e" ]
147156
[ "$ROBOT_SERIES" = "e-series" ]
148-
[ "$URSIM_VERSION" = "latest" ]
157+
[ "$URSIM_VERSION" = "latest" ]
158+
}
159+
160+
@test "test ur7e min version" {
161+
run test_input_handling -m ur7e -v 3.14.3
162+
echo "$output"
163+
[ $status -eq 1 ]
164+
run test_input_handling -m ur7e -v 5.21.0
165+
echo "$output"
166+
[ $status -eq 1 ]
167+
run test_input_handling -m ur7e -v 10.8.0
168+
echo "$output"
169+
[ $status -eq 1 ]
170+
171+
run test_input_handling -m ur7e -v 5.22.0
172+
echo "$output"
173+
[ $status -eq 0 ]
174+
175+
run test_input_handling -m ur7e -v 10.9.0
176+
echo "$output"
177+
[ $status -eq 0 ]
178+
}
179+
180+
@test "test ur12e min version" {
181+
run test_input_handling -m ur12e -v 3.14.3
182+
echo "$output"
183+
[ $status -eq 1 ]
184+
run test_input_handling -m ur12e -v 5.21.0
185+
echo "$output"
186+
[ $status -eq 1 ]
187+
run test_input_handling -m ur12e -v 10.8.0
188+
echo "$output"
189+
[ $status -eq 1 ]
190+
191+
run test_input_handling -m ur12e -v 5.22.0
192+
echo "$output"
193+
[ $status -eq 0 ]
194+
195+
run test_input_handling -m ur12e -v 10.9.0
196+
echo "$output"
197+
[ $status -eq 0 ]
198+
}
199+
200+
@test "test ur15 min version" {
201+
run test_input_handling -m ur15 -v 3.14.3
202+
echo "$output"
203+
[ $status -eq 1 ]
204+
run test_input_handling -m ur15 -v 5.21.0
205+
echo "$output"
206+
[ $status -eq 1 ]
207+
run test_input_handling -m ur15 -v 10.7.0
208+
echo "$output"
209+
[ $status -eq 1 ]
210+
211+
run test_input_handling -m ur15 -v 5.22.0
212+
echo "$output"
213+
[ $status -eq 0 ]
214+
run test_input_handling -m ur15 -v 10.8.0
215+
echo "$output"
216+
[ $status -eq 0 ]
149217
}
150218

151219
@test "test ur20 min version" {
@@ -206,15 +274,15 @@ setup() {
206274
echo "$output"
207275
image=$(echo "$output" | tail -n1 | awk '{ print $NF }')
208276
[ $status -eq 0 ]
209-
[ "$image" == "universalrobots/ursim_cb3:latest" ]
277+
[[ "$image" =~ universalrobots/ursim_cb3:[0-9]+\.[0-9]+\.[0-9]+ ]]
210278
}
211279

212280
@test "docker image e-series latest" {
213281
run main -m ur3e -t
214282
echo "$output"
215283
image=$(echo "$output" | tail -n1 | awk '{ print $NF }')
216284
[ $status -eq 0 ]
217-
[ "$image" == "universalrobots/ursim_e-series:latest" ]
285+
[[ "$image" =~ universalrobots/ursim_e-series:[0-9]+\.[0-9]+\.[0-9]+ ]]
218286
}
219287

220288
@test "docker image cb3 specific" {
@@ -315,6 +383,14 @@ setup() {
315383
strip_robot_model ur30 polyscopex
316384
echo "Robot model is: $ROBOT_MODEL"
317385
[ "$ROBOT_MODEL" = "UR30" ]
386+
387+
strip_robot_model ur7e e-series
388+
echo "Robot model is: $ROBOT_MODEL"
389+
[ "$ROBOT_MODEL" = "UR7e" ]
390+
391+
strip_robot_model ur12e e-series
392+
echo "Robot model is: $ROBOT_MODEL"
393+
[ "$ROBOT_MODEL" = "UR12e" ]
318394
}
319395

320396
@test "help_prints_fine" {
@@ -459,3 +535,64 @@ setup() {
459535
[ "$DETACHED" = "true" ]
460536
}
461537

538+
@test "successful_validate_parameters" {
539+
URSIM_VERSION="5.21.0"
540+
ROBOT_MODEL="ur10e"
541+
ROBOT_SERIES="e-series"
542+
543+
validate_parameters
544+
}
545+
546+
@test "successful_validate_parameters_latest_e" {
547+
URSIM_VERSION="latest"
548+
ROBOT_MODEL="ur10e"
549+
ROBOT_SERIES="e-series"
550+
551+
validate_parameters
552+
}
553+
554+
@test "validate_parameters_on_invalid_model_fails_e" {
555+
URSIM_VERSION="latest"
556+
ROBOT_MODEL="ur10"
557+
ROBOT_SERIES="e-series"
558+
559+
run validate_parameters
560+
[ $status -eq 1 ]
561+
}
562+
563+
@test "successful_validate_parameters_latest_cb3" {
564+
URSIM_VERSION="latest"
565+
ROBOT_MODEL="ur10"
566+
ROBOT_SERIES="cb3"
567+
568+
validate_parameters
569+
}
570+
571+
@test "validate_parameters_on_invalid_model_fails_cb3" {
572+
URSIM_VERSION="latest"
573+
ROBOT_MODEL="ur103"
574+
ROBOT_SERIES="cb3"
575+
576+
run validate_parameters
577+
[ $status -eq 1 ]
578+
}
579+
580+
@test "validate_parameters_on_invalid_version_fails" {
581+
URSIM_VERSION="foobar"
582+
ROBOT_MODEL="ur10e"
583+
ROBOT_SERIES="e-series"
584+
585+
run validate_parameters
586+
[ $status -eq 1 ]
587+
}
588+
589+
@test "validate_parameters_on_invalid_model_fails" {
590+
591+
URSIM_VERSION="5.21.0"
592+
ROBOT_MODEL="ur10"
593+
ROBOT_SERIES="e-series"
594+
run validate_parameters
595+
[ $status -eq 1 ]
596+
597+
}
598+

0 commit comments

Comments
 (0)