Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add system to an entity through Component Inspector #1549

Merged
merged 58 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
0896ac1
Added more tests
Feb 11, 2022
60be532
merged with ign-gazebo6
Feb 11, 2022
2770692
Change clone
Feb 16, 2022
4a9822b
Use sdf::Plugin instead of sdf::ElementPtr
Feb 16, 2022
f32555b
Address review comments
Feb 16, 2022
171d745
Merge branch 'ign-gazebo6' into server-config-root-dom
mjcarroll Feb 16, 2022
7d33cf0
Fix linter, and added tests
Feb 16, 2022
7fedd8d
Merge branch 'server-config-root-dom' of github.com:ignitionrobotics/…
Feb 16, 2022
756e818
Merge branch 'ign-gazebo6' into use_sdf_plugin
Feb 28, 2022
087225e
Merge branch 'ign-gazebo6' into server-config-root-dom
nkoenig Feb 28, 2022
f2ad40b
Merge branch 'ign-gazebo6' into use_sdf_plugin
Mar 8, 2022
f27ec9c
Merge branch 'use_sdf_plugin' of github.com:ignitionrobotics/ign-gaze…
Mar 8, 2022
713f3ba
Merge branch 'ign-gazebo6' into server-config-root-dom
nkoenig Mar 8, 2022
711761d
Update branch
Mar 9, 2022
1b48c9d
Merge branch 'use_sdf_plugin' of github.com:ignitionrobotics/ign-gaze…
Mar 9, 2022
7ac1b4e
Merged with server-config-root-dom
Mar 9, 2022
d60d34a
Tweaks
Mar 9, 2022
bb3d2a6
Merge branch 'ign-gazebo6' into server-config-root-dom
nkoenig Mar 14, 2022
1469cd3
Merge branch 'server-config-root-dom' into use_sdf_plugin
Mar 14, 2022
ae00505
Updates to match garden forward port
Mar 14, 2022
f23935c
Updated documentation and minor cleanup
Mar 14, 2022
0402553
Merge branch 'ign-gazebo6' into server-config-root-dom
ahcorde Mar 15, 2022
146ecf9
Merge branch 'ign-gazebo6' into server-config-root-dom
nkoenig Mar 15, 2022
71ee327
Merge branch 'ign-gazebo6' into server-config-root-dom
nkoenig Mar 15, 2022
d0695a4
use sdf 12.4
Mar 16, 2022
977847e
Merge branch 'ign-gazebo6' into server-config-root-dom
nkoenig Mar 18, 2022
3af47f1
Merge branch 'ign-gazebo6' into server-config-root-dom
Mar 24, 2022
c6cd141
Merge branch 'server-config-root-dom' into use_sdf_plugin
Mar 24, 2022
e0d90ce
Merged from ign-gazebo6
Apr 4, 2022
aa28fec
Merge branch 'ign-gazebo6' into use_sdf_plugin
nkoenig Apr 7, 2022
3ae56ea
merged with ign-gazebo6
Apr 21, 2022
611e9aa
Merge branch 'use_sdf_plugin' of github.com:ignitionrobotics/ign-gaze…
Apr 21, 2022
a1b5953
Merge branch 'ign-gazebo6' into use_sdf_plugin
May 13, 2022
fd2b9b1
resolve some comments
May 13, 2022
61fcf05
Resolve issue #1363
May 13, 2022
15d31a9
Merge branch 'ign-gazebo6' into use_sdf_plugin
Jun 8, 2022
c3dbeb7
Remove components::VisualPlugins
Jun 8, 2022
cd39a3d
Merge branch 'ign-gazebo6' into use_sdf_plugin
nkoenig Jun 15, 2022
a78dc39
add system to entity
iche033 Jun 7, 2022
780a569
add integration test
iche033 Jun 7, 2022
b88aa15
remove debug msgs
iche033 Jun 7, 2022
ce0cbd1
doc
iche033 Jun 7, 2022
38beefc
doc
iche033 Jun 7, 2022
278579d
add test world
iche033 Jun 7, 2022
1e22d2c
use new LoadPlugin function
iche033 Jun 15, 2022
0ec7ad1
remove line
iche033 Jun 15, 2022
4695b88
check empty plugins, update issue url
iche033 Jun 15, 2022
8335ebd
keep node namespace
iche033 Jun 16, 2022
9dcbaf9
add button in component inspector for adding system to a model
iche033 Jun 22, 2022
da4f16a
model -> entity
iche033 Jun 23, 2022
6cbf8fb
merged from ign-gazebo6
chapulina Jun 23, 2022
0dba7aa
Merge branch 'ign-gazebo6' into entity_system_add_gui
chapulina Jun 23, 2022
d7503c5
add world
iche033 Jun 25, 2022
b247ce4
Merge branch 'ign-gazebo6' into entity_system_add_gui
iche033 Jun 25, 2022
0811e9c
Merge branch 'ign-gazebo6' into entity_system_add_gui
iche033 Jul 7, 2022
e4217d9
Merge branch 'ign-gazebo6' into entity_system_add_gui
chapulina Jul 28, 2022
e58ac69
Populate Add System dialog's filename list (#1581)
iche033 Jul 29, 2022
f14b79c
cppcheck
chapulina Jul 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions include/ignition/gazebo/Conversions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <ignition/msgs/light.pb.h>
#include <ignition/msgs/material.pb.h>
#include <ignition/msgs/particle_emitter.pb.h>
#include <ignition/msgs/plugin.pb.h>
#include <ignition/msgs/plugin_v.pb.h>
#include <ignition/msgs/physics.pb.h>
#include <ignition/msgs/scene.pb.h>
#include <ignition/msgs/sensor.pb.h>
Expand Down Expand Up @@ -742,6 +744,54 @@ namespace ignition
/// \return Plugin message.
template<>
msgs::Plugin convert(const sdf::Plugin &_in);

/// \brief Generic conversion from an SDF plugins to another type.
/// \param[in] _in SDF plugins.
/// \return Conversion result.
/// \tparam Out Output type.
template<class Out>
Out convert(const sdf::Plugins &/*_in*/)
{
Out::ConversionNotImplemented;
}

/// \brief Specialized conversion from an SDF plugins to a plugin_v message.
/// \param[in] _in SDF plugins.
/// \return Plugin_V message.
template<>
msgs::Plugin_V convert(const sdf::Plugins &_in);

/// \brief Generic conversion from a msgs::Plugin to another type.
/// \param[in] _in msgs::Plugin.
/// \return Conversion result.
/// \tparam Out Output type.
template<class Out>
Out convert(const msgs::Plugin &/*_in*/)
{
Out::ConversionNotImplemented;
}

/// \brief Specialized conversion from a msgs::Plugin to an sdf::Plugin.
/// \param[in] _in msgs::Plugin.
/// \return sdf::Plugin.
template<>
sdf::Plugin convert(const sdf::Plugin &_in);

/// \brief Generic conversion from a msgs::Plugin_V to another type.
/// \param[in] _in msgs::Plugin_V.
/// \return Conversion result.
/// \tparam Out Output type.
template<class Out>
Out convert(const msgs::Plugin_V &/*_in*/)
{
Out::ConversionNotImplemented;
}

/// \brief Specialized conversion from a msgs::Plugin_V to an sdf::Plugins.
/// \param[in] _in msgs::Plugin_V.
/// \return sdf::Plugins.
template<>
sdf::Plugins convert(const msgs::Plugin_V &_in);
}
}
}
Expand Down
16 changes: 15 additions & 1 deletion include/ignition/gazebo/Events.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define IGNITION_GAZEBO_EVENTS_HH_

#include <sdf/Element.hh>
#include <sdf/Plugin.hh>

#include <ignition/common/Event.hh>

Expand Down Expand Up @@ -53,11 +54,24 @@ namespace ignition
/// \endcode
using Stop = ignition::common::EventT<void(void), struct StopTag>;

/// \brief Event used to load plugins for an entity into simulation.
/// \brief Please use the LoadSdfPlugins event. The LoadPlugins event
/// will be deprecrated in Gazebo 7 (Garden). Also make sure to
/// connect to only LoadSdfPlugins or LoadPlugins, and not both events.
///
/// Event used to load plugins for an entity into simulation.
/// Pass in the entity which will own the plugins, and an SDF element for
/// the entity, which may contain multiple `<plugin>` tags.
/// \note This will be deprecated in Gazebo 7 (Garden), please the use
/// sdf::Plugin interface.
using LoadPlugins = common::EventT<void(Entity, sdf::ElementPtr),
struct LoadPluginsTag>;

/// \brief Event used to load plugins for an entity into simulation.
/// Pass in the entity which will own the plugins, and an SDF element for
/// the entity, which may contain multiple `<plugin>` tags.
/// Makre sure that you don't also connect to the LoadPlugins event.
using LoadSdfPlugins = common::EventT<void(Entity, sdf::Plugins),
struct LoadPluginsTag>;
}
} // namespace events
} // namespace gazebo
Expand Down
39 changes: 39 additions & 0 deletions include/ignition/gazebo/ServerConfig.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <string>
#include <vector>
#include <sdf/Element.hh>
#include <sdf/Plugin.hh>
#include <sdf/Root.hh>
#include <ignition/gazebo/config.hh>
#include <ignition/gazebo/Export.hh>
Expand Down Expand Up @@ -86,12 +87,26 @@ namespace ignition
/// \param[in] _name Name of the interface within the plugin library
/// to load.
/// \param[in] _sdf Plugin XML elements associated with this plugin.
/// \note This will be deprecated in Gazebo 7 (Garden), please the use
/// sdf::Plugin interface.
public: PluginInfo(const std::string &_entityName,
const std::string &_entityType,
const std::string &_filename,
const std::string &_name,
const sdf::ElementPtr &_sdf);

/// \brief Constructor with plugin information specified.
/// \param[in] _entityName Name of the entity which should receive
/// this plugin. The name is used in conjuction with _entityType to
/// uniquely identify an entity.
/// \param[in] _entityType Entity type which should receive this
/// plugin. The type is used in conjuction with _entityName to
/// uniquely identify an entity.
/// \param[in] _plugin SDF Plugin library information.
public: PluginInfo(const std::string &_entityName,
const std::string &_entityType,
const sdf::Plugin &_plugin);

/// \brief Copy constructor.
/// \param[in] _info Plugin to copy.
public: PluginInfo(const PluginInfo &_info);
Expand Down Expand Up @@ -127,32 +142,56 @@ namespace ignition

/// \brief Get the plugin library filename.
/// \return Plugin library filename.
/// \note This will be deprecated in Gazebo 7 (Garden), please the use
/// sdf::Plugin interface.
public: const std::string &Filename() const;

/// \brief Set the type of the entity which should receive this
/// plugin. The type is used in conjuction with EntityName to
/// uniquely identify an entity.
/// \param[in] _filename Entity type string.
/// \note This will be deprecated in Gazebo 7 (Garden), please the use
/// sdf::Plugin interface.
public: void SetFilename(const std::string &_filename);

/// \brief Name of the interface within the plugin library
/// to load.
/// \return Interface name.
/// \note This will be deprecated in Gazebo 7 (Garden), please the use
/// sdf::Plugin interface.
public: const std::string &Name() const;

/// \brief Set the name of the interface within the plugin library
/// to load.
/// \param[in] _name Interface name.
/// \note This will be deprecated in Gazebo 7 (Garden), please the use
/// sdf::Plugin interface.
public: void SetName(const std::string &_name);

/// \brief Plugin XML elements associated with this plugin.
/// \return SDF pointer.
/// \note This will be deprecated in Gazebo 7 (Garden), please the use
/// sdf::Plugin interface.
public: const sdf::ElementPtr &Sdf() const;

/// \brief Set the plugin XML elements associated with this plugin.
/// \param[in] _sdf SDF pointer, it will be cloned.
/// \note This will be deprecated in Gazebo 7 (Garden), please the use
/// sdf::Plugin interface.
public: void SetSdf(const sdf::ElementPtr &_sdf);

/// \brief Get the SDF plugin information.
/// \return The SDF Plugin object.
public: const sdf::Plugin &Plugin() const;

/// \brief Get a mutable version of the SDF plugin information.
/// \return The SDF Plugin object.
public: sdf::Plugin &Plugin();

/// \brief Set the SDF plugin information.
/// \param[in] _plugin The SDF Plugin object to use.
public: void SetPlugin(const sdf::Plugin &_plugin) const;

/// \brief Private data pointer
private: std::unique_ptr<ServerConfig::PluginInfoPrivate> dataPtr;
};
Expand Down
11 changes: 11 additions & 0 deletions include/ignition/gazebo/SystemLoader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <string>

#include <sdf/Element.hh>
#include <sdf/Plugin.hh>

#include <ignition/gazebo/Export.hh>
#include <ignition/gazebo/System.hh>
Expand Down Expand Up @@ -53,6 +54,8 @@ namespace ignition
/// \brief Load and instantiate system plugin from an SDF element.
/// \param[in] _sdf SDF Element describing plugin instance to be loaded.
/// \returns Shared pointer to system instance or nullptr.
/// \note This will be deprecated in Gazebo 7 (Garden), please the use
/// sdf::Plugin interface.
public: std::optional<SystemPluginPtr> LoadPlugin(
const sdf::ElementPtr &_sdf);

Expand All @@ -61,11 +64,19 @@ namespace ignition
/// \param[in] _name Class name to be instantiated.
/// \param[in] _sdf SDF Element describing plugin instance to be loaded.
/// \returns Shared pointer to system instance or nullptr.
/// \note This will be deprecated in Gazebo 7 (Garden), please the use
/// sdf::Plugin interface.
public: std::optional<SystemPluginPtr> LoadPlugin(
const std::string &_filename,
const std::string &_name,
const sdf::ElementPtr &_sdf);

/// \brief Load and instantiate system plugin from name/filename.
/// \param[in] _plugin SDF Plugin to be loaded.
/// \returns Shared pointer to system instance or nullptr.
public: std::optional<SystemPluginPtr> LoadPlugin(
const sdf::Plugin &_plugin);

/// \brief Makes a printable string with info about systems
/// \returns A pretty string
public: std::string PrettyStr() const;
Expand Down
25 changes: 25 additions & 0 deletions include/ignition/gazebo/gui/GuiEvents.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <ignition/math/Vector3.hh>
#include <ignition/utils/ImplPtr.hh>
#include <sdf/Element.hh>
#include <sdf/Plugin.hh>

#include "ignition/gazebo/gui/Export.hh"
#include "ignition/gazebo/Entity.hh"
Expand Down Expand Up @@ -215,6 +216,8 @@ namespace events
};

/// \brief Event that notifies a visual plugin is to be loaded
/// \note This will be deprecated in Gazebo 7 (Garden), please the use
/// VisualPlugins class.
class IGNITION_GAZEBO_GUI_VISIBLE VisualPlugin: public QEvent
{
/// \brief Constructor
Expand All @@ -235,6 +238,28 @@ namespace events
/// \brief Private data pointer
IGN_UTILS_IMPL_PTR(dataPtr)
};

/// \brief Event that notifies a visual plugin is to be loaded
class IGNITION_GAZEBO_GUI_VISIBLE VisualPlugins: public QEvent
{
/// \brief Constructor
/// \param[in] _entity Visual entity id
/// \param[in] _plugins SDF plugin object
public: explicit VisualPlugins(ignition::gazebo::Entity _entity,
const sdf::Plugins &_plugins);

/// \brief Get the entity to load the visual plugin for
public: ignition::gazebo::Entity Entity() const;

/// \brief Get the SDF Plugin of the visual plugin
public: const sdf::Plugins &Plugins() const;

static const QEvent::Type kType = QEvent::Type(QEvent::User + 8);

/// \internal
/// \brief Private data pointer
IGN_UTILS_IMPL_PTR(dataPtr)
};
} // namespace events
}
} // namespace gui
Expand Down
32 changes: 32 additions & 0 deletions src/Conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1792,3 +1792,35 @@ msgs::Plugin ignition::gazebo::convert(const sdf::Plugin &_in)

return result;
}

//////////////////////////////////////////////////
template<>
IGNITION_GAZEBO_VISIBLE
msgs::Plugin_V ignition::gazebo::convert(const sdf::Plugins &_in)
{
msgs::Plugin_V result;
for (const sdf::Plugin &plugin : _in)
{
result.add_plugins()->CopyFrom(convert<msgs::Plugin>(plugin));
}
return result;
}

//////////////////////////////////////////////////
template<>
IGNITION_GAZEBO_VISIBLE
sdf::Plugin ignition::gazebo::convert(const msgs::Plugin &_in)
{
return sdf::Plugin(_in.filename(), _in.name(), _in.innerxml());
}

//////////////////////////////////////////////////
template<>
IGNITION_GAZEBO_VISIBLE
sdf::Plugins ignition::gazebo::convert(const msgs::Plugin_V &_in)
{
sdf::Plugins result;
for (int i = 0; i < _in.plugins_size(); ++i)
result.push_back(convert<sdf::Plugin>(_in.plugins(i)));
return result;
}
2 changes: 2 additions & 0 deletions src/LevelManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ void LevelManager::ReadLevelPerformerInfo()
this->ConfigureDefaultLevel();

// Load world plugins.
this->runner->EventMgr().Emit<events::LoadSdfPlugins>(this->worldEntity,
this->runner->sdfWorld->Plugins());
this->runner->EventMgr().Emit<events::LoadPlugins>(this->worldEntity,
this->runner->sdfWorld->Element());

Expand Down
Loading