PS: Don't reset color information of existing objects when new entries are added #410
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This implements a fix for #408.
When adding two different objects with color information one after the other (in two different PlanningScene updates), the color information of the first update is lost and overwritten during the second update.
As a result the color specified in the first update is lost and the existing (the first) object changes back to default-green in RViz.
In order to avoid memory leaks, I added explicit remove operations upon object removal.
However, this slightly changes current behavior: If you add an object with color information, remove it, and later on add that object back without specifying a color, the previous color was still cached - That is, unless any other PlanningScene update with color information was received in between.
Because of the changed behavior I would not backport this to i/j.
While I read through the code I found the explicit removal operations where missing for
ObjectType
s too, so I added these in a second commit.Notice that both remove functions do nothing if the entry is not present, so calling them cannot break anything here.