gym_gz.randomizers#
gym_gz.randomizers.abc#
- class gym_gz.randomizers.abc.ModelDescriptionRandomizer#
Bases:
ABC
- class gym_gz.randomizers.abc.ModelRandomizer#
Bases:
ABC
- class gym_gz.randomizers.abc.PhysicsRandomizer(randomize_after_rollouts_num=0)#
Bases:
ABC
Abstract class that provides the machinery for randomizing the physics of a Task.
- Parameters:
randomize_after_rollouts_num (
int
) – defines after many rollouts physics should be randomized (i.e. the amount of timesgym.Env.reset()
is called).
- abstract get_engine()#
Return the physics engine to use for the rollout.
- Returns:
The desired physics engine to set in the world.
- increase_rollout_counter()#
Increase the rollouts counter.
- Return type:
None
- physics_expired()#
Checks if the physics needs to be randomized.
- Return type:
bool
- Returns:
True if the physics has expired, false otherwise.
- abstract randomize_physics(task, **kwargs)#
Method that insert and configures the physics of a Task’s world.
By default this method loads a plugin that uses DART with no randomizations. Randomizing physics engine parameters or changing physics engine backend could be done by redefining this method and passing it to
GazeboRuntime
.- Parameters:
task (
Task
) – A task containing a world object without physics.- Return type:
None
- class gym_gz.randomizers.abc.TaskRandomizer#
Bases:
ABC
- abstract randomize_task(task, **kwargs)#
Randomize a
Task
instance.- Parameters:
task (
Task
) – the task to randomize.- Return type:
None
Note
Note that each task has a
world
property that provides access to the simulatedscenario.bindings.core.World
.
gym_gz.randomizers.gazebo_env_randomizer#
- class gym_gz.randomizers.gazebo_env_randomizer.GazeboEnvRandomizer(env, physics_randomizer=<gym_gz.randomizers.physics.dart.DART object>, **kwargs)#
Bases:
Wrapper
,TaskRandomizer
,ABC
Base class to implement an environment randomizer for Gz sim.
The randomizer is a
gym.Wrapper
that extends thegym.Env.reset()
method. Objects that inherit from this class are used to setup the environment for the handledTask
.In its simplest form, a randomizer populates the world with all the models that need to be part of the simulation. The task could then operate on them from a
Model
object.More complex environments may require to randomize one or more simulated entities. Concrete classes that implement a randomizer could use
SDFRandomizer
to randomize the model andPhysicsRandomizer
to randomize the physics.- Parameters:
env (
Union
[str
,Callable
[[Optional
[Dict
]],Env
]]) – Defines the environment to handle. This argument could be either the string id if the environment does not need to be registered or a function that returns an environment object.physics_randomizer (
PhysicsRandomizer
) – Object that randomizes physics. The default physics engine is DART with no randomizations.
Note
In order to randomize physics, the handled
scenario.gazebo.GazeboSimulator
is destroyed and created again. This operation is demanding, consider randomizing physics at a low rate.