gazebosim / gazebosim/gz-rendering

Add plugin mechanism for extending render engine interfaces and objects

Open
#702 5 comments 0 reactions 1 assignee Claimed by @iche033 View on GitHub
enhancement
Dominant language
C++
Stars
81
Forks
90
Avg merge
1d 13h
Merged PRs (30d)
10

Description

## Desired behaviour

Add a mechanism for external projects to extend the render engine interface and implementation.

The present render engine plugin mechanism allows external projects to add custom render engines that implement part or all of the current render engine interface, but it does not allow the interface to be extended via plugins.

For example if you wanted to add a `ForceVisual` the current approach would be to add classes to the existing `gz-rendering` library and add a `CreateForceVisual` method to `Scene` (and equivalents for each render engine implementation). It would be useful to be able to add such objects in external projects without having to change the core libraries.

The use case I have in mind is for an plugin for an OceanVisual. The visual plugin requires a number of custom rendering objects that subclass from `rendering::Visual` and `rendering::Geometry`. My current implementation defines these directly in the system plugin, however it turns out that on some platforms the approach is sensitive to the order in which the plugins are loaded which can result in either the render engine being improperly initialised or the loader reporting missing symbols.

## Alternatives considered

Define extensions directly in system plugins. This can be made to work, but is not robust and may fail on some platforms. It is also not very modular and does not enable custom rendering extensions to be easily shared.

## Implementation suggestion

Add a mechanism analogous to RenderEngine, RenderEnginePlugin, RenderEngineManger that allows extension interfaces and their implementation to be defined in plugins and loaded at runtime. The extension manager should have a mechanism to check that required (render engine) dependencies are available and have been loaded before attempting to load extensions.

## Additional context

I'll attempt to implement this approach in an external project (asv_wave_sim). If it works I'll factor out the extension mechanism and submit it as a PR. In the meanwhile if the team have any suggestions of recommendations on an approach that would be welcomed!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.