|
34 | 34 | #include <ur_client_library/ur/ur_driver.h> |
35 | 35 | #include <ur_client_library/example_robot_wrapper.h> |
36 | 36 | #include <algorithm> |
| 37 | +#include <thread> |
37 | 38 | #include "test_utils.h" |
38 | 39 |
|
39 | 40 | using namespace urcl; |
@@ -331,6 +332,46 @@ TEST_F(UrDriverTest, read_error_code) |
331 | 332 | EXPECT_NO_THROW(g_my_robot->getPrimaryClient()->commandUnlockProtectiveStop()); |
332 | 333 | } |
333 | 334 |
|
| 335 | +TEST_F(UrDriverTest, set_tcp_offset) |
| 336 | +{ |
| 337 | + ASSERT_TRUE(g_my_robot->getUrDriver()->setTcpOffset({ 0, 0, 0, 0, 0, 0 })); |
| 338 | + |
| 339 | + vector6d_t tcp_offset = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6 }; |
| 340 | + ASSERT_TRUE(g_my_robot->getUrDriver()->setTcpOffset(tcp_offset)); |
| 341 | + |
| 342 | + rtde_interface::DataPackage data_pkg(g_my_robot->getUrDriver()->getRTDEOutputRecipe()); |
| 343 | + vector6d_t tcp_offset_received; |
| 344 | + for (int i = 0; i < 10; ++i) |
| 345 | + { |
| 346 | + ASSERT_TRUE(g_my_robot->getUrDriver()->getDataPackage(data_pkg)); |
| 347 | + |
| 348 | + data_pkg.getData("tcp_offset", tcp_offset_received); |
| 349 | + if (tcp_offset_received == tcp_offset) |
| 350 | + { |
| 351 | + break; |
| 352 | + } |
| 353 | + std::this_thread::sleep_for(std::chrono::milliseconds(2)); |
| 354 | + } |
| 355 | + g_my_robot->getUrDriver()->getDataPackage(data_pkg); |
| 356 | + for (unsigned int i = 0; i < tcp_offset.size(); ++i) |
| 357 | + { |
| 358 | + EXPECT_DOUBLE_EQ(tcp_offset_received[i], tcp_offset[i]); |
| 359 | + } |
| 360 | + |
| 361 | + // Stop program on robot |
| 362 | + g_my_robot->getUrDriver()->stopControl(); |
| 363 | + g_my_robot->waitForProgramNotRunning(1000); |
| 364 | + |
| 365 | + // TODO (feex): We cannot see from the outside whether the script command interface is connected. There is a race |
| 366 | + // condition between the reverse interface disconnection callback and the script_command_interface disconnect |
| 367 | + // callback. For now, we will just have to wait a bit to ensure that the script command interface |
| 368 | + // is disconnected before trying to use the script command interface. |
| 369 | + std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
| 370 | + |
| 371 | + // Check that we can't set TCP offset when the program isn't running |
| 372 | + ASSERT_FALSE(g_my_robot->getUrDriver()->setTcpOffset(tcp_offset)); |
| 373 | +} |
| 374 | + |
334 | 375 | TEST(UrDriverInitTest, setting_connection_limits_works_correctly) |
335 | 376 | { |
336 | 377 | UrDriverConfiguration config; |
|
0 commit comments