Skip to content

Commit 83c5e8c

Browse files
author
Felix Exner
authored
Merge pull request UniversalRobots#209 from fmauch/testing_scripts
Add integration tests for automated testing
2 parents 7c2fd87 + f6196af commit 83c5e8c

File tree

21 files changed

+706
-7
lines changed

21 files changed

+706
-7
lines changed
2 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#
2+
#Thu May 28 16:20:13 BST 2020
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/ursim/programs.UR5

.github/dockerursim/Dockerfile

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# MIT License
2+
#
3+
# Original from https://github.com/ahobsonsayers/DockURSim
4+
# Copyright (c) 2019 Arran Hobson Sayers
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
24+
FROM lsiobase/guacgui:latest
25+
26+
# Set Version Information
27+
ARG BUILD_DATE="15/08/19"
28+
ARG VERSION="5.8.0.10253"
29+
LABEL build_version="URSim Version: ${VERSION} Build Date: ${BUILD_DATE}"
30+
LABEL maintainer="Arran Hobson Sayers"
31+
LABEL MAINTAINER="Arran Hobson Sayers"
32+
ENV APPNAME="URSim"
33+
34+
# Set Timezone
35+
ARG TZ="Europe/London"
36+
ENV TZ ${TZ}
37+
38+
# Setup Environment
39+
ENV DEBIAN_FRONTEND noninteractive
40+
41+
# Set Home Directory
42+
ENV HOME /ursim
43+
44+
# Set robot model - Can be UR3, UR5 or UR10
45+
ENV ROBOT_MODEL UR5
46+
47+
RUN \
48+
echo "**** Installing Dependencies ****" && \
49+
apt-get update && \
50+
apt-get install -qy --no-install-recommends \
51+
openjdk-8-jre psmisc && \
52+
# Change java alternatives so we use openjdk8 (required by URSim) not openjdk11 that comes with guacgui
53+
update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 10000
54+
55+
# Setup JAVA_HOME
56+
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
57+
58+
RUN \
59+
echo "**** Downloading URSim ****" && \
60+
# Make sure we are in the root
61+
cd / && \
62+
# Download URSim Linux tar.gz
63+
curl https://s3-eu-west-1.amazonaws.com/ur-support-site/69987/URSim_Linux-5.8.0.10253.tar.gz -o URSim-Linux.tar.gz && \
64+
#curl https://s3-eu-west-1.amazonaws.com/ur-support-site/54411/URSim_Linux-5.4.2.76197.tar.gz -o URSim-Linux.tar.gz && \
65+
# Extract tarball
66+
tar xvzf URSim-Linux.tar.gz && \
67+
#Remove the tarball
68+
rm URSim-Linux.tar.gz && \
69+
# Rename the URSim folder to jus ursim
70+
mv /ursim* /ursim
71+
72+
RUN \
73+
echo "**** Installing URSim ****" && \
74+
# cd to ursim folder
75+
cd /ursim && \
76+
# Make URControl and all sh files executable
77+
chmod +x ./*.sh ./URControl && \
78+
#
79+
# Stop install of unnecessary packages and install required ones quietly
80+
sed -i 's|apt-get -y install|apt-get -qy install --no-install-recommends|g' ./install.sh && \
81+
# Skip xterm command. We dont have a desktop
82+
sed -i 's|tty -s|(exit 0)|g' install.sh && \
83+
# Skip Check of Java Version as we have the correct installed and the command will fail
84+
sed -i 's|needToInstallJava$|(exit 0)|g' install.sh && \
85+
# Skip install of desktop shortcuts - we dont have a desktop
86+
sed -i '/for TYPE in UR3 UR5 UR10/,$ d' ./install.sh && \
87+
# Remove commands that are not relevant on docker as we are root user
88+
sed -i 's|pkexec ||g' ./install.sh && \
89+
sed -i 's|sudo ||g' ./install.sh && \
90+
sed -i 's|sudo ||g' ./ursim-certificate-check.sh && \
91+
#
92+
# Install URSim
93+
./install.sh && \
94+
#
95+
echo "Installed URSim"
96+
97+
RUN \
98+
echo "**** Clean Up ****" && \
99+
rm -rf \
100+
/tmp/* \
101+
/var/lib/apt/lists/* \
102+
/var/tmp/*
103+
104+
# Copy ursim run service script
105+
COPY ursim /etc/services.d/ursim
106+
COPY safety.conf.UR5 /ursim/.urcontrol/
107+
# Expose ports
108+
# Guacamole web browser viewer
109+
EXPOSE 8080
110+
# VNC viewer
111+
EXPOSE 3389
112+
# Modbus Port
113+
EXPOSE 502
114+
# Interface Ports
115+
EXPOSE 29999
116+
EXPOSE 30001-30004
117+
118+
# Mount Volumes
119+
VOLUME /ursim
120+
121+
ENTRYPOINT ["/init"]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
4+
5+
6+
docker build ${DIR} -t mydockerursim
7+
docker volume create dockerursim
8+
docker run --name="mydockerursim" -d \
9+
-e ROBOT_MODEL=UR5 \
10+
-p 8080:8080 \
11+
-p 29999:29999 \
12+
-p 30001-30004:30001-30004 \
13+
-v "${DIR}/.vol":/ursim/programs \
14+
-v dockursim:/ursim \
15+
--privileged \
16+
--cpus=1 \
17+
mydockerursim
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Beware: This file is auto-generated from PolyScope.
2+
# NOTE: The SafetyParameters section is protected by a CRC checksum, please use the supplied tool
3+
4+
## SafetyParameters ##
5+
[NormalModeSafetyLimits]
6+
maxTcpSpeed = 1.5
7+
maxForce = 150.0
8+
maxElbowSpeed = 1.5
9+
maxElbowForce = 150.0
10+
maxStoppingDistance = 0.5
11+
maxStoppingTime = 0.4
12+
maxPower = 300.0
13+
maxMomentum = 25.0
14+
maxJointSpeed = [3.3415926, 3.3415926, 3.3415926, 3.3415926, 3.3415926, 3.3415926]
15+
minJointPosition = [6.2308254, 6.2308254, 6.2308254, 6.2308254, 6.2308254, 6.2308254]
16+
maxJointPosition = [0.05235988, 0.05235988, 0.05235988, 0.05235988, 0.05235988, 0.05235988]
17+
minJointRevolutions = [-2, -2, -2, -2, -2, -2]
18+
maxJointRevolutions = [1, 1, 1, 1, 1, 1]
19+
plane0 = [0.0, 0.0, 0.0, 0.0, 0]
20+
plane1 = [0.0, 0.0, 0.0, 0.0, 0]
21+
plane2 = [0.0, 0.0, 0.0, 0.0, 0]
22+
plane3 = [0.0, 0.0, 0.0, 0.0, 0]
23+
plane4 = [0.0, 0.0, 0.0, 0.0, 0]
24+
plane5 = [0.0, 0.0, 0.0, 0.0, 0]
25+
plane6 = [0.0, 0.0, 0.0, 0.0, 0]
26+
plane7 = [0.0, 0.0, 0.0, 0.0, 0]
27+
tcpOrientationVector = [0.0, 0.0, 1.0]
28+
maximumTcpOrientationDeviation = 6.2831855
29+
30+
[ReducedModeSafetyLimits]
31+
maxTcpSpeed = 0.75
32+
maxForce = 120.0
33+
maxElbowSpeed = 0.75
34+
maxElbowForce = 120.0
35+
maxStoppingDistance = 0.3
36+
maxStoppingTime = 0.3
37+
maxPower = 200.0
38+
maxMomentum = 10.0
39+
maxJointSpeed = [3.3415926, 3.3415926, 3.3415926, 3.3415926, 3.3415926, 3.3415926]
40+
minJointPosition = [6.2308254, 6.2308254, 6.2308254, 6.2308254, 6.2308254, 6.2308254]
41+
maxJointPosition = [0.05235988, 0.05235988, 0.05235988, 0.05235988, 0.05235988, 0.05235988]
42+
minJointRevolutions = [-2, -2, -2, -2, -2, -2]
43+
maxJointRevolutions = [1, 1, 1, 1, 1, 1]
44+
plane0 = [0.0, 0.0, 0.0, 0.0, 0]
45+
plane1 = [0.0, 0.0, 0.0, 0.0, 0]
46+
plane2 = [0.0, 0.0, 0.0, 0.0, 0]
47+
plane3 = [0.0, 0.0, 0.0, 0.0, 0]
48+
plane4 = [0.0, 0.0, 0.0, 0.0, 0]
49+
plane5 = [0.0, 0.0, 0.0, 0.0, 0]
50+
plane6 = [0.0, 0.0, 0.0, 0.0, 0]
51+
plane7 = [0.0, 0.0, 0.0, 0.0, 0]
52+
tcpOrientationVector = [0.0, 0.0, 1.0]
53+
maximumTcpOrientationDeviation = 6.2831855
54+
55+
[MiscConfiguration]
56+
teach_pendant = 1
57+
euromap67 = 0
58+
59+
[SafetyIOConfiguration]
60+
emergencyStopInputA = 255
61+
emergencyStopInputB = 255
62+
reducedModeInputA = 255
63+
reducedModeInputB = 255
64+
safeguardStopResetInputA = 0
65+
safeguardStopResetInputB = 1
66+
threePositionEnablingInputA = 255
67+
threePositionEnablingInputB = 255
68+
operationalModeInputA = 255
69+
operationalModeInputB = 255
70+
systemEmergencyStopOutputA = 255
71+
systemEmergencyStopOutputB = 255
72+
robotMovingOutputA = 255
73+
robotMovingOutputB = 255
74+
robotNotStoppingOutputA = 255
75+
robotNotStoppingOutputB = 255
76+
reducedModeOutputA = 255
77+
reducedModeOutputB = 255
78+
notReducedModeOutputA = 255
79+
notReducedModeOutputB = 255
80+
81+
[ReducedModeTriggerPlanes]
82+
plane0 = [0.0, 0.0, 0.0, 0.0, 0]
83+
plane1 = [0.0, 0.0, 0.0, 0.0, 0]
84+
plane2 = [0.0, 0.0, 0.0, 0.0, 0]
85+
plane3 = [0.0, 0.0, 0.0, 0.0, 0]
86+
plane4 = [0.0, 0.0, 0.0, 0.0, 0]
87+
plane5 = [0.0, 0.0, 0.0, 0.0, 0]
88+
plane6 = [0.0, 0.0, 0.0, 0.0, 0]
89+
plane7 = [0.0, 0.0, 0.0, 0.0, 0]
90+
91+
[WorkpieceConfiguration]
92+
toolSpheres = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]
93+
toolDirectionInclination = 0.0
94+
toolDirectionAzimuth = 0.0
95+
96+
97+
## SafetyParameters ##
98+
[Checksum]
99+
safetyParameters = 3478627865
100+
majorVersion = 5
101+
minorVersion = 0

.github/dockerursim/ursim/run

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/execlineb -P
2+
3+
s6-envdir -fn -- /var/run/s6/container_environment
4+
importas -i ROBOT_MODEL ROBOT_MODEL
5+
6+
# Redirect stderr to stdout.
7+
fdmove -c 2 1
8+
9+
# Wait until openbox is running
10+
if { s6-svwait -t 10000 -U /var/run/s6/services/openbox/ }
11+
12+
# Set env
13+
s6-env DISPLAY=:1
14+
15+
# Execute URSim
16+
/ursim/start-ursim.sh ${ROBOT_MODEL}

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,21 @@ jobs:
2121
- ROS_DISTRO: kinetic
2222
UPSTREAM_WORKSPACE: .ci.rosinstall
2323
ROS_REPO: main
24+
DOCKER_RUN_OPTS: --network bridge
25+
BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 172.17.0.2'
26+
IMMEDIATE_TEST_OUTPUT: true
2427
- ROS_DISTRO: melodic
2528
UPSTREAM_WORKSPACE: .ci.rosinstall
2629
ROS_REPO: main
30+
DOCKER_RUN_OPTS: --network bridge
31+
BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 172.17.0.2'
32+
IMMEDIATE_TEST_OUTPUT: true
2733

2834
steps:
2935
- uses: actions/checkout@v1
36+
- name: start ursim
37+
run: |
38+
.github/dockerursim/build_and_run_docker_ursim.sh
3039
- uses: 'ros-industrial/industrial_ci@master'
3140
env: ${{matrix.env}}
3241

ur_robot_driver/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,18 @@ add_executable(robot_state_helper
141141
target_link_libraries(robot_state_helper ${catkin_LIBRARIES} ur_robot_driver)
142142
add_dependencies(robot_state_helper ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
143143

144+
if(CATKIN_ENABLE_TESTING)
145+
find_package(rostest REQUIRED)
146+
147+
add_rostest(test/driver.test)
148+
149+
catkin_add_gtest(test_rtde_client
150+
test/test_rtde_client.cpp
151+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test)
152+
target_link_libraries(test_rtde_client ${catkin_LIBRARIES} ur_robot_driver)
153+
endif()
154+
155+
144156
install(TARGETS ur_robot_driver ur_robot_driver_plugin ur_robot_driver_node robot_state_helper dashboard_client
145157
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
146158
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}

ur_robot_driver/include/ur_robot_driver/rtde/rtde_writer.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,16 @@ class RTDEWriter
5555
* \param recipe The recipe to use for communication
5656
*/
5757
RTDEWriter(comm::URStream<RTDEPackage>* stream, const std::vector<std::string>& recipe);
58-
~RTDEWriter() = default;
58+
59+
~RTDEWriter()
60+
{
61+
running_ = false;
62+
std::this_thread::sleep_for(std::chrono::seconds(5));
63+
if (writer_thread_.joinable())
64+
{
65+
writer_thread_.join();
66+
}
67+
}
5968
/*!
6069
* \brief Starts the writer thread, which periodically clears the queue to write packages to the
6170
* robot.
@@ -120,6 +129,7 @@ class RTDEWriter
120129
uint8_t recipe_id_;
121130
moodycamel::BlockingReaderWriterQueue<std::unique_ptr<DataPackage>> queue_;
122131
std::thread writer_thread_;
132+
bool running_;
123133
};
124134

125135
} // namespace rtde_interface

0 commit comments

Comments
 (0)