gym_ignition.randomizers

gym_ignition.randomizers.abc

class gym_ignition.randomizers.abc.ModelDescriptionRandomizer

Bases: abc.ABC

abstract randomize_model_description(task, **kwargs)

Randomize the model description.

Parameters

task (Task) – The task that operates on the model description to randomize.

Return type

str

Returns

A string with the randomized model description.

class gym_ignition.randomizers.abc.ModelRandomizer

Bases: abc.ABC

abstract randomize_model(task, **kwargs)

Randomize the model.

Parameters

task (Task) – The task that operates on the model to randomize.

Return type

Model

Returns

The randomized model.

class gym_ignition.randomizers.abc.PhysicsRandomizer(randomize_after_rollouts_num=0)

Bases: abc.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 times gym.Env.reset() is called).

abstract get_engine()

Return the physics engine to use for the rollout.

Note

Supported physics engines:

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_ignition.randomizers.abc.TaskRandomizer

Bases: abc.ABC

abstract randomize_task(task, **kwargs)

Randomize a Task instance.

Parameters

task (Task) – the task to randomize.

Note

Note that each task has a world property that provides access to the simulated scenario.bindings.core.World.

Return type

None

gym_ignition.randomizers.gazebo_env_randomizer

class gym_ignition.randomizers.gazebo_env_randomizer.GazeboEnvRandomizer(env, physics_randomizer=<gym_ignition.randomizers.physics.dart.DART object>, **kwargs)

Bases: gym.core.Wrapper, gym_ignition.randomizers.abc.TaskRandomizer, abc.ABC

Base class to implement an environment randomizer for Ignition Gazebo.

The randomizer is a gym.Wrapper that extends the gym.Env.reset() method. Objects that inherit from this class are used to setup the environment for the handled Task.

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 and PhysicsRandomizer to randomize the physics.

Parameters
  • env (Union[str, Callable[[Optional[Dict, None]], 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.

reset(**kwargs)

Resets the environment to an initial state and returns an initial observation.

Note that this function should not reset the environment’s random number generator(s); random variables in the environment’s state should be sampled independently between multiple calls to reset(). In other words, each call of reset() should yield an environment suitable for a new episode, independent of previous episodes.

Returns

the initial observation.

Return type

observation (object)