Actuator#

class genesis_forge.managers.actuator.ActuatorManager(env: GenesisEnv, joint_names: list[str] | str = '.*', default_pos: float | NoisyValue | dict = {'.*': 0.0}, kp: float | NoisyValue | dict = None, kv: float | NoisyValue | dict = None, max_force: float | NoisyValue | tuple[Any, Any] | dict = None, damping: float | NoisyValue | dict = None, stiffness: float | NoisyValue | dict = None, frictionloss: float | NoisyValue | dict = None, armature: float | NoisyValue | dict = None, default_noise_scale: float = 0.0, entity_attr: str = 'robot')[source]#

Bases: BaseManager

Configures and manages the actuators of your robot. You can define values for all actuators, or target specific joints by name or name pattern (see example). To add some domain randomization, you can define the values as NoisyValue objects, which will apply random noise at each reset.

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

  • joint_names – The joint names to manage.

  • default_pos – The default DOF positions. The DOF joints will be set to these positions on reset.

  • kp – The positional gain values.

  • kv – The velocity gains values.

  • max_force – Define the maximum actuator force. Either as a single value or a tuple range.

  • damping – The damping values.

  • stiffness – The stiffness values.

  • frictionloss – The frictionloss values.

  • armature – The armature values.

  • entity_attr – The attribute of the environment to get the robot from.

  • default_noise_scale – (deprecated) This noise scale will be applied to all actuator values. Use NoisyValue instead.

Example:

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

        self.actuator_manager = ActuatorManager(
            self,
            joint_names=".*",
            default_pos={
                "Leg[1-2]_Hip": -1.0,
                "Leg[3-4]_Hip": 1.0,
                "Leg[1-4]_Femur": 0.5,
                "Leg[1-4]_Tibia": 0.6,
            },
            kp={
                ".*_Hip": NoisyValue(50, 0.02),
                "*__Femur": NoisyValue(30, 0.01),
                "*__Tibia": NoisyValue(30, 0.01),
            },
            kv=0.5,
            max_force=8.0,
        )
build()[source]#

Builds the manager and initialized all the buffers.

control_dofs_position(position: torch.Tensor, dofs_idx: list[int] | None = None)[source]#

Control the position of the configured DOFs. This is a wrapper for RigidEntity.control_dofs_position.

Parameters:
  • position – The position to set the DOFs to. The indices of this tensor should match the configured DOFs (see: dofs_names and dofs_idx properties).

  • dofs_idx – The indices of the DOFs to control. If None, all the DOFs of this actuator manager are used.

get_dofs_control_force(noise: float = 0.0, clip_to_max_force: bool = False, dofs_idx: list[int] | None = None) torch.Tensor[source]#

Return the force output by the configured DOFs. This is a wrapper for RigidEntity.get_dofs_control_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 of the actuators.

  • dofs_idx – The indices of the DOFs to get the force for. If None, all the DOFs of this actuator manager are used.

Returns:

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

Return type:

force

get_dofs_force(noise: float = 0.0, clip_to_max_force: bool = False, dofs_idx: list[int] | None = None) torch.Tensor[source]#

Return the force experienced by the configured 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 of the actuators.

  • dofs_idx – The indices of the DOFs to get the force for. If None, all the DOFs of this actuator manager are used.

Returns:

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

Return type:

force

get_dofs_limits(dofs_idx: list[int] | None = None) tuple[torch.Tensor, torch.Tensor][source]#

Return the position limits of the configured DOFs. This is a wrapper for RigidEntity.get_dofs_limit.

Parameters:

dofs_idx – The indices of the DOFs to get the limits for. If None, all the DOFs of this actuator manager are used.

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_max_force() torch.Tensor[source]#

Get the positive force/torque limit per configured DOF from max_force config.

Returns:

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

Upper force limit per DOF (symmetric limits use the same magnitude).

Return type:

limits

Raises:

ValueError – If max_force was not configured on this actuator manager.

get_dofs_position(noise: float = 0.0, dofs_idx: list[int] | None = None) torch.Tensor[source]#

Return the current position of the configured 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.

  • dofs_idx – The indices of the DOFs to get the position for. If None, all the DOFs of this actuator manager are used.

Returns:

torch.Tensor, shape (n_envs, n_dofs) The position of the enabled DOFs.

Return type:

position

get_dofs_velocity(noise: float = 0.0, clip: tuple[float, float] = None, dofs_idx: list[int] | None = None) torch.Tensor[source]#

Return the current velocity of the configured 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.

  • dofs_idx – The indices of the DOFs to get the velocity for. If None, all the DOFs of this actuator manager are used.

Returns:

torch.Tensor, shape (n_envs, n_dofs) The velocity of the enabled DOFs.

Return type:

velocity

reset(envs_idx: list[int] = None)[source]#

Reset the DOF positions.

set_dofs_position(position: torch.Tensor, dofs_idx: list[int] | None = None)[source]#

Set the position of the configured DOFs. This is a wrapper for RigidEntity.set_dofs_position.

Parameters:
  • position – The position to set the DOFs to. The indices of this tensor should match the configured DOFs (see: dofs_names and dofs_idx properties).

  • dofs_idx – The indices of the DOFs to control. If None, all the DOFs of this actuator manager are used.

step()#

Called when the environment is stepped

property default_dofs_pos: torch.Tensor#

Return the default DOF positions.

property dofs: dict[str, int]#

Get the names of the joints that are enabled, in the order of the DOF indices.

property dofs_idx: list[int]#

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

property dofs_names: list[str]#

Get the names of the configured DOFs.

property num_dofs: int#

Get the number of configured DOFs.