diff --git a/.github/workflows/industrial-ci.yml b/.github/workflows/industrial-ci.yml index 98d83ada6..a151d3c10 100644 --- a/.github/workflows/industrial-ci.yml +++ b/.github/workflows/industrial-ci.yml @@ -34,38 +34,6 @@ jobs: DOCKER_RUN_OPTS: --network static_test_net BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 192.168.56.101' URSIM_VERSION: 5.8.0.10253 - - ROS_DISTRO: foxy - ROS_REPO: main - IMMEDIATE_TEST_OUTPUT: true - DOWNSTREAM_WORKSPACE: "github:UniversalRobots/Universal_Robots_ROS2_Driver#foxy" - DOCKER_RUN_OPTS: --network static_test_net - BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 192.168.56.101' - URSIM_VERSION: 5.8.0.10253 - NOT_TEST_DOWNSTREAM: true - - ROS_DISTRO: galactic - ROS_REPO: main - IMMEDIATE_TEST_OUTPUT: true - DOWNSTREAM_WORKSPACE: "github:UniversalRobots/Universal_Robots_ROS2_Driver#galactic" - DOCKER_RUN_OPTS: --network static_test_net - BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 192.168.56.101' - URSIM_VERSION: 5.8.0.10253 - NOT_TEST_DOWNSTREAM: true - - ROS_DISTRO: humble - ROS_REPO: main - IMMEDIATE_TEST_OUTPUT: true - DOWNSTREAM_WORKSPACE: "github:UniversalRobots/Universal_Robots_ROS2_Driver#main https://raw.githubusercontent.com/UniversalRobots/Universal_Robots_ROS2_Driver/main/Universal_Robots_ROS2_Driver-not-released.humble.repos" - DOCKER_RUN_OPTS: --network static_test_net - BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 192.168.56.101' - URSIM_VERSION: 5.8.0.10253 - NOT_TEST_DOWNSTREAM: true - - ROS_DISTRO: rolling - ROS_REPO: main - IMMEDIATE_TEST_OUTPUT: true - DOWNSTREAM_WORKSPACE: "github:UniversalRobots/Universal_Robots_ROS2_Driver#main https://raw.githubusercontent.com/UniversalRobots/Universal_Robots_ROS2_Driver/main/Universal_Robots_ROS2_Driver-not-released.rolling.repos" - DOCKER_RUN_OPTS: --network static_test_net - BEFORE_INIT: 'apt-get update -qq && apt-get install -y iproute2 iputils-ping && ip addr && ping -c5 192.168.56.101' - URSIM_VERSION: 5.8.0.10253 - NOT_TEST_DOWNSTREAM: true steps: - uses: actions/checkout@v1 diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 82beec911..071875dde 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,8 +2,23 @@ Changelog for package ur_client_library ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1.1.0 (2022-04-22) +0.4.0 (2022-10-10) ------------------ +* Initialized receive timeout and changed exception to warning (`#118 `_) +* Added tests for the control interface classes (`#112 `_) +* Added note about Polyscope version requirement +* Added tcp_offset +* Added interface for forwarding script commands to the robot, that is … (`#111 `_) +* Fixed parsing of incomming packages when using rtde protocol v1 (`#114 `_) + The received rtde packages should be parsed slightly different whether we use protocol v1 or v2. +* Add codecov step (`#116 `_) +* Added humble build +* Fixed downstream test instructions +* Update atomicops.h (`#117 `_) + Fix the url in the comment regarding POSIX semaphores to fix error in the CI +* Make the read during boot depend on the frequency of the robot controller (`#102 `_) +* Ignore debian folder in check_links (`#100 `_) + Otherwise this job raises an error in the release repository. * Support starting the driver, before the robot is booted (`#98 `_) * Clear the queue when consumer reads from it (`#96 `_) * Fix build with newer glibc @@ -16,21 +31,80 @@ Changelog for package ur_client_library * register package with ament index * Corrected smaller doxygen errors * Added rosdoc_lite check -* Contributors: Cory Crean, Felix Exner, Jørn Bersvendsen, Mads Holm Peters, Martin Jansa, Stefan Scherzinger +* Contributors: Cory Crean, Felix Exner, Jørn Bersvendsen, Mads Holm Peters, Martin Jansa, Stefan Scherzinger, Rune Søe-Knudsen, urmahp, urmarp -1.0.0 (2021-06-18) +0.3.2 (2021-09-15) ------------------ -* Added Cartesian streaming interface `#75 `_ -* Added trajectory forwarding interface `#72 `_ -* Refactored Reverse interface `#70 `_ from fmauch/refactor_reverse_interface -* Added option for robot_ip as runtime argument for rtde_test (`#71 `_) -* Added reverse_ip parameter (`#52 `_) -* Move calibration check out of constructor. `#65 `_ from fmauch/calibration_check_optional +* Removed console_bridge dependency (`#74 `_) + As log handlers for the client library has been created in the drivers, the console bridge dependency is no longer needed. +* Added "On behalf of Universal Robots A/S" notice (`#81 `_) + to all files that have been created by FZI +* Contributors: Felix Exner, Mads Holm Peters + +0.3.1 (2021-06-22) +------------------ +* Always install package.xml file +* Contributors: Felix Exner + +0.3.0 (2021-06-18) +------------------ +* Added Cartesian streaming interface `#75 `_ from UniversalRobots/cartesian_interface +* Add trajectory interface to library `#72 `_ from fmauch/trajectory_interface +* Refactor reverse interface `#70 `_ from fmauch/refactor_reverse_interface +* Contributors: Felix Exner, Mads Holm Peters, Tristan Schnell + +0.2.2 (2021-05-31) +------------------ +* Add reverse_ip parameter to UrDriver (`#52 `_) +* Make calibration check optionally callable +* Use file= fields for license tags in package.xml (`#63 `_) * Install the resources folder instead of the script file directly (`#62 `_) -* Use a non-blocking tcp server for the `ReverseInterface` and `ScriptSender`. `#46 `_ from fmauch/tcp_server -* Added LogHandler `#40 `_ from urmahp/logging_feature +* Contributors: Felix Exner, JS00000 + +0.2.1 (2021-05-06) +------------------ +* Run ci also for ROS2 foxy +* Prepare package.xml and cmakelists for ROS2 +* Add downstream workspace +* Contributors: Felix Exner, Lennart Puck + +0.2.0 (2021-05-03) +------------------ +* Add function to set keepalive counter +* Use a non-blocking tcp server for the `ReverseInterface` and `ScriptSender`. +* Added header and control loop definitions. +* Update documentation on ReverseInterface +* Testing improvements: + + Run coverage on tests + + Added unit test for tcp server + + Remove the special boost include dir from the ci pipeline + + Install boost in test container +* Implement a TCPServer class +* Move script file to resources folder instead of examples/resources +* Add interface function to receive configured RTDE output recipe from driver +* Added loghandler, this enables the possibility for the driver to change the behavior when logging messages with this library. * Fixed links in README (`#35 `_) -* Contributors: Felix Exner, G.A. vd. Hoorn, JS00000, Lennart Puck, Mads Holm Peters, Tristan Schnell +* Documentation improvements: + + Added Compiler minimum version table + + Corrected links to driver's files + + Add a requirements section to the README + + Removed unstable warning + + Added a requirement note about Linux + + Further elaborated license statements in README + + readme: missing whitespace +* Merge changes from boost branch + Changes + * Added changelog from boost branch + * fixed build warnings +* Reduce build warnings + + Removing unused code + + Bumping the minimum required cmake version to 3.0.2 + + Using const qualifiers for size_t variables used to initialize arrays +* Use const qualifier for array size_t variables +* Removed unused and incomplete code from example +* Bump minimum required cmake version to 3.0.2 +* Install package.xml when built with catkin support +* Contributors: Felix Exner, G.A. vd. Hoorn, urmahp 0.1.1 (2020-09-15) ------------------ diff --git a/CMakeLists.txt b/CMakeLists.txt index 756e9e197..6e0f605ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,12 +8,14 @@ if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo) endif() +find_package(Boost REQUIRED) + ## ## Check C++11 support / enable global pedantic and Wall ## -include(DefineCXX17CompilerFlag) -DEFINE_CXX_17_COMPILER_FLAG(CXX17_FLAG) +include(DefineCXX11CompilerFlag) +DEFINE_CXX_11_COMPILER_FLAG(CXX11_FLAG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic") add_library(urcl SHARED @@ -48,10 +50,11 @@ add_library(urcl SHARED ) add_library(ur_client_library::urcl ALIAS urcl) target_compile_options(urcl PRIVATE -Wall -Wextra -Wno-unused-parameter) -target_compile_options(urcl PUBLIC ${CXX17_FLAG}) +target_compile_options(urcl PUBLIC ${CXX11_FLAG}) target_include_directories( urcl PUBLIC $ $ + ${Boost_INCLUDE_DIRS} ) find_package(Threads REQUIRED) @@ -73,6 +76,8 @@ else() endif() +target_link_libraries(urcl INTERFACE ${Boost_Libraries}) + add_subdirectory(examples) include(GNUInstallDirs) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5daa20d12..ae77ac335 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -6,21 +6,21 @@ project(ur_driver_examples) ## ## Check C++11 support / enable global pedantic and Wall ## -include(DefineCXX17CompilerFlag) -DEFINE_CXX_17_COMPILER_FLAG(CXX17_FLAG) +include(DefineCXX11CompilerFlag) +DEFINE_CXX_11_COMPILER_FLAG(CXX11_FLAG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic") add_executable(driver_example full_driver.cpp) -target_compile_options(driver_example PUBLIC ${CXX17_FLAG}) +target_compile_options(driver_example PUBLIC ${CXX11_FLAG}) target_link_libraries(driver_example ur_client_library::urcl) add_executable(primary_pipeline_example primary_pipeline.cpp) -target_compile_options(primary_pipeline_example PUBLIC ${CXX17_FLAG}) +target_compile_options(primary_pipeline_example PUBLIC ${CXX11_FLAG}) target_link_libraries(primary_pipeline_example ur_client_library::urcl) add_executable(rtde_client_example rtde_client.cpp) -target_compile_options(rtde_client_example PUBLIC ${CXX17_FLAG}) +target_compile_options(rtde_client_example PUBLIC ${CXX11_FLAG}) target_link_libraries(rtde_client_example ur_client_library::urcl) diff --git a/include/ur_client_library/comm/tcp_server.h b/include/ur_client_library/comm/tcp_server.h index feb91065c..974d1a8ad 100644 --- a/include/ur_client_library/comm/tcp_server.h +++ b/include/ur_client_library/comm/tcp_server.h @@ -37,6 +37,7 @@ #include #include #include +#include namespace urcl { diff --git a/include/ur_client_library/rtde/data_package.h b/include/ur_client_library/rtde/data_package.h index 3f03855f9..e90e30747 100644 --- a/include/ur_client_library/rtde/data_package.h +++ b/include/ur_client_library/rtde/data_package.h @@ -30,11 +30,11 @@ #define UR_CLIENT_LIBRARY_DATA_PACKAGE_H_INCLUDED #include -#include #include #include "ur_client_library/types.h" #include "ur_client_library/rtde/rtde_package.h" +#include namespace urcl { @@ -60,8 +60,8 @@ enum class RUNTIME_STATE : uint32_t class DataPackage : public RTDEPackage { public: - using _rtde_type_variant = std::variant; + using _rtde_type_variant = boost::variant; DataPackage() = delete; @@ -121,6 +121,7 @@ class DataPackage : public RTDEPackage * * \param name The string identifier for the data field as used in the documentation. * \param val Target variable. Make sure, it's the correct type. + * \exception boost::bad_get if the type under given \p name does not match the template type T. * * \returns True on success, false if the field cannot be found inside the package. */ @@ -129,7 +130,7 @@ class DataPackage : public RTDEPackage { if (data_.find(name) != data_.end()) { - val = std::get(data_[name]); + val = boost::strict_get(data_[name]); } else { @@ -145,6 +146,7 @@ class DataPackage : public RTDEPackage * * \param name The string identifier for the data field as used in the documentation. * \param val Target variable. Make sure, it's the correct type. + * \exception boost::bad_get if the type under given \p name does not match the template type T. * * \returns True on success, false if the field cannot be found inside the package. */ @@ -155,7 +157,7 @@ class DataPackage : public RTDEPackage if (data_.find(name) != data_.end()) { - val = std::bitset(std::get(data_[name])); + val = std::bitset(boost::strict_get(data_[name])); } else { @@ -204,6 +206,41 @@ class DataPackage : public RTDEPackage uint8_t recipe_id_; std::unordered_map data_; std::vector recipe_; + + struct ParseVisitor : public boost::static_visitor<> + { + template + void operator()(T& d, comm::BinParser& bp) const + { + bp.parse(d); + } + }; + struct StringVisitor : public boost::static_visitor + { + template + std::string operator()(T& d) const + { + std::stringstream ss; + ss << d; + return ss.str(); + } + }; + struct SizeVisitor : public boost::static_visitor + { + template + uint16_t operator()(T& d) const + { + return sizeof(d); + } + }; + struct SerializeVisitor : public boost::static_visitor + { + template + size_t operator()(T& d, uint8_t* buffer) const + { + return comm::PackageSerializer::serialize(buffer, d); + } + }; uint16_t protocol_version_; }; diff --git a/package.xml b/package.xml index 2f75e478a..36cdc8d11 100644 --- a/package.xml +++ b/package.xml @@ -2,7 +2,7 @@ ur_client_library - 1.1.0 + 0.4.0 Standalone C++ library for accessing Universal Robots interfaces. This has been forked off the ur_robot_driver. Thomas Timm Andersen Simon Rasmussen @@ -21,6 +21,7 @@ cmake + boost catkin ament_cmake diff --git a/resources/external_control.urscript b/resources/external_control.urscript index ab865d59b..8d065acdc 100644 --- a/resources/external_control.urscript +++ b/resources/external_control.urscript @@ -1,7 +1,7 @@ -{{BEGIN_REPLACE}} - # HEADER_BEGIN +{{BEGIN_REPLACE}} + steptime = get_steptime() textmsg("ExternalControl: steptime=", steptime) diff --git a/src/rtde/data_package.cpp b/src/rtde/data_package.cpp index bb3ba6799..e69a9a00c 100644 --- a/src/rtde/data_package.cpp +++ b/src/rtde/data_package.cpp @@ -579,7 +579,8 @@ bool rtde_interface::DataPackage::parseWith(comm::BinParser& bp) if (g_type_list.find(item) != g_type_list.end()) { _rtde_type_variant entry = g_type_list[item]; - std::visit([&bp](auto&& arg) { bp.parse(arg); }, entry); + auto bound_visitor = std::bind(ParseVisitor(), std::placeholders::_1, bp); + boost::apply_visitor(bound_visitor, entry); data_[item] = entry; } else @@ -596,8 +597,7 @@ std::string rtde_interface::DataPackage::toString() const for (auto& item : data_) { ss << item.first << ": "; - std::visit([&ss](auto&& arg) { ss << arg; }, item.second); - ss << std::endl; + ss << boost::apply_visitor(StringVisitor{}, item.second) << std::endl; } return ss.str(); } @@ -608,16 +608,15 @@ size_t rtde_interface::DataPackage::serializePackage(uint8_t* buffer) for (auto& item : data_) { - payload_size += std::visit([](auto&& arg) -> uint16_t { return sizeof(arg); }, item.second); + payload_size += boost::apply_visitor(SizeVisitor{}, item.second); } size_t size = 0; size += PackageHeader::serializeHeader(buffer, PackageType::RTDE_DATA_PACKAGE, payload_size); size += comm::PackageSerializer::serialize(buffer + size, recipe_id_); for (auto& item : recipe_) { - size += std::visit( - [&buffer, &size](auto&& arg) -> size_t { return comm::PackageSerializer::serialize(buffer + size, arg); }, - data_[item]); + auto bound_visitor = std::bind(SerializeVisitor(), std::placeholders::_1, buffer + size); + size += boost::apply_visitor(bound_visitor, data_[item]); } return size; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b93e49ba0..20b1044f9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -22,8 +22,8 @@ if (NOT TARGET ur_client_library::urcl) endif() # Check C++11 support -include(DefineCXX17CompilerFlag) -DEFINE_CXX_17_COMPILER_FLAG(CXX17_FLAG) +include(DefineCXX11CompilerFlag) +DEFINE_CXX_11_COMPILER_FLAG(CXX11_FLAG) # Build Tests @@ -31,7 +31,7 @@ if (INTEGRATION_TESTS) # Integration tests require a robot reachable at 192.168.56.101. Therefore, they have to be # activated separately. add_executable(rtde_tests test_rtde_client.cpp) - target_compile_options(rtde_tests PRIVATE ${CXX17_FLAG}) + target_compile_options(rtde_tests PRIVATE ${CXX11_FLAG}) target_include_directories(rtde_tests PRIVATE ${GTEST_INCLUDE_DIRS}) target_link_libraries(rtde_tests PRIVATE ur_client_library::urcl ${GTEST_LIBRARIES}) gtest_add_tests(TARGET rtde_tests @@ -42,21 +42,14 @@ else() endif() add_executable(primary_parser_tests test_primary_parser.cpp) -target_compile_options(primary_parser_tests PRIVATE ${CXX17_FLAG}) +target_compile_options(primary_parser_tests PRIVATE ${CXX11_FLAG}) target_include_directories(primary_parser_tests PRIVATE ${GTEST_INCLUDE_DIRS}) target_link_libraries(primary_parser_tests PRIVATE ur_client_library::urcl ${GTEST_LIBRARIES}) gtest_add_tests(TARGET primary_parser_tests ) -add_executable(rtde_data_package test_rtde_data_package.cpp) -target_compile_options(rtde_data_package PRIVATE ${CXX17_FLAG}) -target_include_directories(rtde_data_package PRIVATE ${GTEST_INCLUDE_DIRS}) -target_link_libraries(rtde_data_package PRIVATE ur_client_library::urcl ${GTEST_LIBRARIES}) -gtest_add_tests(TARGET rtde_data_package -) - add_executable(rtde_parser_tests test_rtde_parser.cpp) -target_compile_options(rtde_parser_tests PRIVATE ${CXX17_FLAG}) +target_compile_options(rtde_parser_tests PRIVATE ${CXX11_FLAG}) target_include_directories(rtde_parser_tests PRIVATE ${GTEST_INCLUDE_DIRS}) target_link_libraries(rtde_parser_tests PRIVATE ur_client_library::urcl ${GTEST_LIBRARIES}) gtest_add_tests(TARGET rtde_parser_tests diff --git a/tests/test_rtde_data_package.cpp b/tests/test_rtde_data_package.cpp deleted file mode 100644 index 4f805440f..000000000 --- a/tests/test_rtde_data_package.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- - -// -- BEGIN LICENSE BLOCK ---------------------------------------------- -// Copyright 2020 FZI Forschungszentrum Informatik -// Created on behalf of Universal Robots A/S -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -- END LICENSE BLOCK ------------------------------------------------ - -//---------------------------------------------------------------------- -/*!\file - * - * \author Felix Exner mauch@fzi.de - * \date 2020-09-11 - * - */ -//---------------------------------------------------------------------- - -#include - -#include - -using namespace urcl; - -TEST(rtde_data_package, serialize_pkg) -{ - std::vector recipe{ "speed_slider_mask" }; - rtde_interface::DataPackage package(recipe); - package.initEmpty(); - - uint32_t value = 1; - package.setData("speed_slider_mask", value); - - uint8_t buffer[4096]; - package.setRecipeID(1); - size_t size = package.serializePackage(buffer); - - EXPECT_EQ(size, 8); - - uint8_t expected[] = { 0x0, 0x08, 0x55, 0x01, 0x00, 0x00, 0x00, 0x01 }; - std::cout << "Serialized buffer: " << std::endl; - for (size_t i = 0; i < size; ++i) - { - EXPECT_EQ(buffer[i], expected[i]); - } - std::cout << std::endl; -} - -int main(int argc, char* argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -}