Skip to content

Commit cafe282

Browse files
author
Felix Exner
committed
Add a gtest for RTDE client only
1 parent 1ce9215 commit cafe282

File tree

5 files changed

+121
-0
lines changed

5 files changed

+121
-0
lines changed

ur_robot_driver/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ if(CATKIN_ENABLE_TESTING)
145145
find_package(rostest REQUIRED)
146146

147147
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)
148153
endif()
149154

150155

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
speed_slider_mask
2+
speed_slider_fraction
3+
standard_digital_output_mask
4+
standard_digital_output
5+
configurable_digital_output_mask
6+
configurable_digital_output
7+
tool_digital_output_mask
8+
tool_digital_output
9+
standard_analog_output_mask
10+
standard_analog_output_type
11+
standard_analog_output_0
12+
standard_analog_output_1
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
timestamp
2+
actual_q
3+
actual_qd
4+
speed_scaling
5+
target_speed_fraction
6+
runtime_state
7+
actual_TCP_force
8+
actual_TCP_pose
9+
actual_digital_input_bits
10+
actual_digital_output_bits
11+
standard_analog_input0
12+
standard_analog_input1
13+
standard_analog_output0
14+
standard_analog_output1
15+
analog_io_types
16+
tool_mode
17+
tool_analog_input_types
18+
tool_analog_input0
19+
tool_analog_input1
20+
tool_output_voltage
21+
tool_output_current
22+
tool_temperature
23+
robot_mode
24+
safety_mode
25+
robot_status_bits
26+
safety_status_bits
27+
actual_current
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2+
3+
// -- BEGIN LICENSE BLOCK ----------------------------------------------
4+
// -- END LICENSE BLOCK ------------------------------------------------
5+
6+
//----------------------------------------------------------------------
7+
/*!\file
8+
*
9+
* \author Felix Exner [email protected]
10+
* \date 2020-07-09
11+
*
12+
*/
13+
//----------------------------------------------------------------------
14+
15+
#include <gtest/gtest.h>
16+
17+
#include <ur_robot_driver/rtde/rtde_client.h>
18+
19+
using namespace ur_driver;
20+
21+
const std::string ROBOT_IP = "172.17.0.2";
22+
23+
TEST(UrRobotDriver, rtde_handshake)
24+
{
25+
comm::INotifier notifier;
26+
std::string output_recipe = "resources/rtde_output_recipe.txt";
27+
std::string input_recipe = "resources/rtde_input_recipe.txt";
28+
rtde_interface::RTDEClient client(ROBOT_IP, notifier, output_recipe, input_recipe);
29+
30+
EXPECT_TRUE(client.init());
31+
}
32+
33+
TEST(UrRobotDriver, rtde_handshake_wrong_ip)
34+
{
35+
comm::INotifier notifier;
36+
std::string output_recipe = "resources/rtde_output_recipe.txt";
37+
std::string input_recipe = "resources/rtde_input_recipe.txt";
38+
rtde_interface::RTDEClient client("1.2.3.4", notifier, output_recipe, input_recipe);
39+
40+
EXPECT_THROW(client.init(), UrException);
41+
}
42+
43+
TEST(UrRobotDriver, rtde_handshake_illegal_ip)
44+
{
45+
comm::INotifier notifier;
46+
std::string output_recipe = "resources/rtde_output_recipe.txt";
47+
std::string input_recipe = "resources/rtde_input_recipe.txt";
48+
rtde_interface::RTDEClient client("abcd", notifier, output_recipe, input_recipe);
49+
50+
EXPECT_THROW(client.init(), UrException);
51+
}
52+
53+
TEST(UrRobotDriver, no_recipe)
54+
{
55+
comm::INotifier notifier;
56+
std::string output_recipe = "";
57+
std::string input_recipe = "";
58+
EXPECT_THROW(rtde_interface::RTDEClient client(ROBOT_IP, notifier, output_recipe, input_recipe), UrException);
59+
}
60+
61+
TEST(UrRobotDriver, empty_recipe)
62+
{
63+
comm::INotifier notifier;
64+
std::string output_recipe = "resources/empty.txt";
65+
std::string input_recipe = "resources/empty.txt";
66+
rtde_interface::RTDEClient client(ROBOT_IP, notifier, output_recipe, input_recipe);
67+
68+
EXPECT_THROW(client.init(), UrException);
69+
}
70+
71+
int main(int argc, char* argv[])
72+
{
73+
::testing::InitGoogleTest(&argc, argv);
74+
75+
return RUN_ALL_TESTS();
76+
}

0 commit comments

Comments
 (0)