From 5f240a5f917bcfac07f632cafd4bc744b98f1231 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Wed, 12 Jul 2023 15:47:37 -0500 Subject: [PATCH 01/15] Only build integration tests if libraries exist (#523) Signed-off-by: Michael Carroll --- test/integration/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index a863807d2..ae5215847 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -5,6 +5,10 @@ if (SKIP_av OR INTERNAL_SKIP_av) list(REMOVE_ITEM tests video_encoder.cc) endif() +if (SKIP_graphics OR INTERNAL_SKIP_graphics) + list(REMOVE_ITEM tests mesh.cc) +endif() + gz_build_tests( TYPE INTEGRATION SOURCES ${tests} @@ -19,10 +23,12 @@ if(TARGET INTEGRATION_plugin) target_include_directories(INTEGRATION_plugin PRIVATE ${PROJECT_SOURCE_DIR}/test) endif() +# Graphics specific integration tests if(TARGET INTEGRATION_mesh) target_link_libraries(INTEGRATION_mesh ${PROJECT_LIBRARY_TARGET_NAME}-graphics) endif() +# AV specific integration tests if(TARGET INTEGRATION_encoder_timing) target_link_libraries(INTEGRATION_encoder_timing ${PROJECT_LIBRARY_TARGET_NAME}-av) endif() From 15ef98538811881d5c3f5e9fa20ad1b77a28af3d Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 17 Jul 2023 14:39:17 -0700 Subject: [PATCH 02/15] Fix Github Actions on macOS (#524) Signed-off-by: Michael Carroll --- .github/workflows/macos.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index e544a8c48..54e002fd5 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -14,6 +14,15 @@ jobs: uses: Homebrew/actions/setup-homebrew@master - run: brew config + # Workaround for https://github.com/actions/setup-python/issues/577 + - name: Clean up python binaries + run: | + rm -f /usr/local/bin/2to3*; + rm -f /usr/local/bin/idle3*; + rm -f /usr/local/bin/pydoc3*; + rm -f /usr/local/bin/python3*; + rm -f /usr/local/bin/python3*-config; + - name: Install base dependencies run: | brew tap osrf/simulation; From 3d6197bdd26d8d5bb313984209b1f34ab44e3bc1 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Tue, 1 Aug 2023 15:56:21 -0500 Subject: [PATCH 03/15] Fix Github project automation for new project board (#526) Signed-off-by: Addisu Z. Taddese --- .github/workflows/triage.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index 736670e0e..152404bee 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -1,7 +1,7 @@ on: issues: types: [opened] - pull_request_target: + pull_request: types: [opened] name: Ticket opened jobs: @@ -10,10 +10,8 @@ jobs: runs-on: ubuntu-latest steps: - name: Add ticket to inbox - uses: technote-space/create-project-card-action@v1 + uses: actions/add-to-project@v0.5.0 with: - PROJECT: Core development - COLUMN: Inbox - GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }} - CHECK_ORG_PROJECT: true + project-url: https://github.com/orgs/gazebosim/projects/7 + github-token: ${{ secrets.TRIAGE_TOKEN }} From e282a8d3e89efeef0e788baa5dbd7e4459fed574 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Wed, 2 Aug 2023 15:48:11 -0500 Subject: [PATCH 04/15] Use `pull_request_target` for triage workflow (#527) Signed-off-by: Addisu Z. Taddese --- .github/workflows/triage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index 152404bee..2c94852da 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -1,7 +1,7 @@ on: issues: types: [opened] - pull_request: + pull_request_target: types: [opened] name: Ticket opened jobs: From 83f87583f9b5bc8902bb89115ef973534aa46688 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 21 Aug 2023 19:28:22 -0500 Subject: [PATCH 05/15] =?UTF-8?q?=F0=9F=8E=88=205.4.1=20release=20(#531)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Carroll --- CMakeLists.txt | 2 +- Changelog.md | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f48a733dd..b13ff3b98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(gz-common5 VERSION 5.4.0) +project(gz-common5 VERSION 5.4.1) set(GZ_COMMON_VER ${PROJECT_VERSION_MAJOR}) #============================================================================ diff --git a/Changelog.md b/Changelog.md index e38588937..c1fa7779b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,40 @@ ## Gazebo Common 5.x +## Gazebo Common 5.4.1 (2023-08-21) + +1. Use `pull_request_target` for triage workflow + * [Pull request #527](https://github.com/gazebosim/gz-common/pull/527) + +1. Fix Github project automation for new project board + * [Pull request #526](https://github.com/gazebosim/gz-common/pull/526) + +1. Fix Github Actions on macOS + * [Pull request #524](https://github.com/gazebosim/gz-common/pull/524) + +1. Only build integration tests if libraries exist + * [Pull request #523](https://github.com/gazebosim/gz-common/pull/523) + +1. Fix compiling under linux + * [Pull request #521](https://github.com/gazebosim/gz-common/pull/521) + +1. Add missing header includes + * [Pull request #518](https://github.com/gazebosim/gz-common/pull/518) + +1. Header was dropped in the forward port and breaks downstream + * [Pull request #515](https://github.com/gazebosim/gz-common/pull/515) + +1. Port: 4 to 5 + * [Pull request #511](https://github.com/gazebosim/gz-common/pull/511) + +1. Lint + * [Pull request #Lint](https://github.com/gazebosim/gz-common/pull/Lint) + +1. 🎈 4.7.0 + * [Pull request #510](https://github.com/gazebosim/gz-common/pull/510) + +1. Fix build error when using gz:: with ign-common4 + * [Pull request #489](https://github.com/gazebosim/gz-common/pull/489) + ## Gazebo Common 5.4.0 (2023-04-28) 1. Add support for bayer images to be saved in a directory From 6e2444ff97616f68a2bcfd97b4cd2acec880b93b Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 28 Aug 2023 09:04:28 -0500 Subject: [PATCH 06/15] Build examples from CMake rather than executable (#502) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Carroll Signed-off-by: Michael Carroll Signed-off-by: Michael Carroll Co-authored-by: Alejandro Hernández Cordero Co-authored-by: Ian Chen --- .github/workflows/macos.yml | 10 ++++++---- CMakeLists.txt | 11 ++++++++++- examples/CMakeLists.txt | 4 +++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 54e002fd5..de4fd5d0a 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -48,12 +48,14 @@ jobs: run: cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/${PACKAGE}/HEAD - run: make working-directory: build - - run: make test - working-directory: build - env: - CTEST_OUTPUT_ON_FAILURE: 1 + # Run make install before make test so that the package will be available to + # build examples as part of the test - name: make install working-directory: build run: | make install; brew link ${PACKAGE}; + - run: make test + working-directory: build + env: + CTEST_OUTPUT_ON_FAILURE: 1 diff --git a/CMakeLists.txt b/CMakeLists.txt index b13ff3b98..ad6213748 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,7 +144,6 @@ gz_configure_build(QUIT_IF_BUILD_ERRORS #============================================================================ gz_create_packages() - #============================================================================ # Create documentation #============================================================================ @@ -157,3 +156,13 @@ gz_create_docs( TAGFILES "${GZ-MATH_DOXYGEN_TAGFILE} = ${GZ-MATH_API_URL}" ) + +#============================================================================ +# Build examples +#============================================================================ +if (BUILD_TESTING) + gz_build_examples( + SOURCE_DIR ${PROJECT_SOURCE_DIR}/examples + BINARY_DIR ${PROJECT_BINARY_DIR}/examples + ) +endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 22f20252c..3908f3878 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,4 +1,6 @@ -cmake_minimum_required(VERSION 2.8 FATAL_ERROR) +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) + +project(gz-common-examples) # Find the gz-common library find_package(gz-common5 QUIET REQUIRED COMPONENTS events profiler) From e18906b178c6dc3b2af5b418d90ea08bd571f540 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Wed, 30 Aug 2023 20:01:22 -0700 Subject: [PATCH 07/15] Fix glTF metalness and roughness map orientation (#532) Signed-off-by: Ian Chen --- graphics/src/AssimpLoader.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/graphics/src/AssimpLoader.cc b/graphics/src/AssimpLoader.cc index f38da665d..eeac1bee3 100644 --- a/graphics/src/AssimpLoader.cc +++ b/graphics/src/AssimpLoader.cc @@ -507,13 +507,13 @@ std::pair std::vector metalnessData(width * height * bytesPerPixel); std::vector roughnessData(width * height * bytesPerPixel); - for (unsigned int x = 0; x < width; ++x) + for (unsigned int y = 0; y < height; ++y) { - for (unsigned int y = 0; y < height; ++y) + for (unsigned int x = 0; x < width; ++x) { // RGBA so 4 bytes per pixel, alpha fully opaque - auto baseIndex = bytesPerPixel * (x * height + y); - auto color = _img.Pixel(x, y); + auto baseIndex = bytesPerPixel * (y * width + x); + auto color = _img.Pixel(x, (height - y - 1)); metalnessData[baseIndex] = color.B() * 255.0; metalnessData[baseIndex + 1] = color.B() * 255.0; metalnessData[baseIndex + 2] = color.B() * 255.0; From 038bf79cda4d66065431212ad175ec220fda6893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez=20Cordero?= Date: Tue, 5 Sep 2023 21:51:01 +0200 Subject: [PATCH 08/15] Update profiler.md (#535) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alejandro Hernández Cordero --- tutorials/profiler.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorials/profiler.md b/tutorials/profiler.md index 22808d649..b0c07a11f 100644 --- a/tutorials/profiler.md +++ b/tutorials/profiler.md @@ -125,8 +125,8 @@ colcon build --cmake-args -DENABLE_PROFILER=1 ``` Run your Gazebo library then go to your Gazebo installation path and open the profiler browser using: -``` -libexec/gz/gz-common/gz_remotery_vis +```{.sh} +/install/libexec/gz/gz-common/gz_remotery_vis ``` If the profiler is run successfully, you should see output in a browser. Similar to this From 33b6175fde4e2fad25e3b734f3ede3adbffacab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez=20Cordero?= Date: Tue, 5 Sep 2023 22:09:37 +0200 Subject: [PATCH 09/15] Update README.md (#534) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alejandro Hernández Cordero --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a634002bf..445034321 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ callback system. # Install -See the [installation tutorial](https://gazebosim.org/api/common/4.0/install.html). +See the [installation tutorial](https://gazebosim.org/api/common/5/install.html). # Usage @@ -69,8 +69,10 @@ Refer to the following table for information about important directories and fil +-- av Header and source files for the AV component. +-- events Header and source files for the Event component. +-- examples Example programs. ++-- geospatial Geospatial component for heightmap & DEMs +-- graphics Header and source files for the Graphics component. -+-- include/gz/common Header files for the core component. ++-- include/gz/common Header files for the core component. ++-- io IO component. Read object from stream. +-- profiler Header and source files for the Profiler component. +-- src Core source files and unit tests. +-- test From 0e866d8d2663096b98516c1de17c133f0cbc7253 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Tue, 26 Sep 2023 14:49:25 -0500 Subject: [PATCH 10/15] Prepare for 5.4.2 release (#536) Signed-off-by: Addisu Z. Taddese --- CMakeLists.txt | 2 +- Changelog.md | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad6213748..09f53ebbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(gz-common5 VERSION 5.4.1) +project(gz-common5 VERSION 5.4.2) set(GZ_COMMON_VER ${PROJECT_VERSION_MAJOR}) #============================================================================ diff --git a/Changelog.md b/Changelog.md index c1fa7779b..976e01331 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,18 @@ ## Gazebo Common 5.x +## Gazebo Common 5.4.2 (2023-09-26) + +1. Documentation fixes + * [Pull request #534](https://github.com/gazebosim/gz-common/pull/534) + * [Pull request #535](https://github.com/gazebosim/gz-common/pull/535) + +1. Fix glTF metalness and roughness map orientation + * [Pull request #532](https://github.com/gazebosim/gz-common/pull/532) + +1. Build examples from CMake rather than executable + * [Pull request #502](https://github.com/gazebosim/gz-common/pull/502) + + ## Gazebo Common 5.4.1 (2023-08-21) 1. Use `pull_request_target` for triage workflow From ca982d23cfa593531745d90dacff9f6d96f4f5ee Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Tue, 26 Sep 2023 20:33:48 +0000 Subject: [PATCH 11/15] update installation tutorial link to version 6 Signed-off-by: Ian Chen --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ba247c3e..498c9201a 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ callback system. # Install -See the [installation tutorial](https://gazebosim.org/api/common/5/install.html). +See the [installation tutorial](https://gazebosim.org/api/common/6/install.html). # Usage From e5465f14ba5c71921fb9debff85be2ccc6f56853 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Thu, 28 Sep 2023 17:19:12 -0500 Subject: [PATCH 12/15] Remove deprecated std::iterator inheritance (#529) Signed-off-by: Michael Carroll --- include/gz/common/EnumIface.hh | 401 +++++++++++++++++---------------- src/EnumIface_TEST.cc | 21 +- 2 files changed, 220 insertions(+), 202 deletions(-) diff --git a/include/gz/common/EnumIface.hh b/include/gz/common/EnumIface.hh index 2b0fe1dd8..4cc494518 100644 --- a/include/gz/common/EnumIface.hh +++ b/include/gz/common/EnumIface.hh @@ -17,6 +17,7 @@ #ifndef GZ_COMMON_ENUMITERATOR_HH_ #define GZ_COMMON_ENUMITERATOR_HH_ +#include #include #include #include @@ -24,220 +25,236 @@ #include #include -namespace gz +namespace gz::common { - namespace common + /// \brief Enum interface. Use this interface to convert an enum to + /// a string, and set an enum from a string. + template + class EnumIface { - /// \brief A macro that allows an enum to have an iterator and string - /// conversion. - /// \param[in] name EnumIface instance name. - /// \param[in] enumType Enum type - /// \param[in] begin Enum value that marks the beginning of the enum - /// values. - /// \param[in] end Enum value that marks the end of the enum values. - /// \param[in] names A vector of strings, one for each enum value. - /// \sa EnumIface - /// \sa EnumIterator - #define GZ_ENUM(name, enumType, begin, end, ...) \ - static gz::common::EnumIface name( \ - begin, end, {__VA_ARGS__}); - - /// \brief Enum interface. Use this interface to convert an enum to - /// a string, and set an enum from a string. - template - class EnumIface + /// \brief Constructor + /// \param[in] _start Starting enum value. + /// \param[in] _end Ending enum value. + /// \param[in] _names Name of each enum value. + public: EnumIface(T _start, T _end, + const std::vector &_names) + : names(_names) { - /// \brief Constructor - /// \param[in] _start Starting enum value. - /// \param[in] _end Ending enum value. - /// \param[in] _names Name of each enum value. - public: EnumIface(T _start, T _end, - const std::vector &_names) - : names(_names) - { - this->range[0] = _start; - this->range[1] = _end; - } - - /// \brief Get the beginning enum value. - /// \return Enum value that marks the beginning of the enum list. - public: T Begin() - { - return range[0]; - } + this->range[0] = _start; + this->range[1] = _end; + } - /// \brief Get the end enum value. - /// \return Enum value that marks the end of the enum list. - public: T End() - { - return range[1]; - } + /// \brief Get the beginning enum value. + /// \return Enum value that marks the beginning of the enum list. + public: T Begin() + { + return range[0]; + } - /// \brief Convert enum value to string. - /// \param[in] _e Enum value to convert. - /// \return String representation of the enum. An empty string is - /// returned if _e is invalid, or the names for the enum have not been - /// set. - public: std::string Str(T const &_e) - { - if (static_cast(_e) < names.size()) - return names[static_cast(_e)]; - else - return ""; - } + /// \brief Get the end enum value. + /// \return Enum value that marks the end of the enum list. + public: T End() + { + return range[1]; + } - /// \brief Set an enum from a string. This function requires a valid - /// string, and an array of names for the enum must exist. - /// \param[in] _str String value to convert to enum value. - /// \param[in] _e Enum variable to set. - /// \sa EnumIterator - public: void Set(T &_e, const std::string &_str) - { - auto begin = std::begin(names); - auto end = std::end(names); - - auto find = std::find(begin, end, _str); - if (find != end) - { - _e = static_cast(std::distance(begin, find)); - } - } + /// \brief Convert enum value to string. + /// \param[in] _e Enum value to convert. + /// \return String representation of the enum. An empty string is + /// returned if _e is invalid, or the names for the enum have not been + /// set. + public: std::string Str(T const &_e) + { + std::string ret; + if (static_cast(_e) < names.size()) + ret = names[static_cast(_e)]; + return ret; + } - /// \internal - /// \brief The beginning and end values. Do not use this directly. - public: T range[2]; - - /// \internal - /// \brief Array of string names for each element in the enum. Do not - /// use this directly. - public: std::vector names; - }; - - /// \brief An iterator over enum types. - /// - /// Example: - /// - /// \verbatim - /// enum MyType - /// { - /// MY_TYPE_BEGIN = 0, - /// TYPE1 = MY_TYPE_BEGIN, - /// TYPE2 = 1, - /// MY_TYPE_END - /// }; - /// - /// GZ_ENUM(myTypeIface, MyType, MY_TYPE_BEGIN, MY_TYPE_END, - /// "TYPE1", - /// "TYPE2", - /// "MY_TYPE_END") - /// - /// int main() - /// { - /// EnumIterator i = MY_TYPE_BEGIN; - /// std::cout << "Type Number[" << *i << "]\n"; - /// std::cout << "Type Name[" << myTypeIface.Str(*i) << "]\n"; - /// i++; - /// std::cout << "Type++ Number[" << *i << "]\n"; - /// std::cout << "Type++ Name[" << myTypeIface.Str(*i) << "]\n"; - /// } - /// \verbatim - template - class EnumIterator - : std::iterator + /// \brief Set an enum from a string. This function requires a valid + /// string, and an array of names for the enum must exist. + /// \param[in] _str String value to convert to enum value. + /// \param[in] _e Enum variable to set. + /// \sa EnumIterator + public: void Set(T &_e, const std::string &_str) { - /// \brief Constructor - public: EnumIterator() - { - } + auto begin = std::begin(names); + auto end = std::end(names); - /// \brief Constructor - /// \param[in] _c Enum value - // cppcheck-suppress noExplicitConstructor - public: EnumIterator(const Enum &_c) : c(_c) + auto find = std::find(begin, end, _str); + if (find != end) { + _e = static_cast(std::distance(begin, find)); } + } - /// \brief Equal operator - /// \param[in] _c Enum value to copy - public: EnumIterator &operator=(const Enum &_c) - { - this->c = _c; - return *this; - } + /// \internal + /// \brief The beginning and end values. Do not use this directly. + public: T range[2]; - /// \brief Prefix increment operator. - /// \return Iterator pointing to the next value in the enum. - public: EnumIterator &operator++() - { - this->c = static_cast(static_cast(this->c) + 1); - return *this; - } + /// \internal + /// \brief Array of string names for each element in the enum. Do not + /// use this directly. + public: std::vector names; + }; - /// \brief Postfix increment operator. - /// \return Iterator pointing to the next value in the enum. - public: EnumIterator operator++(const int) - { - EnumIterator cpy(*this); - ++*this; - return cpy; - } + /// \brief An iterator over enum types. + /// + /// Example: + /// + /// \verbatim + /// enum MyType + /// { + /// MY_TYPE_BEGIN = 0, + /// TYPE1 = MY_TYPE_BEGIN, + /// TYPE2 = 1, + /// MY_TYPE_END + /// }; + /// + /// auto myTypeIface = gzEnum(MY_TYPE_BEGIN, MY_TYPE_END, + /// {"TYPE1", + /// "TYPE2", + /// "MY_TYPE_END"}); + /// + /// int main() + /// { + /// EnumIterator i = MY_TYPE_BEGIN; + /// std::cout << "Type Number[" << *i << "]\n"; + /// std::cout << "Type Name[" << myTypeIface.Str(*i) << "]\n"; + /// i++; + /// std::cout << "Type++ Number[" << *i << "]\n"; + /// std::cout << "Type++ Name[" << myTypeIface.Str(*i) << "]\n"; + /// } + /// \verbatim + template + class EnumIterator + { + public: using iterator_category = std::bidirectional_iterator_tag; + public: using value_type = Enum; + public: using difference_type = std::ptrdiff_t; + public: using pointer = Enum*; + public: using reference = Enum&; - /// \brief Prefix decrement operator - /// \return Iterator pointing to the previous value in the enum - public: EnumIterator &operator--() - { - this->c = static_cast(static_cast(this->c) - 1); - return *this; - } + /// \brief Constructor + public: EnumIterator() = default; - /// \brief Postfix decrement operator - /// \return Iterator pointing to the previous value in the enum - public: EnumIterator operator--(const int) - { - EnumIterator cpy(*this); - --*this; - return cpy; - } + /// \brief Constructor + /// \param[in] _c Enum value + // cppcheck-suppress noExplicitConstructor + public: explicit EnumIterator(const Enum &_c) : c(_c) + { + } - /// \brief Dereference operator - /// \return Value of the iterator - public: Enum operator*() const - { - return c; - } + /// \brief Equal operator + /// \param[in] _c Enum value to copy + public: EnumIterator &operator=(const Enum &_c) + { + this->c = _c; + return *this; + } - /// \brief Get the enum value. - /// \return Value of the iterator - public: Enum Value() const - { - return this->c; - } + /// \brief Prefix increment operator. + /// \return Iterator pointing to the next value in the enum. + public: EnumIterator &operator++() + { + this->c = static_cast(static_cast(this->c) + 1); + return *this; + } + + /// \brief Postfix increment operator. + /// \return Iterator pointing to the next value in the enum. + public: EnumIterator operator++(const int) + { + EnumIterator cpy(*this); + ++*this; + return cpy; + } + + /// \brief Prefix decrement operator + /// \return Iterator pointing to the previous value in the enum + public: EnumIterator &operator--() + { + this->c = static_cast(static_cast(this->c) - 1); + return *this; + } + + /// \brief Postfix decrement operator + /// \return Iterator pointing to the previous value in the enum + public: EnumIterator operator--(const int) + { + EnumIterator cpy(*this); + --*this; + return cpy; + } - /// \brief Enum value - /// Did not use a private data class since this should be the only - /// member value ever used. - private: Enum c; - }; - - /// \brief Equality operator - /// \param[in] _e1 First iterator - /// \param[in] _e1 Second iterator - /// \return True if the two iterators contain equal enum values. - template - bool operator==(EnumIterator _e1, EnumIterator _e2) + /// \brief Dereference operator + /// \return Value of the iterator + public: Enum operator*() const { - return _e1.Value() == _e2.Value(); + return c; } - /// \brief Inequality operator - /// \param[in] _e1 First iterator - /// \param[in] _e1 Second iterator - /// \return True if the two iterators do not contain equal enum values. - template - bool operator!=(EnumIterator _e1, EnumIterator _e2) + /// \brief Get the enum value. + /// \return Value of the iterator + public: Enum Value() const { - return !(_e1 == _e2); + return this->c; } + + /// \brief Enum value + /// Did not use a private data class since this should be the only + /// member value ever used. + private: Enum c; + }; + + /// \brief Equality operator + /// \param[in] _e1 First iterator + /// \param[in] _e1 Second iterator + /// \return True if the two iterators contain equal enum values. + template + bool operator==(EnumIterator _e1, EnumIterator _e2) + { + return _e1.Value() == _e2.Value(); + } + + /// \brief Inequality operator + /// \param[in] _e1 First iterator + /// \param[in] _e1 Second iterator + /// \return True if the two iterators do not contain equal enum values. + template + bool operator!=(EnumIterator _e1, EnumIterator _e2) + { + return !(_e1 == _e2); + } + + /// \brief A template that allows an enum to have an iterator and string + /// conversion. + /// \param[in] begin Enum value that marks the beginning of the enum + /// values. + /// \param[in] end Enum value that marks the end of the enum values. + /// \param[in] names A vector of strings, one for each enum value. + /// \sa EnumIface + /// \sa EnumIterator + template + static constexpr gz::common::EnumIface gzEnum( + T _enumBegin, T _enumEnd, const std::vector &_enumVals) + { + return gz::common::EnumIface(_enumBegin, _enumEnd, _enumVals); } -} -#endif +} // namespace gz::common + + +/// \brief A macro that allows an enum to have an iterator and string +/// conversion. +/// \param[in] name EnumIface instance name. +/// \param[in] enumType Enum type +/// \param[in] begin Enum value that marks the beginning of the enum +/// values. +/// \param[in] end Enum value that marks the end of the enum values. +/// \param[in] names A vector of strings, one for each enum value. +/// \sa EnumIface +/// \sa EnumIterator +#define GZ_ENUM(name, enumType, begin, end, ...) \ +static auto name = gz::common::gzEnum(begin, end, {__VA_ARGS__}); + +#endif // GZ_COMMON_ENUMITERATOR_HH_ diff --git a/src/EnumIface_TEST.cc b/src/EnumIface_TEST.cc index a8a8fd51a..8f21f02c2 100644 --- a/src/EnumIface_TEST.cc +++ b/src/EnumIface_TEST.cc @@ -33,11 +33,12 @@ enum MyType MY_TYPE_END }; -GZ_ENUM(myTypeIface, MyType, MY_TYPE_BEGIN, MY_TYPE_END, - "TYPE1", - "TYPE2", - "MY_TYPE_END" -) +auto myTypeIface = gz::common::gzEnum( + MY_TYPE_BEGIN, MY_TYPE_END, { + "TYPE1", + "TYPE2", + "MY_TYPE_END" +}); ///////////////////////////////////////////////// TEST_F(EnumIfaceTest, StringCoversion) @@ -58,16 +59,16 @@ TEST_F(EnumIfaceTest, StringCoversion) ///////////////////////////////////////////////// TEST_F(EnumIfaceTest, Iterator) { - common::EnumIterator end = MY_TYPE_END; + common::EnumIterator end {MY_TYPE_END}; ASSERT_EQ(end.Value(), MY_TYPE_END); - common::EnumIterator begin = MY_TYPE_BEGIN; + common::EnumIterator begin {MY_TYPE_BEGIN}; ASSERT_EQ(*begin, MY_TYPE_BEGIN); int i = 0; // Prefix ++ operator - for (common::EnumIterator typeIter = MY_TYPE_BEGIN; + for (common::EnumIterator typeIter {MY_TYPE_BEGIN}; typeIter != end; ++typeIter, ++i) { ASSERT_EQ(*typeIter, i); @@ -79,7 +80,7 @@ TEST_F(EnumIfaceTest, Iterator) // Postfix ++ operator i = 0; - for (common::EnumIterator typeIter = MY_TYPE_BEGIN; + for (common::EnumIterator typeIter {MY_TYPE_BEGIN}; typeIter != end; ++typeIter, ++i) { ASSERT_EQ(typeIter.Value(), i); @@ -103,7 +104,7 @@ TEST_F(EnumIfaceTest, Iterator) // Postfix -- operator i = MY_TYPE_END - 1; - common::EnumIterator end2 = MY_TYPE_END; + common::EnumIterator end2{MY_TYPE_END}; for (common::EnumIterator typeIter = --end2; typeIter != begin; --typeIter, --i) { From 7838ced4b8547be15ddeaa76fbf3ff6d900a7b72 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Thu, 5 Oct 2023 09:50:31 -0700 Subject: [PATCH 13/15] Prevent loading lightmaps if mesh is a glb file that has an occlusion-metallic-roughness texture (#538) * Prevent loading lightmaps if mesh is a glb file --------- Signed-off-by: Ian Chen --- graphics/src/AssimpLoader.cc | 24 +++++++++++++++--------- graphics/src/AssimpLoader_TEST.cc | 10 ++++++++-- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/graphics/src/AssimpLoader.cc b/graphics/src/AssimpLoader.cc index eeac1bee3..ba2c57655 100644 --- a/graphics/src/AssimpLoader.cc +++ b/graphics/src/AssimpLoader.cc @@ -425,6 +425,21 @@ MaterialPtr AssimpLoader::Implementation::CreateMaterial( this->GenerateTextureName(_scene, assimpMat, "Roughness")); pbr.SetRoughnessMap(texName, texData); } + // Load lightmap only if it is not a glb/glTF mesh that contains a + // MetallicRoughness texture + // It was found that lightmap field just stores the entire MetallicRoughness + // texture. Issues were also reported in assimp: + // https://github.com/assimp/assimp/issues/3120 + // https://github.com/assimp/assimp/issues/4637 + unsigned int uvIdx = 0; + ret = assimpMat->GetTexture( + aiTextureType_LIGHTMAP, 0, &texturePath, NULL, &uvIdx); + if (ret == AI_SUCCESS) + { + auto [texName, texData] = this->LoadTexture(_scene, texturePath, + this->GenerateTextureName(_scene, assimpMat, "Lightmap")); + pbr.SetLightMap(texName, uvIdx, texData); + } } #endif ret = assimpMat->GetTexture(aiTextureType_NORMALS, 0, &texturePath); @@ -442,15 +457,6 @@ MaterialPtr AssimpLoader::Implementation::CreateMaterial( this->GenerateTextureName(_scene, assimpMat, "Emissive")); pbr.SetEmissiveMap(texName, texData); } - unsigned int uvIdx = 0; - ret = assimpMat->GetTexture( - aiTextureType_LIGHTMAP, 0, &texturePath, NULL, &uvIdx); - if (ret == AI_SUCCESS) - { - auto [texName, texData] = this->LoadTexture(_scene, texturePath, - this->GenerateTextureName(_scene, assimpMat, "Lightmap")); - pbr.SetLightMap(texName, uvIdx, texData); - } #ifndef GZ_ASSIMP_PRE_5_2_0 float value; ret = assimpMat->Get(AI_MATKEY_METALLIC_FACTOR, value); diff --git a/graphics/src/AssimpLoader_TEST.cc b/graphics/src/AssimpLoader_TEST.cc index 87e6b8210..f171d427e 100644 --- a/graphics/src/AssimpLoader_TEST.cc +++ b/graphics/src/AssimpLoader_TEST.cc @@ -708,10 +708,16 @@ TEST_F(AssimpLoader, LoadGlbPbrAsset) // Check pixel values to test metallicroughness texture splitting EXPECT_FLOAT_EQ(pbr->MetalnessMapData()->Pixel(256, 256).R(), 0.0); EXPECT_FLOAT_EQ(pbr->RoughnessMapData()->Pixel(256, 256).R(), 124.0 / 255.0); + // Bug in assimp 5.0.x that doesn't parse coordinate sets properly - EXPECT_EQ(pbr->LightMapTexCoordSet(), 1); + // \todo(iche033) Lightmaps are disabled for glb meshes + // due to upstream bug + // EXPECT_EQ(pbr->LightMapTexCoordSet(), 1); #endif - EXPECT_NE(pbr->LightMapData(), nullptr); + + // \todo(iche033) Lightmaps are disabled for glb meshes + // due to upstream bug + // EXPECT_NE(pbr->LightMapData(), nullptr); // Mesh has 3 animations auto skel = mesh->MeshSkeleton(); From d9d1722d3251ded4c716a1d30a146d17eca4534c Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Sat, 7 Oct 2023 22:31:37 -0700 Subject: [PATCH 14/15] EnumIface: suppress deprecation warning (#540) The EnumIterator inherits from std::iterator, which has been deprecated in c++17. There is a fix in gz-common6 but it breaks API, so it can't be merged to Garden. So just suppress the deprecation warning in Garden. Signed-off-by: Steve Peters --- include/gz/common/EnumIface.hh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/gz/common/EnumIface.hh b/include/gz/common/EnumIface.hh index 2b0fe1dd8..83a03e22a 100644 --- a/include/gz/common/EnumIface.hh +++ b/include/gz/common/EnumIface.hh @@ -141,6 +141,7 @@ namespace gz /// std::cout << "Type++ Name[" << myTypeIface.Str(*i) << "]\n"; /// } /// \verbatim + GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION template class EnumIterator : std::iterator @@ -218,6 +219,7 @@ namespace gz /// member value ever used. private: Enum c; }; + GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION /// \brief Equality operator /// \param[in] _e1 First iterator From 2765c5fd42bf4f44940c5bd8f3d1a220b6e4fe3e Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Mon, 16 Oct 2023 19:10:48 -0500 Subject: [PATCH 15/15] Bumps in ionic: use gz-cmake4, gz-utils3, gz-math8 (#539) --------- Signed-off-by: Addisu Z. Taddese Signed-off-by: Steve Peters Co-authored-by: Steve Peters --- .github/ci/packages.apt | 6 +++--- .github/workflows/ci.yml | 13 ++----------- .github/workflows/macos.yml | 2 +- CMakeLists.txt | 12 ++++++------ 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/.github/ci/packages.apt b/.github/ci/packages.apt index 00715fab4..ab5c4d03a 100644 --- a/.github/ci/packages.apt +++ b/.github/ci/packages.apt @@ -6,9 +6,9 @@ libavutil-dev libfreeimage-dev libgdal-dev libgts-dev -libgz-cmake3-dev -libgz-math7-dev -libgz-utils2-dev +libgz-cmake4-dev +libgz-math8-dev +libgz-utils3-dev libswscale-dev libtinyxml2-dev pkg-config diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 329049cc6..29307b2ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,17 +3,6 @@ name: Ubuntu CI on: [push, pull_request] jobs: - focal-ci: - runs-on: ubuntu-latest - name: Ubuntu Focal CI - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Compile and test - id: ci - uses: gazebo-tooling/action-gz-ci@focal - with: - codecov-enabled: true jammy-ci: runs-on: ubuntu-latest name: Ubuntu Jammy CI @@ -23,3 +12,5 @@ jobs: - name: Compile and test id: ci uses: gazebo-tooling/action-gz-ci@jammy + with: + codecov-enabled: true diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 866b25d2c..76164932e 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -39,7 +39,7 @@ jobs: popd echo '# END SECTION' fi - # gz-math7 has problems with swig, remove it for now + # gz-math8 has problems with swig, remove it for now brew remove swig || true brew install --only-dependencies ${PACKAGE}; - run: mkdir build diff --git a/CMakeLists.txt b/CMakeLists.txt index cf9e820b5..7f79a98e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,8 +9,8 @@ set(GZ_COMMON_VER ${PROJECT_VERSION_MAJOR}) #============================================================================ # Find gz-cmake #============================================================================ -find_package(gz-cmake3 REQUIRED) -set(GZ_CMAKE_VER ${gz-cmake3_VERSION_MAJOR}) +find_package(gz-cmake4 REQUIRED) +set(GZ_CMAKE_VER ${gz-cmake4_VERSION_MAJOR}) #============================================================================ # Configure the project @@ -49,13 +49,13 @@ message(STATUS "\n\n-- ====== Finding Dependencies ======") #-------------------------------------- # Find gz-math -gz_find_package(gz-math7 REQUIRED_BY geospatial graphics events) -set(GZ_MATH_VER ${gz-math7_VERSION_MAJOR}) +gz_find_package(gz-math8 REQUIRED_BY geospatial graphics events) +set(GZ_MATH_VER ${gz-math8_VERSION_MAJOR}) #-------------------------------------- # Find gz-utils -gz_find_package(gz-utils2 REQUIRED) -set(GZ_UTILS_VER ${gz-utils2_VERSION_MAJOR}) +gz_find_package(gz-utils3 REQUIRED) +set(GZ_UTILS_VER ${gz-utils3_VERSION_MAJOR}) #-------------------------------------- # Find Tinyxml2