Skip to content
Merged
Show file tree
Hide file tree
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
60 changes: 50 additions & 10 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="" # If not set, the latest version will be downloaded
URCAP_VERSION="latest"
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 @@ -212,15 +212,58 @@
post_setup_cb3
}

get_effective_url()
{
curl -Ls -o /dev/null -w %\{url_effective\} "$1"
}

get_version_from_release_url()
{
echo "$effective_url" | grep -oP '\d+\.\d+\.\d+' | head -n 1
}

# Get the latest tag from a GitHub release page. Provide a link to its latest release e.g.
# https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCapX/releases/latest
get_latest_release_tag()
{
effective_url=$(get_effective_url "$1")
get_version_from_release_url "$effective_url"
}

# Get the URCAPX download URL for a given version
#
# Specify the desired version or "latest" as the first argument
#
# sets URCAPX_VERSION
# sets URCAPX_DOWNLOAD_URL
get_download_url_urcapx()
{
release_url="https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCapX/releases/$1"

Check warning on line 241 in scripts/start_ursim.sh

View check run for this annotation

Codecov / codecov/patch

scripts/start_ursim.sh#L241

Added line #L241 was not covered by tests
URCAPX_VERSION=$(get_latest_release_tag "$release_url")
URCAPX_DOWNLOAD_URL="https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCapX/releases/download/$URCAPX_VERSION/external-control-$URCAPX_VERSION.urcapx"
}

# Get the URCAPX download URL for a given version
#
# Specify the desired version or "latest" as the first argument
#
# sets URCAPX_VERSION
# sets URCAPX_DOWNLOAD_URL
get_download_url_urcap()
{
release_url="https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCap/releases/$1"
URCAP_VERSION=$(get_latest_release_tag "$release_url")
URCAP_DOWNLOAD_URL="https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCap/releases/download/v$URCAP_VERSION/externalcontrol-$URCAP_VERSION.jar"
}

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)
get_download_url_urcapx latest

Check warning on line 261 in scripts/start_ursim.sh

View check run for this annotation

Codecov / codecov/patch

scripts/start_ursim.sh#L261

Added line #L261 was not covered by tests
mkdir -p "${URCAP_STORAGE}"
urcapx_file="${URCAP_STORAGE}/external_control-$URCAPX_VERSION.urcapx"
urcapx_file="${URCAP_STORAGE}/external-control-$URCAPX_VERSION.urcapx"

Check warning on line 263 in scripts/start_ursim.sh

View check run for this annotation

Codecov / codecov/patch

scripts/start_ursim.sh#L263

Added line #L263 was not covered by tests
if [[ ! -f "$urcapx_file" ]]; then
echo "Downloading External Control URCapX version ${URCAPX_VERSION}"
curl -L -o "$urcapx_file" "$urcapx_download_url"
curl -L -o "$urcapx_file" "$URCAPX_DOWNLOAD_URL"

Check warning on line 266 in scripts/start_ursim.sh

View check run for this annotation

Codecov / codecov/patch

scripts/start_ursim.sh#L266

Added line #L266 was not covered by tests
fi

echo -ne "Starting URSim. Waiting for UrService to be up..."
Expand Down Expand Up @@ -383,13 +426,10 @@
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
get_download_url_urcap $URCAP_VERSION
if [[ ! -f "${URCAP_STORAGE}/externalcontrol-${URCAP_VERSION}.jar" ]]; then
echo "Downloading and installing External Control URCap version ${URCAP_VERSION}"
curl -L -o "${URCAP_STORAGE}/externalcontrol-${URCAP_VERSION}.jar" "$urcap_download_url"
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
22 changes: 22 additions & 0 deletions tests/test_start_ursim.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ setup() {
source $DIR/../scripts/start_ursim.sh
}

@test "test_get_version_from_release_url" {
effective_url="https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCapX/releases/0.1.0"

VERSION=$(get_version_from_release_url "$effective_url")

[ "$VERSION" = "0.1.0" ]
}

@test "test_get_download_url_urcapx" {
get_download_url_urcapx "0.1.0"
echo "Download URL: $URCAPX_DOWNLOAD_URL"
echo "URCAPX_VERSION: $URCAPX_VERSION"
[ "$URCAPX_DOWNLOAD_URL" = "https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCapX/releases/download/0.1.0/external-control-0.1.0.urcapx" ]
}

@test "test_get_download_url_urcap" {
get_download_url_urcap "1.0.5"
echo "Download URL: $URCAP_DOWNLOAD_URL"
echo "URCAP_VERSION: $URCAP_VERSION"
[ "$URCAP_DOWNLOAD_URL" = "https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCap/releases/download/v1.0.5/externalcontrol-1.0.5.jar" ]
}

@test "test get_series_from_model" {
get_series_from_model "ur10e"
echo "ROBOT_SERIES: $ROBOT_SERIES"
Expand Down
Loading