PositionActionManager#

class genesis_forge.managers.action.PositionActionManager(env: GenesisEnv, joint_names: list[str] | str = '.*', default_pos: dict[str, float] | float = {'.*': 0.0}, scale: dict[str, float] | float = 1.0, clip: dict[str, tuple[float, float]] | tuple[float, float] = None, offset: dict[str, float] | float = 0.0, use_default_offset: bool = True, pd_kp: dict[str, float] | float = None, pd_kv: dict[str, float] | float = None, max_force: dict[str, float | tuple[float, float]] | float | tuple[float, float] = None, damping: dict[str, float] | float = None, stiffness: dict[str, float] | float = None, frictionloss: dict[str, float] | float = None, noise_scale: float = 0.0, action_handler: Callable[[torch.Tensor], None] = None, quiet_action_errors: bool = False, delay_step: int = 0)[source]#

Bases: BaseActionManager

Converts actions to DOF positions, using affine transformations (scale and offset).

\[position = offset + scaling * action\]

If use_default_offset is True, the offset will be set to the default_pos value for each DOF/joint.

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

  • joint_names – The joint names to manage.

  • default_pos – The default DOF positions.

  • scale – How much to scale the action.

  • offset – Offset factor for the action.

  • use_default_offset – Whether to use default joint positions configured in the articulation asset as offset. Defaults to True.

  • clip – Clip the action values to the range. If omitted, the action values will automatically be clipped to the joint limits.

  • pd_kp – The PD kp values.

  • pd_kv – The PD kv values.

  • max_force – The max force values.

  • damping – The damping values.

  • stiffness – The stiffness values.

  • frictionloss – The frictionloss values.

  • reset_random_scale – Scale all DOF values on reset by this amount +/-.

  • quiet_action_errors – Whether to quiet action errors.

  • randomization_cfg – The randomization configuration used to randomize the DOF values across all environments and between resets.

  • resample_randomization_s – The time interval to resample the randomization values.

  • 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)
        # ...define scene and robot...

    def config(self):
        self.action_manager = PositionActionManager(
            self,
            joint_names=".*",
            scale=0.5,
            use_default_offset=True,
            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,
            },
            pd_kp=50,
            pd_kv=0.5,
            max_force=8.0,
        )

Example using the manager directly:

class MyEnv(GenesisEnv):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # ...define scene and robot...

    def config(self):
        self.action_manager = PositionActionManager(
            self,
            joint_names=".*",
            action_scale=0.5,
            action_offset=0.0,
            use_default_offset=True,
            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,
            },
            pd_kp=50,
            pd_kv=0.5,
            max_force=8.0,
        )

    def build(self):
        super().build()
        config()

    step(self, actions: torch.Tensor) -> None:
        super().step(actions)
        self.action_manager.step(actions)

        # ...do other step things...

    reset(self, envs_idx: list[int] = None) -> None:
        super().reset(envs_idx)
        self.action_manager.reset(envs_idx)

        # ...do other reset things...
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)[source]#

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)[source]#

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)[source]#

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)[source]#

Reset the DOF positions.

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

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