diff --git a/Changelog.md b/Changelog.md index 7508cae2a5..9ad8583183 100644 --- a/Changelog.md +++ b/Changelog.md @@ -155,7 +155,25 @@ ## Ignition Gazebo 3.x -### Ignition Gazebo 3.X.X (20XX-XX-XX) +### Ignition Gazebo 3.7.0 (2021-01-13) + +1. Fix examples in migration plugins tutorial. + * [Pull Request 543](https://github.com/ignitionrobotics/ign-gazebo/pull/543) + +1. Added missing namespace in `detail/EntityComponentManager.hh`. + * [Pull Request 541](https://github.com/ignitionrobotics/ign-gazebo/pull/541) + +1. Automatically load a subset of world plugins. + * [Pull Request 281](https://github.com/ignitionrobotics/ign-gazebo/pull/281) + +1. Update gtest to 1.10.0 for Windows compilation. + * [Pull Request 506](https://github.com/ignitionrobotics/ign-gazebo/pull/506) + +1. Updates to ardupilot migration tutorial. + * [Pull Request 525](https://github.com/ignitionrobotics/ign-gazebo/pull/525) + +1. Don't make docs on macOS. + * [Pull Request 528](https://github.com/ignitionrobotics/ign-gazebo/pull/528) ### Ignition Gazebo 3.6.0 (2020-12-30) diff --git a/include/ignition/gazebo/detail/EntityComponentManager.hh b/include/ignition/gazebo/detail/EntityComponentManager.hh index 027baf355c..880dba745c 100644 --- a/include/ignition/gazebo/detail/EntityComponentManager.hh +++ b/include/ignition/gazebo/detail/EntityComponentManager.hh @@ -32,6 +32,8 @@ namespace ignition { namespace gazebo { +// Inline bracket to help doxygen filtering. +inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE { ////////////////////////////////////////////////// namespace traits { @@ -547,5 +549,6 @@ bool EntityComponentManager::RemoveComponent(Entity _entity) } } } +} #endif diff --git a/tutorials/migration_plugins.md b/tutorials/migration_plugins.md index 25a87cfb60..a84271249b 100644 --- a/tutorials/migration_plugins.md +++ b/tutorials/migration_plugins.md @@ -103,6 +103,11 @@ On Ignition Gazebo, that would be implemented as follows: #include #include #include +#include + +using namespace ignition; +using namespace gazebo; +using namespace systems; // Inherit from System and 2 extra interfaces: // ISystemConfigure and ISystemPostUpdate @@ -113,25 +118,25 @@ class MyPlugin { // Implement Configure callback, provided by ISystemConfigure // and called once at startup. - void MyPlugin::Configure(const Entity &_entity, - const std::shared_ptr &_sdf, - EntityComponentManager &_ecm, - EventManager &/*_eventMgr*/) + virtual void Configure(const Entity &_entity, + const std::shared_ptr &_sdf, + EntityComponentManager &_ecm, + EventManager &/*_eventMgr*/) override { // Read property from SDF auto linkName = _sdf->Get("link_name"); - // Create model object, to access convenient functions + // Create model object to access convenient functions auto model = Model(_entity); // Get link entity - auto linkEntity = model->LinkByName(_ecm, linkName); + this->linkEntity = model.LinkByName(_ecm, linkName); } // Implement PostUpdate callback, provided by ISystemPostUpdate // and called at every iteration, after physics is done - void MyPlugin::PostUpdate(const UpdateInfo &/*_info*/, - const EntityComponentManager &_ecm) + virtual void PostUpdate(const UpdateInfo &/*_info*/, + const EntityComponentManager &_ecm) override { // Get link pose and print it std::cout << worldPose(this->linkEntity, _ecm) << std::endl; @@ -149,7 +154,7 @@ IGNITION_ADD_PLUGIN(MyPlugin, // Add plugin alias so that we can refer to the plugin without the version // namespace -IGNITION_ADD_PLUGIN_ALIAS(MyPlugin,"ignition::gazebo::systems::MyPlugin") +IGNITION_ADD_PLUGIN_ALIAS(MyPlugin, "ignition::gazebo::systems::MyPlugin") ``` The example above uses headers like `Model.hh` and `Util.hh`, which offer @@ -161,6 +166,15 @@ the ECM's API: ```cpp #include #include +#include +#include +#include +#include +#include + +using namespace ignition; +using namespace gazebo; +using namespace systems; // Inherit from System and 2 extra interfaces: // ISystemConfigure and ISystemPostUpdate @@ -169,43 +183,43 @@ class MyPlugin public ISystemConfigure, public ISystemPostUpdate { - void MyPlugin::Configure(const Entity &_entity, - const std::shared_ptr &_sdf, - EntityComponentManager &_ecm, - EventManager &/*_eventMgr*/) + virtual void Configure(const Entity &_entity, + const std::shared_ptr &_sdf, + EntityComponentManager &_ecm, + EventManager &/*_eventMgr*/) override { + // Read property from SDF auto linkName = _sdf->Get("link_name"); - // Create link entity by querying for an entity that has a specific set of + // Get link entity by querying for an entity that has a specific set of // components this->linkEntity = _ecm.EntityByComponents( - components::ParentEntity(this->dataPtr->id), - components::Name(_name), - components::Link()); + components::ParentEntity(_entity), + components::Name(linkName), components::Link()); } - void MyPlugin::PostUpdate(const UpdateInfo &/*_info*/, - const EntityComponentManager &_ecm) + virtual void PostUpdate(const UpdateInfo &/*_info*/, + const EntityComponentManager &_ecm) override { // Get link's local pose auto pose = _ecm.Component(this->linkEntity)->Data(); // Get link's parent entity - auto p = _ecm.Component(this->linkEntity); + auto parent = _ecm.Component(this->linkEntity); // Iterate over parents until world is reached - while (p) + while (parent) { // Get parent entity's pose - auto parentPose = _ecm.Component(p->Data()); + auto parentPose = _ecm.Component(parent->Data()); if (!parentPose) break; // Add pose - pose = pose + parentPose->Data(); + pose = parentPose->Data() * pose; // keep going up the tree - p = _ecm.Component(p->Data()); + parent = _ecm.Component(parent->Data()); } std::cout << pose << std::endl; @@ -220,7 +234,7 @@ IGNITION_ADD_PLUGIN(MyPlugin, MyPlugin::ISystemConfigure, MyPlugin::ISystemPostUpdate) -IGNITION_ADD_PLUGIN_ALIAS(MyPlugin,"ignition::gazebo::systems::MyPlugin") +IGNITION_ADD_PLUGIN_ALIAS(MyPlugin, "ignition::gazebo::systems::MyPlugin") ``` In summary, the key differences between Gazebo Classic and Ignition Gazebo are: @@ -234,7 +248,7 @@ In summary, the key differences between Gazebo Classic and Ignition Gazebo are: * Plugins don't have direct access to physics objects such as `physics::Model`. Instead, they can either deal directly with entities and their components by - calling functions in the ECM, or using convenient objects such as + calling functions of the ECM, or use convenient objects such as `ignition::gazebo::Model` which wrap the ECM interface. All these changes are meant to give plugin developers more flexibility to