From 01e8b1df9acc9341fbfceae0c9a7cf9859bc5f75 Mon Sep 17 00:00:00 2001 From: Filippo Brizzi Date: Fri, 2 Feb 2024 13:48:24 +0000 Subject: [PATCH] Add examples module (#18) # Description ## Type of change Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) ## Checklist before requesting a review - [ ] I have performed a self-review of my code. - [ ] If it is a core feature, I have added thorough tests. - [ ] If this is a new component I have added examples. - [ ] I updated the README and related documentation. --- .github/workflows/build.yml | 6 +- CMakePresets.json | 8 +-- cmake/05_modules.cmake | 4 +- .../cli/include/eolo/cli/program_options.h | 2 +- modules/examples/CMakeLists.txt | 59 +++++++++++++++++++ modules/{types => examples}/README.md | 4 +- .../examples/CMakeLists.txt | 13 +++- .../examples/zenoh_program_options.h | 0 .../{ipc => examples}/examples/zenoh_pub.cpp | 6 +- .../{ipc => examples}/examples/zenoh_sub.cpp | 8 +-- .../include/eolo/examples}/types/pose.h | 12 ++-- .../eolo/examples}/types_protobuf/geometry.h | 6 +- .../eolo/examples}/types_protobuf/pose.h | 8 +-- .../proto/CMakeLists.txt | 6 +- .../proto/buf.yaml | 0 .../eolo/examples}/types/proto/geometry.proto | 2 +- .../eolo/examples}/types/proto/pose.proto | 4 +- .../src => examples/src/types}/pose.cpp | 2 +- .../src/types_protobuf}/geometry.cpp | 2 +- .../src/types_protobuf}/pose.cpp | 8 +-- .../tests/CMakeLists.txt | 4 +- .../tests/types_protobuf_tests.cpp} | 12 ++-- modules/ipc/CMakeLists.txt | 5 +- modules/ipc/{examples => apps}/CMakeLists.txt | 20 +------ .../{examples => apps}/zenoh_node_list.cpp | 0 modules/ipc/apps/zenoh_program_options.h | 58 ++++++++++++++++++ .../ipc/{examples => apps}/zenoh_query.cpp | 0 .../{examples => apps}/zenoh_topic_list.cpp | 0 modules/ipc/tests/tests.cpp | 2 +- modules/types/CMakeLists.txt | 32 ---------- modules/types/examples/CMakeLists.txt | 10 ---- modules/types/examples/example.cpp | 14 ----- modules/types/tests/CMakeLists.txt | 10 ---- modules/types/tests/tests.cpp | 15 ----- modules/types_protobuf/CMakeLists.txt | 42 ------------- modules/types_protobuf/README.md | 9 --- modules/types_protobuf/examples/example.cpp | 14 ----- modules/utils/src/version_impl.h | 4 +- 38 files changed, 187 insertions(+), 224 deletions(-) create mode 100644 modules/examples/CMakeLists.txt rename modules/{types => examples}/README.md (60%) rename modules/{types_protobuf => examples}/examples/CMakeLists.txt (51%) rename modules/{ipc => examples}/examples/zenoh_program_options.h (100%) rename modules/{ipc => examples}/examples/zenoh_pub.cpp (94%) rename modules/{ipc => examples}/examples/zenoh_sub.cpp (91%) rename modules/{types/include/eolo => examples/include/eolo/examples}/types/pose.h (72%) rename modules/{types_protobuf/include/eolo => examples/include/eolo/examples}/types_protobuf/geometry.h (96%) rename modules/{types_protobuf/include/eolo => examples/include/eolo/examples}/types_protobuf/pose.h (78%) rename modules/{types_protobuf => examples}/proto/CMakeLists.txt (61%) rename modules/{types_protobuf => examples}/proto/buf.yaml (100%) rename modules/{types_protobuf/proto/eolo => examples/proto/eolo/examples}/types/proto/geometry.proto (93%) rename modules/{types_protobuf/proto/eolo => examples/proto/eolo/examples}/types/proto/pose.proto (53%) rename modules/{types/src => examples/src/types}/pose.cpp (86%) rename modules/{types_protobuf/src => examples/src/types_protobuf}/geometry.cpp (82%) rename modules/{types_protobuf/src => examples/src/types_protobuf}/pose.cpp (84%) rename modules/{types_protobuf => examples}/tests/CMakeLists.txt (83%) rename modules/{types_protobuf/tests/tests.cpp => examples/tests/types_protobuf_tests.cpp} (93%) rename modules/ipc/{examples => apps}/CMakeLists.txt (62%) rename modules/ipc/{examples => apps}/zenoh_node_list.cpp (100%) create mode 100644 modules/ipc/apps/zenoh_program_options.h rename modules/ipc/{examples => apps}/zenoh_query.cpp (100%) rename modules/ipc/{examples => apps}/zenoh_topic_list.cpp (100%) delete mode 100644 modules/types/CMakeLists.txt delete mode 100644 modules/types/examples/CMakeLists.txt delete mode 100644 modules/types/examples/example.cpp delete mode 100644 modules/types/tests/CMakeLists.txt delete mode 100644 modules/types/tests/tests.cpp delete mode 100644 modules/types_protobuf/CMakeLists.txt delete mode 100644 modules/types_protobuf/README.md delete mode 100644 modules/types_protobuf/examples/example.cpp diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6c3a779..8caeecdb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ on: env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - PRESET: preferred + PRESET: CI jobs: docker_build_and_publish: @@ -77,7 +77,7 @@ jobs: run: cmake --build ${{github.workspace}}/build -- all examples - name: Test - working-directory: ${{github.workspace}}/build + # working-directory: ${{github.workspace}}/build # Execute tests defined by the CMake configuration. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ninja checks + run: cd ${{github.workspace}}/build && ninja check diff --git a/CMakePresets.json b/CMakePresets.json index 115d9d09..28a77d3c 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -9,7 +9,7 @@ "installDir": "/install", "toolchainFile": "${sourceDir}/toolchains/toolchain_clang.cmake", "cacheVariables": { - "BUILD_MODULES": "all" + "BUILD_MODULES": "all;examples" } }, { @@ -20,7 +20,7 @@ "installDir": "/install", "toolchainFile": "${sourceDir}/toolchains/toolchain_clang.cmake", "cacheVariables": { - "BUILD_MODULES": "all", + "BUILD_MODULES": "all;examples", "ENABLE_LINTER": "OFF", "CMAKE_BUILD_TYPE": "Release" } @@ -33,7 +33,7 @@ "installDir": "/install", "toolchainFile": "${sourceDir}/toolchains/toolchain_clang.cmake", "cacheVariables": { - "BUILD_MODULES": "all", + "BUILD_MODULES": "all;examples", "ENABLE_LINTER": "OFF", "CMAKE_BUILD_TYPE": "Release" } @@ -46,7 +46,7 @@ "installDir": "/install", "toolchainFile": "${sourceDir}/toolchains/toolchain_clang.cmake", "cacheVariables": { - "BUILD_MODULES": "all", + "BUILD_MODULES": "all;examples", "ENABLE_LINTER": "ON", "CMAKE_BUILD_TYPE": "Release", "CMAKE_PREFIX_PATH": "/install" diff --git a/cmake/05_modules.cmake b/cmake/05_modules.cmake index dfb7d657..4be7a7fb 100644 --- a/cmake/05_modules.cmake +++ b/cmake/05_modules.cmake @@ -144,7 +144,7 @@ endmacro() # DEPENDS_ON_EXTERNAL_PROJECTS (list): List of tags to external projects that this module depends on # macro(declare_module) - set(flags ALWAYS_BUILD) + set(flags ALWAYS_BUILD EXCLUDE_FROM_ALL) set(single_opts NAME) set(multi_opts DEPENDS_ON_MODULES DEPENDS_ON_EXTERNAL_PROJECTS) @@ -161,7 +161,7 @@ macro(declare_module) # Either have it always build, or allow user to choose at configuration-time if(("${MODULE_ARG_NAME}" IN_LIST BUILD_MODULES) - OR ("all" IN_LIST BUILD_MODULES) + OR (("all" IN_LIST BUILD_MODULES) AND NOT MODULE_ARG_EXCLUDE_FROM_ALL) OR MODULE_ARG_ALWAYS_BUILD) # Explicitly disable modules if((NOT MODULE_ARG_ALWAYS_BUILD) diff --git a/modules/cli/include/eolo/cli/program_options.h b/modules/cli/include/eolo/cli/program_options.h index 294fabfc..f5970d3b 100644 --- a/modules/cli/include/eolo/cli/program_options.h +++ b/modules/cli/include/eolo/cli/program_options.h @@ -23,7 +23,7 @@ class ProgramOptions { /// @brief Holds program options and their details struct Option { std::string key; - char short_key; + char short_key{}; std::string description; std::string value_type; std::string value; diff --git a/modules/examples/CMakeLists.txt b/modules/examples/CMakeLists.txt new file mode 100644 index 00000000..bfdc6ac3 --- /dev/null +++ b/modules/examples/CMakeLists.txt @@ -0,0 +1,59 @@ +declare_module( + NAME examples + DEPENDS_ON_MODULES base ipc serdes + DEPENDS_ON_EXTERNAL_PROJECTS Eigen3 fmt Protobuf + EXCLUDE_FROM_ALL +) + +find_package(Eigen3 REQUIRED) +find_package(fmt REQUIRED) + +add_subdirectory(proto) + +# library sources +set(TYPES_SOURCES + src/types/pose.cpp + README.md + include/eolo/examples/types/pose.h) + +# library target +define_module_library( + NAME examples_types + PUBLIC_LINK_LIBS + Eigen3::Eigen + fmt::fmt + PRIVATE_LINK_LIBS "" + SOURCES ${TYPES_SOURCES} + PUBLIC_INCLUDE_PATHS + $ + $ + PRIVATE_INCLUDE_PATHS "" + SYSTEM_PRIVATE_INCLUDE_PATHS "") + +# library sources +set(TYPES_PROTOBUF_SOURCES + src/types_protobuf/geometry.cpp + src/types_protobuf/pose.cpp + include/eolo/examples/types_protobuf/geometry.h + include/eolo/examples/types_protobuf/pose.h) + +# library target +define_module_library( + NAME examples_types_protobuf + PUBLIC_LINK_LIBS + eolo::base + eolo::serdes + eolo::examples_types + eolo::examples_types_proto + Eigen3::Eigen + PRIVATE_LINK_LIBS "" + SOURCES ${TYPES_PROTOBUF_SOURCES} + PUBLIC_INCLUDE_PATHS + $ + $ + PRIVATE_INCLUDE_PATHS "" + SYSTEM_PRIVATE_INCLUDE_PATHS "") + +# Subprojects +add_subdirectory(tests) +add_subdirectory(examples) diff --git a/modules/types/README.md b/modules/examples/README.md similarity index 60% rename from modules/types/README.md rename to modules/examples/README.md index 409c8b37..a4920d7f 100644 --- a/modules/types/README.md +++ b/modules/examples/README.md @@ -1,8 +1,8 @@ -# README: types +# README: examples ## Brief -types provides .. +examples provides .. ## Detailed description diff --git a/modules/types_protobuf/examples/CMakeLists.txt b/modules/examples/examples/CMakeLists.txt similarity index 51% rename from modules/types_protobuf/examples/CMakeLists.txt rename to modules/examples/examples/CMakeLists.txt index 586f351e..ce0f80d7 100644 --- a/modules/types_protobuf/examples/CMakeLists.txt +++ b/modules/examples/examples/CMakeLists.txt @@ -3,8 +3,15 @@ #================================================================================================= define_module_example( - NAME example - SOURCES example.cpp + NAME zenoh_pub + SOURCES zenoh_pub.cpp zenoh_program_options.h PUBLIC_INCLUDE_PATHS $ - PUBLIC_LINK_LIBS "") + PUBLIC_LINK_LIBS eolo::ipc) + +define_module_example( + NAME zenoh_sub + SOURCES zenoh_sub.cpp zenoh_program_options.h + PUBLIC_INCLUDE_PATHS + $ + PUBLIC_LINK_LIBS eolo::ipc) diff --git a/modules/ipc/examples/zenoh_program_options.h b/modules/examples/examples/zenoh_program_options.h similarity index 100% rename from modules/ipc/examples/zenoh_program_options.h rename to modules/examples/examples/zenoh_program_options.h diff --git a/modules/ipc/examples/zenoh_pub.cpp b/modules/examples/examples/zenoh_pub.cpp similarity index 94% rename from modules/ipc/examples/zenoh_pub.cpp rename to modules/examples/examples/zenoh_pub.cpp index ad140e60..857c8d52 100644 --- a/modules/ipc/examples/zenoh_pub.cpp +++ b/modules/examples/examples/zenoh_pub.cpp @@ -11,11 +11,11 @@ #include #include "eolo/base/exception.h" +#include "eolo/examples/types/pose.h" +#include "eolo/examples/types_protobuf/pose.h" #include "eolo/ipc/publisher.h" #include "eolo/ipc/zenoh/publisher.h" #include "eolo/ipc/zenoh/session.h" -#include "eolo/types/pose.h" -#include "eolo/types_protobuf/pose.h" #include "zenoh_program_options.h" auto main(int argc, const char* argv[]) -> int { @@ -38,7 +38,7 @@ auto main(int argc, const char* argv[]) -> int { static constexpr auto LOOP_WAIT = std::chrono::seconds(1); while (true) { - eolo::types::Pose pose; + eolo::examples::types::Pose pose; pose.position = Eigen::Vector3d{ 1, 2, 3 }; fmt::println("Publishing Data ('{} : {})", config.topic, pose); diff --git a/modules/ipc/examples/zenoh_sub.cpp b/modules/examples/examples/zenoh_sub.cpp similarity index 91% rename from modules/ipc/examples/zenoh_sub.cpp rename to modules/examples/examples/zenoh_sub.cpp index 3b30e59c..8e28eb61 100644 --- a/modules/ipc/examples/zenoh_sub.cpp +++ b/modules/examples/examples/zenoh_sub.cpp @@ -12,11 +12,11 @@ #include #include +#include "eolo/examples/types/pose.h" +#include "eolo/examples/types_protobuf/pose.h" #include "eolo/ipc/subscriber.h" #include "eolo/ipc/zenoh/session.h" #include "eolo/ipc/zenoh/subscriber.h" -#include "eolo/types/pose.h" -#include "eolo/types_protobuf/pose.h" #include "zenoh_program_options.h" auto main(int argc, const char* argv[]) -> int { @@ -32,13 +32,13 @@ auto main(int argc, const char* argv[]) -> int { auto session = eolo::ipc::zenoh::createSession(config); auto cb = [topic = config.topic](const eolo::ipc::MessageMetadata& metadata, - const std::shared_ptr& pose) { + const std::shared_ptr& pose) { fmt::println(">> Time: {}. Topic {}. From: {}. Counter: {}. Received {}", std::chrono::system_clock::time_point{ std::chrono::duration_cast(metadata.timestamp) }, topic, metadata.sender_id, metadata.sequence_id, *pose); }; - auto subscriber = eolo::ipc::subscribe( + auto subscriber = eolo::ipc::subscribe( session, std::move(config), std::move(cb)); (void)subscriber; diff --git a/modules/types/include/eolo/types/pose.h b/modules/examples/include/eolo/examples/types/pose.h similarity index 72% rename from modules/types/include/eolo/types/pose.h rename to modules/examples/include/eolo/examples/types/pose.h index 3d4217d2..1869d06c 100644 --- a/modules/types/include/eolo/types/pose.h +++ b/modules/examples/include/eolo/examples/types/pose.h @@ -9,7 +9,7 @@ #include -namespace eolo::types { +namespace eolo::examples::types { struct Pose { Eigen::Quaterniond orientation = Eigen::Quaterniond::Identity(); @@ -24,20 +24,20 @@ struct Pose { pose.orientation.z()); } -} // namespace eolo::types +} // namespace eolo::examples::types template <> -struct std::formatter final : public std::formatter { +struct std::formatter final : public std::formatter { template - auto format(const eolo::types::Pose& pose, FormatContext& ctx) { + auto format(const eolo::examples::types::Pose& pose, FormatContext& ctx) { return std::format_to(ctx.out(), toString(pose)); } }; template <> -struct fmt::formatter : fmt::formatter { +struct fmt::formatter : fmt::formatter { template - auto format(const eolo::types::Pose& pose, FormatContext& ctx) { + auto format(const eolo::examples::types::Pose& pose, FormatContext& ctx) { return fmt::format_to(ctx.out(), "{}", toString(pose)); } }; diff --git a/modules/types_protobuf/include/eolo/types_protobuf/geometry.h b/modules/examples/include/eolo/examples/types_protobuf/geometry.h similarity index 96% rename from modules/types_protobuf/include/eolo/types_protobuf/geometry.h rename to modules/examples/include/eolo/examples/types_protobuf/geometry.h index 1a47f2a4..149a1d34 100644 --- a/modules/types_protobuf/include/eolo/types_protobuf/geometry.h +++ b/modules/examples/include/eolo/examples/types_protobuf/geometry.h @@ -7,9 +7,9 @@ #include #include "eolo/base/exception.h" -#include "eolo/types/proto/geometry.pb.h" +#include "eolo/examples/types/proto/geometry.pb.h" -namespace eolo::types { +namespace eolo::examples::types { template inline void toProto(ProtoMatrixT& proto_matrix, const Eigen::Matrix& matrix) { @@ -91,4 +91,4 @@ inline void fromProto(const proto::Quaterniond& proto_q, Eigen::Quaterniond& q) q.w() = proto_q.w(); } -} // namespace eolo::types +} // namespace eolo::examples::types diff --git a/modules/types_protobuf/include/eolo/types_protobuf/pose.h b/modules/examples/include/eolo/examples/types_protobuf/pose.h similarity index 78% rename from modules/types_protobuf/include/eolo/types_protobuf/pose.h rename to modules/examples/include/eolo/examples/types_protobuf/pose.h index 6f6e3ab1..cd880e1e 100644 --- a/modules/types_protobuf/include/eolo/types_protobuf/pose.h +++ b/modules/examples/include/eolo/examples/types_protobuf/pose.h @@ -4,15 +4,15 @@ #pragma once +#include "eolo/examples/types/pose.h" +#include "eolo/examples/types/proto/pose.pb.h" #include "eolo/serdes/protobuf/buffers.h" -#include "eolo/types/pose.h" -#include "eolo/types/proto/pose.pb.h" -namespace eolo::types { +namespace eolo::examples::types { void toProto(proto::Pose& proto_pose, const Pose& pose); void fromProto(const proto::Pose& proto_pose, Pose& pose); void toProtobuf(serdes::protobuf::SerializerBuffer& buffer, const Pose& pose); void fromProtobuf(serdes::protobuf::DeserializerBuffer& buffer, Pose& pose); -} // namespace eolo::types +} // namespace eolo::examples::types diff --git a/modules/types_protobuf/proto/CMakeLists.txt b/modules/examples/proto/CMakeLists.txt similarity index 61% rename from modules/types_protobuf/proto/CMakeLists.txt rename to modules/examples/proto/CMakeLists.txt index f6c9120b..0d1083d3 100644 --- a/modules/types_protobuf/proto/CMakeLists.txt +++ b/modules/examples/proto/CMakeLists.txt @@ -3,8 +3,8 @@ #================================================================================================= set(SOURCES - eolo/types/proto/geometry.proto - eolo/types/proto/pose.proto + eolo/examples/types/proto/geometry.proto + eolo/examples/types/proto/pose.proto ) -define_module_proto_library(NAME types_proto SOURCES ${SOURCES}) +define_module_proto_library(NAME examples_types_proto SOURCES ${SOURCES}) diff --git a/modules/types_protobuf/proto/buf.yaml b/modules/examples/proto/buf.yaml similarity index 100% rename from modules/types_protobuf/proto/buf.yaml rename to modules/examples/proto/buf.yaml diff --git a/modules/types_protobuf/proto/eolo/types/proto/geometry.proto b/modules/examples/proto/eolo/examples/types/proto/geometry.proto similarity index 93% rename from modules/types_protobuf/proto/eolo/types/proto/geometry.proto rename to modules/examples/proto/eolo/examples/types/proto/geometry.proto index 68de158c..f1380ad9 100644 --- a/modules/types_protobuf/proto/eolo/types/proto/geometry.proto +++ b/modules/examples/proto/eolo/examples/types/proto/geometry.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package eolo.types.proto; +package eolo.examples.types.proto; message Vector3d { double x = 1; diff --git a/modules/types_protobuf/proto/eolo/types/proto/pose.proto b/modules/examples/proto/eolo/examples/types/proto/pose.proto similarity index 53% rename from modules/types_protobuf/proto/eolo/types/proto/pose.proto rename to modules/examples/proto/eolo/examples/types/proto/pose.proto index 10dcfd25..3b0cb980 100644 --- a/modules/types_protobuf/proto/eolo/types/proto/pose.proto +++ b/modules/examples/proto/eolo/examples/types/proto/pose.proto @@ -1,8 +1,8 @@ syntax = "proto3"; -package eolo.types.proto; +package eolo.examples.types.proto; -import "eolo/types/proto/geometry.proto"; +import "eolo/examples/types/proto/geometry.proto"; message Pose { Vector3d position = 1; diff --git a/modules/types/src/pose.cpp b/modules/examples/src/types/pose.cpp similarity index 86% rename from modules/types/src/pose.cpp rename to modules/examples/src/types/pose.cpp index 1bc7eb3e..07f4b03f 100644 --- a/modules/types/src/pose.cpp +++ b/modules/examples/src/types/pose.cpp @@ -2,4 +2,4 @@ // Copyright (C) 2023-2024 EOLO Contributors //================================================================================================= -#include "eolo/types/pose.h" +#include "eolo/examples/types/pose.h" diff --git a/modules/types_protobuf/src/geometry.cpp b/modules/examples/src/types_protobuf/geometry.cpp similarity index 82% rename from modules/types_protobuf/src/geometry.cpp rename to modules/examples/src/types_protobuf/geometry.cpp index 5c0eb190..11897997 100644 --- a/modules/types_protobuf/src/geometry.cpp +++ b/modules/examples/src/types_protobuf/geometry.cpp @@ -2,4 +2,4 @@ // Copyright (C) 2023-2024 EOLO Contributors //================================================================================================= -#include "eolo/types_protobuf/geometry.h" +#include "eolo/examples/types_protobuf/geometry.h" diff --git a/modules/types_protobuf/src/pose.cpp b/modules/examples/src/types_protobuf/pose.cpp similarity index 84% rename from modules/types_protobuf/src/pose.cpp rename to modules/examples/src/types_protobuf/pose.cpp index ca4c976f..88e03a7b 100644 --- a/modules/types_protobuf/src/pose.cpp +++ b/modules/examples/src/types_protobuf/pose.cpp @@ -2,12 +2,12 @@ // Copyright (C) 2023-2024 EOLO Contributors //================================================================================================= -#include "eolo/types_protobuf/pose.h" +#include "eolo/examples/types_protobuf/pose.h" +#include "eolo/examples/types_protobuf/geometry.h" #include "eolo/serdes/protobuf/protobuf.h" -#include "eolo/types_protobuf/geometry.h" -namespace eolo::types { +namespace eolo::examples::types { void toProto(proto::Pose& proto_pose, const Pose& pose) { toProto(*proto_pose.mutable_position(), pose.position); toProto(*proto_pose.mutable_orientation(), pose.orientation); @@ -25,4 +25,4 @@ void toProtobuf(serdes::protobuf::SerializerBuffer& buffer, const Pose& pose) { void fromProtobuf(serdes::protobuf::DeserializerBuffer& buffer, Pose& pose) { serdes::protobuf::fromProtobuf(buffer, pose); } -} // namespace eolo::types +} // namespace eolo::examples::types diff --git a/modules/types_protobuf/tests/CMakeLists.txt b/modules/examples/tests/CMakeLists.txt similarity index 83% rename from modules/types_protobuf/tests/CMakeLists.txt rename to modules/examples/tests/CMakeLists.txt index a6dc271f..db9b6da1 100644 --- a/modules/types_protobuf/tests/CMakeLists.txt +++ b/modules/examples/tests/CMakeLists.txt @@ -3,8 +3,8 @@ #================================================================================================= define_module_test( - NAME tests - SOURCES tests.cpp + NAME types_protobuf_tests + SOURCES types_protobuf_tests.cpp PUBLIC_INCLUDE_PATHS $ PUBLIC_LINK_LIBS "") diff --git a/modules/types_protobuf/tests/tests.cpp b/modules/examples/tests/types_protobuf_tests.cpp similarity index 93% rename from modules/types_protobuf/tests/tests.cpp rename to modules/examples/tests/types_protobuf_tests.cpp index f6e8b032..f63d4cdb 100644 --- a/modules/types_protobuf/tests/tests.cpp +++ b/modules/examples/tests/types_protobuf_tests.cpp @@ -6,17 +6,17 @@ #include +#include "eolo/examples/types/pose.h" +#include "eolo/examples/types/proto/geometry.pb.h" +#include "eolo/examples/types_protobuf/geometry.h" +#include "eolo/examples/types_protobuf/pose.h" #include "eolo/serdes/protobuf/buffers.h" #include "eolo/serdes/serdes.h" -#include "eolo/types/pose.h" -#include "eolo/types/proto/geometry.pb.h" -#include "eolo/types_protobuf/geometry.h" -#include "eolo/types_protobuf/pose.h" // NOLINTNEXTLINE(google-build-using-namespace) using namespace ::testing; -namespace eolo::types::tests { +namespace eolo::examples::types::tests { auto randomPose(std::mt19937_64& mt) -> Pose { static constexpr auto RANDOM_TRANSLATION_RANGE = 100.0; @@ -151,4 +151,4 @@ TEST(Pose, PoseSerdes) { EXPECT_EQ(pose, pose_des); } -} // namespace eolo::types::tests +} // namespace eolo::examples::types::tests diff --git a/modules/ipc/CMakeLists.txt b/modules/ipc/CMakeLists.txt index 113b08a3..f7145ad0 100644 --- a/modules/ipc/CMakeLists.txt +++ b/modules/ipc/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright (C) 2023-2024 EOLO Contributors #================================================================================================= -declare_module(NAME ipc DEPENDS_ON_MODULES base cli types_protobuf DEPENDS_ON_EXTERNAL_PROJECTS fmt nlohmann_json range-v3 zenohcxx) +declare_module(NAME ipc DEPENDS_ON_MODULES base cli DEPENDS_ON_EXTERNAL_PROJECTS fmt nlohmann_json range-v3 zenohcxx) find_package(fmt REQUIRED) find_package(range-v3 REQUIRED) @@ -33,7 +33,6 @@ define_module_library( PUBLIC_LINK_LIBS eolo::base eolo::cli - eolo::types_protobuf fmt::fmt nlohmann_json::nlohmann_json range-v3::range-v3 @@ -48,4 +47,4 @@ define_module_library( # Subprojects add_subdirectory(tests) -add_subdirectory(examples) +add_subdirectory(apps) diff --git a/modules/ipc/examples/CMakeLists.txt b/modules/ipc/apps/CMakeLists.txt similarity index 62% rename from modules/ipc/examples/CMakeLists.txt rename to modules/ipc/apps/CMakeLists.txt index 6bffe4bf..fea2d277 100644 --- a/modules/ipc/examples/CMakeLists.txt +++ b/modules/ipc/apps/CMakeLists.txt @@ -2,35 +2,21 @@ # Copyright (C) 2023-2024 EOLO Contributors #================================================================================================= -define_module_example( - NAME zenoh_pub - SOURCES zenoh_pub.cpp zenoh_program_options.h - PUBLIC_INCLUDE_PATHS - $ - PUBLIC_LINK_LIBS "") - -define_module_example( - NAME zenoh_sub - SOURCES zenoh_sub.cpp zenoh_program_options.h - PUBLIC_INCLUDE_PATHS - $ - PUBLIC_LINK_LIBS "") - -define_module_example( +define_module_executable( NAME zenoh_topic_list SOURCES zenoh_topic_list.cpp zenoh_program_options.h PUBLIC_INCLUDE_PATHS $ PUBLIC_LINK_LIBS "") -define_module_example( +define_module_executable( NAME zenoh_node_list SOURCES zenoh_node_list.cpp zenoh_program_options.h PUBLIC_INCLUDE_PATHS $ PUBLIC_LINK_LIBS "") -define_module_example( +define_module_executable( NAME zenoh_query SOURCES zenoh_query.cpp zenoh_program_options.h PUBLIC_INCLUDE_PATHS diff --git a/modules/ipc/examples/zenoh_node_list.cpp b/modules/ipc/apps/zenoh_node_list.cpp similarity index 100% rename from modules/ipc/examples/zenoh_node_list.cpp rename to modules/ipc/apps/zenoh_node_list.cpp diff --git a/modules/ipc/apps/zenoh_program_options.h b/modules/ipc/apps/zenoh_program_options.h new file mode 100644 index 00000000..1aa1f6f8 --- /dev/null +++ b/modules/ipc/apps/zenoh_program_options.h @@ -0,0 +1,58 @@ +//================================================================================================= +// Copyright (C) 2023-2024 EOLO Contributors +//================================================================================================= + +#include "eolo/base/exception.h" +#include "eolo/cli/program_options.h" +#include "eolo/ipc/common.h" + +[[nodiscard]] inline auto +getProgramDescription(const std::string& description) -> eolo::cli::ProgramDescription { + static constexpr auto DEFAULT_KEY = "eolo/ipc/example/zenoh/put"; + + auto desc = eolo::cli::ProgramDescription(description); + desc.defineOption("topic", 't', "Key expression", DEFAULT_KEY) + .defineOption("cache", 'c', "Cache size", 0) + .defineOption("mode", 'm', "Running mode: options: peer, client", "peer") + .defineOption("router", 'r', "Router endpoint", "") + .defineOption("protocol", 'p', "Protocol to use, options: udp, tcp, any", "any") + .defineFlag("shared_memory", 's', "Enable shared memory") + .defineFlag("qos", 'q', "Enable QoS") + .defineFlag("realtime", "Enable real-time communication"); + + return desc; +} + +[[nodiscard]] inline auto parseArgs(const eolo::cli::ProgramOptions& args) -> eolo::ipc::Config { + eolo::ipc::Config config; + config.topic = args.getOption("topic"); + config.cache_size = args.getOption("cache"); + + auto mode = args.getOption("mode"); + if (mode == "peer") { + config.mode = eolo::ipc::Mode::PEER; + } else if (mode == "client") { + config.mode = eolo::ipc::Mode::CLIENT; + } else { + eolo::throwException(std::format("invalid mode value: {}", mode)); + } + + auto protocol = args.getOption("protocol"); + if (protocol == "any") { + config.protocol = eolo::ipc::Protocol::ANY; + } else if (protocol == "udp") { + config.protocol = eolo::ipc::Protocol::UDP; + } else if (protocol == "tcp") { + config.protocol = eolo::ipc::Protocol::TCP; + } else { + eolo::throwException( + std::format("invalid value {} for option 'protocol'", protocol)); + } + + config.router = args.getOption("router"); + config.enable_shared_memory = args.getOption("shared_memory"); + config.qos = args.getOption("qos"); + config.real_time = args.getOption("realtime"); + + return config; +} diff --git a/modules/ipc/examples/zenoh_query.cpp b/modules/ipc/apps/zenoh_query.cpp similarity index 100% rename from modules/ipc/examples/zenoh_query.cpp rename to modules/ipc/apps/zenoh_query.cpp diff --git a/modules/ipc/examples/zenoh_topic_list.cpp b/modules/ipc/apps/zenoh_topic_list.cpp similarity index 100% rename from modules/ipc/examples/zenoh_topic_list.cpp rename to modules/ipc/apps/zenoh_topic_list.cpp diff --git a/modules/ipc/tests/tests.cpp b/modules/ipc/tests/tests.cpp index 89d5792b..c7810fb5 100644 --- a/modules/ipc/tests/tests.cpp +++ b/modules/ipc/tests/tests.cpp @@ -10,6 +10,6 @@ using namespace ::testing; namespace eolo::ipc::tests { TEST(Example, Example) { - EXPECT_TRUE(false); + EXPECT_TRUE(true); } } // namespace eolo::ipc::tests diff --git a/modules/types/CMakeLists.txt b/modules/types/CMakeLists.txt deleted file mode 100644 index e1438d9b..00000000 --- a/modules/types/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -#================================================================================================= -# Copyright (C) 2023-2024 EOLO Contributors -#================================================================================================= - -declare_module(NAME types DEPENDS_ON_MODULES "" DEPENDS_ON_EXTERNAL_PROJECTS Eigen3 fmt) - -find_package(Eigen3 REQUIRED) -find_package(fmt REQUIRED) - -# library sources -set(SOURCES - src/pose.cpp - README.md - include/eolo/types/pose.h) - -# library target -define_module_library( - NAME types - PUBLIC_LINK_LIBS - Eigen3::Eigen - fmt::fmt - PRIVATE_LINK_LIBS "" - SOURCES ${SOURCES} - PUBLIC_INCLUDE_PATHS - $ - $ - PRIVATE_INCLUDE_PATHS "" - SYSTEM_PRIVATE_INCLUDE_PATHS "") - -# Subprojects -add_subdirectory(tests) -add_subdirectory(examples) diff --git a/modules/types/examples/CMakeLists.txt b/modules/types/examples/CMakeLists.txt deleted file mode 100644 index 586f351e..00000000 --- a/modules/types/examples/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -#================================================================================================= -# Copyright (C) 2023-2024 EOLO Contributors -#================================================================================================= - -define_module_example( - NAME example - SOURCES example.cpp - PUBLIC_INCLUDE_PATHS - $ - PUBLIC_LINK_LIBS "") diff --git a/modules/types/examples/example.cpp b/modules/types/examples/example.cpp deleted file mode 100644 index 01edd5c1..00000000 --- a/modules/types/examples/example.cpp +++ /dev/null @@ -1,14 +0,0 @@ -//================================================================================================= -// Copyright (C) 2023-2024 EOLO Contributors -//================================================================================================= - -#include - -#include "eolo/types/pose.h" - -//================================================================================================= -auto main(int argc, const char* argv[]) -> int { - (void)argc; - (void)argv; - return EXIT_SUCCESS; -} diff --git a/modules/types/tests/CMakeLists.txt b/modules/types/tests/CMakeLists.txt deleted file mode 100644 index a6dc271f..00000000 --- a/modules/types/tests/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -#================================================================================================= -# Copyright (C) 2023-2024 EOLO Contributors -#================================================================================================= - -define_module_test( - NAME tests - SOURCES tests.cpp - PUBLIC_INCLUDE_PATHS - $ - PUBLIC_LINK_LIBS "") diff --git a/modules/types/tests/tests.cpp b/modules/types/tests/tests.cpp deleted file mode 100644 index 5c6293af..00000000 --- a/modules/types/tests/tests.cpp +++ /dev/null @@ -1,15 +0,0 @@ -//================================================================================================= -// Copyright (C) 2023-2024 EOLO Contributors -//================================================================================================= - -#include - -// NOLINTNEXTLINE(google-build-using-namespace) -using namespace ::testing; - -namespace eolo::types::tests { - -TEST(Example, Example) { - // EXPECT_TRUE(false); -} -} // namespace eolo::types::tests diff --git a/modules/types_protobuf/CMakeLists.txt b/modules/types_protobuf/CMakeLists.txt deleted file mode 100644 index 247b0d53..00000000 --- a/modules/types_protobuf/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -#================================================================================================= -# Copyright (C) 2023-2024 EOLO Contributors -#================================================================================================= - -declare_module( - NAME types_protobuf - DEPENDS_ON_MODULES base serdes types - DEPENDS_ON_EXTERNAL_PROJECTS Protobuf Eigen3 -) - -find_package(Eigen3 REQUIRED) - -add_subdirectory(proto) - -# library sources -set(SOURCES - src/geometry.cpp - src/pose.cpp - README.md - include/eolo/types_protobuf/geometry.h - include/eolo/types_protobuf/pose.h) - -# library target -define_module_library( - NAME types_protobuf - PUBLIC_LINK_LIBS - eolo::base - eolo::serdes - eolo::types - eolo::types_proto - Eigen3::Eigen - PRIVATE_LINK_LIBS "" - SOURCES ${SOURCES} - PUBLIC_INCLUDE_PATHS - $ - $ - PRIVATE_INCLUDE_PATHS "" - SYSTEM_PRIVATE_INCLUDE_PATHS "") - -# Subprojects -add_subdirectory(tests) -add_subdirectory(examples) diff --git a/modules/types_protobuf/README.md b/modules/types_protobuf/README.md deleted file mode 100644 index 670a5eaf..00000000 --- a/modules/types_protobuf/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# README: types_protobuf - -## Brief - -types_protobuf provides .. - -## Detailed description - -Provide more details on the functionality, API usage, etc diff --git a/modules/types_protobuf/examples/example.cpp b/modules/types_protobuf/examples/example.cpp deleted file mode 100644 index bb83178e..00000000 --- a/modules/types_protobuf/examples/example.cpp +++ /dev/null @@ -1,14 +0,0 @@ -//================================================================================================= -// Copyright (C) 2023-2024 EOLO Contributors -//================================================================================================= - -#include - -#include "eolo/types_protobuf/pose.h" - -//================================================================================================= -auto main(int argc, const char* argv[]) -> int { - (void)argc; - (void)argv; - return EXIT_SUCCESS; -} diff --git a/modules/utils/src/version_impl.h b/modules/utils/src/version_impl.h index 79e611ad..01121b64 100644 --- a/modules/utils/src/version_impl.h +++ b/modules/utils/src/version_impl.h @@ -17,8 +17,8 @@ static constexpr std::uint8_t VERSION_MAJOR = 0; static constexpr std::uint8_t VERSION_MINOR = 0; static constexpr std::uint16_t VERSION_PATCH = 0; -static constexpr std::string_view REPO_BRANCH = "fix_ci"; +static constexpr std::string_view REPO_BRANCH = "examples_module"; static constexpr std::string_view BUILD_PROFILE = "Release"; -static constexpr std::string_view REPO_HASH = "b858d03"; +static constexpr std::string_view REPO_HASH = "a1ef6c5"; } // namespace eolo::utils