conda-forge / libignition-gazebo-feedstock

A conda-smithy repository for libignition-gazebo.
BSD 3-Clause "New" or "Revised" License
4 stars 4 forks source link

Fix ign server -s on Windows (take two) #52

Closed traversaro closed 1 year ago

traversaro commented 1 year ago

Re-do of https://github.com/conda-forge/libignition-gazebo-feedstock/pull/49 after cherry-picking https://github.com/gazebosim/gz-sim/pull/1574 on the 6.12.0 release (branch for reference: https://github.com/traversaro/ign-gazebo/tree/backportwindowsfixgz6120).

Checklist

conda-forge-linter commented 1 year ago

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

traversaro commented 1 year ago

@conda-forge-admin, please rerender

github-actions[bot] commented 1 year ago

Hi! This is the friendly automated conda-forge-webservice.

I tried to rerender for you, but it looks like there was nothing to do.

This message was generated by GitHub actions workflow run https://github.com/conda-forge/libignition-gazebo-feedstock/actions/runs/3284461027.

traversaro commented 1 year ago

@conda-forge-admin, please rerender

traversaro commented 1 year ago

In https://github.com/conda-forge/libignition-gazebo-feedstock/pull/52/commits/7d53cfd34c7bca7d08a47109f7df5ed4ccd472be I enabled the upload of artifacts by the CI jobs, so that I can test locally if ign gazebo -s is working fine after this changes.

traversaro commented 1 year ago

As there are a few doubts in https://github.com/gazebosim/gz-sim/pull/1764#issuecomment-1285038401 about some stranges CI failures on Ubuntu, let's apply the patch just on Windows.

traversaro commented 1 year ago

I tried this locally, but for some reason it is failing with:

(libignition-gazebo6) C:\Users\STraversaro\AppData\Local\mambaforge\envs\libignition-gazebo6\Library\share\ignition\ignition-gazebo6\worlds>ign gazebo -s .\shapes.sdf
Library error: C:/Users/STraversaro/AppData/Local/mambaforge/envs/libignition-gazebo6/Library/lib/ignition-tools-backward.dll not found. Improved backtrace generation will be disabled
[Err] [D:\bld\libignition-gazebo6_1666215155937\work\src\SystemLoader.cc:64] Failed to load system plugin [ignition-gazebo-physics-system] : couldn't find shared library.
[Err] [D:\bld\libignition-gazebo6_1666215155937\work\src\SystemLoader.cc:64] Failed to load system plugin [ignition-gazebo-user-commands-system] : couldn't find shared library.
[Err] [D:\bld\libignition-gazebo6_1666215155937\work\src\SystemLoader.cc:64] Failed to load system plugin [ignition-gazebo-scene-broadcaster-system] : couldn't find shared library.

For some reason, the files installed by the https://github.com/gazebosim/gz-sim/blob/ign-gazebo6/src/systems/CMakeLists.txt#L85 are not copied correctly in the conda packaage.

traversaro commented 1 year ago

I tried this locally, but for some reason it is failing with:

(libignition-gazebo6) C:\Users\STraversaro\AppData\Local\mambaforge\envs\libignition-gazebo6\Library\share\ignition\ignition-gazebo6\worlds>ign gazebo -s .\shapes.sdf
Library error: C:/Users/STraversaro/AppData/Local/mambaforge/envs/libignition-gazebo6/Library/lib/ignition-tools-backward.dll not found. Improved backtrace generation will be disabled
[Err] [D:\bld\libignition-gazebo6_1666215155937\work\src\SystemLoader.cc:64] Failed to load system plugin [ignition-gazebo-physics-system] : couldn't find shared library.
[Err] [D:\bld\libignition-gazebo6_1666215155937\work\src\SystemLoader.cc:64] Failed to load system plugin [ignition-gazebo-user-commands-system] : couldn't find shared library.
[Err] [D:\bld\libignition-gazebo6_1666215155937\work\src\SystemLoader.cc:64] Failed to load system plugin [ignition-gazebo-scene-broadcaster-system] : couldn't find shared library.

For some reason, the files installed by the https://github.com/gazebosim/gz-sim/blob/ign-gazebo6/src/systems/CMakeLists.txt#L85 are not copied correctly in the conda packaage.

Actually, this is not the problem. The problem is probably related to the fact that binary relocation does not work correctly on Windows. Anyhow, setting the path to find plugins manually, i.e.:

(libignition-gazebo6) C:\Users\STraversaro\AppData\Local\mambaforge\envs\libignition-gazebo6\Library\share\ignition\ignition-gazebo6\worlds>set IGN_GAZEBO_PHYSICS_ENGINE_PATH=C:\Users\STraversaro\AppData\Local\mambaforge\envs\libignition-gazebo6\Library\lib\ign-physics-5\engine-plugins
(libignition-gazebo6) C:\Users\STraversaro\AppData\Local\mambaforge\envs\libignition-gazebo6\Library\share\ignition\ignition-gazebo6\worlds>set IGN_GAZEBO_PHYSICS_ENGINE_PATH=C:\Users\STraversaro\AppData\Local\mambaforge\envs\libignition-gazebo6\Library\lib\ign-physics-5\engine-plugins

The test described in https://github.com/gazebosim/gz-sim/pull/1574 is working fine.

traversaro commented 1 year ago

I tried this locally, but for some reason it is failing with:

(libignition-gazebo6) C:\Users\STraversaro\AppData\Local\mambaforge\envs\libignition-gazebo6\Library\share\ignition\ignition-gazebo6\worlds>ign gazebo -s .\shapes.sdf
Library error: C:/Users/STraversaro/AppData/Local/mambaforge/envs/libignition-gazebo6/Library/lib/ignition-tools-backward.dll not found. Improved backtrace generation will be disabled
[Err] [D:\bld\libignition-gazebo6_1666215155937\work\src\SystemLoader.cc:64] Failed to load system plugin [ignition-gazebo-physics-system] : couldn't find shared library.
[Err] [D:\bld\libignition-gazebo6_1666215155937\work\src\SystemLoader.cc:64] Failed to load system plugin [ignition-gazebo-user-commands-system] : couldn't find shared library.
[Err] [D:\bld\libignition-gazebo6_1666215155937\work\src\SystemLoader.cc:64] Failed to load system plugin [ignition-gazebo-scene-broadcaster-system] : couldn't find shared library.

For some reason, the files installed by the https://github.com/gazebosim/gz-sim/blob/ign-gazebo6/src/systems/CMakeLists.txt#L85 are not copied correctly in the conda packaage.

Actually, this is not the problem. The problem is probably related to the fact that binary relocation does not work correctly on Windows. Anyhow, setting the path to find plugins manually, i.e.:

(libignition-gazebo6) C:\Users\STraversaro\AppData\Local\mambaforge\envs\libignition-gazebo6\Library\share\ignition\ignition-gazebo6\worlds>set IGN_GAZEBO_PHYSICS_ENGINE_PATH=C:\Users\STraversaro\AppData\Local\mambaforge\envs\libignition-gazebo6\Library\lib\ign-physics-5\engine-plugins
(libignition-gazebo6) C:\Users\STraversaro\AppData\Local\mambaforge\envs\libignition-gazebo6\Library\share\ignition\ignition-gazebo6\worlds>set IGN_GAZEBO_SYSTEM_PLUGIN_PATH=C:\Users\STraversaro\AppData\Local\mambaforge\envs\libignition-gazebo6\Library\lib\ign-gazebo-6\plugins

The test described in gazebosim/gz-sim#1574 is working fine.

Probably the variables that we need to make sure to override with env variables are all the one contained in ignition\gazebo\config.hh, i.e. :

#define IGNITION_GAZEBO_GUI_CONFIG_PATH "D:/bld/libignition-gazebo6_1666215155937/_h_env/Library/share/ignition/ignition-gazebo6/gui"
#define IGNITION_GAZEBO_SYSTEM_CONFIG_PATH "D:/bld/libignition-gazebo6_1666215155937/_h_env/Library/share/ignition/ignition-gazebo6/systems"
#define IGNITION_GAZEBO_SERVER_CONFIG_PATH "D:/bld/libignition-gazebo6_1666215155937/_h_env/Library/share/ignition/ignition-gazebo6"
#define IGN_GAZEBO_PLUGIN_INSTALL_DIR "D:/bld/libignition-gazebo6_1666215155937/_h_env/Library/lib/ign-gazebo-6/plugins"
#define IGN_GAZEBO_GUI_PLUGIN_INSTALL_DIR "D:/bld/libignition-gazebo6_1666215155937/_h_env/Library/lib/ign-gazebo-6/plugins/gui"
#define IGN_GAZEBO_WORLD_INSTALL_DIR "D:/bld/libignition-gazebo6_1666215155937/_h_env/Library/share/ignition/ignition-gazebo6/worlds"

In this table I try to map each C preprocssor macro with the corresponding env variable:

Macro Env Variable Related Code
IGNITION_GAZEBO_GUI_CONFIG_PATH Apparently, it does not exists. https://github.com/gazebosim/gz-sim/blob/4e10c35624b554eb9bd4cfaabea5dd4e2dd0f0ab/src/gui/Gui.cc#L93
IGNITION_GAZEBO_SYSTEM_CONFIG_PATH Apparently, it is not used. https://github.com/gazebosim/gz-sim/search?q=GZ_SIM_SYSTEM_CONFIG_PATH
IGNITION_GAZEBO_SERVER_CONFIG_PATH Apparently, it does not exists. A IGN_GAZEBO_SERVER_CONFIG_PATH variable exists, but it has a different meaning. https://github.com/gazebosim/gz-sim/blob/1258c5286012419fc34ac06dfcbb2b2dbf12533d/src/ServerConfig.cc#L927
IGN_GAZEBO_PLUGIN_INSTALL_DIR IGN_GAZEBO_SYSTEM_PLUGIN_PATH
IGN_GAZEBO_GUI_PLUGIN_INSTALL_DIR IGN_GUI_PLUGIN_PATH
IGN_GAZEBO_WORLD_INSTALL_DIR IGN_GAZEBO_RESOURCE_PATH https://github.com/gazebosim/gz-sim/blob/4e10c35624b554eb9bd4cfaabea5dd4e2dd0f0ab/src/Util.cc#L732, https://github.com/gazebosim/gz-sim/blob/4e10c35624b554eb9bd4cfaabea5dd4e2dd0f0ab/include/ignition/gazebo/Util.hh#L291
IGNITION_PHYSICS_ENGINE_INSTALL_DIR Note: this is actually defined in ign-physics, while the corresponding env variable is defined and read by ign-gazebo IGN_GAZEBO_PHYSICS_ENGINE_PATH

See https://github.com/gazebosim/gz-sim/issues/626 for a related issue.

traversaro commented 1 year ago

Investigating Gazebo Sim docs I found two more env variables, i.e. IGN_GAZEBO_RENDER_ENGINE_PATH (related issue: https://github.com/gazebosim/gz-sim/issues/1765) and IGN_GAZEBO_PHYSICS_ENGINE_PATH, but there is no need to set them as ignition gazebo does not install any rendering or physics engine beside the one already installed by ign-physics and ign-rendering. Anyhow, we need to make sure that the env variable used by those libraries are properly set.

traversaro commented 1 year ago

Investigating Gazebo Sim docs I found two more env variables, i.e. IGN_GAZEBO_RENDER_ENGINE_PATH (related issue: gazebosim/gz-sim#1765) and IGN_GAZEBO_PHYSICS_ENGINE_PATH, but there is no need to set them as ignition gazebo does not install any rendering or physics engine beside the one already installed by ign-physics and ign-rendering. Anyhow, we need to make sure that the env variable used by those libraries are properly set.

Actually it turns out that the rendering and physics library on their own do not provide any mechanism to override the default directory specified by the code, so we need to set this variables here, as the variables are consumed just by ign-gazebo.

traversaro commented 1 year ago

Investigating Gazebo Sim docs I found two more env variables, i.e. IGN_GAZEBO_RENDER_ENGINE_PATH (related issue: gazebosim/gz-sim#1765) and IGN_GAZEBO_PHYSICS_ENGINE_PATH, but there is no need to set them as ignition gazebo does not install any rendering or physics engine beside the one already installed by ign-physics and ign-rendering. Anyhow, we need to make sure that the env variable used by those libraries are properly set.

Actually it turns out that the rendering and physics library on their own do not provide any mechanism to override the default directory specified by the code, so we need to set this variables here, as the variables are consumed just by ign-gazebo.

Actually, this is not completly true: for gz-rendering, there is the GZ_RENDERING_PLUGIN_PATH env variable, see https://github.com/gazebosim/gz-rendering/blob/90a13e0b295766bb3a3a33ef3da195d2fc52521b/src/RenderEngineManager.cc#L103 . Instead for gz-physics there is no env variable, and the directory used to search for physics engines are just manager by Ignition Gazebo/gz-sim .

traversaro commented 1 year ago

In https://github.com/conda-forge/libignition-gazebo-feedstock/pull/52/commits/bafc5db219eaea52e5cf23322d6af30d5452afdf and https://github.com/conda-forge/libignition-gazebo-feedstock/pull/52/commits/3647c7160cabd254e75c892c781b0c772ca75bfd I added all the env variables I was able to add to solve the problem that is caused by ign-gazebo not being relocatable (https://github.com/gazebosim/gz-sim/issues/626) and of the binary relocation not properly working on Windows.

traversaro commented 1 year ago

In bafc5db and 3647c71 I added all the env variables I was able to add to solve the problem that is caused by ign-gazebo not being relocatable and of the binary relocation not properly working on Windows.

That was almost correct. The only wrong one was the IGNITION_GAZEBO_SERVER_CONFIG_PATH, that even if it has the same name of the preprocessor macro, it has a different meaning, so you can't just override it. So, for the time being we can't do anything, let's avoid to set it. However, I am not really sure that the simulation is actually correctly running if the default server.config file was not copied and used.

github-actions[bot] commented 1 year ago

Hi! This is the friendly conda-forge automerge bot!

I considered the following status checks when analyzing this PR:

Thus the PR was passing and merged! Have a great day!