Add method to get the link visual elements

#2900 Merged at 64a099d
Repository
ocrave
Branch
model_visibility
Repository
osrf
Branch
default
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 (6)

  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);
          }
        }