From fb3f3d43eee648e387f89d611dd2a9973fff201e Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Thu, 25 Apr 2024 16:44:34 -0500 Subject: [PATCH 1/6] Fix namespace and class links in documentation references that use namespace `gz` (#2385) The `gz` namespace is not recognized by doxygen enough for it to autogenerate links to inner namespaces and classes. For example, `\ref gz::sim::systems` or simply `gz::sim::systems` don't link to the namespace documentation. You'd have to use `ignition::gazebo::systems` instead. I was hoping there was a more clever solution that would allow all `gz::` refs to work automatically, but I was not able to find one, so this is a compromise to fix the landing page for ign-gazebo6 (https://gazebosim.org/api/sim/6) Signed-off-by: Addisu Z. Taddese --- api.md.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api.md.in b/api.md.in index 43eb2ebe20..066b311269 100644 --- a/api.md.in +++ b/api.md.in @@ -5,10 +5,10 @@ designed to rapidly develop robot and simulation applications. **Useful links** -1. gz::sim::components : List of built-in Component types. Components represent data, such as position information, that can be added to an Entity. -2. gz::sim::systems : List of available Systems. A System operates on Entities that have a specific set of Components. -3. gz::sim::events : List of simulation events. See the - gz::sim::EventManager for details about events and how to use them. +1. [gz::sim::components](\ref ignition::gazebo::components) : List of built-in Component types. Components represent data, such as position information, that can be added to an Entity. +2. [gz::sim::systems](\ref ignition::gazebo::systems) : List of available Systems. A System operates on Entities that have a specific set of Components. +3. [gz::sim::events](\ref ignition::gazebo::events) : List of simulation events. See the + [gz::sim::EventManager](\ref ignition::gazebo::EventManager) for details about events and how to use them. ## License From 0b4585a7735fe517bcd0caac0d484840adb44dfb Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Wed, 29 May 2024 10:04:36 -0700 Subject: [PATCH 2/6] Rephrase cmake comment about CMP0077 (#2419) Signed-off-by: Steve Peters --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e85730863b..d287de59aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,7 @@ option(USE_DIST_PACKAGES_FOR_PYTHON #============================================================================ # Setting this policy enables using the protobuf_MODULE_COMPATIBLE -# set command in CMake versions older than 13.13 +# set command when cmake_minimum_required is less than 3.13 set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) # This option is needed to use the PROTOBUF_GENERATE_CPP # in case protobuf is found with the CMake config files From ae68e812466cbd580c0e7707b557e55c3d10e965 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Fri, 31 May 2024 00:55:15 +0900 Subject: [PATCH 3/6] Support mesh optimization when using AttachMeshShapeFeature (#2417) Signed-off-by: Ian Chen --- include/gz/sim/Util.hh | 7 ++++ src/Util.cc | 78 ++++++++++++++++++++++++++++++++++++++++++ src/Util_TEST.cc | 8 +++++ 3 files changed, 93 insertions(+) diff --git a/include/gz/sim/Util.hh b/include/gz/sim/Util.hh index e8e4bed0e0..de0585e5c0 100644 --- a/include/gz/sim/Util.hh +++ b/include/gz/sim/Util.hh @@ -316,6 +316,13 @@ namespace gz /// \return The loaded mesh or null if the mesh can not be loaded. GZ_SIM_VISIBLE const common::Mesh *loadMesh(const sdf::Mesh &_meshSdf); + /// \brief Optimize input mesh. + /// \param[in] _meshSdf Mesh SDF DOM with mesh optimization parameters + /// \param[in] _mesh Input mesh to optimize. + /// \return The optimized mesh or null if the mesh can not be optimized. + GZ_SIM_VISIBLE const common::Mesh *optimizeMesh(const sdf::Mesh &_meshSdf, + const common::Mesh &_mesh); + /// \brief Environment variable holding resource paths. const std::string kResourcePathEnv{"GZ_SIM_RESOURCE_PATH"}; diff --git a/src/Util.cc b/src/Util.cc index 8adfedbee7..e9cb2406f0 100644 --- a/src/Util.cc +++ b/src/Util.cc @@ -15,12 +15,17 @@ * */ +#include +#include +#include + #include #include #include #include #include +#include #include #include #include @@ -862,8 +867,81 @@ const common::Mesh *loadMesh(const sdf::Mesh &_meshSdf) << "]." << std::endl; return nullptr; } + + if (mesh && _meshSdf.Optimization() != sdf::MeshOptimization::NONE) + { + const common::Mesh *optimizedMesh = optimizeMesh(_meshSdf, *mesh); + if (optimizedMesh) + return optimizedMesh; + else + gzwarn << "Failed to optimize Mesh " << mesh->Name() << std::endl; + } + return mesh; } + +const common::Mesh *optimizeMesh(const sdf::Mesh &_meshSdf, + const common::Mesh &_mesh) +{ + if (_meshSdf.Optimization() != + sdf::MeshOptimization::CONVEX_DECOMPOSITION && + _meshSdf.Optimization() != + sdf::MeshOptimization::CONVEX_HULL) + return nullptr; + + auto &meshManager = *common::MeshManager::Instance(); + std::size_t maxConvexHulls = 16u; + if (_meshSdf.Optimization() == sdf::MeshOptimization::CONVEX_HULL) + { + /// create 1 convex hull for the whole submesh + maxConvexHulls = 1u; + } + else if (_meshSdf.ConvexDecomposition()) + { + // limit max number of convex hulls to generate + maxConvexHulls = _meshSdf.ConvexDecomposition()->MaxConvexHulls(); + } + // Check if MeshManager contains the decomposed mesh already. If not + // add it to the MeshManager so we do not need to decompose it again. + const std::string convexMeshName = + _mesh.Name() + "_CONVEX_" + std::to_string(maxConvexHulls); + auto *optimizedMesh = meshManager.MeshByName(convexMeshName); + if (!optimizedMesh) + { + // Merge meshes before convex decomposition + auto mergedMesh = gz::common::MeshManager::MergeSubMeshes(_mesh); + if (mergedMesh && mergedMesh->SubMeshCount() == 1u) + { + // Decompose and add mesh to MeshManager + auto mergedSubmesh = mergedMesh->SubMeshByIndex(0u).lock(); + std::vector decomposed = + gz::common::MeshManager::ConvexDecomposition( + *mergedSubmesh.get(), maxConvexHulls); + gzdbg << "Optimizing mesh (" << _meshSdf.OptimizationStr() << "): " + << _mesh.Name() << std::endl; + // Create decomposed mesh and add it to MeshManager + // Note: MeshManager will call delete on this mesh in its destructor + // \todo(iche033) Consider updating MeshManager to accept + // unique pointers instead + common::Mesh *convexMesh = new common::Mesh; + convexMesh->SetName(convexMeshName); + for (const auto & submesh : decomposed) + convexMesh->AddSubMesh(submesh); + meshManager.AddMesh(convexMesh); + if (decomposed.empty()) + { + // Print an error if convex decomposition returned empty submeshes + // but still add it to MeshManager to avoid going through the + // expensive convex decomposition process for the same mesh again + gzerr << "Convex decomposition generated zero meshes: " + << _mesh.Name() << std::endl; + } + optimizedMesh = meshManager.MeshByName(convexMeshName); + } + } + return optimizedMesh; +} + } } } diff --git a/src/Util_TEST.cc b/src/Util_TEST.cc index 6be8d27903..9ec0e9be1a 100644 --- a/src/Util_TEST.cc +++ b/src/Util_TEST.cc @@ -1023,4 +1023,12 @@ TEST_F(UtilTest, LoadMesh) "test", "media", "duck.dae"); meshSdf.SetFilePath(filePath); EXPECT_NE(nullptr, loadMesh(meshSdf)); + + EXPECT_TRUE(meshSdf.SetOptimization("convex_decomposition")); + sdf::ConvexDecomposition convexDecomp; + convexDecomp.SetMaxConvexHulls(16u); + meshSdf.SetConvexDecomposition(convexDecomp); + auto *optimizedMesh = loadMesh(meshSdf); + EXPECT_NE(nullptr, optimizedMesh); + EXPECT_EQ(16u, optimizedMesh->SubMeshCount()); } From 3c52690a085153961429d30307f1b72649365023 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Thu, 30 May 2024 10:16:39 -0700 Subject: [PATCH 4/6] Use VERSION_GREATER_EQUAL in cmake logic (#2418) Signed-off-by: Steve Peters --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 157c55ea0a..8a81a7583d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -255,7 +255,7 @@ foreach(CMD_TEST # to the PATH. This is done via the ENVIRONMENT_MODIFICATION that is only available # since CMake 3.22. However, if an older CMake is used another trick to install the libraries # beforehand - if (WIN32 AND CMAKE_VERSION STRGREATER "3.22") + if (WIN32 AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.22") set_tests_properties(${CMD_TEST} PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() From bd1d057a80bcb7deb91c0ff40bfb35ed8edc3e41 Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Fri, 31 May 2024 08:17:18 -0700 Subject: [PATCH 5/6] Remove a few extra zeros from some sdf files (#2426) Signed-off-by: Nate Koenig --- test/worlds/quadcopter.sdf | 8 ++++---- test/worlds/quadcopter_velocity_control.sdf | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/worlds/quadcopter.sdf b/test/worlds/quadcopter.sdf index bc93489ee5..b45f431aa4 100644 --- a/test/worlds/quadcopter.sdf +++ b/test/worlds/quadcopter.sdf @@ -91,7 +91,7 @@ - 0 0 0 1.57 0 0 0 + 0 0 0 1.57 0 0 0.2 @@ -136,7 +136,7 @@ - 0 0 0 1.57 0 0 0 + 0 0 0 1.57 0 0 0.2 @@ -181,7 +181,7 @@ - 0 0 0 1.57 0 0 0 + 0 0 0 1.57 0 0 0.2 @@ -226,7 +226,7 @@ - 0 0 0 1.57 0 0 0 + 0 0 0 1.57 0 0 0.2 diff --git a/test/worlds/quadcopter_velocity_control.sdf b/test/worlds/quadcopter_velocity_control.sdf index 09390c0274..1650b5852c 100644 --- a/test/worlds/quadcopter_velocity_control.sdf +++ b/test/worlds/quadcopter_velocity_control.sdf @@ -91,7 +91,7 @@ - 0 0 0 1.57 0 0 0 + 0 0 0 1.57 0 0 0.2 @@ -136,7 +136,7 @@ - 0 0 0 1.57 0 0 0 + 0 0 0 1.57 0 0 0.2 @@ -181,7 +181,7 @@ - 0 0 0 1.57 0 0 0 + 0 0 0 1.57 0 0 0.2 @@ -226,7 +226,7 @@ - 0 0 0 1.57 0 0 0 + 0 0 0 1.57 0 0 0.2 From 9e60fdc5dea81344d6b3c9c715ef27f1fc21968a Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Wed, 5 Jun 2024 15:45:57 +0800 Subject: [PATCH 6/6] Optimize rendering sensor pose updates (#2425) --------- Signed-off-by: Ian Chen --- src/rendering/RenderUtil.cc | 93 ++++++------------------------------- 1 file changed, 13 insertions(+), 80 deletions(-) diff --git a/src/rendering/RenderUtil.cc b/src/rendering/RenderUtil.cc index 0c833a60ca..9b2cbf8acd 100644 --- a/src/rendering/RenderUtil.cc +++ b/src/rendering/RenderUtil.cc @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -1323,6 +1324,18 @@ void RenderUtil::Update() gzerr << "Failed to create sensor [" << sensorName << "]" << std::endl; } + else + { + auto sensorNode = this->dataPtr->sceneManager.NodeById(entity); + auto semPose = dataSdf.SemanticPose(); + math::Pose3d sensorPose; + sdf::Errors errors = semPose.Resolve(sensorPose); + if (!errors.empty()) + { + sensorPose = dataSdf.RawPose(); + } + sensorNode->SetLocalPose(sensorPose); + } } } } @@ -2388,86 +2401,6 @@ void RenderUtilPrivate::UpdateRenderingEntities( this->entityPoses[_entity] = _pose->Data(); return true; }); - - // Update cameras - _ecm.Each( - [&](const Entity &_entity, - const components::Camera *, - const components::Pose *_pose)->bool - { - this->entityPoses[_entity] = _pose->Data(); - return true; - }); - - // Update depth cameras - _ecm.Each( - [&](const Entity &_entity, - const components::DepthCamera *, - const components::Pose *_pose)->bool - { - this->entityPoses[_entity] = _pose->Data(); - return true; - }); - - // Update RGBD cameras - _ecm.Each( - [&](const Entity &_entity, - const components::RgbdCamera *, - const components::Pose *_pose)->bool - { - this->entityPoses[_entity] = _pose->Data(); - return true; - }); - - // Update gpu_lidar - _ecm.Each( - [&](const Entity &_entity, - const components::GpuLidar *, - const components::Pose *_pose)->bool - { - this->entityPoses[_entity] = _pose->Data(); - return true; - }); - - // Update thermal cameras - _ecm.Each( - [&](const Entity &_entity, - const components::ThermalCamera *, - const components::Pose *_pose)->bool - { - this->entityPoses[_entity] = _pose->Data(); - return true; - }); - - // Update segmentation cameras - _ecm.Each( - [&](const Entity &_entity, - const components::SegmentationCamera *, - const components::Pose *_pose)->bool - { - this->entityPoses[_entity] = _pose->Data(); - return true; - }); - - // Update bounding box cameras - _ecm.Each( - [&](const Entity &_entity, - const components::BoundingBoxCamera *, - const components::Pose *_pose)->bool - { - this->entityPoses[_entity] = _pose->Data(); - return true; - }); - - // Update wide angle cameras - _ecm.Each( - [&](const Entity &_entity, - const components::WideAngleCamera *, - const components::Pose *_pose)->bool - { - this->entityPoses[_entity] = _pose->Data(); - return true; - }); } //////////////////////////////////////////////////