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

Inheritance chains #19

Closed
danepowell opened this issue Aug 19, 2013 · 3 comments
Closed

Inheritance chains #19

danepowell opened this issue Aug 19, 2013 · 3 comments

Comments

@danepowell
Copy link
Contributor

Should inheritance 'chains' be possible with plugins? i.e., Base Class > Derived Class 1 > Derived Class 2.

My problem: I want to build a plugin (rviz::OmniTool) that uses rviz::InteractionTool as a base. But rviz::InteractionTool is already derived from rviz::Tool. So the desired inheritance is rviz::Tool > rviz::InteractionTool > rviz::OmniTool.

The problem is that rviz::OmniTool doesn't show up in rviz, although it does get returned by rospack plugins, so pluginlib knows it exists. However, if I change it to be derived directly from rviz::Tool, it shows up just fine.

Does this sound like a problem with pluginlib or rviz?

@mirzashah
Copy link
Member

@danepowell Ah, this is an interesting question!

It's likely that rviz when loading plugins is looking for classes that have the interface rviz::Tool. Even though rviz::InteractionTool is an rviz::Tool, the plugin system does not know that unless you tell it explicitly through the PLUGINLIB_EXPORT_CLASS macro. I'm betting the problem isn't you deriving from rviz::InteractionTool as it is with your PLUGINLIB_EXPORT_CLASS macro. So...

  1. Derive from rviz::InteractionTool as you had desired
  2. Make sure your PLUGINLIB_EXPORT_CLASS Macro looks like this this:
    PLUGINLIB_EXPORT_CLASS(rviz::OmniTool, rviz::Tool)
    Make sure that the second argument is rviz::Tool and NOT rviz::InteractionTool.

Hopefully that was your issue and this resolves it. If not, just leave a comment.

Also note that if you want to register plugins that can be used through any interface in the hierarchy, you can use the PLUGINLIB_EXPORT_CLASS multiple times, each time for a different base. e.g.:

PLUGINLIB_EXPORT_CLASS(rviz::OmniTool, rviz::InteractionTool) 
PLUGINLIB_EXPORT_CLASS(rviz::OmniTool, rviz::Tool)

Oh also note that rospack plugin querying just looks at the plugin xml files that packages export. That's what the package promises, but it may not actually contain the plugins it promises at runtime.

@danepowell
Copy link
Contributor Author

Awesome! That did the trick. Maybe it's worth mentioning the multiple-PLUGINLIB_EXPORT_CLASS trick on the wiki page?

@mirzashah
Copy link
Member

Good idea, will do that now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants