diff --git a/.github/workflows/cmake_ubuntu.yml b/.github/workflows/cmake_ubuntu.yml index aaf5f628d..41ed9a196 100644 --- a/.github/workflows/cmake_ubuntu.yml +++ b/.github/workflows/cmake_ubuntu.yml @@ -1,6 +1,11 @@ name: cmake Ubuntu -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) @@ -15,7 +20,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04] + os: [ubuntu-22.04] steps: - uses: actions/checkout@v2 @@ -23,14 +28,9 @@ jobs: - name: Install Conan id: conan uses: turtlebrowser/get-conan@main - with: - version: 1.59.0 - name: Create default profile - run: conan profile new default --detect - - - name: Update profile - run: conan profile update settings.compiler.libcxx=libstdc++11 default + run: conan profile detect - name: Create Build Environment # Some projects don't allow in-source building, so create a separate build directory @@ -44,7 +44,7 @@ jobs: - name: Configure CMake shell: bash working-directory: ${{github.workspace}}/build - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake + run: cmake ${{github.workspace}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake - name: Build shell: bash @@ -52,8 +52,8 @@ jobs: run: cmake --build . --config ${{env.BUILD_TYPE}} - name: run test (Linux) - working-directory: ${{github.workspace}}/build - run: ./tests/behaviortree_cpp_test + working-directory: ${{github.workspace}}/build/tests + run: ctest - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 diff --git a/.github/workflows/cmake_windows.yml b/.github/workflows/cmake_windows.yml index 192fdcac6..34f4f97ce 100644 --- a/.github/workflows/cmake_windows.yml +++ b/.github/workflows/cmake_windows.yml @@ -1,6 +1,11 @@ name: cmake Windows -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) diff --git a/.github/workflows/pixi.yaml b/.github/workflows/pixi.yaml index 81ee4b675..ddd1cbfb8 100644 --- a/.github/workflows/pixi.yaml +++ b/.github/workflows/pixi.yaml @@ -1,6 +1,11 @@ name: Pixi (conda) -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] jobs: pixi_conda_build: diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index 6095e0861..ee7fa9229 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -1,9 +1,11 @@ name: pre-commit on: - pull_request: push: - branches: [master] + branches: + - master + pull_request: + types: [opened, synchronize, reopened] jobs: pre-commit: diff --git a/.github/workflows/ros1.yaml b/.github/workflows/ros1.yaml deleted file mode 100644 index 9d244f60f..000000000 --- a/.github/workflows/ros1.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: ros1 - -on: [push, pull_request] - -jobs: - industrial_ci: - strategy: - matrix: - env: - - {ROS_DISTRO: noetic, ROS_REPO: main} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: 'ros-industrial/industrial_ci@master' - env: ${{matrix.env}} - with: - package-name: behaviortree_cpp diff --git a/.github/workflows/ros2-rolling.yaml b/.github/workflows/ros2-rolling.yaml index cb5004506..446c49879 100644 --- a/.github/workflows/ros2-rolling.yaml +++ b/.github/workflows/ros2-rolling.yaml @@ -1,6 +1,11 @@ name: ros2-rolling -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] jobs: industrial_ci: diff --git a/.github/workflows/ros2.yaml b/.github/workflows/ros2.yaml index afdccc466..51eabc44b 100644 --- a/.github/workflows/ros2.yaml +++ b/.github/workflows/ros2.yaml @@ -1,6 +1,11 @@ name: ros2 -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] jobs: industrial_ci: diff --git a/.github/workflows/sonarcube.yml b/.github/workflows/sonarcube.yml index 29d83fb4a..926306125 100644 --- a/.github/workflows/sonarcube.yml +++ b/.github/workflows/sonarcube.yml @@ -1,10 +1,12 @@ name: Sonarcube Scan + on: push: branches: - master pull_request: types: [opened, synchronize, reopened] + jobs: build: name: Build diff --git a/CMakeLists.txt b/CMakeLists.txt index 2712f17a2..f0809a4e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) option(BTCPP_SHARED_LIBS "Build shared libraries" ON) option(BTCPP_BUILD_TOOLS "Build commandline tools" ON) option(BTCPP_EXAMPLES "Build tutorials and examples" ON) -option(BTCPP_UNIT_TESTS "Build the unit tests" ON) +option(BUILD_TESTING "Build the unit tests" ON) option(BTCPP_GROOT_INTERFACE "Add Groot2 connection. Requires ZeroMQ" ON) option(BTCPP_SQLITE_LOGGING "Add SQLite logging." ON) @@ -82,15 +82,6 @@ if ( ament_cmake_FOUND ) message(STATUS "BehaviorTree is being built using AMENT.") message(STATUS "------------------------------------------") include(cmake/ament_build.cmake) - -elseif( CATKIN_DEVEL_PREFIX OR CATKIN_BUILD_BINARY_PACKAGE) - - add_definitions( -DUSING_ROS ) - message(STATUS "------------------------------------------") - message(STATUS "BehaviorTree is being built using CATKIN.") - message(STATUS "------------------------------------------") - include(cmake/catkin_build.cmake) - set(catkin_FOUND TRUE) else() message(STATUS "------------------------------------------") message(STATUS "BehaviorTree is being built with conan.") @@ -229,15 +220,16 @@ endif() ############################################################# message( STATUS "BTCPP_LIB_DESTINATION: ${BTCPP_LIB_DESTINATION} " ) message( STATUS "BTCPP_INCLUDE_DESTINATION: ${BTCPP_INCLUDE_DESTINATION} " ) -message( STATUS "BTCPP_UNIT_TESTS: ${BTCPP_UNIT_TESTS} " ) -if (BTCPP_UNIT_TESTS OR BTCPP_EXAMPLES) +if (BUILD_TESTING OR BTCPP_EXAMPLES) add_subdirectory(sample_nodes) endif() ###################################################### -if (BTCPP_UNIT_TESTS) +include(CTest) +message( STATUS "BUILD_TESTING: ${BUILD_TESTING} " ) +if (BUILD_TESTING) add_subdirectory(tests) endif() diff --git a/README.md b/README.md index cd8e3371a..17d79e7f3 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,6 @@ If you are looking for a more fancy graphical user interface (and I know you do) Three build systems are supported: -- **catkin**, if you use ROS - **colcon (ament)**, if you use ROS2 - **conan** otherwise (Linux/Windows). - **straight cmake** if you want to be personally responsible for dependencies :) diff --git a/cmake/catkin_build.cmake b/cmake/catkin_build.cmake deleted file mode 100644 index 487d84773..000000000 --- a/cmake/catkin_build.cmake +++ /dev/null @@ -1,40 +0,0 @@ -#---- Add the subdirectory cmake ---- -set(CMAKE_CONFIG_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CONFIG_PATH}") - -if(BTCPP_GROOT_INTERFACE) - find_package(ZeroMQ REQUIRED) -endif() - -if(BTCPP_SQLITE_LOGGING) - find_package(SQLite3 REQUIRED) -endif() - -find_package(catkin REQUIRED COMPONENTS roslib) - -catkin_package( - INCLUDE_DIRS include - LIBRARIES ${BTCPP_LIBRARY} - CATKIN_DEPENDS roslib ) - -set(BTCPP_EXTRA_INCLUDE_DIRS ${catkin_INCLUDE_DIRS} ) - -set( BTCPP_EXTRA_LIBRARIES - ${catkin_LIBRARIES} - ${ZeroMQ_LIBRARIES} - ${SQLite3_LIBRARIES}) - -set( BTCPP_LIB_DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} ) -set( BTCPP_INCLUDE_DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION} ) -set( BTCPP_BIN_DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} ) - -mark_as_advanced( - BTCPP_EXTRA_LIBRARIES - BTCPP_EXTRA_INCLUDE_DIRS - BTCPP_LIB_DESTINATION - BTCPP_INCLUDE_DESTINATION - BTCPP_BIN_DESTINATION ) - -macro(export_btcpp_package) - # do nothing -endmacro() diff --git a/include/behaviortree_cpp/bt_factory.h b/include/behaviortree_cpp/bt_factory.h index c20385b3b..880099125 100644 --- a/include/behaviortree_cpp/bt_factory.h +++ b/include/behaviortree_cpp/bt_factory.h @@ -279,9 +279,8 @@ class BehaviorTreeFactory /** * @brief registerFromROSPlugins finds all shared libraries that export ROS plugins for behaviortree_cpp, and calls registerFromPlugin for each library. * @throws If not compiled with ROS support or if the library cannot load for any reason - * */ - void registerFromROSPlugins(); + [[deprecated("Removed support for ROS1")]] void registerFromROSPlugins(); /** * @brief registerBehaviorTreeFromFile. diff --git a/package.xml b/package.xml index c4cb75729..512d3ba89 100644 --- a/package.xml +++ b/package.xml @@ -14,8 +14,6 @@ ros_environment - catkin - roslib ament_cmake rclcpp @@ -27,7 +25,6 @@ ament_cmake_gtest - catkin ament_cmake diff --git a/src/bt_factory.cpp b/src/bt_factory.cpp index f66c3661f..af70a94c5 100644 --- a/src/bt_factory.cpp +++ b/src/bt_factory.cpp @@ -17,10 +17,6 @@ #include "behaviortree_cpp/xml_parsing.h" #include "wildcards/wildcards.hpp" -#ifdef USING_ROS -#include -#endif - namespace BT { @@ -196,66 +192,12 @@ void BehaviorTreeFactory::registerFromPlugin(const std::string& file_path) } } -#ifdef USING_ROS - -#ifdef _WIN32 -const char os_pathsep(';'); // NOLINT -#else -const char os_pathsep(':'); // NOLINT -#endif - -// This function is a copy from the one in class_loader_imp.hpp in ROS pluginlib -// package, licensed under BSD. -// https://github.com/ros/pluginlib -std::vector getCatkinLibraryPaths() -{ - std::vector lib_paths; - const char* env = std::getenv("CMAKE_PREFIX_PATH"); - if(env) - { - const std::string env_catkin_prefix_paths(env); - std::vector catkin_prefix_paths = - splitString(env_catkin_prefix_paths, os_pathsep); - for(BT::StringView catkin_prefix_path : catkin_prefix_paths) - { - std::filesystem::path path(static_cast(catkin_prefix_path)); - std::filesystem::path lib("lib"); - lib_paths.push_back((path / lib).string()); - } - } - return lib_paths; -} - -void BehaviorTreeFactory::registerFromROSPlugins() -{ - std::vector plugins; - ros::package::getPlugins("behaviortree_cpp", "bt_lib_plugin", plugins, true); - std::vector catkin_lib_paths = getCatkinLibraryPaths(); - - for(const auto& plugin : plugins) - { - auto filename = std::filesystem::path(plugin + BT::SharedLibrary::suffix()); - for(const auto& lib_path : catkin_lib_paths) - { - const auto full_path = std::filesystem::path(lib_path) / filename; - if(std::filesystem::exists(full_path)) - { - std::cout << "Registering ROS plugins from " << full_path.string() << std::endl; - registerFromPlugin(full_path.string()); - break; - } - } - } -} -#else - void BehaviorTreeFactory::registerFromROSPlugins() { throw RuntimeError("Using attribute [ros_pkg] in , but this library was " "compiled without ROS support. Recompile the BehaviorTree.CPP " "using catkin"); } -#endif void BehaviorTreeFactory::registerBehaviorTreeFromFile( const std::filesystem::path& filename) diff --git a/src/xml_parsing.cpp b/src/xml_parsing.cpp index 885244ed9..8b9ce95a1 100644 --- a/src/xml_parsing.cpp +++ b/src/xml_parsing.cpp @@ -36,10 +36,6 @@ #include "tinyxml2/tinyxml2.h" #include -#ifdef USING_ROS -#include -#endif - #ifdef USING_ROS2 #include #endif @@ -283,9 +279,7 @@ void XMLParser::PImpl::loadDocImpl(XMLDocument* doc, bool add_includes) else { std::string ros_pkg_path; -#ifdef USING_ROS - ros_pkg_path = ros::package::getPath(ros_pkg_relative_path); -#elif defined USING_ROS2 +#if defined USING_ROS2 ros_pkg_path = ament_index_cpp::get_package_share_directory(ros_pkg_relative_path); #else diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 700aa64af..f83db1e7d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -33,41 +33,27 @@ set(BT_TESTS test_helper.hpp ) -set(TEST_DEPENDECIES - ${BTCPP_LIBRARY} - foonathan::lexy - bt_sample_nodes) - if(ament_cmake_FOUND) find_package(ament_cmake_gtest REQUIRED) - ament_add_gtest(${BTCPP_LIBRARY}_test ${BT_TESTS}) - target_link_libraries(${BTCPP_LIBRARY}_test - ${TEST_DEPENDECIES} - ${ament_LIBRARIES}) - -elseif(catkin_FOUND AND CATKIN_ENABLE_TESTING) - - catkin_add_gtest(${BTCPP_LIBRARY}_test ${BT_TESTS}) - target_link_libraries(${BTCPP_LIBRARY}_test - ${TEST_DEPENDECIES} - Threads::Threads - ${catkin_LIBRARIES}) + ament_add_gtest(behaviortree_cpp_test ${BT_TESTS}) + target_link_libraries(behaviortree_cpp_test ${ament_LIBRARIES}) else() find_package(GTest REQUIRED) - enable_testing() - add_executable(${BTCPP_LIBRARY}_test ${BT_TESTS}) + enable_testing() + add_executable(behaviortree_cpp_test ${BT_TESTS}) + add_test(NAME btcpp_test COMMAND behaviortree_cpp_test) - target_link_libraries(${PROJECT_NAME}_test - ${TEST_DEPENDECIES} - Threads::Threads - GTest::gtest) + target_link_libraries(behaviortree_cpp_test + GTest::gtest + GTest::gtest_main) endif() -target_include_directories(${BTCPP_LIBRARY}_test PRIVATE include ${PROJECT_SOURCE_DIR}/3rdparty) -target_compile_definitions(${BTCPP_LIBRARY}_test PRIVATE BT_TEST_FOLDER="${CMAKE_CURRENT_SOURCE_DIR}") +target_link_libraries(behaviortree_cpp_test ${BTCPP_LIBRARY} bt_sample_nodes foonathan::lexy) +target_include_directories(behaviortree_cpp_test PRIVATE include ${PROJECT_SOURCE_DIR}/3rdparty) +target_compile_definitions(behaviortree_cpp_test PRIVATE BT_TEST_FOLDER="${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/tests/gtest_ports.cpp b/tests/gtest_ports.cpp index 69c351594..c694fffa9 100644 --- a/tests/gtest_ports.cpp +++ b/tests/gtest_ports.cpp @@ -150,7 +150,7 @@ TEST(PortsTest, NonPorts) ASSERT_EQ(root->type(), NodeType::ACTION); EXPECT_EQ(root->config().other_attributes.size(), 1); - ASSERT_TRUE(root->config().other_attributes.contains("_not_da_port")); + ASSERT_EQ(root->config().other_attributes.count("_not_da_port"), 1); EXPECT_EQ(root->config().other_attributes.at("_not_da_port"), "whateva"); }