From 89dbbb78bc9ec7e357accab733d09a38ac6256e3 Mon Sep 17 00:00:00 2001 From: Marq Rasmussen Date: Wed, 28 Aug 2024 10:54:54 -0400 Subject: [PATCH 1/2] Export plugins to share directory & register CrossDoor plugin (#804) --- sample_nodes/CMakeLists.txt | 12 ++++++++++++ sample_nodes/crossdoor_nodes.cpp | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/sample_nodes/CMakeLists.txt b/sample_nodes/CMakeLists.txt index e8aaafffe..217fec77d 100644 --- a/sample_nodes/CMakeLists.txt +++ b/sample_nodes/CMakeLists.txt @@ -33,3 +33,15 @@ target_link_libraries(movebase_node_dyn PRIVATE ${BTCPP_LIBRARY}) target_compile_definitions(movebase_node_dyn PRIVATE BT_PLUGIN_EXPORT ) set_target_properties(movebase_node_dyn PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${BTCPP_BIN_DESTINATION} ) + +###################################################### +# INSTALL plugins for other packages to load + +INSTALL(TARGETS + crossdoor_nodes_dyn + dummy_nodes_dyn + movebase_node_dyn + LIBRARY DESTINATION share/${PROJECT_NAME}/bt_plugins + ARCHIVE DESTINATION share/${PROJECT_NAME}/bt_plugins + RUNTIME DESTINATION share/${PROJECT_NAME}/bt_plugins +) diff --git a/sample_nodes/crossdoor_nodes.cpp b/sample_nodes/crossdoor_nodes.cpp index c9b0f0b82..29463c451 100644 --- a/sample_nodes/crossdoor_nodes.cpp +++ b/sample_nodes/crossdoor_nodes.cpp @@ -74,3 +74,11 @@ void CrossDoor::reset() _door_locked = true; _pick_attempts = 0; } + +// This function must be implemented in the .cpp file to create +// a plugin that can be loaded at run-time +BT_REGISTER_NODES(factory) +{ + static CrossDoor cross_door; + cross_door.registerNodes(factory); +} From 4f664475980d3a25eaba35fc6e3071a995dc3888 Mon Sep 17 00:00:00 2001 From: kinly Date: Wed, 28 Aug 2024 22:55:54 +0800 Subject: [PATCH 2/2] fixed: support utf-8 path xml-file (#845) * fixed: 1. added compile version check to support Chinese path xml-file parsing 2. cmake add msvc /utf-8 options * change cmake /utf-8 option add mode --- CMakeLists.txt | 2 +- src/xml_parsing.cpp | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b6d1ebaa..16993735a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,6 @@ else() include(cmake/conan_build.cmake) endif() - ############################################################# # LIBRARY @@ -187,6 +186,7 @@ target_compile_definitions(${BTCPP_LIBRARY} PUBLIC BTCPP_LIBRARY_VERSION="${CMAK target_compile_features(${BTCPP_LIBRARY} PUBLIC cxx_std_17) if(MSVC) + target_compile_options(${BTCPP_LIBRARY} PRIVATE "/source-charset:utf-8") else() target_compile_options(${BTCPP_LIBRARY} PRIVATE -Wall -Wextra) endif() diff --git a/src/xml_parsing.cpp b/src/xml_parsing.cpp index b74b1ddb4..2e950e4d9 100644 --- a/src/xml_parsing.cpp +++ b/src/xml_parsing.cpp @@ -19,6 +19,12 @@ #include #include +#if defined(_MSVC_LANG) && !defined(__clang__) +#define __bt_cplusplus (_MSC_VER == 1900 ? 201103L : _MSVC_LANG) +#else +#define __bt_cplusplus __cplusplus +#endif + #if defined(__linux) || defined(__linux__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wattributes" @@ -254,7 +260,12 @@ void XMLParser::PImpl::loadDocImpl(XMLDocument* doc, bool add_includes) break; } - std::filesystem::path file_path(incl_node->Attribute("path")); +#if __bt_cplusplus >= 202002L + auto file_path(std::filesystem::path(incl_node->Attribute("path"))); +#else + auto file_path(std::filesystem::u8path(incl_node->Attribute("path"))); +#endif + const char* ros_pkg_relative_path = incl_node->Attribute("ros_pkg"); if(ros_pkg_relative_path)