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 55 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
1 change: 1 addition & 0 deletions src/ServerConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class ignition::gazebo::ServerConfig::PluginInfoPrivate

/// \brief XML elements associated with this plugin
public: sdf::ElementPtr sdf = nullptr;

};

//////////////////////////////////////////////////
Expand Down
31 changes: 30 additions & 1 deletion src/gui/plugins/component_inspector/ComponentInspector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,6 @@ void ComponentInspector::Update(const UpdateInfo &,
auto comp = _ecm.Component<components::Material>(this->dataPtr->entity);
if (comp)
{
this->SetType("material");
setData(item, comp->Data());
}
}
Expand Down Expand Up @@ -1268,6 +1267,36 @@ transport::Node &ComponentInspector::TransportNode()
return this->dataPtr->node;
}

/////////////////////////////////////////////////
void ComponentInspector::OnAddSystem(const QString &_name,
const QString &_filename, const QString &_innerxml)
{
msgs::EntityPlugin_V req;
auto ent = req.mutable_entity();
ent->set_id(this->dataPtr->entity);
auto plugin = req.add_plugins();
std::string name = _name.toStdString();
std::string filename = _filename.toStdString();
std::string innerxml = _innerxml.toStdString();
plugin->set_name(name);
plugin->set_filename(filename);
plugin->set_innerxml(innerxml);

msgs::Boolean res;
bool result;
unsigned int timeout = 5000;
std::string service{"/world/" + this->dataPtr->worldName +
"/entity/system/add"};
if (!this->dataPtr->node.Request(service, req, timeout, res, result))
{
ignerr << "Error adding new system to entity: "
<< this->dataPtr->entity << "\n"
<< "Name: " << name << "\n"
<< "Filename: " << filename << "\n"
<< "Inner XML: " << innerxml << std::endl;
}
}

// Register this plugin
IGNITION_ADD_PLUGIN(ignition::gazebo::ComponentInspector,
ignition::gui::Plugin)
7 changes: 7 additions & 0 deletions src/gui/plugins/component_inspector/ComponentInspector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,13 @@ namespace gazebo
/// \return Transport node
public: transport::Node &TransportNode();

/// \brief Callback when a new system is to be added to an entity
/// \param[in] _name Name of system
/// \param[in] _filename Filename of system
/// \param[in] _innerxml Inner XML content of the system
public: Q_INVOKABLE void OnAddSystem(const QString &_name,
const QString &_filename, const QString &_innerxml);

/// \internal
/// \brief Pointer to private data.
private: std::unique_ptr<ComponentInspectorPrivate> dataPtr;
Expand Down
117 changes: 116 additions & 1 deletion src/gui/plugins/component_inspector/ComponentInspector.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*
*/
import QtQuick 2.9
import QtQuick.Controls 1.4
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.1
import QtQuick.Dialogs 1.1
import QtQuick.Layouts 1.3
import QtQuick.Controls.Styles 1.4
import IgnGazebo 1.0 as IgnGazebo
Expand Down Expand Up @@ -216,6 +216,27 @@ Rectangle {
}
}

ToolButton {
id: addSystemButton
checkable: false
text: "\u002B"
contentItem: Text {
text: addSystemButton.text
color: "#b5b5b5"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
visible: (entityType == "model" || entityType == "visual" ||
entityType == "sensor" || entityType == "world")
ToolTip.text: "Add a system to this entity"
ToolTip.visible: hovered
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
onClicked: {
addSystemDialog.open()
}
}


Label {
id: entityLabel
text: 'Entity ' + ComponentInspector.entity
Expand All @@ -227,6 +248,100 @@ Rectangle {
}
}

Dialog {
id: addSystemDialog
modal: false
focus: true
title: "Add System"
closePolicy: Popup.CloseOnEscape

ColumnLayout {
GridLayout {
columns: 2
columnSpacing: 30
Text {
text: "Name"
Layout.row: 0
Layout.column: 0
}

TextField {
id: nameField
selectByMouse: true
Layout.row: 0
Layout.column: 1
Layout.minimumWidth: 250
onTextEdited: {
addSystemDialog.updateButtonState();
}
}

Text {
text: "Filename"
chapulina marked this conversation as resolved.
Show resolved Hide resolved
Layout.row: 1
Layout.column: 0
}

TextField {
id: filenameField
selectByMouse: true
Layout.row: 1
Layout.column: 1
Layout.minimumWidth: 250
onTextEdited: {
addSystemDialog.updateButtonState();
}
}
}

Text {
id: innerxmlLabel
text: "Inner XML"
}

Flickable {
id: innerxmlFlickable
Layout.minimumHeight: 300
Layout.fillWidth: true
Layout.fillHeight: true

flickableDirection: Flickable.VerticalFlick
TextArea.flickable: TextArea {
id: innerxmlField
wrapMode: Text.WordWrap
selectByMouse: true
textFormat: TextEdit.PlainText
font.pointSize: 10
}
ScrollBar.vertical: ScrollBar {
policy: ScrollBar.AlwaysOn
}
}
}

footer: DialogButtonBox {
id: buttons
standardButtons: Dialog.Ok | Dialog.Cancel
}

onOpened: {
addSystemDialog.updateButtonState();
}

onAccepted: {
ComponentInspector.OnAddSystem(nameField.text.trim(),
filenameField.text.trim(), innerxmlField.text.trim())
}

function updateButtonState() {
buttons.standardButton(Dialog.Ok).enabled =
(nameField.text.trim() != '' &&
filenameField.text.trim() != '')
}
}



ListView {
anchors.top: header.bottom
anchors.bottom: parent.bottom
Expand Down
4 changes: 4 additions & 0 deletions test/worlds/diff_drive_no_plugin.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
filename="ignition-gazebo-physics-system"
name="ignition::gazebo::systems::Physics">
</plugin>
<plugin
filename="ignition-gazebo-scene-broadcaster-system"
name="ignition::gazebo::systems::SceneBroadcaster">
</plugin>

<light type="directional" name="sun">
<cast_shadows>true</cast_shadows>
Expand Down