gym_gz_environments.tasks#

gym_gz_environments.tasks.cartpole_continuous_balancing#

class gym_gz_environments.tasks.cartpole_continuous_balancing.CartPoleContinuousBalancing(agent_rate, reward_cart_at_center=True, **kwargs)#

Bases: Task, ABC

create_spaces()#

Create the action and observations spaces.

Note

This method does not currently have access to the Models part of the environment. If the Task is meant to work on different models, we recommend using their URDF / SDF model to extract the information you need (e.g. number of DoFs, joint position limits, etc). Since actions and observations are often normalized, in many cases there’s no need to extract a lot of information from the model file.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

A tuple containing the action and observation spaces.

get_observation()#

Return the task observation.

This method contains the logic for constructing the environment observation. It is called in the end of both gym.Env.reset() and gym.Env.step() methods.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

The task observation.

get_reward()#

Return the task reward.

This method contains the logic for computing the environment reward. It is called in the end of the gym.Env.step() method.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

The scalar reward.

is_terminated()#

Return the task termination flag.

This method contains the logic for defining when the environment has terminated. Subsequent calls to Task.set_action() should be preceded by a task reset through Task.reset_task().

It is called in the end of the gym.Env.step() method.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

True if the environment terminated, False otherwise.

is_truncated()#

Return the task truncation flag.

This method contains the logic for defining when the environment has truncated. Subsequent calls to Task.set_action() should be preceded by a task reset through Task.reset_task().

It is called in the end of the gym.Env.step() method.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

True if the environment truncated, False otherwise.

reset_task()#

Reset the task.

This method contains the logic for resetting the task. It is called in the gym.Env.reset() method of the corresponding environment.

Raises:

RuntimeError – In case of failure.

Return type:

set_action(action)#

Set the task action.

This method contains the logic for setting the environment action. It is called in the beginning of the gym.Env.step() method.

Parameters:

action () – The action to set.

Raises:

RuntimeError – In case of failure.

Return type:

gym_gz_environments.tasks.cartpole_continuous_swingup#

class gym_gz_environments.tasks.cartpole_continuous_swingup.CartPoleContinuousSwingup(agent_rate, reward_cart_at_center=True, **kwargs)#

Bases: Task, ABC

create_spaces()#

Create the action and observations spaces.

Note

This method does not currently have access to the Models part of the environment. If the Task is meant to work on different models, we recommend using their URDF / SDF model to extract the information you need (e.g. number of DoFs, joint position limits, etc). Since actions and observations are often normalized, in many cases there’s no need to extract a lot of information from the model file.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

A tuple containing the action and observation spaces.

get_observation()#

Return the task observation.

This method contains the logic for constructing the environment observation. It is called in the end of both gym.Env.reset() and gym.Env.step() methods.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

The task observation.

get_reward()#

Return the task reward.

This method contains the logic for computing the environment reward. It is called in the end of the gym.Env.step() method.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

The scalar reward.

is_terminated()#

Return the task termination flag.

This method contains the logic for defining when the environment has terminated. Subsequent calls to Task.set_action() should be preceded by a task reset through Task.reset_task().

It is called in the end of the gym.Env.step() method.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

True if the environment terminated, False otherwise.

is_truncated()#

Return the task truncation flag.

This method contains the logic for defining when the environment has truncated. Subsequent calls to Task.set_action() should be preceded by a task reset through Task.reset_task().

It is called in the end of the gym.Env.step() method.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

True if the environment truncated, False otherwise.

reset_task()#

Reset the task.

This method contains the logic for resetting the task. It is called in the gym.Env.reset() method of the corresponding environment.

Raises:

RuntimeError – In case of failure.

Return type:

set_action(action)#

Set the task action.

This method contains the logic for setting the environment action. It is called in the beginning of the gym.Env.step() method.

Parameters:

action () – The action to set.

Raises:

RuntimeError – In case of failure.

Return type:

gym_gz_environments.tasks.cartpole_discrete_balancing#

class gym_gz_environments.tasks.cartpole_discrete_balancing.CartPoleDiscreteBalancing(agent_rate, reward_cart_at_center=True, **kwargs)#

Bases: Task, ABC

create_spaces()#

Create the action and observations spaces.

Note

This method does not currently have access to the Models part of the environment. If the Task is meant to work on different models, we recommend using their URDF / SDF model to extract the information you need (e.g. number of DoFs, joint position limits, etc). Since actions and observations are often normalized, in many cases there’s no need to extract a lot of information from the model file.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

A tuple containing the action and observation spaces.

get_observation()#

Return the task observation.

This method contains the logic for constructing the environment observation. It is called in the end of both gym.Env.reset() and gym.Env.step() methods.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

The task observation.

get_reward()#

Return the task reward.

This method contains the logic for computing the environment reward. It is called in the end of the gym.Env.step() method.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

The scalar reward.

is_terminated()#

Return the task termination flag.

This method contains the logic for defining when the environment has terminated. Subsequent calls to Task.set_action() should be preceded by a task reset through Task.reset_task().

It is called in the end of the gym.Env.step() method.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

True if the environment terminated, False otherwise.

is_truncated()#

Return the task truncation flag.

This method contains the logic for defining when the environment has truncated. Subsequent calls to Task.set_action() should be preceded by a task reset through Task.reset_task().

It is called in the end of the gym.Env.step() method.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

True if the environment truncated, False otherwise.

reset_task()#

Reset the task.

This method contains the logic for resetting the task. It is called in the gym.Env.reset() method of the corresponding environment.

Raises:

RuntimeError – In case of failure.

Return type:

set_action(action)#

Set the task action.

This method contains the logic for setting the environment action. It is called in the beginning of the gym.Env.step() method.

Parameters:

action () – The action to set.

Raises:

RuntimeError – In case of failure.

Return type:

gym_gz_environments.tasks.pendulum_swingup#

class gym_gz_environments.tasks.pendulum_swingup.PendulumSwingUp(agent_rate, **kwargs)#

Bases: Task, ABC

create_spaces()#

Create the action and observations spaces.

Note

This method does not currently have access to the Models part of the environment. If the Task is meant to work on different models, we recommend using their URDF / SDF model to extract the information you need (e.g. number of DoFs, joint position limits, etc). Since actions and observations are often normalized, in many cases there’s no need to extract a lot of information from the model file.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

A tuple containing the action and observation spaces.

get_observation()#

Return the task observation.

This method contains the logic for constructing the environment observation. It is called in the end of both gym.Env.reset() and gym.Env.step() methods.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

The task observation.

get_reward()#

Return the task reward.

This method contains the logic for computing the environment reward. It is called in the end of the gym.Env.step() method.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

The scalar reward.

is_terminated()#

Return the task termination flag.

This method contains the logic for defining when the environment has terminated. Subsequent calls to Task.set_action() should be preceded by a task reset through Task.reset_task().

It is called in the end of the gym.Env.step() method.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

True if the environment terminated, False otherwise.

is_truncated()#

Return the task truncation flag.

This method contains the logic for defining when the environment has truncated. Subsequent calls to Task.set_action() should be preceded by a task reset through Task.reset_task().

It is called in the end of the gym.Env.step() method.

Raises:

RuntimeError – In case of failure.

Return type:

Returns:

True if the environment truncated, False otherwise.

reset_task()#

Reset the task.

This method contains the logic for resetting the task. It is called in the gym.Env.reset() method of the corresponding environment.

Raises:

RuntimeError – In case of failure.

Return type:

set_action(action)#

Set the task action.

This method contains the logic for setting the environment action. It is called in the beginning of the gym.Env.step() method.

Parameters:

action () – The action to set.

Raises:

RuntimeError – In case of failure.

Return type: