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

Add environment variable to locate plugins #104

Merged
merged 3 commits into from
Jul 10, 2020

Conversation

Levi-Armstrong
Copy link
Contributor

I just copied how this was done in Ignition GUI

I just copied how this was done in Ignition GUI

Signed-off-by: Levi Armstrong <levi.armstrong@gmail.com>
@Levi-Armstrong
Copy link
Contributor Author

I am not sure why the tests are failing on windows and I do not have a way to test this locally.

@Levi-Armstrong
Copy link
Contributor Author

This change solved the issue with locating the ignition rendering plugins within a snap package, but now at runtime Ogre does not have the OpenGL render plugin. I believe the Ignition Ogre Plugin is setting the path for ogre plugin but I am not certain. Does anyone have any thoughts on the issue?

@chapulina chapulina added enhancement New feature or request 🔮 dome Ignition Dome labels Jun 22, 2020
@chapulina
Copy link
Contributor

chapulina commented Jun 22, 2020

I am not sure why the tests are failing on windows and I do not have a way to test this locally.

They were failing before, not this PR's fault.

now at runtime Ogre does not have the OpenGL render plugin

Interesting, I wouldn't expect the existing plugins to be affected by this change. How are you loading Ogre? Would one of the existing examples in this package fail the same way? Are you loading Ogre using the environment variable?

@chapulina chapulina added this to Inbox in Core development via automation Jun 22, 2020
@chapulina chapulina moved this from Inbox to In review in Core development Jun 22, 2020
@Levi-Armstrong
Copy link
Contributor Author

It looks like the path it looks for ogre plugins is set at compile time here. I am testing a solution at the moment to address this similar to how this is done in ogre.

Another possible option would be to not provide the full path for the ogre plugins as done here but only include the names when loading ogre plugins. The only reason I can see to not make this change, is it would not support switching to the debug version. The reason behind only using the plugin name is that Ogre already supports bundling so it would detect that it inside a snap package and correctly locate its resources if the plugin name was only provided.

@Levi-Armstrong
Copy link
Contributor Author

So with these changes I have been able to successfully create a snap package leveraging ignition gui. Below is a app configuration setting leveraging the environment variables so resources are located within the snap package.

apps:
  tesseract-setup-wizard:
    extensions:
      - kde-neon
    environment:
      IGN_GUI_PLUGIN_PATH: $SNAP/opt/ros/melodic/lib/
      IGN_RENDERING_PLUGIN_PATH: $SNAP/opt/ros/melodic/lib/
      IGN_RENDERING_RESOURCE_PATH: $SNAP/opt/ros/melodic/share/ignition/ignition-rendering4/
      OGRE_RESOURCE_PATH: $SNAP/usr/lib/x86_64-linux-gnu/OGRE-1.9.0/
    command: opt/ros/melodic/bin/demo_window

@Levi-Armstrong
Copy link
Contributor Author

If you find these changes acceptable, I can go through and update OGRE2 plugin also.

@chapulina
Copy link
Contributor

The approach looks reasonable to me. The only thing I'm wondering is whether we can avoid exposing engine specific configuration to downstream users.

So I could see OGRE_RESOURCE_PATH somehow combined with IGN_RENDERING_RESOURCE_PATH, or maybe using a more generic variable name such as IGN_RENDERING_ENGINE_RESOURCE_PATH which is shared by all rendering engines.

I'm not 100% sure this is a good idea though. Not sure what @iche033 thinks of this?

@iche033
Copy link
Contributor

iche033 commented Jun 25, 2020

One small edge case issue I can think of for using a shared env variable like IGN_RENDERING_ENGINE_RESOURCE_PATH is when users load multiple render engines and need to specify a different resource path per engine. Ign-rendering is designed to support loading multiple rendering engines and switching between them at run time (at least that was the case when optix was working). So users may need to a way to specify different resource paths, and that may be easier to do with engine specific env variables.

@Levi-Armstrong
Copy link
Contributor Author

Another option is how ogre does this. The only reason I had to expose the OGRE_RESOURCE_PATH environment variable was because I am bundling it using snap. In this case ogre looks for the environment variable SNAP and if it exists it prepends the path as shown here.

        // With Ubuntu snaps absolute paths are relative to the snap package.
        char* env_SNAP = getenv("SNAP");
        if(env_SNAP && !path.empty() && path[0] == '/') // only adjust absolute dirs
            path = env_SNAP + path;

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.

Let's go with the OGRE_RESOURCE_PATH approach for now as it's working. The changes look good to me.

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.

Besides the inline comment, I'd like to clarify whether this is enough to close #100 (i.e. can we load rendering engine plugins other than Ogre and Optix?).

I suspect that the answer is no, which is fine and shouldn't block this PR.

ogre/src/OgreRenderEngine.cc Outdated Show resolved Hide resolved
Signed-off-by: Levi Armstrong <levi.armstrong@gmail.com>
@Levi-Armstrong
Copy link
Contributor Author

Besides the inline comment, I'd like to clarify whether this is enough to close #100 (i.e. can we load rendering engine plugins other than Ogre and Optix?).

I suspect that the answer is no, which is fine and shouldn't block this PR.

I believe it should be enough to load plugins outside this package. Essential that is what is happening when I am bundling this into a snap. Everything is being loaded from the environment variables because the location of all resources are not in the location of the original install location.

@Levi-Armstrong
Copy link
Contributor Author

@chapulina and @iche033 I added one more commit which makes the same change in the ogre2 plugin.

Signed-off-by: Levi Armstrong <levi.armstrong@gmail.com>
@chapulina
Copy link
Contributor

I believe it should be enough to load plugins outside this package.

That sounds great, thanks!

Unrelated to this PR, but I'd say we need some documentation and a demo on how to load a custom engine before closing #100. Similar to the ign-physics examples. I haven't tried to do it myself, but looking at the code, I'm concerned about some assumptions made about the "default engines" in places like this:

https://github.com/ignitionrobotics/ign-rendering/blob/dfcf7c4a574b6b0e94419b7ba1ab3ebce64055f3/src/RenderEngineManager.cc#L287-L312

@Levi-Armstrong
Copy link
Contributor Author

Is this good to merge?

@iche033
Copy link
Contributor

iche033 commented Jul 10, 2020

merging!

@iche033 iche033 merged commit 6338cdb into gazebosim:master Jul 10, 2020
Core development automation moved this from In review to Done Jul 10, 2020
@j-rivero j-rivero removed this from Done in Core development May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔮 dome Ignition Dome enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants