-
Notifications
You must be signed in to change notification settings - Fork 284
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
notify other GUI plugins of added/removed entities via GUI events #1138
Conversation
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
3fb372f
to
8f7714c
Compare
Codecov Report
@@ Coverage Diff @@
## ign-gazebo6 #1138 +/- ##
===============================================
- Coverage 63.84% 63.73% -0.12%
===============================================
Files 256 256
Lines 20077 20116 +39
===============================================
+ Hits 12818 12820 +2
- Misses 7259 7296 +37
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the events propagated to the entity tree and it displays newly added entities now, thanks. I noticed that the id of the new entity added to the entity tree starts at 0 though. I think it's an 64 vs 32 bit unsigned int issue.
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
…zebosim#1138) Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
While working on a release, I noticed that the event introduced in this PR is very similar to another one created on #1053. I'd like to conciliate both of them before making a release. I'm just not sure what's the intended use case for this event. It sounds like it's notifying of entities that are created only on the GUI, but not on the server yet, right? Isn't it important for the receiver of this event to understand this distinction? I may be misunderstanding the point here, but at the moment I think this addition is confusing to both developers and users.
Sorry to only catch this now, but we haven't released it yet, so we can improve the situation. I was hoping some of my questions would have been raised before this PR was merged, or maybe would have been addressed on gazebosim/design#8. @adlarkin , @iche033 , @nkoenig , what do you think of reverting this PR until we have a concrete use case up for review? As it stands right now, no plugins are using it, right? |
It was added mainly because I think we can revert this PR for the release. We do need an alternative way to be notified of added / removed entities in the GUI plugin though. Currently the |
It seems like the two events could be consolidated, but it doesn't seem like the consolidation would block a release.
This event is designed to support the model editor. Models can be added or removed while paused, and those changes are not sent to the server. The changes only exist on the GUI's ECM. This design decision should be in the design document. The event in this PR lets other plugins know of GUI additions and removals so that the user can see the additions and removals. For example, the EntityTree responds to this event. We could rename the event and/or add extra documentation if that would help clarify things. I think you can still make a release with this event in place as it doesn't break anything. |
Thanks for the extra context.
Now that I understand the use case a bit more, I think that if we wanted to consolidate, we'd need an extra flag to explain if the event is GUI-only or not.
I think this is also a good idea. Right now a user doesn't know the difference between this event and I don't have a preference between:
It seems to me that all plugins which listen to one of them may want to listen to both?
I haven't tried the The event isn't even emitted by any widgets at the moment, so downstream users may try to use it and be frustrated to see that it doesn't have the expected results.
If we release this event as it is, we can't change it anymore. We can't rename it, combine it, or even add a flag. I'm coming from the place of a downstream developer who is not up-to-date with the model editor's implementation, sees this new event added and gets confused about the usage. On the flip side, reverting this PR doesn't break anything. That's why I suggested doing that instead. |
Thanks @nkoenig and @iche033 for providing additional context. I will add a few more thoughts/comments as well:
We've only thought about entities that are "staged to be created" (i.e., entities that were created by a GUI plugin, but haven't been shared with the server if simulation is still paused). I do agree that this can be confusing to users if they use command line tools, which would give different information (we didn't think about this scenario at the time of implementing this event). Perhaps it would be worth updating things like the entity tree to show that these new entities are "pending" while simulation is still paused.
I just updated the design document to make this clear: gazebosim/design@df6f649
I actually don't think the entity IDs should change: see #1122 and #1145 for some workarounds that were made to ensure that newly created GUI entities have a unique ID. |
So you mean that the entity will keep its "GUI ID" after it's created on the server? I'm wondering how plugins like |
I'm not sure that I understand what you mean by "GUI ID". From my understanding, an entity that exists in the GUI/server has the same ID on both the GUI and server. Is that not true? Is "GUI ID" different than an entity's ID? |
Ah sorry, so I'm probably thinking about the way things worked pre-model-editor. For example, when we spawn a simple shape from the |
Yeah, that's right - it should be the actual entity ID, since the GUI ECM is being modified directly (if anyone thinks this could be a problem - or if I'm wrong 😬 - feel free to chime in). Regarding the discussion about reverting this PR and/or updating the event before the release is made, I don't have a strong preference. If we don't revert this PR and decide to update the event so that it can be included in the release, I think it would be best to rename this event to something more specific to the model editor, because as @iche033 previously mentioned, the event introduced here is a temporary workaround until we introduce things like I will note that I do think it's a good idea to enhance the UI a bit by marking entities modified/created/removed by the model editor as "staged" until the server processes these updates. For example, perhaps in the entity tree, staged created entities can be colored green, staged removed entities can be colored red, and staged modified entities can be colored yellow/orange. Then, in the component inspector, we can add a field that indicates these entities are staged/not shared with the server yet. If doing something like this is a non-trivial amount of work, then maybe it would be best to revert this PR for now (or move it over to the |
Please see my suggestion in #1213. Let me know if I misunderstood the use case for this event. |
Signed-off-by: Ashton Larkin ashton@openrobotics.org
🎉 New feature
Related to #1106
Summary
This PR builds on top of #1122. If a GUI plugin modifies the GUI's ECM directly, other GUI plugins may need to be aware of new/removed entities. Since gui plugins currently don't have a
PostUpdate
method (they only haveUpdate
), the approach here is to have a GUI plugin emit aAddedRemovedEntities
event, which contains all of the plugin's new/removed entities. Other GUI plugins that need this information should listen for this event and then update accordingly.This PR creates the new
AddedRemovedEntities
GUI event, and also implements how the entity tree GUI plugin updates whenever it receives information from this event. This PR does not implement any GUI plugins that add/remove entities and emits this event (this will be done in other PRs).When this code is forward-ported to Garden, the plan is to modify the
gazebo::GuiSystem
interface to add aPostUpdate
method so that we don't need to use this event approach anymore (we can't make this change in Fortress because it will break ABI).Test it
To test, one can create/remove entities in a
gazebo::GuiSystem
plugin, emit an event with this information, and see if the entity tree is updated properly.Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge