Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Use a single environment variable to find both models and meshes #31

Merged
merged 2 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,23 @@ Only GNU/Linux distributions are currently supported.

#### Standalone usage

If you use Ignition Gazebo, you need to execute the following commands (from outside the directory where you cloned this repository):
If you use Ignition Gazebo, you need to specify where the models and their dependent resources are located in the filesystem.
The simulator reads the `IGN_GAZEBO_RESOURCE_PATH` environment variable.

Execute the following commands from outside the directory where you cloned this repository to temporarily configure your environment:

```sh
PKG_DIR=$(python -c "import gym_ignition_models, inspect, os; print(os.path.dirname(inspect.getfile(gym_ignition_models)))")
export SDF_PATH=$PKG_DIR:SDF_PATH
export IGN_GAZEBO_RESOURCE_PATH=$PKG_DIR:$IGN_GAZEBO_RESOURCE_PATH
```

If you want to make this change persistent, add the lines above to your `~/.bashrc`.

**Note:** waiting an [upstream fix](https://bitbucket.org/osrf/sdformat/issues/227/error-loading-meshes-from-a-relative), you also need to add to the `IGN_FILE_PATH` environment variable all the directories that contain model's meshes.
**Note:** waiting an [upstream fix](https://github.com/osrf/sdformat/issues/227), you also need to add
to `IGN_GAZEBO_RESOURCE_PATH` all the directories containing model's meshes.

**Note:** Alternatively, instead of using `IGN_GAZEBO_RESOURCE_PATH`, you can use `SDF_PATH` for the models and
`IGN_FILE_PATH` for the meshes.

#### Python usage

Expand Down
12 changes: 6 additions & 6 deletions gym_ignition_models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ def setup_environment() -> None:
raise NotADirectoryError(f"Failed to find path '{models_path}'")

# Setup the environment to find the models
if "SDF_PATH" in os.environ:
os.environ["SDF_PATH"] += f":{models_path}"
if "IGN_GAZEBO_RESOURCE_PATH" in os.environ:
os.environ["IGN_GAZEBO_RESOURCE_PATH"] += f":{models_path}"
else:
os.environ["SDF_PATH"] = f"{models_path}"
os.environ["IGN_GAZEBO_RESOURCE_PATH"] = f"{models_path}"

# Models with mesh files
# Workaround for https://github.com/osrf/sdformat/issues/227
Expand All @@ -111,10 +111,10 @@ def setup_environment() -> None:
if not model_path.exists():
raise NotADirectoryError(f"Failed to find path '{model_path}'")

if "IGN_FILE_PATH" in os.environ:
os.environ["IGN_FILE_PATH"] += f':{model_path}'
if "IGN_GAZEBO_RESOURCE_PATH" in os.environ:
os.environ["IGN_GAZEBO_RESOURCE_PATH"] += f':{model_path}'
else:
os.environ["IGN_FILE_PATH"] = f'{model_path}'
os.environ["IGN_GAZEBO_RESOURCE_PATH"] = f'{model_path}'


# Setup the environment when the package is imported
Expand Down