diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 76164932e..c6bc32c77 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -1,6 +1,12 @@ name: macOS latest -on: [push, pull_request] +on: + pull_request: + push: + branches: + - 'ign-common[0-9]' + - 'gz-common[0-9]' + - 'main' jobs: build: @@ -8,22 +14,24 @@ jobs: PACKAGE: gz-common6 runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Homebrew id: set-up-homebrew uses: Homebrew/actions/setup-homebrew@master - run: brew config + - run: brew list # 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; - + rm -f $(brew --prefix)/bin/2to3*; + rm -f $(brew --prefix)/bin/idle3*; + rm -f $(brew --prefix)/bin/pydoc3*; + rm -f $(brew --prefix)/bin/python3*; + rm -f $(brew --prefix)/bin/python3*-config; - name: Install base dependencies + env: + HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 run: | brew tap osrf/simulation; # check for ci_matching_branch @@ -45,7 +53,7 @@ jobs: - run: mkdir build - name: cmake working-directory: build - run: cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/${PACKAGE}/HEAD + run: cmake .. -DCMAKE_INSTALL_PREFIX=$(brew --prefix)/Cellar/${PACKAGE}/HEAD - run: make working-directory: build # Run make install before make test so that the package will be available to diff --git a/.github/workflows/package_xml.yml b/.github/workflows/package_xml.yml new file mode 100644 index 000000000..4bd4a9aa0 --- /dev/null +++ b/.github/workflows/package_xml.yml @@ -0,0 +1,11 @@ +name: Validate package.xml + +on: + pull_request: + +jobs: + package-xml: + runs-on: ubuntu-latest + name: Validate package.xml + steps: + - uses: gazebo-tooling/action-gz-ci/validate_package_xml@jammy diff --git a/Changelog.md b/Changelog.md index 99cef4c9c..7e9ef3d00 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,23 @@ ## Gazebo Common 5.x +## Gazebo Common 5.6.0 (2024-04-23) + +1. Clarify units for the DEM classes + * [Pull request #595](https://github.com/gazebosim/gz-common/pull/595) + +1. Remove pessimizing move + * [Pull request #593](https://github.com/gazebosim/gz-common/pull/593) + +1. Fix bazel build + * [Pull request #592](https://github.com/gazebosim/gz-common/pull/592) + +1. Add new function in MeshManager to merge all submeshes of a mesh into one + * [Pull request #588](https://github.com/gazebosim/gz-common/pull/588) + +1. Adds new function in MeshManager for performing convex decomposition + * [Pull request #585](https://github.com/gazebosim/gz-common/pull/585) + ## Gazebo Common 5.5.1 (2024-03-14) 1. Various Bazel adjustments for linting diff --git a/av/src/AudioDecoder.cc b/av/src/AudioDecoder.cc index a1f7b29c4..a9969484f 100644 --- a/av/src/AudioDecoder.cc +++ b/av/src/AudioDecoder.cc @@ -52,7 +52,13 @@ common::AudioDecoder::Implementation::~Implementation() { // Close the codec if (this->codecCtx) + { +#if LIBAVFORMAT_VERSION_MAJOR < 59 avcodec_close(this->codecCtx); +#else + avcodec_free_context(&this->codecCtx); +#endif + } // Close the audio file if (this->formatCtx) diff --git a/av/src/Video.cc b/av/src/Video.cc index 4958b85ef..75376ae5c 100644 --- a/av/src/Video.cc +++ b/av/src/Video.cc @@ -114,7 +114,11 @@ void Video::Cleanup() avformat_close_input(&this->dataPtr->formatCtx); // Close the codec +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101) + avcodec_free_context(&this->dataPtr->codecCtx); +#else avcodec_close(this->dataPtr->codecCtx); +#endif av_free(this->dataPtr->avFrameDst); } diff --git a/geospatial/include/gz/common/geospatial/Dem.hh b/geospatial/include/gz/common/geospatial/Dem.hh index be3ea6bf3..00928e6e3 100644 --- a/geospatial/include/gz/common/geospatial/Dem.hh +++ b/geospatial/include/gz/common/geospatial/Dem.hh @@ -58,8 +58,8 @@ namespace gz public: int Load(const std::string &_filename = ""); /// \brief Get the elevation of a terrain's point in meters. - /// \param[in] _x X coordinate of the terrain. - /// \param[in] _y Y coordinate of the terrain. + /// \param[in] _x X coordinate of the terrain in raster coordinates. + /// \param[in] _y Y coordinate of the terrain in raster coordinates. /// \return Terrain's elevation at (x,y) in meters or infinity if illegal /// coordinates were provided. public: double Elevation(double _x, double _y); diff --git a/geospatial/include/gz/common/geospatial/HeightmapData.hh b/geospatial/include/gz/common/geospatial/HeightmapData.hh index 8b413ac16..1921665b9 100644 --- a/geospatial/include/gz/common/geospatial/HeightmapData.hh +++ b/geospatial/include/gz/common/geospatial/HeightmapData.hh @@ -37,7 +37,7 @@ namespace gz /// Ex: A subsampling of 2 in a terrain of 129x129 means that the height /// vector will be 257 * 257. /// \param[in] _vertSize Number of points per row. - /// \param[in] _size Real dimmensions of the terrain. + /// \param[in] _size Real dimensions of the terrain. /// \param[in] _scale Vector3 used to scale the height. /// \param[in] _flipY If true, it inverts the order in which the vector /// is filled. @@ -48,11 +48,11 @@ namespace gz std::vector &_heights) const = 0; /// \brief Get the terrain's height. - /// \return The terrain's height. + /// \return The terrain's height [pixels]. public: virtual unsigned int Height() const = 0; /// \brief Get the terrain's width. - /// \return The terrain's width. + /// \return The terrain's width [pixels]. public: virtual unsigned int Width() const = 0; /// \brief Get the maximum terrain's elevation. diff --git a/graphics/src/AssimpLoader.cc b/graphics/src/AssimpLoader.cc index 49a9b5deb..bcbd7096a 100644 --- a/graphics/src/AssimpLoader.cc +++ b/graphics/src/AssimpLoader.cc @@ -15,7 +15,9 @@ * */ +#include #include +#include #include #include "gz/common/graphics/Types.hh" @@ -69,10 +71,12 @@ class AssimpLoader::Implementation /// \param[in] _scene the assimp scene /// \param[in] _matIdx index of the material in the scene /// \param[in] _path path where the mesh is located + /// \param[in] _fileBaseName Base name of the mesh file. /// \return pointer to the converted common::Material - public: MaterialPtr CreateMaterial(const aiScene* _scene, + public: MaterialPtr CreateMaterial(const aiScene *_scene, unsigned _matIdx, - const std::string& _path) const; + const std::string &_path, + const std::string &_fileBaseName) const; /// \brief Load a texture embedded in a mesh (i.e. for GLB format) /// into a gz::common::Image @@ -82,13 +86,15 @@ class AssimpLoader::Implementation /// \brief Utility function to generate a texture name for both embedded /// and external textures + /// \param[in] _prefix Prefix to add to the texture name /// \param[in] _scene the assimp scene /// \param[in] _mat the assimp material /// \param[in] _type the type of texture (i.e. Diffuse, Metal) /// \return the generated texture name - public: std::string GenerateTextureName(const aiScene* _scene, - aiMaterial* _mat, - const std::string& _type) const; + public: std::string GenerateTextureName(const std::string &_prefix, + const aiScene* _scene, + aiMaterial *_mat, + const std::string &_type) const; /// \brief Function to parse texture information and load it if embedded /// \param[in] _scene the assimp scene @@ -320,7 +326,8 @@ void AssimpLoader::Implementation::RecursiveSkeletonCreate(const aiNode* _node, ////////////////////////////////////////////////// MaterialPtr AssimpLoader::Implementation::CreateMaterial( - const aiScene* _scene, unsigned _matIdx, const std::string& _path) const + const aiScene *_scene, unsigned _matIdx, const std::string &_path, + const std::string &_fileBaseName) const { MaterialPtr mat = std::make_shared(); aiColor4D color; @@ -386,8 +393,8 @@ MaterialPtr AssimpLoader::Implementation::CreateMaterial( if (ret == AI_SUCCESS) { // Check if the texture is embedded or not - auto [texName, texData] = this->LoadTexture(_scene, - texturePath, this->GenerateTextureName(_scene, assimpMat, "Diffuse")); + auto [texName, texData] = this->LoadTexture(_scene, texturePath, + this->GenerateTextureName(_fileBaseName, _scene, assimpMat, "Diffuse")); if (texData != nullptr) mat->SetTextureImage(texName, texData); else @@ -421,18 +428,19 @@ MaterialPtr AssimpLoader::Implementation::CreateMaterial( if (ret == AI_SUCCESS) { auto [texName, texData] = this->LoadTexture(_scene, texturePath, - this->GenerateTextureName(_scene, assimpMat, "MetallicRoughness")); + this->GenerateTextureName(_fileBaseName, _scene, assimpMat, + "MetallicRoughness")); // Load it into a common::Image then split it auto texImg = texData != nullptr ? texData : std::make_shared(joinPaths(_path, texName)); auto [metalTexture, roughTexture] = this->SplitMetallicRoughnessMap(*texImg); pbr.SetMetalnessMap( - this->GenerateTextureName(_scene, assimpMat, "Metalness"), - metalTexture); + this->GenerateTextureName(_fileBaseName, _scene, assimpMat, + "Metalness"), metalTexture); pbr.SetRoughnessMap( - this->GenerateTextureName(_scene, assimpMat, "Roughness"), - roughTexture); + this->GenerateTextureName(_fileBaseName, _scene, assimpMat, + "Roughness"), roughTexture); } else { @@ -441,7 +449,8 @@ MaterialPtr AssimpLoader::Implementation::CreateMaterial( if (ret == AI_SUCCESS) { auto [texName, texData] = this->LoadTexture(_scene, texturePath, - this->GenerateTextureName(_scene, assimpMat, "Metalness")); + this->GenerateTextureName(_fileBaseName, _scene, assimpMat, + "Metalness")); pbr.SetMetalnessMap(texName, texData); } ret = assimpMat->GetTexture( @@ -449,7 +458,8 @@ MaterialPtr AssimpLoader::Implementation::CreateMaterial( if (ret == AI_SUCCESS) { auto [texName, texData] = this->LoadTexture(_scene, texturePath, - this->GenerateTextureName(_scene, assimpMat, "Roughness")); + this->GenerateTextureName(_fileBaseName, _scene, assimpMat, + "Roughness")); pbr.SetRoughnessMap(texName, texData); } // Load lightmap only if it is not a glb/glTF mesh that contains a @@ -464,7 +474,8 @@ MaterialPtr AssimpLoader::Implementation::CreateMaterial( if (ret == AI_SUCCESS) { auto [texName, texData] = this->LoadTexture(_scene, texturePath, - this->GenerateTextureName(_scene, assimpMat, "Lightmap")); + this->GenerateTextureName(_fileBaseName, _scene, assimpMat, + "Lightmap")); pbr.SetLightMap(texName, uvIdx, texData); } } @@ -473,7 +484,7 @@ MaterialPtr AssimpLoader::Implementation::CreateMaterial( if (ret == AI_SUCCESS) { auto [texName, texData] = this->LoadTexture(_scene, texturePath, - this->GenerateTextureName(_scene, assimpMat, "Normal")); + this->GenerateTextureName(_fileBaseName, _scene, assimpMat, "Normal")); // TODO(luca) different normal map spaces pbr.SetNormalMap(texName, NormalMapSpace::TANGENT, texData); } @@ -481,7 +492,8 @@ MaterialPtr AssimpLoader::Implementation::CreateMaterial( if (ret == AI_SUCCESS) { auto [texName, texData] = this->LoadTexture(_scene, texturePath, - this->GenerateTextureName(_scene, assimpMat, "Emissive")); + this->GenerateTextureName(_fileBaseName, _scene, assimpMat, + "Emissive")); pbr.SetEmissiveMap(texName, texData); } #ifndef GZ_ASSIMP_PRE_5_2_0 @@ -600,15 +612,16 @@ ImagePtr AssimpLoader::Implementation::LoadEmbeddedTexture( ////////////////////////////////////////////////// std::string AssimpLoader::Implementation::GenerateTextureName( - const aiScene* _scene, aiMaterial* _mat, const std::string& _type) const + const std::string &_prefix, const aiScene *_scene, aiMaterial *_mat, + const std::string &_type) const { #ifdef GZ_ASSIMP_PRE_5_2_0 auto rootName = _scene->mRootNode->mName; #else auto rootName = _scene->mName; #endif - return ToString(rootName) + "_" + ToString(_mat->GetName()) + - "_" + _type; + return _prefix + "_" + ToString(rootName) + "_" + + ToString(_mat->GetName()) + "_" + _type; } ////////////////////////////////////////////////// @@ -695,12 +708,18 @@ Mesh *AssimpLoader::Load(const std::string &_filename) } auto& rootNode = scene->mRootNode; auto rootName = ToString(rootNode->mName); - - // compute assimp root node transform - std::string extension = _filename.substr(_filename.rfind(".") + 1, - _filename.size()); + auto fileBaseName = common::basename(_filename); + std::string extension; + std::size_t extIdx = _filename.rfind("."); + if (extIdx != std::string::npos) + { + extension = _filename.substr(extIdx + 1, _filename.size()); + fileBaseName = fileBaseName.substr(0, fileBaseName.rfind(extension) - 1); + } std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower); + + // compute assimp root node transform bool useIdentityRotation = (extension != "glb" && extension != "glTF"); auto transform = this->dataPtr->UpdatedRootNodeTransform(scene, useIdentityRotation); @@ -709,7 +728,8 @@ Mesh *AssimpLoader::Load(const std::string &_filename) // Add the materials first for (unsigned _matIdx = 0; _matIdx < scene->mNumMaterials; ++_matIdx) { - auto mat = this->dataPtr->CreateMaterial(scene, _matIdx, path); + auto mat = this->dataPtr->CreateMaterial(scene, _matIdx, path, + fileBaseName); mesh->AddMaterial(mat); } // Create the skeleton diff --git a/graphics/src/AssimpLoader_TEST.cc b/graphics/src/AssimpLoader_TEST.cc index 0c8bed064..aa3c44318 100644 --- a/graphics/src/AssimpLoader_TEST.cc +++ b/graphics/src/AssimpLoader_TEST.cc @@ -721,9 +721,9 @@ TEST_F(AssimpLoader, LoadGlTF2BoxWithJPEGTexture) // Assimp 5.2.0 and above uses the scene name for its texture names, // older version use the root node instead. #ifdef GZ_ASSIMP_PRE_5_2_0 - EXPECT_EQ("Cube_Material_Diffuse", mat->TextureImage()); + EXPECT_EQ("box_texture_jpg_Cube_Material_Diffuse", mat->TextureImage()); #else - EXPECT_EQ("Scene_Material_Diffuse", mat->TextureImage()); + EXPECT_EQ("box_texture_jpg_Scene_Material_Diffuse", mat->TextureImage()); #endif EXPECT_NE(nullptr, mat->TextureData()); delete mesh; diff --git a/package.xml b/package.xml new file mode 100644 index 000000000..50f966bf7 --- /dev/null +++ b/package.xml @@ -0,0 +1,28 @@ + + + gz-common6 + 6.0.0 + Gazebo Common : AV, Graphics, Events, and much more. + Nate Koenig + Apache License 2.0 + https://github.com/gazebosim/gz-common + + cmake + pkg-config + + gz-cmake4 + + assimp-dev + ffmpeg-dev + gz-math8 + gz-utils3 + libfreeimage-dev + libgdal-dev + libgts + tinyxml2 + uuid + + + cmake + +