PositionWithinLimitsActionManager#

class genesis_forge.managers.action.PositionWithinLimitsActionManager(env: GenesisEnv, actuator_manager: ActuatorManager | None = None, action_handler: Callable[[torch.Tensor], None] = None, quiet_action_errors: bool = False, 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.

  • action_handler – A function to handle the actions.

  • 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.

Example:

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

    def config(self):
        self.actuator_manager = ActuatorManager(
            self,
            joint_names=".*",
            default_pos={
                # Hip joints
                "Leg[1-2]_Hip": -1.0,
                "Leg[3-4]_Hip": 1.0,
                # Femur joints
                "Leg[1-4]_Femur": 0.5,
                # Tibia joints
                "Leg[1-4]_Tibia": 0.6,
            },
            kp={".*": 50},
            kv={".*": 0.5},
            max_force={".*": 8.0},
        )
        self.action_manager = PositionalActionManager(
            self,
            actuator_manager=self.actuator_manager,
        )
build()[source]#

Builds the manager and initialized all the buffers.

get_actions() torch.Tensor#

Get the current actions for the environments.

get_dofs_force(noise: float = 0.0, clip_to_max_force: bool = False)#

Deprecated: Use the actuator manager directly.

Return the force experienced by the enabled DOFs. This is a wrapper for RigidEntity.get_dofs_force.

Parameters:
  • noise – The maximum amount of random noise to add to the force values returned.

  • clip_to_max_force – Clip the force returned to the maximum force defined by the max_force parameter.

Returns:

The force experienced by the enabled DOFs.

get_dofs_position(noise: float = 0.0)#

Deprecated: Use the actuator manager directly.

Return the current position of the enabled DOFs. This is a wrapper for RigidEntity.get_dofs_position.

Parameters:

noise – The maximum amount of random noise to add to the position values returned.

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

Deprecated: Use the actuator manager directly.

Return the current velocity of the enabled DOFs. This is a wrapper for RigidEntity.get_dofs_velocity.

Parameters:
  • noise – The maximum amount of random noise to add to the velocity values returned.

  • clip – Clip the velocity returned.

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

Converts the actions to position commands, and send them to the DOF actuators. Override this function if you want to change the action handling logic.

Parameters:

actions – The incoming step actions to handle.

Returns:

The processed and handled actions.

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

Reset environments.

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

Take the incoming actions for this step and handle them.

Parameters:

actions – The incoming step actions to handle.

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 actions for for the current step.

property actuators: ActuatorManager#

Get the actuator manager.

property default_dofs_pos: torch.Tensor#

Return the default DOF positions.

property dofs_idx: list[int]#

Get the indices of the DOF that are enabled (via joint_names).

property num_actions: int#

Get the number of actions.

property raw_actions: torch.Tensor#

The actions received from the policy, before being converted.