Skip to content

Commit 35c96dd

Browse files
committed
Always download and install the latest URCap(X) if not present
1 parent f977b70 commit 35c96dd

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

scripts/start_ursim.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# POSSIBILITY OF SUCH DAMAGE.
3030

3131
PERSISTENT_BASE="${HOME}/.ursim"
32-
URCAP_VERSION="1.0.5"
32+
URCAP_VERSION="" # If not set, the latest version will be downloaded
3333
IP_ADDRESS="192.168.56.101"
3434
PORT_FORWARDING_WITH_DASHBOARD="-p 30001-30004:30001-30004 -p 29999:29999"
3535
PORT_FORWARDING_WITHOUT_DASHBOARD="-p 30001-30004:30001-30004"
@@ -214,6 +214,14 @@ post_setup_e-series()
214214

215215
post_setup_polyscopex()
216216
{
217+
urcapx_download_url=$(curl -s https://api.github.com/repos/UniversalRobots/Universal_Robots_ExternalControl_URCapX/releases/latest | grep "browser_download_url.*urcapx" | cut -d ":" -f 2,3 | tr -d "\"[:space:]")
218+
URCAPX_VERSION=$(echo "$urcapx_download_url" | grep -oP '\d+\.\d+\.\d+' | head -n 1)
219+
mkdir -p "${URCAP_STORAGE}"
220+
urcapx_file="${URCAP_STORAGE}/external_control-$URCAPX_VERSION.urcapx"
221+
if [[ ! -f "$urcapx_file" ]]; then
222+
echo "Downloading External Control URCapX version ${URCAPX_VERSION}"
223+
curl -L -o "$urcapx_file" "$urcapx_download_url"
224+
fi
217225

218226
echo -ne "Starting URSim. Waiting for UrService to be up..."
219227
curl_cmd="curl --retry-connrefused -f --write-out %{http_code} --silent --output /dev/null $IP_ADDRESS/universal-robots/urservice/api/v1/urcaps"
@@ -228,11 +236,9 @@ post_setup_polyscopex()
228236

229237
echo ""; echo "UrService is up"
230238

231-
# TODO: Once we have a downloadable URCapX, we can use the following code to install it
232-
#urcapx_file="${HOME}/Downloads/external-control-0.1.0.urcapx"
233-
#echo "Installing URCapX $urcapx_file"
234-
#curl --location --request POST --silent --output /dev/null "$IP_ADDRESS/universal-robots/urservice/api/v1/urcaps" --form urcapxFile=@"${urcapx_file}"
235-
#echo "";
239+
echo "Installing URCapX $urcapx_file"
240+
curl --location --request POST --silent --output /dev/null "$IP_ADDRESS/universal-robots/urservice/api/v1/urcaps" --form urcapxFile=@"${urcapx_file}"
241+
echo "";
236242

237243
echo -e "\nTo access PolyScopeX, open the following URL in a web browser."
238244
printf "\n\n\thttp://%s\n\n" "$IP_ADDRESS"
@@ -377,9 +383,13 @@ main() {
377383
PROGRAM_STORAGE=$(realpath "$PROGRAM_STORAGE")
378384

379385
# Download external_control URCap
386+
if [[ -z "$URCAP_VERSION" ]]; then
387+
urcap_download_url=$(curl -s https://api.github.com/repos/UniversalRobots/Universal_Robots_ExternalControl_URCap/releases/latest | grep "browser_download_url.*jar" | cut -d ":" -f 2,3 | tr -d "\"[:space:]")
388+
URCAP_VERSION=$(echo "$urcap_download_url" | grep -oP '\d+\.\d+\.\d+' | head -n 1)
389+
fi
380390
if [[ ! -f "${URCAP_STORAGE}/externalcontrol-${URCAP_VERSION}.jar" ]]; then
381-
curl -L -o "${URCAP_STORAGE}/externalcontrol-${URCAP_VERSION}.jar" \
382-
"https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCap/releases/download/v${URCAP_VERSION}/externalcontrol-${URCAP_VERSION}.jar"
391+
echo "Downloading and installing External Control URCap version ${URCAP_VERSION}"
392+
curl -L -o "${URCAP_STORAGE}/externalcontrol-${URCAP_VERSION}.jar" "$urcap_download_url"
383393
fi
384394
docker_cmd="docker run --rm -d --net ursim_net --ip $IP_ADDRESS\
385395
-v ${URCAP_STORAGE}:/urcaps \

0 commit comments

Comments
 (0)