Skip to content

Commit a183669

Browse files
committed
Merge remote-tracking branch 'origin/master' into more_motion_target_interfaces
2 parents d766304 + 01cf607 commit a183669

6 files changed

Lines changed: 45 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767
-DWITH_ASAN=ON
6868
-DPRIMARY_CLIENT_STRICT_PARSING=ON
6969
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
70+
-DCHECK_RTDE_DOCS_RECIPE=ON
7071
env:
7172
CXXFLAGS: -g -O2 -fprofile-arcs -ftest-coverage
7273
CFLAGS: -g -O2 -fprofile-arcs -ftest-coverage

include/ur_client_library/primary/primary_client.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,20 @@ class PrimaryClient
258258
return consumer_->getConfigurationData();
259259
}
260260

261+
/*!
262+
* \brief Get the latest kinematics info.
263+
*
264+
* The kinematics info contains the controller's calibrated DH parameters: the nominal model
265+
* combined with the per-arm calibration deltas, plus the calibration checksum/status. It
266+
* will be updated in the background. This will always show the latest received kinematics
267+
* info independent of the time that has passed since receiving it. If no kinematics info
268+
* has been received yet, this will return a nullptr.
269+
*/
270+
std::shared_ptr<KinematicsInfo> getKinematicsInfo()
271+
{
272+
return consumer_->getKinematicsInfo();
273+
}
274+
261275
/*!
262276
* \brief Get the Robot type
263277
*

include/ur_client_library/primary/primary_consumer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class PrimaryConsumer : public AbstractPrimaryConsumer
107107
virtual bool consume(KinematicsInfo& pkg) override
108108
{
109109
URCL_LOG_DEBUG("%s", pkg.toString().c_str());
110+
std::scoped_lock lock(kinematics_info_mutex_);
110111
kinematics_info_ = std::make_shared<KinematicsInfo>(pkg);
111112
return true;
112113
}
@@ -203,6 +204,7 @@ class PrimaryConsumer : public AbstractPrimaryConsumer
203204
*/
204205
std::shared_ptr<KinematicsInfo> getKinematicsInfo()
205206
{
207+
std::scoped_lock lock(kinematics_info_mutex_);
206208
return kinematics_info_;
207209
}
208210

@@ -259,6 +261,7 @@ class PrimaryConsumer : public AbstractPrimaryConsumer
259261
private:
260262
std::function<void(ErrorCode&)> error_code_message_callback_;
261263
std::shared_ptr<KinematicsInfo> kinematics_info_;
264+
std::mutex kinematics_info_mutex_;
262265
std::mutex robot_mode_mutex_;
263266
std::shared_ptr<RobotModeData> robot_mode_;
264267
std::mutex version_information_mutex_;

tests/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,27 @@ include(GoogleTest)
2121

2222
option(INTEGRATION_TESTS "Build the integration tests that require a running robot / URSim" OFF)
2323
option(POLYSCOPE_X_TESTS_WITH_REMOTE_CONTROL "Run Polyscope X tests that require remote control" OFF)
24+
option(CHECK_RTDE_DOCS_RECIPE "Fetch the RTDE documentation to auto-generate a recipe containing all output fields and check that with the RTDE client. Requires python3 and pandas and an internet connection." OFF)
2425
# Build Tests
2526
if (INTEGRATION_TESTS)
2627
# Integration tests require a robot reachable at 192.168.56.101. Therefore, they have to be
2728
# activated separately.
2829

29-
find_package(Python3 COMPONENTS Interpreter REQUIRED)
3030
if(POLYSCOPE_X_TESTS_WITH_REMOTE_CONTROL)
3131
add_compile_definitions(POLYSCOPE_X_TESTS_WITH_REMOTE_CONTROL=1 )
3232
endif()
3333

34-
add_custom_target(generate_outputs ALL COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/resources/generate_rtde_outputs.py)
3534
add_executable(rtde_tests test_rtde_client.cpp fake_rtde_server.cpp)
36-
add_dependencies(rtde_tests generate_outputs)
3735
target_link_libraries(rtde_tests PRIVATE ur_client_library::urcl GTest::gtest_main)
3836
gtest_add_tests(TARGET rtde_tests
3937
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
4038
)
39+
if (CHECK_RTDE_DOCS_RECIPE)
40+
find_package(Python3 COMPONENTS Interpreter REQUIRED)
41+
add_custom_target(generate_outputs ALL COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/resources/generate_rtde_outputs.py)
42+
add_dependencies(rtde_tests generate_outputs)
43+
target_compile_definitions(rtde_tests PRIVATE CHECK_RTDE_DOCS_RECIPE=1)
44+
endif()
4145

4246
add_executable(dashboard_client_g5_tests test_dashboard_client_g5.cpp)
4347
target_link_libraries(dashboard_client_g5_tests PRIVATE ur_client_library::urcl GTest::gtest_main)

tests/test_primary_client.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,24 @@ TEST_F(PrimaryClientTest, test_configuration_data)
267267
EXPECT_NE(client_->getRobotType(), RobotType::UNDEFINED);
268268
}
269269

270+
TEST_F(PrimaryClientTest, test_kinematics_info)
271+
{
272+
EXPECT_NO_THROW(client_->start());
273+
274+
// Once we connect to the primary client we should receive kinematics info
275+
auto start_time = std::chrono::system_clock::now();
276+
const auto timeout = std::chrono::seconds(1);
277+
auto kinematics_info = client_->getKinematicsInfo();
278+
while (kinematics_info == nullptr && std::chrono::system_clock::now() - start_time < timeout)
279+
{
280+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
281+
kinematics_info = client_->getKinematicsInfo();
282+
}
283+
284+
// We should have received a kinematics info package
285+
EXPECT_NE(kinematics_info, nullptr);
286+
}
287+
270288
TEST_F(PrimaryClientTest, test_get_robot_series)
271289
{
272290
EXPECT_NO_THROW(client_->start());

tests/test_rtde_client.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ TEST_F(RTDEClientTest, check_all_rtde_output_variables_exist)
680680
client_->pause();
681681
}
682682

683+
#ifdef CHECK_RTDE_DOCS_RECIPE
683684
TEST_F(RTDEClientTest, check_rtde_data_fields_match_docs)
684685
{
685686
std::ifstream docs_file(docs_output_recipe_file_);
@@ -724,6 +725,7 @@ TEST_F(RTDEClientTest, check_rtde_data_fields_match_docs)
724725
GTEST_FAIL();
725726
}
726727
}
728+
#endif
727729

728730
TEST_F(RTDEClientTest, check_unknown_rtde_output_variable)
729731
{

0 commit comments

Comments
 (0)