Skip to content

Always download and install the latest URCap(X) if not present #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions scripts/start_ursim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# POSSIBILITY OF SUCH DAMAGE.

PERSISTENT_BASE="${HOME}/.ursim"
URCAP_VERSION="1.0.5"
URCAP_VERSION="" # If not set, the latest version will be downloaded
IP_ADDRESS="192.168.56.101"
PORT_FORWARDING_WITH_DASHBOARD="-p 30001-30004:30001-30004 -p 29999:29999"
PORT_FORWARDING_WITHOUT_DASHBOARD="-p 30001-30004:30001-30004"
Expand Down Expand Up @@ -214,6 +214,14 @@

post_setup_polyscopex()
{
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:]")
URCAPX_VERSION=$(echo "$urcapx_download_url" | grep -oP '\d+\.\d+\.\d+' | head -n 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add a URCAPX version argument as well or do we wait until there are multiple versions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would rather not have one at all. In the past, we had it as we didn't pull the latest version from the Github release page. I would have even removed the other one, but left it there if anybody was actively using that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with leaving it out for know. I guess that we could end up in a situation where different releases of the URCap only work for specific releases of PolyscopeX, but then we can always add it later if that becomes a problem.

mkdir -p "${URCAP_STORAGE}"
urcapx_file="${URCAP_STORAGE}/external_control-$URCAPX_VERSION.urcapx"
if [[ ! -f "$urcapx_file" ]]; then
echo "Downloading External Control URCapX version ${URCAPX_VERSION}"
curl -L -o "$urcapx_file" "$urcapx_download_url"

Check warning on line 223 in scripts/start_ursim.sh

View check run for this annotation

Codecov / codecov/patch

scripts/start_ursim.sh#L219-L223

Added lines #L219 - L223 were not covered by tests
fi

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

echo ""; echo "UrService is up"

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

Check warning on line 241 in scripts/start_ursim.sh

View check run for this annotation

Codecov / codecov/patch

scripts/start_ursim.sh#L239-L241

Added lines #L239 - L241 were not covered by tests

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

# Download external_control URCap
if [[ -z "$URCAP_VERSION" ]]; then
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:]")
URCAP_VERSION=$(echo "$urcap_download_url" | grep -oP '\d+\.\d+\.\d+' | head -n 1)
fi
if [[ ! -f "${URCAP_STORAGE}/externalcontrol-${URCAP_VERSION}.jar" ]]; then
curl -L -o "${URCAP_STORAGE}/externalcontrol-${URCAP_VERSION}.jar" \
"https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCap/releases/download/v${URCAP_VERSION}/externalcontrol-${URCAP_VERSION}.jar"
echo "Downloading and installing External Control URCap version ${URCAP_VERSION}"
curl -L -o "${URCAP_STORAGE}/externalcontrol-${URCAP_VERSION}.jar" "$urcap_download_url"
fi
docker_cmd="docker run --rm -d --net ursim_net --ip $IP_ADDRESS\
-v ${URCAP_STORAGE}:/urcaps \
Expand Down
Loading