metasim.sim#

All Simulation packages.

Base Handler

BaseSimHandler

Base class for simulation handler.

Simulator Handlers

isaaclab.IsaacLabHandler

isaacgym.IsaacGymHandler

mujoco.MujocoHandler

pybullet.PybulletHandler

alias of SinglePybulletHandler

genesis.GenesisHandler

sapien.sapien2.Sapien2Handler

Sapien2 Handler class.

sapien.sapien3.Sapien3Handler

Sapien3 Handler class.

Base Handler#

class metasim.sim.BaseSimHandler#

Base class for simulation handler.

object_dict#

A dict mapping object names to object cfg instances. It includes objects, robot, and checker debug viewers.

launch() None#

Launch the simulation.

reset(env_ids: list[int] | None = None) tuple[TensorState, Dict[str, Any]]#

Reset the environment.

Parameters:

env_ids – The indices of the environments to reset. If None, all environments are reset.

Returns:

The observation of the environment. Currently all the environments are returned. Do we need to return only the reset environments? extra: Extra information. Currently is empty.

Return type:

obs

close() None#

Close the simulation.

set_states(states: list[EnvState], env_ids: list[int] | None = None) None#

Set the states of the environment.

Parameters:
  • states (dict) – A dictionary containing the states of the environment

  • env_ids (list[int]) – List of environment ids to set the states. If None, set the states of all environments

set_dof_targets(obj_name: str, actions: list[Action]) None#

Set the dof targets of the robot.

Parameters:
  • obj_name (str) – The name of the robot

  • actions (list[Action]) – The target actions for the robot

get_states(env_ids: list[int] | None = None) list[EnvState]#

Get the states of the environment.

Parameters:

env_ids – List of environment ids to get the states from. If None, get the states of all environments.

Returns:

A dictionary containing the states of the environment

Return type:

dict

simulate()#

Step the simulation.

refresh_render() None#

Refresh the render.

get_joint_names(obj_name: str, sort: bool = True) list[str]#

Get the joint names for a given object.

Note

Different simulators may have different joint order, but joint names should be the same.

Parameters:
  • obj_name (str) – The name of the object.

  • sort (bool) – Whether to sort the joint names. Default is True. If True, the joint names are returned in alphabetical order. If False, the joint names are returned in the order defined by the simulator.

Returns:

A list of joint names. For non-articulation objects, return an empty list.

Return type:

list[str]

get_joint_reindex(obj_name: str) list[int]#

Get the reindexing order for joint indices of a given object. The returned indices can be used to reorder the joints such that they are sorted alphabetically by their names.

Parameters:

obj_name (str) – The name of the object.

Returns:

A list of joint indices that specifies the order to sort the joints alphabetically by their names.

The length of the list matches the number of joints.

Return type:

list[int]

Example

Suppose obj_name = "h1", and the h1 has joints:

index 0: "hip"

index 1: "knee"

index 2: "ankle"

This function will return: [2, 0, 1], which corresponds to the alphabetical order:

"ankle", "hip", "knee".

get_body_names(obj_name: str, sort: bool = True) list[str]#

Get the body names for a given object.

Note

Different simulators may have different body order, but body names should be the same.

Parameters:
  • obj_name (str) – The name of the object.

  • sort (bool) – Whether to sort the body names. Default is True. If True, the body names are returned in alphabetical order. If False, the body names are returned in the order defined by the simulator.

Returns:

A list of body names. For non-articulation objects, return an empty list.

Return type:

list[str]

get_body_reindex(obj_name: str) list[int]#

Get the reindexing order for body indices of a given object. The returned indices can be used to reorder the bodies such that they are sorted alphabetically by their names.

Parameters:

obj_name (str) – The name of the object.

Returns:

A list of body indices that specifies the order to sort the bodies alphabetically by their names.

The length of the list matches the number of bodies.

Return type:

list[int]

Example

Suppose obj_name = "h1", and the h1 has the following bodies:

  • index 0: "torso"

  • index 1: "left_leg"

  • index 2: "right_leg"

This function will return: [1, 2, 0], which corresponds to the alphabetical order:

"left_leg", "right_leg", "torso".

property episode_length_buf: list[int]#

The timestep of each environment, restart from 0 when reset, plus 1 at each step.

property actions_cache: list[Action]#

Cache of actions.