Skip to content

Commit 62f0a58

Browse files
author
Felix Exner (fexner)
authored
Start ursim from lib (#733)
* Forward start_ursim.sh to the one from the client library * Update docs and tests to start ursim from the ur_client_library script
1 parent ac2c7d6 commit 62f0a58

File tree

6 files changed

+18
-100
lines changed

6 files changed

+18
-100
lines changed

ur_robot_driver/doc/installation/ursim_docker.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ address. The VNC web server will be available at `<http://192.168.56.101:6080/vn
8282
Script startup
8383
--------------
8484

85-
All of the above is put together in a script in the ``ur_robot_driver`` package.
85+
All of the above is put together in a script in the ``ur_client_library`` package.
8686

8787
.. code-block:: bash
8888
89-
ros2 run ur_robot_driver start_ursim.sh
89+
ros2 run ur_client_library start_ursim.sh
9090
9191
This will start a URSim docker container running on ``192.168.56.101`` with the ``external_control``
9292
URCap preinstalled. Created programs and installation changes will be stored persistently inside

ur_robot_driver/doc/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ To start it, we've prepared a script:
8989

9090
.. code-block:: bash
9191
92-
ros2 run ur_robot_driver start_ursim.sh -m <ur_type>
92+
ros2 run ur_client_library start_ursim.sh -m <ur_type>
9393
9494
With this, we can spin up a driver using
9595

ur_robot_driver/scripts/start_ursim.sh

Lines changed: 5 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -28,97 +28,10 @@
2828
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2929
# POSSIBILITY OF SUCH DAMAGE.
3030

31-
PERSISTENT_BASE="${HOME}/.ursim"
32-
URCAP_VERSION="1.0.5"
31+
ORANGE='\033[0;33m'
32+
NC='\033[0m' # No Color
3333

34-
help()
35-
{
36-
# Display Help
37-
echo "Starts URSim inside a docker container"
38-
echo
39-
echo "Syntax: `basename "$0"` [-m|s|h]"
40-
echo "options:"
41-
echo " -m <model> Robot model. One of [ur3, ur3e, ur5, ur5e, ur10, ur10e, ur16e]. Defaults to ur5e."
42-
echo " -h Print this Help."
43-
echo
44-
}
34+
URSIM_CMD="ros2 run ur_client_library start_ursim.sh"
4535

46-
ROBOT_MODEL=UR5
47-
ROBOT_SERIES=e-series
48-
49-
validate_model()
50-
{
51-
case $ROBOT_MODEL in
52-
ur3|ur5|ur10)
53-
ROBOT_MODEL=${ROBOT_MODEL^^}
54-
ROBOT_SERIES=cb3
55-
;;
56-
ur3e|ur5e|ur10e|ur16e)
57-
ROBOT_MODEL=${ROBOT_MODEL^^}
58-
ROBOT_MODEL=$(echo ${ROBOT_MODEL:0:$((${#ROBOT_MODEL}-1))})
59-
ROBOT_SERIES=e-series
60-
;;
61-
*)
62-
echo "Not a valid robot model: $ROBOT_MODEL"
63-
exit
64-
;;
65-
esac
66-
}
67-
68-
69-
while getopts ":hm:s:" option; do
70-
case $option in
71-
h) # display Help
72-
help
73-
exit;;
74-
m) # robot model
75-
ROBOT_MODEL=${OPTARG}
76-
validate_model
77-
;;
78-
\?) # invalid option
79-
echo "Error: Invalid option"
80-
help
81-
exit;;
82-
esac
83-
done
84-
85-
URCAP_STORAGE="${PERSISTENT_BASE}/${ROBOT_SERIES}/urcaps"
86-
PROGRAM_STORAGE="${PERSISTENT_BASE}/${ROBOT_SERIES}/programs"
87-
88-
# Create local storage for programs and URCaps
89-
mkdir -p "${URCAP_STORAGE}"
90-
mkdir -p "${PROGRAM_STORAGE}"
91-
92-
# Download external_control URCap
93-
if [[ ! -f "${URCAP_STORAGE}/externalcontrol-${URCAP_VERSION}.jar" ]]; then
94-
curl -L -o "${URCAP_STORAGE}/externalcontrol-${URCAP_VERSION}.jar" \
95-
"https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCap/releases/download/v${URCAP_VERSION}/externalcontrol-${URCAP_VERSION}.jar"
96-
fi
97-
98-
# Check whether network already exists
99-
docker network inspect ursim_net > /dev/null
100-
if [ $? -eq 0 ]; then
101-
echo "ursim_net already exists"
102-
else
103-
echo "Creating ursim_net"
104-
docker network create --subnet=192.168.56.0/24 ursim_net
105-
fi
106-
107-
# run docker container
108-
docker run --rm -d --net ursim_net --ip 192.168.56.101\
109-
-v "${URCAP_STORAGE}":/urcaps \
110-
-v "${PROGRAM_STORAGE}":/ursim/programs \
111-
-e ROBOT_MODEL="${ROBOT_MODEL}" \
112-
--name ursim \
113-
universalrobots/ursim_${ROBOT_SERIES} || exit
114-
115-
trap "echo killing; docker container kill ursim; exit" SIGINT SIGTERM
116-
117-
echo "Docker URSim is running"
118-
printf "\nTo access Polyscope, open the following URL in a web browser.\n\thttp://192.168.56.101:6080/vnc.html\n\n"
119-
echo "To exit, press CTRL+C"
120-
121-
while :
122-
do
123-
sleep 1
124-
done
36+
echo -e "${ORANGE} DEPRECATION WARNING: The script starting URSim was moved to the ur_client_library package. This script here does still work, but will be removed with ROS Jazzy. Please use `${URSIM_CMD}` to start URSim in future."
37+
$URSIM_CMD

ur_robot_driver/test/dashboard_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ def generate_test_description():
8989
cmd=[
9090
PathJoinSubstitution(
9191
[
92-
FindPackagePrefix("ur_robot_driver"),
92+
FindPackagePrefix("ur_client_library"),
9393
"lib",
94-
"ur_robot_driver",
94+
"ur_client_library",
9595
"start_ursim.sh",
9696
]
9797
),

ur_robot_driver/test/robot_driver.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ def generate_test_description(tf_prefix):
113113
ursim = ExecuteProcess(
114114
cmd=[
115115
PathJoinSubstitution(
116-
[FindPackagePrefix("ur_robot_driver"), "lib", "ur_robot_driver", "start_ursim.sh"]
116+
[
117+
FindPackagePrefix("ur_client_library"),
118+
"lib",
119+
"ur_client_library",
120+
"start_ursim.sh",
121+
]
117122
),
118123
" ",
119124
"-m ",

ur_robot_driver/test/urscript_interface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ def generate_test_description():
103103
cmd=[
104104
PathJoinSubstitution(
105105
[
106-
FindPackagePrefix("ur_robot_driver"),
106+
FindPackagePrefix("ur_client_library"),
107107
"lib",
108-
"ur_robot_driver",
108+
"ur_client_library",
109109
"start_ursim.sh",
110110
]
111111
),

0 commit comments

Comments
 (0)