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

Visualize Lidar Plugin for ign-gazebo #301

Merged
merged 12 commits into from
Sep 23, 2020

Conversation

mihirk284
Copy link
Contributor

@mihirk284 mihirk284 commented Aug 20, 2020

@ahcorde Can you please review it.

This PR integrates the LidarVisual from ignition rendering into ign-gazebo. Options are provided to select the visual type, the subscribed topic and to display or ignore lidar rays that do not hit an obstacle.

Example1

src/gui/plugins/visualize_lidar/VisualizeLidar.hh Outdated Show resolved Hide resolved
examples/worlds/visualize_lidar.sdf Outdated Show resolved Hide resolved
examples/worlds/visualize_lidar.sdf Outdated Show resolved Hide resolved
examples/worlds/visualize_lidar.sdf Outdated Show resolved Hide resolved
@chapulina chapulina added enhancement New feature or request 🔮 dome Ignition Dome labels Aug 20, 2020
Copy link
Contributor

@iche033 iche033 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one small feature request is to add a checkbox for toggling visibility of the lidar visual in case user has multiple plugins running and they want to selectively disable/enable visualizations

#include <ignition/common/MeshManager.hh>
#include <ignition/common/Profiler.hh>
#include <ignition/common/Uuid.hh>
#include <ignition/common/VideoEncoder.hh>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of these headers are not needed. Can you remove the ones not used?

src/gui/plugins/visualize_lidar/VisualizeLidar.cc Outdated Show resolved Hide resolved
src/gui/plugins/visualize_lidar/VisualizeLidar.cc Outdated Show resolved Hide resolved
src/gui/plugins/visualize_lidar/VisualizeLidar.cc Outdated Show resolved Hide resolved
src/gui/plugins/visualize_lidar/VisualizeLidar.cc Outdated Show resolved Hide resolved
src/gui/plugins/visualize_lidar/VisualizeLidar.cc Outdated Show resolved Hide resolved
{
parent = child;
foundChild = true;
if (i+1 == lidarURIVec.size()-1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic in this block assumes the model > link > sensor hierarchy?

We also support nested models, i.e.g model > model > link > sensor, in which case the logic above may not work?

src/gui/plugins/visualize_lidar/VisualizeLidar.cc Outdated Show resolved Hide resolved
igndbg << "Creating lidar visual" << std::endl;

auto root = scene->RootVisual();
this->dataPtr->lidar = scene->CreateLidarVisual();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the visual destroyed? we need to be careful not to leave any dangling visuals around when the plugin exits

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

following up on this, we should destroy the visual when the user closes the plugin, i.e. by clicking on X in the corner of the plugin window. Currently I see that lidar visual remains in the scene after exiting the plugin, and when I open the same plugin again, a duplicate lidar visual gets created.

Copy link
Contributor

@iche033 iche033 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are a couple of minor code check errors:

./src/gui/plugins/visualize_lidar/VisualizeLidar.cc:323:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
./src/gui/plugins/visualize_lidar/VisualizeLidar.cc:374:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]

if (!_value)
{
ignmsg << "Lidar Visual Display OFF." << std::endl;
this->dataPtr->lidar->SetType(rendering::LidarVisualType::LVT_NONE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should be able to call this->dataPtr->lidar->SetVisible(false) to make it invisible, which is a faster operation than clearing all the lidar data. Same for re-enabling the lidar visual display below

igndbg << "Creating lidar visual" << std::endl;

auto root = scene->RootVisual();
this->dataPtr->lidar = scene->CreateLidarVisual();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

following up on this, we should destroy the visual when the user closes the plugin, i.e. by clicking on X in the corner of the plugin window. Currently I see that lidar visual remains in the scene after exiting the plugin, and when I open the same plugin again, a duplicate lidar visual gets created.

@iche033
Copy link
Contributor

iche033 commented Aug 25, 2020

one small issue:

  1. uncheck Display Lidar Visual -> lidar becomes invisible - correct
  2. uncheck Show Non Hitting Rays -> lidar becomes visible again when it should stay invisible

@mihirk284
Copy link
Contributor Author

one small issue:

  1. uncheck Display Lidar Visual -> lidar becomes invisible - correct
  2. uncheck Show Non Hitting Rays -> lidar becomes visible again when it should stay invisible

@iche033 Thanks for bringing it to my attention. I think this is happening whenever the DynamicRenderables inside the visual are being deleted and new renderables are being used to display the visual. This happens in the case when there is a change in the LidarVisualType or if we have displayNonHitting = false.
This is happening despite having lidar->SetVisible(false). The new DynamicRenderables generated after this operation always cause the visual to show up.

I can solve this by not updating the visual in the plugin if the display option is off.
Or should we change something in the rendering part of the code?

@iche033
Copy link
Contributor

iche033 commented Aug 26, 2020

Or should we change something in the rendering part of the code?

sounds like once we clear the visual data and create new ones in ign-rendering, we need to call SetVisible again with the current visible value so that the visibility is correct.

@iche033
Copy link
Contributor

iche033 commented Aug 31, 2020

sounds like once we clear the visual data and create new ones in ign-rendering, we need to call SetVisible again with the current visible value so that the visibility is correct.

fixed in gazebosim/gz-rendering#133

@iche033
Copy link
Contributor

iche033 commented Aug 31, 2020

changes look good. Can you merge with / rebase on master?

@mihirk284 mihirk284 force-pushed the visualise_lidar branch 2 times, most recently from 20c1799 to c185c8d Compare September 1, 2020 08:59
@iche033 iche033 requested a review from ahcorde September 3, 2020 21:24
Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, two small comments

examples/worlds/visualize_lidar.sdf Outdated Show resolved Hide resolved
src/gui/plugins/visualize_lidar/VisualizeLidar.cc Outdated Show resolved Hide resolved
Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Mac build failed, I think we need to bump the ign-rendering revision on homebrew-simulation:

/Users/jenkins/workspace/ignition_gazebo-ci-pr_any-homebrew-amd64/ign-gazebo/src/gui/plugins/visualize_lidar/VisualizeLidar.cc:49:10: fatal error: 'ignition/rendering/LidarVisual.hh' file not found
#include "ignition/rendering/LidarVisual.hh"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@chapulina chapulina added needs upstream release Blocked by a release of an upstream library beta Targeting beta release of upcoming collection labels Sep 6, 2020
@chapulina
Copy link
Contributor

@osrf-jenkins run tests, let's see what happens now

@chapulina chapulina removed the needs upstream release Blocked by a release of an upstream library label Sep 18, 2020
@chapulina
Copy link
Contributor

@osrf-jenkins run tests 🤞

@chapulina chapulina merged commit 7cac3e4 into gazebosim:master Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Targeting beta release of upcoming collection 🔮 dome Ignition Dome enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants