Skip to content

Commit a9de3f5

Browse files
author
Felix Exner
committed
Use more flexible start_ursim.sh and move it to a visible place
Since this script is also rather useful for non-testing purpose it might be worthwile putting it to a more visible place.
1 parent a50f530 commit a9de3f5

File tree

5 files changed

+189
-53
lines changed

5 files changed

+189
-53
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@ jobs:
1111
- DOCKER_RUN_OPTS: --network static_test_net
1212
BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 192.168.56.101'
1313
CTEST_OUTPUT_ON_FAILURE: 1
14-
URSIM_DOCKER_IMAGE: 'universalrobots/ursim_cb3:3.12.1'
15-
PROGRAM_FOLDER: 'programs/cb3'
14+
ROBOT_MODEL: 'ur5'
15+
URSIM_VERSION: '3.12.1'
16+
PROGRAM_FOLDER: 'tests/resources/dockerursim/programs/cb3'
1617
- DOCKER_RUN_OPTS: --network static_test_net
1718
BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 192.168.56.101'
1819
CTEST_OUTPUT_ON_FAILURE: 1
19-
URSIM_DOCKER_IMAGE: 'universalrobots/ursim_e-series:5.5.1'
20-
PROGRAM_FOLDER: 'programs/e-series'
20+
ROBOT_MODEL: 'ur5e'
21+
URSIM_VERSION: '5.5.1'
22+
PROGRAM_FOLDER: 'tests/resources/dockerursim/programs/e-series'
2123

2224
steps:
2325
- uses: actions/checkout@v1
2426
- name: start ursim
2527
run: |
26-
tests/resources/dockerursim/build_and_run_docker_ursim.sh $URSIM_DOCKER_IMAGE $PROGRAM_FOLDER
28+
scripts/start_ursim.sh -m $ROBOT_MODEL -v $URSIM_VERSION -p $PROGRAM_FOLDER
2729
env: ${{matrix.env}}
2830
- name: install gtest
2931
run: sudo apt-get install -y libgtest-dev

.github/workflows/industrial-ci.yml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,59 +25,65 @@ jobs:
2525
DOWNSTREAM_WORKSPACE: "github:UniversalRobots/Universal_Robots_ROS_Driver#master https://raw.githubusercontent.com/UniversalRobots/Universal_Robots_ROS_Driver/master/.melodic.rosinstall"
2626
DOCKER_RUN_OPTS: --network static_test_net
2727
BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 192.168.56.101'
28-
URSIM_DOCKER_IMAGE: 'universalrobots/ursim_e-series:5.5.1'
29-
PROGRAM_FOLDER: 'programs/e-series'
28+
URSIM_VERSION: '5.5.1'
29+
ROBOT_MODEL: 'ur5e'
30+
PROGRAM_FOLDER: 'tests/resources/dockerursim/programs/e-series'
3031
- ROS_DISTRO: noetic
3132
ROS_REPO: main
3233
IMMEDIATE_TEST_OUTPUT: true
3334
DOWNSTREAM_WORKSPACE: "github:UniversalRobots/Universal_Robots_ROS_Driver#master https://raw.githubusercontent.com/UniversalRobots/Universal_Robots_ROS_Driver/master/.noetic.rosinstall"
3435
BUILDER: catkin_tools
3536
DOCKER_RUN_OPTS: --network static_test_net
3637
BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 192.168.56.101'
37-
URSIM_DOCKER_IMAGE: 'universalrobots/ursim_e-series:5.5.1'
38-
PROGRAM_FOLDER: 'programs/e-series'
38+
URSIM_VERSION: '5.5.1'
39+
ROBOT_MODEL: 'ur5e'
40+
PROGRAM_FOLDER: 'tests/resources/dockerursim/programs/e-series'
3941
- ROS_DISTRO: foxy
4042
ROS_REPO: main
4143
IMMEDIATE_TEST_OUTPUT: true
4244
DOWNSTREAM_WORKSPACE: "github:UniversalRobots/Universal_Robots_ROS2_Driver#foxy"
4345
DOCKER_RUN_OPTS: --network static_test_net
4446
BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 192.168.56.101'
45-
URSIM_DOCKER_IMAGE: 'universalrobots/ursim_e-series:5.5.1'
46-
PROGRAM_FOLDER: 'programs/e-series'
47+
URSIM_VERSION: '5.5.1'
48+
ROBOT_MODEL: 'ur5e'
49+
PROGRAM_FOLDER: 'tests/resources/dockerursim/programs/e-series'
4750
NOT_TEST_DOWNSTREAM: true
4851
- ROS_DISTRO: galactic
4952
ROS_REPO: main
5053
IMMEDIATE_TEST_OUTPUT: true
5154
DOWNSTREAM_WORKSPACE: "github:UniversalRobots/Universal_Robots_ROS2_Driver#galactic"
5255
DOCKER_RUN_OPTS: --network static_test_net
5356
BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 192.168.56.101'
54-
URSIM_DOCKER_IMAGE: 'universalrobots/ursim_e-series:5.5.1'
55-
PROGRAM_FOLDER: 'programs/e-series'
57+
URSIM_VERSION: '5.5.1'
58+
ROBOT_MODEL: 'ur5e'
59+
PROGRAM_FOLDER: 'tests/resources/dockerursim/programs/e-series'
5660
NOT_TEST_DOWNSTREAM: true
5761
- ROS_DISTRO: humble
5862
ROS_REPO: main
5963
IMMEDIATE_TEST_OUTPUT: true
6064
DOWNSTREAM_WORKSPACE: "github:UniversalRobots/Universal_Robots_ROS2_Driver#main https://raw.githubusercontent.com/UniversalRobots/Universal_Robots_ROS2_Driver/main/Universal_Robots_ROS2_Driver-not-released.humble.repos"
6165
DOCKER_RUN_OPTS: --network static_test_net
6266
BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 192.168.56.101'
63-
URSIM_DOCKER_IMAGE: 'universalrobots/ursim_e-series:5.5.1'
64-
PROGRAM_FOLDER: 'programs/e-series'
67+
URSIM_VERSION: '5.5.1'
68+
ROBOT_MODEL: 'ur5e'
69+
PROGRAM_FOLDER: 'tests/resources/dockerursim/programs/e-series'
6570
NOT_TEST_DOWNSTREAM: true
6671
- ROS_DISTRO: rolling
6772
ROS_REPO: main
6873
IMMEDIATE_TEST_OUTPUT: true
6974
DOWNSTREAM_WORKSPACE: "github:UniversalRobots/Universal_Robots_ROS2_Driver#main https://raw.githubusercontent.com/UniversalRobots/Universal_Robots_ROS2_Driver/main/Universal_Robots_ROS2_Driver-not-released.rolling.repos"
7075
DOCKER_RUN_OPTS: --network static_test_net
7176
BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 192.168.56.101'
72-
URSIM_DOCKER_IMAGE: 'universalrobots/ursim_e-series:5.5.1'
73-
PROGRAM_FOLDER: 'programs/e-series'
77+
URSIM_VERSION: '5.5.1'
78+
ROBOT_MODEL: 'ur5e'
79+
PROGRAM_FOLDER: 'tests/resources/dockerursim/programs/e-series'
7480
NOT_TEST_DOWNSTREAM: true
7581

7682
steps:
7783
- uses: actions/checkout@v1
7884
- name: start ursim
7985
run: |
80-
tests/resources/dockerursim/build_and_run_docker_ursim.sh $URSIM_DOCKER_IMAGE $PROGRAM_FOLDER
86+
scripts/start_ursim.sh -m $ROBOT_MODEL -v $URSIM_VERSION -p $PROGRAM_FOLDER
8187
env: ${{matrix.env}}
8288
- uses: 'ros-industrial/industrial_ci@master'
8389
env: ${{matrix.env}}

scripts/start_ursim.sh

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
#!/bin/bash
2+
3+
# copyright 2022 Universal Robots A/S
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are met:
7+
#
8+
# * Redistributions of source code must retain the above copyright
9+
# notice, this list of conditions and the following disclaimer.
10+
#
11+
# * Redistributions in binary form must reproduce the above copyright
12+
# notice, this list of conditions and the following disclaimer in the
13+
# documentation and/or other materials provided with the distribution.
14+
#
15+
# * Neither the name of the {copyright_holder} nor the names of its
16+
# contributors may be used to endorse or promote products derived from
17+
# this software without specific prior written permission.
18+
#
19+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29+
# POSSIBILITY OF SUCH DAMAGE.
30+
31+
PERSISTENT_BASE="${HOME}/.ursim"
32+
33+
help()
34+
{
35+
# Display Help
36+
echo "Starts URSim inside a docker container"
37+
echo
38+
echo "Syntax: `basename "$0"` [-m|s|h]"
39+
echo "options:"
40+
echo " -m <model> Robot model. One of [ur3, ur3e, ur5, ur5e, ur10, ur10e, ur16e]. Defaults to ur5e."
41+
echo " -v <version> URSim version that should be used.
42+
See https://hub.docker.com/r/universalrobots/ursim_e-series/tags
43+
for available versions. Defaults to 'latest'"
44+
echo " -p <folder> Location from which programs are read / to which programs are written.
45+
If not specified, will fallback to ${PERSISTENT_BASE}/${ROBOT_SERIES}/programs"
46+
echo " -u <folder> Location from which URCaps are read / to which URCaps are written.
47+
If not specified, will fallback to ${PERSISTENT_BASE}/${ROBOT_SERIES}/urcaps"
48+
echo " -h Print this Help."
49+
echo
50+
}
51+
52+
ROBOT_MODEL=UR5
53+
ROBOT_SERIES=e-series
54+
URSIM_VERSION=latest
55+
URCAP_STORAGE="${PERSISTENT_BASE}/${ROBOT_SERIES}/urcaps"
56+
PROGRAM_STORAGE="${PERSISTENT_BASE}/${ROBOT_SERIES}/programs"
57+
58+
59+
validate_model()
60+
{
61+
case $ROBOT_MODEL in
62+
ur3|ur5|ur10)
63+
ROBOT_MODEL=${ROBOT_MODEL^^}
64+
ROBOT_SERIES=cb3
65+
;;
66+
ur3e|ur5e|ur10e|ur16e)
67+
ROBOT_MODEL=${ROBOT_MODEL^^}
68+
ROBOT_MODEL=$(echo ${ROBOT_MODEL:0:$((${#ROBOT_MODEL}-1))})
69+
ROBOT_SERIES=e-series
70+
;;
71+
*)
72+
echo "Not a valid robot model: $ROBOT_MODEL"
73+
exit
74+
;;
75+
esac
76+
}
77+
78+
verlte()
79+
{
80+
[ "$1" = $(printf "$1\n$2" | sort -V | head -n1) ]
81+
}
82+
83+
validate_ursim_version()
84+
{
85+
[ $URSIM_VERSION == "latest" ] && return 0
86+
local MIN_CB3="3.12.1"
87+
local MIN_E_SERIES="5.5.1"
88+
89+
case $ROBOT_SERIES in
90+
cb3)
91+
verlte "4.0.0" $URSIM_VERSION && echo "$URSIM_VERSION is no valid CB3 version!" && exit
92+
verlte $MIN_CB3 $URSIM_VERSION && return 0
93+
;;
94+
e-series)
95+
verlte $MIN_E_SERIES $URSIM_VERSION && return 0
96+
;;
97+
esac
98+
99+
echo "Illegal version given. Version must be greater or equal to $MIN_CB3 / $MIN_E_SERIES. Given version: $URSIM_VERSION."
100+
exit
101+
}
102+
103+
104+
while getopts ":hm:v:p:u:" option; do
105+
case $option in
106+
h) # display Help
107+
help
108+
exit;;
109+
m) # robot model
110+
ROBOT_MODEL=${OPTARG}
111+
validate_model
112+
;;
113+
v) # ursim_version
114+
URSIM_VERSION=${OPTARG}
115+
validate_ursim_version
116+
;;
117+
p) # program_folder
118+
PROGRAM_STORAGE=${OPTARG}
119+
;;
120+
u) # urcaps_folder
121+
URCAP_STORAGE=${OPTARG}
122+
;;
123+
\?) # invalid option
124+
echo "Error: Invalid option"
125+
help
126+
exit;;
127+
esac
128+
done
129+
130+
# Create local storage for programs and URCaps
131+
mkdir -p "${URCAP_STORAGE}"
132+
mkdir -p "${PROGRAM_STORAGE}"
133+
URCAP_STORAGE=$(realpath "$URCAP_STORAGE")
134+
PROGRAM_STORAGE=$(realpath "$PROGRAM_STORAGE")
135+
136+
137+
# Check whether network already exists
138+
docker network inspect ursim_net > /dev/null
139+
if [ $? -eq 0 ]; then
140+
echo "ursim_net already exists"
141+
else
142+
echo "Creating ursim_net"
143+
docker network create --subnet=192.168.56.0/24 ursim_net
144+
fi
145+
146+
# run docker contain
147+
docker run --rm -d --net ursim_net --ip 192.168.56.101\
148+
-v "${URCAP_STORAGE}":/urcaps \
149+
-v "${PROGRAM_STORAGE}":/ursim/programs \
150+
-e ROBOT_MODEL="${ROBOT_MODEL}" \
151+
--name ursim \
152+
universalrobots/ursim_${ROBOT_SERIES}:$URSIM_VERSION || exit
153+
154+
trap "echo killing; docker container kill ursim; exit" SIGINT SIGTERM
155+
156+
echo "Docker URSim is running"
157+
printf "\nTo access Polyscope, open the following URL in a web browser.\n\thttp://192.168.56.101:6080/vnc.html\n\n"
158+
echo "To exit, press CTRL+C"
159+
160+
while :
161+
do
162+
sleep 1
163+
done

tests/resources/dockerursim/build_and_run_docker_ursim.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/resources/dockerursim/ursim/run

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)