-
Notifications
You must be signed in to change notification settings - Fork 276
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
Visualize collisions #531
Visualize collisions #531
Conversation
Codecov Report
@@ Coverage Diff @@
## ign-gazebo3 #531 +/- ##
===============================================
- Coverage 77.73% 77.71% -0.03%
===============================================
Files 208 208
Lines 11590 11595 +5
===============================================
+ Hits 9010 9011 +1
- Misses 2580 2584 +4
Continue to review full report at Codecov.
|
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>
7b2985a
to
4a1cba6
Compare
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.
Works well for me. Did a first review pass and left some comments.
src/rendering/RenderUtil.cc
Outdated
// create new collision visuals | ||
{ | ||
if (!newCollisionLinks.empty()) | ||
DeselectAllEntities(); |
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.
is this done so that the object does not get highlighted with bright white emissive material?
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.
This was done to avoid encountering this error after a new collision was created and clicking elsewhere (deselecting an entity) https://github.com/ignitionrobotics/ign-gazebo/blob/4a1cba6d2e32e493c5dc0f7233db01b406681adf/src/rendering/RenderUtil.cc#L1427-L1428
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 tried commenting the above two lines out to see what's causing this error msg appear but I couldn't reproduce it by selecting the model and toggling View > Collision. Can you list the steps to reproduce this?
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.
- Start up Ignition with a sample world
- Select a model in Scene3D so that it is highlighted
- Then right click the model, View > Collisions
- Then click anywhere else in the scene and the error should appear
The error only appears once, after the collision visual has been created. If you toggle off the collision then run through the above steps again then the error doesn't appear again.
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.
Thanks I was able to reproduce the problem now. I think the issue is that It was trying to update the emissive property of a new geometry (collision visual's geom) that it does not previously know about. The current code works around this problem by deselecting all entities before creating the new collision visual. But there would now a mismatch between what's selected in scene 3d and the entity tree (and other plugins) for example. It's more of a usability issue now. I would recommend seeing if there's another way around this without deselecting all entities, e.g. updating the logic in the LowlightNode
function or simply removing that error msg.
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.
Fixed the issue by adding the collision visual's geometry emissive property to the originalEmissive
map after creation of the collision visual: df7f009
[&](const Entity &_entity, const components::Collision *)->bool | ||
{ | ||
this->removeEntities[_entity] = _info.iterations; | ||
this->viewingCollisions.erase(_entity); |
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.
do you also need to update entityCollisions
and linkToCollisionEntities
, and probably also modelToLinkEntities
when links are removed? hmm there's a bit of maintenance that need to be done to keep these maps update-to-date.
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.
Done in 8522398. Since only a model or a light can be removed from the gui (not a link or a collision), I didn't have to iterate through the maps to keep them updated.
src/rendering/RenderUtil.cc
Outdated
sdf::Visual visual; | ||
visual.SetGeom(*collision.Geom()); | ||
visual.SetMaterial(material); | ||
this->dataPtr->sceneManager.CreateVisual(colEntity, visual, link); |
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.
The code here for creating collision visuals would be a good addition to the SceneManager
class, i.e. a new CreateCollision
function
and we just have to call rendering::VisualPtr colVisual = this->dataPtr->sceneManager.CreateCollision(colEntity, collision, link)
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.
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>
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.
New changes look good. I couldn't visualize collision for the ground plane. Does it work for you?
src/rendering/RenderUtil.cc
Outdated
// create new collision visuals | ||
{ | ||
if (!newCollisionLinks.empty()) | ||
DeselectAllEntities(); |
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 tried commenting the above two lines out to see what's causing this error msg appear but I couldn't reproduce it by selecting the model and toggling View > Collision. Can you list the steps to reproduce this?
No, but it's because it's missing the and if <collision name="collision">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
</collision> The collision for the ground plane is viewable. It's required spec of SDFormat, should I add the |
that's interesting because I thought if a required field is missing, sdf parser would complain. Even if it went through the parser, the default value should 1x1m which is not the behavior we're seeing. So I think we should add |
Yes, I'm assuming branched from and merged to |
yes, thanks! |
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>
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.
@@ -21,6 +21,7 @@ | |||
#include <string> | |||
#include <vector> | |||
|
|||
#include <sdf/Collision.hh> |
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.
Is this include needed by the header? Can it be moved to the cc file?
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.
Yup, done dbf7a0c
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>
Oops, thank you for catching that. It is fixed in dbf7a0c |
Works for me. |
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.
Works great!
Closes #105
Ability to visualize collision (basic shapes or meshes) similar to Gazebo-classic, which are displayed in orange.
Collision visualization can be toggled from (in the scene or in the entity tree):
Collision visuals can be created for basic shapes and meshes but depending on the render order when a collision (visual) is coplaner with the shape/mesh visual there are times when the collision visual can not be seen. This should be resolved in Edifice from this PR gazebosim/gz-rendering#188
Here's an example: