obstacle#
- class gym_socks.envs.obstacle.BaseObstacle(*args, **kwargs)[source]#
Base obstacle class.
This class is ABSTRACT, meaning it is not meant to be instantiated directly. Instead, define a new class that inherits from BaseObstacle.
All obstacles inherit from BaseDynamicalObject, meaning they must implement the step, reset, render, close, and seed methods in their custom implementations. This is necessary so that the World class in gym_socks.envs.world can register them as objects in the world environment.
In addition, all obstacles must implement an intersects method, which returns true if the state of the dynamical system intersects with the obstacle. For instance, this could identify a collision, an unsafe region, or a non-violable constraint.
- Parameters
args (Any) –
kwargs (Any) –
- Return type
Any
- close()[source]#
Override close in your subclass to perform any necessary cleanup.
Environments will automatically
close()themselves when garbage collected or when the program exits.
- abstract intersects(time, state)[source]#
Check if the state intersects the obstacle.
This function is used to check whether or not the state of a dynamical system intersects the given obstacle. It should return True if the system intersects the obstacle and False otherwise.
- Parameters
time – The time step of the simulation.
state – The state of the dynamical system.
- Returns
A boolean indicator.
- abstract render(mode='human')[source]#
Renders the environment.
This method must be overridden in subclasses in order to enable rendering. Not all environments support rendering.
- Parameters
mode – the mode to render with
- abstract reset(state=None)[source]#
Reset the object to an initial state.
Resets the object to an initial state (which may be random).
- Returns
The new initial state of the object.
- seed(seed=None)[source]#
Sets the seed of the random number generator.
- Parameters
seed – Integer value representing the random seed.
- Returns
The seed of the RNG.
- abstract step()[source]#
Advance the object forward in time.
Advances the object in the simulation. By default, an object is uncontrolled, meaning it accepts no parameters and the system evolves forward in time according to its own, internal dynamics. Controlled systems should accept an
actionparameter, which represents the user-selected control input.Additionally, time-varying systems should also accept a
timeparameter.- Returns
A tuple
(obs, cost, done, info), whereobsis the observation vector. Generally, it is the state of the system corrupted by some measurement noise. If the system is fully observable, this is the actual state of the system at the next time step.costis the cost (reward) obtained by the system for taking action u in state x and transitioning to state y. In general, this is not typically used withDynamicalSystemmodels.doneis a flag to indicate the simulation has terminated. Usually toggled by guard conditions, which terminates the simulation if the system violates certain operating constraints.infois a dictionary containing extra information.