Add method to get the link visual elements

#2900 Open
Repository
ocrave
Branch
model_visibility
Repository
osrf
Branch
default

Bitbucket cannot automatically merge this request.

The commits that make up this pull request have been removed.

Bitbucket cannot automatically merge this request due to conflicts.

Review the conflicts on the Overview tab. You can then either decline the request or merge it manually on your local system using the following commands:

hg update default
hg pull -r model_visibility https://bitbucket.org/ocrave/gazebo
hg merge model_visibility
hg commit -m 'Merged in ocrave/gazebo/model_visibility (pull request #2900)'
Author
  1. Olivier Crave
Reviewers
Description

This pull request adds the method Link::Visuals()which returns the link visual elements.

We find it particularly useful to show/hide actors in the scene.

Comments (3)

  1. Louise Poubel

    I have mixed feelings about these functions. Visibility is a rendering property, so I'm not sure if it makes much sense to have this API in physics.

    I imagine you're calling actor->SetVisible(false) from a physics plugin, correct? With just a couple more lines you could publish a message directly from the plugin, is that very inconvenient?

    1. Olivier Crave author

      The issue that I ran into when I tried publishing visual messages from a plugin is that it doesn't have access to a link visual messages. Therefore, and if you're OK with it, I could modify this PR to add a new Link method:

        /// \brief Return the link visual elements.
        /// \return a map of unique ID to visual message
        public: const Visuals_M &Visuals() const;
      

      Then, in a plugin, we could hide a model like so:

        for (const auto &link : model->GetLinks())
        {
          msgs::Visual msg;
          msg.set_parent_name(link->GetScopedName());
          msg.set_parent_id(link->GetId());
          msg.set_visible(false);
          for (const auto &iter : link->Visuals())
          {
            msg.set_name(iter.second.name());
            this->visPub->Publish(msg);
          }
        }