PositionWithinLimitsActionManager#

class genesis_forge.managers.action.PositionWithinLimitsActionManager(env: GenesisEnv, actuator_manager: ActuatorManager | None = None, actuator_joints: list[str] | str = '.*', quiet_action_errors: bool = False, limit: tuple[float, float] | dict[str, tuple[float, float]] = {}, soft_limit_scale_factor: float = 1.0, delay_step: int = 0, **kwargs)[source]#

Bases: PositionActionManager

This is similar to PositionActionManager but converts actions from the range -1.0 - 1.0 to DOF positions within the limits of the actuators.

Parameters:
  • env – The environment to manage the DOF actuators for.

  • actuator_manager – The actuator manager which is used to setup and control the DOF joints.

  • actuator_joints – Which joints of the actuator manager that this action manager will control. These can be full names or regular expressions.

  • limit – A dictionary of DOF name patterns and their position limits. If omitted, the limits will be set to the limits of the actuators defined in the model.

  • soft_limit_scale_factor – Scales the range of all limits by this factor to establish a safety region within the limits. Defaults to 1.0.

  • quiet_action_errors – Whether to quiet action errors.

  • delay_step – The number of steps to delay the actions for. This is an easy way to emulate the latency in the system.

Simple example using the limits defined in the model:

class MyEnv(ManagedEnvironment):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def config(self):
        self.actuator_manager = ActuatorManager(
            self,
            joint_names=".*",
            default_pos={".*": 0.0},
            kp={".*": 50},
            kv={".*": 0.5},
        )
        self.action_manager = PositionalActionManager(
            self,
            actuator_manager=self.actuator_manager,
            actuator_joints=[".*"], # optional joint filter
        )

Example defining custom limits:

class MyEnv(ManagedEnvironment):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def config(self):
        self.actuator_manager = ActuatorManager(
            self,
            joint_names=".*",
            default_pos={".*": 0.0},
            kp={".*": 50},
            kv={".*": 0.5},
        )
        self.action_manager = PositionalActionManager(
            self,
            actuator_manager=self.actuator_manager,
            limit = {
                ".*_Hip": (-1.0, 1.0),
                ".*_Femur": (-1.5, 1.2),
            },
        )
build()[source]#

Builds the manager and initialized all the buffers.

get_actions() torch.Tensor#

Get the current actions for the environments.

get_actions_dict(env_idx: int = 0) dict[str, float]#

Get the latest actions for an environment as a dictionary of DOF names and values.

get_dofs_force(clip_to_max_force: bool = False)#

A wrapper for RigidEntity.get_dofs_force that returns the force experienced by the controlled DOFs.

Parameters:

clip_to_max_force – Clip the force returned to the maximum force defined by the max_force parameter defined in the actuator manager.

Returns:

torch.Tensor, shape (n_envs, n_dofs) The force experienced by the enabled DOFs.

Return type:

force

get_dofs_limits()#

A wrapper for RigidEntity.get_dofs_limit that returns the limits of the controlled DOFs.

Returns:

torch.Tensor, shape (n_dofs,) or (n_envs, n_dofs)

The lower limit of the positional limits for the entity’s dofs.

upper_limit: torch.Tensor, shape (n_dofs,) or (n_envs, n_dofs)

The upper limit of the positional limits for the entity’s dofs.

Return type:

lower_limit

get_dofs_position()#

A wrapper for RigidEntity.get_dofs_limits that returns the position limits of the controlled DOFs.

Returns:

tuple[torch.Tensor, torch.Tensor]

The position of the DOFs managed by this action manager.

Return type:

position

get_dofs_velocity(clip: tuple[float, float] = None)#

A wrapper for RigidEntity.get_dofs_velocity that returns the current velocity of the controlled DOFs.

Parameters:

clip – Range to clip the velocity to.

Returns:

torch.Tensor, shape (n_envs, n_dofs) The velocity of the enabled DOFs managed by this action manager.

Return type:

velocity

process_actions(actions: torch.Tensor) torch.Tensor[source]#

Convert the actions to position commands within the limits.

Parameters:

actions – The incoming step actions to handle.

Returns:

The actions as position commands.

reset(envs_idx: list[int] | None)#

Reset environments.

send_actions_to_simulation(actions: torch.Tensor) torch.Tensor#

Sends the actions as position commands to the actuators in the simulation.

step(actions: torch.Tensor) None#

Handle actions received in this step.

property action_space: tuple[float, float]#

Returns the actions space for the environment, based on the number of DOFs defined in this action manager.

property actions: torch.Tensor#

The processed actions for for the current step.

property actuator_dof_filter: torch.Tensor#

An index filter for the actuator DOF buffer values.

property actuator_manager: ActuatorManager#

Get the actuator manager.

property actuators: ActuatorManager#
property default_dofs_pos: torch.Tensor#

Return the default DOF positions.

property dofs: dict[str, int]#

Get a dictionary of the DOF names and their indices

property dofs_idx: list[int]#

Get the indices of the DOFs that this action manager controls.

property last_actions: torch.Tensor#

The processed actions for for the previous step.

property num_actions: int#

Get the number of actions.

property raw_actions: torch.Tensor#

The actions received from the policy, before being processed.