|
33 | 33 | #include <ur_client_library/ur/dashboard_client.h> |
34 | 34 | #include <ur_client_library/ur/ur_driver.h> |
35 | 35 | #include <ur_client_library/example_robot_wrapper.h> |
| 36 | +#include <algorithm> |
36 | 37 | #include "test_utils.h" |
37 | 38 |
|
38 | 39 | using namespace urcl; |
39 | 40 |
|
40 | 41 | const std::string SCRIPT_FILE = "../resources/external_control.urscript"; |
41 | 42 | const std::string OUTPUT_RECIPE = "resources/rtde_output_recipe.txt"; |
42 | 43 | const std::string INPUT_RECIPE = "resources/rtde_input_recipe.txt"; |
| 44 | +const std::vector<std::string> OUTPUT_RECIPE_VECTOR = { "timestamp", |
| 45 | + "actual_qd", |
| 46 | + "speed_scaling", |
| 47 | + "target_speed_fraction", |
| 48 | + "runtime_state", |
| 49 | + "actual_TCP_force", |
| 50 | + "actual_TCP_pose", |
| 51 | + "actual_digital_input_bits", |
| 52 | + "actual_digital_output_bits", |
| 53 | + "standard_analog_input0", |
| 54 | + "standard_analog_input1", |
| 55 | + "standard_analog_output0", |
| 56 | + "standard_analog_output1", |
| 57 | + "analog_io_types", |
| 58 | + "tool_mode", |
| 59 | + "tool_analog_input_types", |
| 60 | + "tool_analog_input0", |
| 61 | + "tool_analog_input1", |
| 62 | + "tool_output_voltage", |
| 63 | + "tool_output_current", |
| 64 | + "tool_temperature", |
| 65 | + "robot_mode", |
| 66 | + "safety_mode", |
| 67 | + "robot_status_bits", |
| 68 | + "safety_status_bits", |
| 69 | + "actual_current", |
| 70 | + "tcp_offset" }; |
| 71 | +const std::vector<std::string> INPUT_RECIPE_VECTOR = { |
| 72 | + "speed_slider_mask", "standard_digital_output_mask", |
| 73 | + "standard_digital_output", "configurable_digital_output_mask", |
| 74 | + "configurable_digital_output", "tool_digital_output_mask", |
| 75 | + "tool_digital_output", "standard_analog_output_mask", |
| 76 | + "standard_analog_output_type", "standard_analog_output_0", |
| 77 | + "standard_analog_output_1" |
| 78 | +}; |
| 79 | +const std::string OUTPUT_RECIPE_VECTOR_EXCLUDED_VALUE = "actual_q"; |
| 80 | +const std::string INPUT_RECIPE_VECTOR_EXCLUDED_VALUE = "speed_slider_fraction"; |
43 | 81 | const std::string CALIBRATION_CHECKSUM = "calib_12788084448423163542"; |
44 | 82 | std::string g_ROBOT_IP = "192.168.56.101"; |
45 | 83 | bool g_HEADLESS = true; |
@@ -310,6 +348,53 @@ TEST(UrDriverInitTest, setting_connection_limits_works_correctly) |
310 | 348 | EXPECT_THROW(UrDriver ur_driver(config), UrException); |
311 | 349 | } |
312 | 350 |
|
| 351 | +TEST(UrDriverInitTest, no_recipe_throws_error) |
| 352 | +{ |
| 353 | + UrDriverConfiguration config; |
| 354 | + config.socket_reconnect_attempts = 1; |
| 355 | + config.socket_reconnection_timeout = std::chrono::milliseconds(200); |
| 356 | + config.robot_ip = g_ROBOT_IP; // That IP address should not exist on the test network |
| 357 | + config.headless_mode = g_HEADLESS; |
| 358 | + |
| 359 | + EXPECT_THROW(UrDriver ur_driver(config), UrException); |
| 360 | +} |
| 361 | + |
| 362 | +TEST(UrDriverInitTest, non_existing_recipe_file_throws_exception) |
| 363 | +{ |
| 364 | + UrDriverConfiguration config; |
| 365 | + config.socket_reconnect_attempts = 1; |
| 366 | + config.socket_reconnection_timeout = std::chrono::milliseconds(200); |
| 367 | + config.robot_ip = g_ROBOT_IP; // That IP address should not exist on the test network |
| 368 | + config.input_recipe_file = " "; |
| 369 | + config.output_recipe_file = OUTPUT_RECIPE; |
| 370 | + config.headless_mode = g_HEADLESS; |
| 371 | + |
| 372 | + EXPECT_THROW(UrDriver ur_driver(config), UrException); |
| 373 | + |
| 374 | + config.input_recipe_file = INPUT_RECIPE; |
| 375 | + config.output_recipe_file = " "; |
| 376 | +} |
| 377 | + |
| 378 | +TEST(UrDriverInitTest, both_recipe_file_and_vector_select_file) |
| 379 | +{ |
| 380 | + UrDriverConfiguration config; |
| 381 | + config.socket_reconnect_attempts = 1; |
| 382 | + config.socket_reconnection_timeout = std::chrono::milliseconds(200); |
| 383 | + config.robot_ip = g_ROBOT_IP; // That IP address should not exist on the test network |
| 384 | + config.input_recipe_file = INPUT_RECIPE; |
| 385 | + config.output_recipe_file = OUTPUT_RECIPE; |
| 386 | + config.input_recipe = INPUT_RECIPE_VECTOR; |
| 387 | + config.output_recipe = OUTPUT_RECIPE_VECTOR; |
| 388 | + config.headless_mode = g_HEADLESS; |
| 389 | + |
| 390 | + auto driver = UrDriver(config); |
| 391 | + auto output_recipe = driver.getRTDEOutputRecipe(); |
| 392 | + EXPECT_TRUE(std::find(output_recipe.begin(), output_recipe.end(), OUTPUT_RECIPE_VECTOR_EXCLUDED_VALUE) != |
| 393 | + output_recipe.end()); |
| 394 | + auto input_recipe = driver.getRTDEInputRecipe(); |
| 395 | + EXPECT_TRUE(std::find(input_recipe.begin(), input_recipe.end(), INPUT_RECIPE_VECTOR_EXCLUDED_VALUE) != |
| 396 | + output_recipe.end()); |
| 397 | +} |
313 | 398 | // TODO we should add more tests for the UrDriver class. |
314 | 399 |
|
315 | 400 | int main(int argc, char* argv[]) |
|
0 commit comments