Skip to content

Commit

Permalink
Set gz-sim environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
xela-95 committed Apr 4, 2024
1 parent fa67e0e commit 62abdce
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 8 deletions.
5 changes: 5 additions & 0 deletions cmake/template/addPathsToUserEnvVariables.ps1.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ Add-ValueToUserEnvVariable GAZEBO_RESOURCE_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_P
@cmakeif ROBOTOLOGY_USES_GZ
# ROBOTOLOGY_USES_GZ-specific lines
Add-ValueToUserEnvVariable GZ_SIM_SYSTEM_PLUGIN_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\bin";
Add-ValueToUserEnvVariable GZ_SIM_RESOURCE_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\gazebo\models"
Add-ValueToUserEnvVariable GZ_SIM_RESOURCE_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\iCub\robots"
Add-ValueToUserEnvVariable GZ_SIM_RESOURCE_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\ergoCub\robots"
Add-ValueToUserEnvVariable GZ_SIM_RESOURCE_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share"
Add-ValueToUserEnvVariable GZ_SIM_RESOURCE_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\gazebo\worlds"
@endcmakeif ROBOTOLOGY_USES_GZ

@cmakeif ROBOTOLOGY_ENABLE_ROBOT_TESTING
Expand Down
5 changes: 5 additions & 0 deletions cmake/template/removePathsFromUserEnvVariables.ps1.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ Remove-ValueFromUserEnvVariable GAZEBO_RESOURCE_PATH $ROBOTOLOGY_SUPERBUILD_INST
@cmakeif ROBOTOLOGY_USES_GZ
# Cleanup ROBOTOLOGY_USES_GZ-specific lines
Remove-ValueFromUserEnvVariable GZ_SIM_SYSTEM_PLUGIN_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\bin";
Remove-ValueFromUserEnvVariable GZ_SIM_RESOURCE_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\gazebo\models"
Remove-ValueFromUserEnvVariable GZ_SIM_RESOURCE_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\iCub\robots"
Remove-ValueFromUserEnvVariable GZ_SIM_RESOURCE_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\ergoCub\robots"
Remove-ValueFromUserEnvVariable GZ_SIM_RESOURCE_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share"
Remove-ValueFromUserEnvVariable GZ_SIM_RESOURCE_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\gazebo\worlds"
@endcmakeif ROBOTOLOGY_USES_GZ

@cmakeif ROBOTOLOGY_ENABLE_ROBOT_TESTING
Expand Down
2 changes: 2 additions & 0 deletions cmake/template/setup.bat.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set "GAZEBO_RESOURCE_PATH=%GAZEBO_RESOURCE_PATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_
@cmakeif ROBOTOLOGY_USES_GZ
rem ROBOTOLOGY_USES_GZ-specific lines
set "GZ_SIM_SYSTEM_PLUGIN_PATH=%GZ_SIM_SYSTEM_PLUGIN_PATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\bin"
set "GZ_SIM_RESOURCE_PATH=%GZ_SIM_RESOURCE_PATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\gazebo\models;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\iCub\robots;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\ergoCub\robots";%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\gazebo\worlds"
@endcmakeif ROBOTOLOGY_USES_GZ

@cmakeif ROBOTOLOGY_ENABLE_ROBOT_TESTING
Expand All @@ -54,6 +55,7 @@ set "PATH=%PATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\@ROBOTOLOGY_SUPERBUILD_P
rem Set YARP and Gazebo related env variables
set "YARP_DATA_DIRS=%YARP_DATA_DIRS%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\RRbot"
set "GAZEBO_MODEL_PATH=%GAZEBO_MODEL_PATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\RRbot\robots"
set "GZ_SIM_RESOURCE_PATH=%GZ_SIM_RESOURCE_PATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\RRbot\robots"
rem Configure the Matlab
set "MATLABPATH=%MATLABPATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\mex;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\mex\+wbc\simulink;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\mex\+wbc\simulink\MomentumVelocityControl;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\mex\+wbc\examples;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\WBToolbox;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\WBToolbox\images"
@endcmakeif ROBOTOLOGY_USES_MATLAB
Expand Down
2 changes: 2 additions & 0 deletions cmake/template/setup.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export GAZEBO_RESOURCE_PATH=${GAZEBO_RESOURCE_PATH:+${GAZEBO_RESOURCE_PATH}:}${R
# ROBOTOLOGY_USES_GZ-specific lines
# Gazebo related env variables (see https://gazebosim.org/api/sim/8/resources.html )
export GZ_SIM_SYSTEM_PLUGIN_PATH=${GZ_SIM_SYSTEM_PLUGIN_PATH:+${GZ_SIM_SYSTEM_PLUGIN_PATH}:}${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/lib
export GZ_SIM_RESOURCE_PATH=${GZ_SIM_RESOURCE_PATH:+${GZ_SIM_RESOURCE_PATH}:}${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/gazebo/models:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/iCub/robots:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/ergoCub/robots:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/gazebo/worlds
@endcmakeif ROBOTOLOGY_USES_GZ

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH:+${ROS_PACKAGE_PATH}:}${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share
Expand Down Expand Up @@ -58,6 +59,7 @@ export PATH=$PATH:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/@ROBOTOLOGY_SUPERBUILD
# Set YARP and Gazebo related env variables
export YARP_DATA_DIRS=$YARP_DATA_DIRS:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/RRbot
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/RRbot/robots
export GZ_SIM_RESOURCE_PATH=$GZ_SIM_RESOURCE_PATH:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/RRbot/robots
# Configure the Matlab path
export MATLABPATH=${MATLABPATH:+${MATLABPATH}:}${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/mex:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/mex/+wbc/simulink/MomentumVelocityControl:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/mex/+wbc/simulink:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/mex/+wbc/examples:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/WBToolbox:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/WBToolbox/images
# Avoid problems with buggy Linux drivers, see https://github.com/robotology/robotology-superbuild/issues/953
Expand Down
8 changes: 6 additions & 2 deletions conda/multisheller/ergocub-software_activate.msh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ if_(is_set("COMSPEC")).then_([
])

# For some reason setting two times the same variable inside the same if does not work in command prompt
# As a workaround, we move each GAZEBO_MODEL_PATH set to a separate if
# As a workaround, we move each GAZEBO_MODEL_PATH and GZ_SIM_RESOURCE_PATH set to a separate if
if_(is_set("COMSPEC")).then_([
sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share\\ergoCub\\robots"))
sys.list_append("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share\\ergoCub\\robots"))
]).else_([
sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share/ergoCub/robots"))
sys.list_append("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "share/ergoCub/robots"))
])

if_(is_set("COMSPEC")).then_([
sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share"))
sys.list_append("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share"))
]).else_([
sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share"))
])
sys.list_append("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "share"))
])
8 changes: 6 additions & 2 deletions conda/multisheller/ergocub-software_deactivate.msh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ if_(is_set("COMSPEC")).then_([
])

# For some reason setting two times the same variable inside the same if does not work in command prompt
# As a workaround, we move each GAZEBO_MODEL_PATH set to a separate if
# As a workaround, we move each GAZEBO_MODEL_PATH and GZ_SIM_RESOURCE_PATH set to a separate if
if_(is_set("COMSPEC")).then_([
sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share\\ergoCub\\robots"))
sys.list_remove("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share\\ergoCub\\robots"))
]).else_([
sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share/ergoCub/robots"))
sys.list_remove("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "share/ergoCub/robots"))
])

if_(is_set("COMSPEC")).then_([
sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share"))
sys.list_remove("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share"))
]).else_([
sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share"))
])
sys.list_remove("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "share"))
])
6 changes: 5 additions & 1 deletion conda/multisheller/matlab-whole-body-simulator_activate.msh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ if_(is_set("COMSPEC")).then_([
sys.list_append("ROS_PACKAGE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share")),
sys.list_append("AMENT_PREFIX_PATH", path.join(env("CONDA_PREFIX"), "Library")),
sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share\\RRbot\\robots"))
sys.list_append("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share\\RRbot\\robots"))
]).else_([
sys.list_append("YARP_DATA_DIRS", path.join(env("CONDA_PREFIX"), "share/RRbot")),
sys.list_append("ROS_PACKAGE_PATH", path.join(env("CONDA_PREFIX"), "share")),
sys.list_append("AMENT_PREFIX_PATH", env("CONDA_PREFIX")),
sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share/RRbot/robots"))
sys.list_append("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "share/RRbot/robots"))
])

# For some reason setting two times the same variable inside the same if does not work in command prompt
# As a workaround, we move each GAZEBO_MODEL_PATH set to a separate if
# As a workaround, we move each GAZEBO_MODEL_PATH and GZ_SIM_RESOURCE_PATH set to a separate if
if_(is_set("COMSPEC")).then_([
sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share"))
sys.list_append("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share"))
]).else_([
sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share"))
sys.list_append("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "share"))
])
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ if_(is_set("COMSPEC")).then_([
sys.list_remove("ROS_PACKAGE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share")),
sys.list_remove("AMENT_PREFIX_PATH", path.join(env("CONDA_PREFIX"), "Library")),
sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share\\RRbot\\robots"))
sys.list_remove("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share\\RRbot\\robots"))
]).else_([
sys.list_remove("YARP_DATA_DIRS", path.join(env("CONDA_PREFIX"), "share/RRbot")),
sys.list_remove("ROS_PACKAGE_PATH", path.join(env("CONDA_PREFIX"), "share")),
sys.list_remove("AMENT_PREFIX_PATH", env("CONDA_PREFIX")),
sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share/RRbot/robots"))
sys.list_remove("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "share/RRbot/robots"))
])

# For some reason setting two times the same variable inside the same if does not work in command prompt
# As a workaround, we move each GAZEBO_MODEL_PATH set to a separate if
# As a workaround, we move each GAZEBO_MODEL_PATH and GZ_SIM_RESOURCE_PATHset to a separate if
if_(is_set("COMSPEC")).then_([
sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share"))
sys.list_remove("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share"))
]).else_([
sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share"))
sys.list_remove("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "share"))
])
17 changes: 15 additions & 2 deletions doc/environment-variables-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ and`$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/Wearables` must be appended to t
This section covers the configuration necessary for a specific dependency.
For all dependecies option not listed, no additional configuration is necessary.

### Gazebo
### Gazebo Classic
The following enviroment variables need to be appended with robotology-superbuild related directories:
~~~
# Gazebo related env variables (see http://gazebosim.org/tutorials?tut=components#EnvironmentVariables )
Expand All @@ -70,6 +70,14 @@ export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:${ROBOTOLOGY_SUPERBUILD_INSTALL_PR
export GAZEBO_RESOURCE_PATH=${GAZEBO_RESOURCE_PATH}:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/gazebo/worlds
~~~

### Gazebo
The following enviroment variables need to be appended with robotology-superbuild related directories:
~~~
# Gazebo related env variables (see https://gazebosim.org/api/sim/8/resources.html )
export GZ_SIM_SYSTEM_PLUGIN_PATH=${GZ_SIM_SYSTEM_PLUGIN_PATH}:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/lib
export GZ_SIM_RESOURCE_PATH=${GZ_SIM_RESOURCE_PATH}:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/gazebo/models:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/iCub/robots:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/ergoCub/robots:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/gazebo/worlds
~~~

### MATLAB

For adding the multiple libraries to the MATLAB path, the environment variable `MATLABPATH` has to be appended with the following robotology-superbuild related directories:
Expand All @@ -82,11 +90,16 @@ For adding the multiple libraries to the MATLAB path, the environment variable `
For MATLAB to find the robot model files added by the repository [`matlab-whole-body-simulator`](https://github.com/dic-iit/matlab-whole-body-simulator), you need to append `YARP_DATA_DIRS` the directory:
* `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/RRbot`

#### MATLAB/Gazebo
#### MATLAB/Gazebo Classic

`GAZEBO_MODEL_PATH` needs to be appended with:
* `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/RRbot/robots`

#### MATLAB/Gazebo

`GZ_SIM_RESOURCE_PATH` needs to be appended with:
* `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/RRbot/robots`

### Python
`$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/lib/python3.6/dist-packages` and `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/lib/python3.6/site-packages` must be appended to the `PYTHONPATH` environmental variable.

Expand Down

0 comments on commit 62abdce

Please sign in to comment.