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

Added wrapper functionality #10

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jangroter
Copy link
Collaborator

This PR adds wrapper functionality to BlueSky-Gym.

Wrappers are a tool to extend the functionality of an environment, and should ideally be environment independent.
Usage of a wrapper requires initialization of the environment, and then `wrapping' this initialized environment.

See the following example for creating a simple 'noisy observation' environment

import gymnasium as gym
import bluesky_gym
from bluesky_gym.wrappers.wind import NoisyObservationWrapper
bluesky_gym.register_envs()

env = gym.make('MergeEnv-v0', render_mode='human')
noisy_env = NoisyObservationWrapper(env, noise_level=0.2)

In theory wrappers can overwrite or add functionality to all of the core functions of the environments.
Below is a more complex example utilizing the windfield wrapper to create a static windfield with 4 sources of wind and no altitude gradient:

import gymnasium as gym
import bluesky_gym
from bluesky_gym.wrappers.wind import WindFieldWrapper
import numpy as np
bluesky_gym.register_envs()

env = gym.make('MergeEnv-v0', render_mode='human')

# Define the coordinates of the wind
lat = np.array([51.9,51.9,52.1,52.1])
lon = np.array([3.9,4.1,3.9,4.1])
vnorth = np.array([[16, 12, 14, 15]]) # 2D because one dimension is used for altitude, which we leave at None
veast = np.array([[3, 7, 9, 4]])

windy_env = WindFieldWrapper(env, lat=lat, lon=lon, vnorth=vnorth, veast=veast, augment_obs=True)

@jangroter jangroter added the enhancement New feature or request label Dec 13, 2024
@jangroter
Copy link
Collaborator Author

Main.py should not be changed in the PR, revert changes

@jangroter
Copy link
Collaborator Author

Additional check text in the readme.MD file which requires some small changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant