Skip to content

Commit

Permalink
Merge branch 'gz-sim9' into Amal-python-system-GIL
Browse files Browse the repository at this point in the history
  • Loading branch information
AmalDevHaridevan authored Dec 11, 2024
2 parents 26f69d8 + 6f7d21f commit b5f7862
Show file tree
Hide file tree
Showing 19 changed files with 381 additions and 49 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ find_package(gz-cmake4 REQUIRED)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

gz_configure_project(VERSION_SUFFIX pre1)
gz_configure_project(VERSION_SUFFIX)

#============================================================================
# Set project-specific options
Expand Down
75 changes: 74 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,82 @@
## Gazebo Sim 9.x

### Gazebo Sim 9.0.0 (2024-09-XX)
### Gazebo Sim 9.0.0 (2024-09-25)

1. **Baseline:** this includes all changes from 8.6.0 and earlier.

1. Miscellaneous documentation fixes
* [Pull request #2634](https://github.com/gazebosim/gz-sim/pull/2634)
* [Pull request #2632](https://github.com/gazebosim/gz-sim/pull/2632)
* [Pull request #2628](https://github.com/gazebosim/gz-sim/pull/2628)
* [Pull request #2631](https://github.com/gazebosim/gz-sim/pull/2631)
* [Pull request #2627](https://github.com/gazebosim/gz-sim/pull/2627)
* [Pull request #2625](https://github.com/gazebosim/gz-sim/pull/2625)
* [Pull request #2622](https://github.com/gazebosim/gz-sim/pull/2622)
* [Pull request #2607](https://github.com/gazebosim/gz-sim/pull/2607)
* [Pull request #2606](https://github.com/gazebosim/gz-sim/pull/2606)
* [Pull request #2602](https://github.com/gazebosim/gz-sim/pull/2602)
* [Pull request #2601](https://github.com/gazebosim/gz-sim/pull/2601)
* [Pull request #2603](https://github.com/gazebosim/gz-sim/pull/2603)
* [Pull request #2578](https://github.com/gazebosim/gz-sim/pull/2578)
* [Pull request #2592](https://github.com/gazebosim/gz-sim/pull/2592)
* [Pull request #2582](https://github.com/gazebosim/gz-sim/pull/2582)
* [Pull request #2585](https://github.com/gazebosim/gz-sim/pull/2585)
* [Pull request #2576](https://github.com/gazebosim/gz-sim/pull/2576)
* [Pull request #2573](https://github.com/gazebosim/gz-sim/pull/2573)
* [Pull request #2571](https://github.com/gazebosim/gz-sim/pull/2571)
* [Pull request #2574](https://github.com/gazebosim/gz-sim/pull/2574)
* [Pull request #2564](https://github.com/gazebosim/gz-sim/pull/2564)
* [Pull request #2563](https://github.com/gazebosim/gz-sim/pull/2563)
* [Pull request #2562](https://github.com/gazebosim/gz-sim/pull/2562)
* [Pull request #2553](https://github.com/gazebosim/gz-sim/pull/2553)

1. Fix log playback GUI display
* [Pull request #2611](https://github.com/gazebosim/gz-sim/pull/2611)
* [Pull request #2619](https://github.com/gazebosim/gz-sim/pull/2619)

1. Add tutorial + example SDF for shadow texture size
* [Pull request #2597](https://github.com/gazebosim/gz-sim/pull/2597)

1. Fix making breadcrumb static if it's a nested model
* [Pull request #2593](https://github.com/gazebosim/gz-sim/pull/2593)

1. Update physics system error msg when plugin can not be loaded
* [Pull request #2604](https://github.com/gazebosim/gz-sim/pull/2604)

1. Fix configuring global illumination GUI plugin parameters
* [Pull request #2594](https://github.com/gazebosim/gz-sim/pull/2594)

1. Fix particle emitter color range image path warning
* [Pull request #2560](https://github.com/gazebosim/gz-sim/pull/2560)

1. Fix empty gui world file
* [Pull request #2591](https://github.com/gazebosim/gz-sim/pull/2591)

1. Fix crash on windows due to invalid log directory path
* [Pull request #2589](https://github.com/gazebosim/gz-sim/pull/2589)

1. Use ogre2 for DEM worlds
* [Pull request #2586](https://github.com/gazebosim/gz-sim/pull/2586)

1. Fix crash when running the optical tactile sensor world
* [Pull request #2561](https://github.com/gazebosim/gz-sim/pull/2561)

1. Prevent follow actor plugin from crashing when actor is removed
* [Pull request #2577](https://github.com/gazebosim/gz-sim/pull/2577)
* [Pull request #2584](https://github.com/gazebosim/gz-sim/pull/2584)

1. Fix hydrodynamics deprecation warning.
* [Pull request #2579](https://github.com/gazebosim/gz-sim/pull/2579)

1. Removed actor population world due to bad merge
* [Pull request #2581](https://github.com/gazebosim/gz-sim/pull/2581)

1. Fixed warning joint trayectory sdf
* [Pull request #2580](https://github.com/gazebosim/gz-sim/pull/2580)

1. Fix looking up camera name in camera lens system
* [Pull request #2559](https://github.com/gazebosim/gz-sim/pull/2559)

1. Add a flexible mechanism to combine user and default plugins
* [Pull request #2497](https://github.com/gazebosim/gz-sim/pull/2497)

Expand Down
2 changes: 1 addition & 1 deletion examples/plugin/custom_sensor_system/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ include(FetchContent)
FetchContent_Declare(
sensors_clone
GIT_REPOSITORY https://github.com/gazebosim/gz-sensors
GIT_TAG main
GIT_TAG gz-sensors${GZ_SENSORS_VER}
)
FetchContent_Populate(sensors_clone)
add_subdirectory(${sensors_clone_SOURCE_DIR}/examples/custom_sensor ${sensors_clone_BINARY_DIR})
Expand Down
20 changes: 20 additions & 0 deletions include/gz/sim/Link.hh
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ namespace gz
public: sim::Entity CollisionByName(const EntityComponentManager &_ecm,
const std::string &_name) const;

/// \brief Get the ID of a sensor entity which is an immediate child of
/// this link.
/// \param[in] _ecm Entity-component manager.
/// \param[in] _name Sensor name.
/// \return Sensor entity.
public: sim::Entity SensorByName(const EntityComponentManager &_ecm,
const std::string &_name) const;

/// \brief Get the ID of a visual entity which is an immediate child of
/// this link.
/// \param[in] _ecm Entity-component manager.
Expand All @@ -150,6 +158,12 @@ namespace gz
public: std::vector<sim::Entity> Collisions(
const EntityComponentManager &_ecm) const;

/// \brief Get all sensors which are immediate children of this link.
/// \param[in] _ecm Entity-component manager.
/// \return All sensors in this link.
public: std::vector<sim::Entity> Sensors(
const EntityComponentManager &_ecm) const;

/// \brief Get all visuals which are immediate children of this link.
/// \param[in] _ecm Entity-component manager.
/// \return All visuals in this link.
Expand All @@ -162,6 +176,12 @@ namespace gz
/// \return Number of collisions in this link.
public: uint64_t CollisionCount(const EntityComponentManager &_ecm) const;

/// \brief Get the number of sensors which are immediate children of this
/// link.
/// \param[in] _ecm Entity-component manager.
/// \return Number of sensors in this link.
public: uint64_t SensorCount(const EntityComponentManager &_ecm) const;

/// \brief Get the number of visuals which are immediate children of this
/// link.
/// \param[in] _ecm Entity-component manager.
Expand Down
25 changes: 19 additions & 6 deletions include/gz/sim/components/Model.hh
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,18 @@ namespace serializers
}
}

_out << "<?xml version=\"1.0\" ?>"
<< "<sdf version='" << SDF_PROTOCOL_VERSION << "'>"
<< (skip ? std::string() : modelElem->ToString(""))
<< "</sdf>";
if (!skip)
{
_out << "<?xml version=\"1.0\" ?>"
<< "<sdf version='" << SDF_PROTOCOL_VERSION << "'>"
<< modelElem->ToString("")
<< "</sdf>";

}
else
{
_out << "";
}
return _out;
}

Expand All @@ -89,13 +97,18 @@ namespace serializers
public: static std::istream &Deserialize(std::istream &_in,
sdf::Model &_model)
{
sdf::Root root;
std::string sdf(std::istreambuf_iterator<char>(_in), {});
if (sdf.empty())
{
return _in;
}

// Its super expensive to create an SDFElement for some reason
sdf::Root root;
sdf::Errors errors = root.LoadSdfString(sdf);
if (!root.Model())
{
gzwarn << "Unable to deserialize sdf::Model" << std::endl;
gzwarn << "Unable to deserialize sdf::Model " << sdf<< std::endl;
return _in;
}

Expand Down
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ if (BUILD_TESTING)
endif()

set(_env_vars)
list(APPEND _env_vars "PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/python/")
list(APPEND _env_vars "PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/python/:$ENV{PYTHONPATH}")
list(APPEND _env_vars "LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}:$ENV{LD_LIBRARY_PATH}")
set_tests_properties(${test} PROPERTIES
ENVIRONMENT "${_env_vars}")
Expand Down
12 changes: 12 additions & 0 deletions python/src/gz/sim/Link.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ void defineSimLink(py::object module)
py::arg("name"),
"Get the ID of a collision entity which is an immediate child of "
"this link.")
.def("sensor_by_name", &gz::sim::Link::SensorByName,
py::arg("ecm"),
py::arg("name"),
"Get the ID of a sensor entity which is an immediate child of "
"this link.")
.def("visual_by_name", &gz::sim::Link::VisualByName,
py::arg("ecm"),
py::arg("name"),
Expand All @@ -65,13 +70,20 @@ void defineSimLink(py::object module)
.def("collisions", &gz::sim::Link::Collisions,
py::arg("ecm"),
"Get all collisions which are immediate children of this link.")
.def("sensors", &gz::sim::Link::Sensors,
py::arg("ecm"),
"Get all sensors which are immediate children of this link.")
.def("visuals", &gz::sim::Link::Visuals,
py::arg("ecm"),
"Get all visuals which are immediate children of this link.")
.def("collision_count", &gz::sim::Link::CollisionCount,
py::arg("ecm"),
"Get the number of collisions which are immediate children of "
"this link.")
.def("sensor_count", &gz::sim::Link::SensorCount,
py::arg("ecm"),
"Get the number of sensors which are immediate children of this "
"link.")
.def("visual_count", &gz::sim::Link::VisualCount,
py::arg("ecm"),
"Get the number of visuals which are immediate children of this "
Expand Down
3 changes: 3 additions & 0 deletions python/test/link_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def on_pre_udpate_cb(_info, _ecm):
# Collisions Test
self.assertNotEqual(K_NULL_ENTITY, link.collision_by_name(_ecm, 'collision_test'))
self.assertEqual(1, link.collision_count(_ecm))
# Sensors Test
self.assertNotEqual(K_NULL_ENTITY, link.sensor_by_name(_ecm, 'my_sensor'))
self.assertEqual(1, link.sensor_count(_ecm))
# Visuals Test
self.assertNotEqual(K_NULL_ENTITY, link.visual_by_name(_ecm, 'visual_test'))
self.assertEqual(1, link.visual_count(_ecm))
Expand Down
20 changes: 20 additions & 0 deletions src/EntityComponentManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "gz/sim/components/CanonicalLink.hh"
#include "gz/sim/components/ChildLinkName.hh"
#include "gz/sim/components/Component.hh"
#include "gz/sim/components/DetachableJoint.hh"
#include "gz/sim/components/Factory.hh"
#include "gz/sim/components/Joint.hh"
#include "gz/sim/components/Link.hh"
Expand Down Expand Up @@ -711,6 +712,25 @@ void EntityComponentManager::RequestRemoveEntity(Entity _entity,
else
{
this->dataPtr->InsertEntityRecursive(_entity, tmpToRemoveEntities);

// remove detachable joint entities that are connected to
// any of the entities to be removed
std::unordered_set<Entity> detachableJoints;
this->Each<components::DetachableJoint>(
[&](const Entity &_jointEntity,
const components::DetachableJoint *_jointInfo) -> bool
{
Entity parentLinkEntity = _jointInfo->Data().parentLink;
Entity childLinkEntity = _jointInfo->Data().childLink;
if (tmpToRemoveEntities.find(parentLinkEntity) !=
tmpToRemoveEntities.end() ||
tmpToRemoveEntities.find(childLinkEntity) !=
tmpToRemoveEntities.end())
detachableJoints.insert(_jointEntity);
return true;
});
tmpToRemoveEntities.insert(detachableJoints.begin(),
detachableJoints.end());
}

// Remove entities from tmpToRemoveEntities that are marked as
Expand Down
25 changes: 25 additions & 0 deletions src/Link.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "gz/sim/components/Name.hh"
#include "gz/sim/components/ParentEntity.hh"
#include "gz/sim/components/Pose.hh"
#include "gz/sim/components/Sensor.hh"
#include "gz/sim/components/Visual.hh"
#include "gz/sim/components/WindMode.hh"
#include "gz/sim/Util.hh"
Expand Down Expand Up @@ -126,6 +127,16 @@ Entity Link::CollisionByName(const EntityComponentManager &_ecm,
components::Collision());
}

//////////////////////////////////////////////////
Entity Link::SensorByName(const EntityComponentManager &_ecm,
const std::string &_name) const
{
return _ecm.EntityByComponents(
components::ParentEntity(this->dataPtr->id),
components::Name(_name),
components::Sensor());
}

//////////////////////////////////////////////////
Entity Link::VisualByName(const EntityComponentManager &_ecm,
const std::string &_name) const
Expand All @@ -144,6 +155,14 @@ std::vector<Entity> Link::Collisions(const EntityComponentManager &_ecm) const
components::Collision());
}

//////////////////////////////////////////////////
std::vector<Entity> Link::Sensors(const EntityComponentManager &_ecm) const
{
return _ecm.EntitiesByComponents(
components::ParentEntity(this->dataPtr->id),
components::Sensor());
}

//////////////////////////////////////////////////
std::vector<Entity> Link::Visuals(const EntityComponentManager &_ecm) const
{
Expand All @@ -158,6 +177,12 @@ uint64_t Link::CollisionCount(const EntityComponentManager &_ecm) const
return this->Collisions(_ecm).size();
}

//////////////////////////////////////////////////
uint64_t Link::SensorCount(const EntityComponentManager &_ecm) const
{
return this->Sensors(_ecm).size();
}

//////////////////////////////////////////////////
uint64_t Link::VisualCount(const EntityComponentManager &_ecm) const
{
Expand Down
Loading

0 comments on commit b5f7862

Please sign in to comment.