mani_skill.agents ================= .. py:module:: mani_skill.agents Submodules ---------- .. toctree:: :maxdepth: 1 /api/mani_skill/agents/base_agent/index /api/mani_skill/agents/base_real_agent/index /api/mani_skill/agents/controllers/index /api/mani_skill/agents/multi_agent/index /api/mani_skill/agents/registration/index /api/mani_skill/agents/utils/index Attributes ---------- .. autoapisummary:: mani_skill.agents.REGISTERED_AGENTS Classes ------- .. autoapisummary:: mani_skill.agents.BaseAgent mani_skill.agents.MultiAgent Functions --------- .. autoapisummary:: mani_skill.agents.register_agent Package Contents ---------------- .. py:class:: BaseAgent(scene, control_freq, control_mode = None, agent_idx = None, initial_pose = None, build_separate = False) Base class for agents/robots, forming an interface of an articulated robot (SAPIEN's physx.PhysxArticulation). Users implementing their own agents/robots should inherit from this class. A tutorial on how to build your own agent can be found in :doc:`its tutorial ` :param scene: simulation scene instance. :type scene: ManiSkillScene :param control_freq: control frequency (Hz). :type control_freq: int :param control_mode: uid of controller to use :type control_mode: str | None :param fix_root_link: whether to fix the robot root link :type fix_root_link: bool :param agent_idx: an index for this agent in a multi-agent task setup If None, the task should be single-agent :type agent_idx: str | None :param initial_pose: the initial pose of the robot. Important to set for GPU simulation to ensure robot :type initial_pose: sapien.Pose | Pose | None :param does not collide with other objects in the scene during GPU initialization which occurs before `env._initialize_episode` is called: .. py:method:: _after_init() Code that is run after initialization. Some example robot implementations use this to cache a reference to special robot links like an end-effector link. By default this is empty. .. py:method:: _after_loading_articulation() Called after loading articulation and before setting up any controllers. By default this is empty. .. py:method:: _load_articulation(initial_pose = None) Loads the robot articulation .. py:method:: before_simulation_step() Code that runs before each simulation step. By default it calls the controller's before_simulation_step method. .. py:method:: get_controller_state() Get the state of the controller. .. py:method:: get_proprioception() Get the proprioceptive state of the agent, default is the qpos and qvel of the robot and any controller state. .. py:method:: get_state() Get current state, including robot state and controller state .. py:method:: is_grasping(object = None) :abstractmethod: Check if this agent is grasping an object or grasping anything at all :param object: If object is a Actor, this function checks grasping against that. If it is none, the function checks if the agent is grasping anything at all. :type object: Actor | None :returns: True if agent is grasping object. False otherwise. If object is None, returns True if agent is grasping something, False if agent is grasping nothing. .. py:method:: is_static(threshold) :abstractmethod: Check if this robot is static (within the given threshold) in terms of the q velocity :param threshold: The threshold before this agent is considered static :type threshold: float :returns: True if agent is static within the threshold. False otherwise .. py:method:: reset(init_qpos = None) Reset the robot to a clean state with zero velocity and forces. :param init_qpos: The initial qpos to set the robot to. If None, the robot's qpos is not changed. :type init_qpos: torch.Tensor .. py:method:: set_action(action) Set the agent's action which is to be executed in the next environment timestep. This is essentially a wrapper around the controller's set_action method. .. py:method:: set_control_mode(control_mode = None) Sets the controller to an pre-existing controller of this agent. This does not reset the controller. If given control mode is None, will set to the default control mode. .. py:method:: set_controller_state(state) Set the state of the controller. .. py:method:: set_state(state, ignore_controller=False) Set the state of the agent, including the robot state and controller state. If ignore_controller is True, the controller state will not be updated. .. py:attribute:: _agent_idx :value: None .. py:attribute:: _control_freq .. py:property:: _controller_configs :type: dict[str, Union[mani_skill.agents.controllers.base_controller.ControllerConfig, DictControllerConfig]] Returns a dict of controller configs for this agent. By default this is a PDJointPos (delta and non delta) controller for all active joints. .. py:attribute:: _default_control_mode :value: None .. py:property:: _sensor_configs :type: list[mani_skill.sensors.base_sensor.BaseSensorConfig] Returns a list of sensor configs for this agent. By default this is empty. .. py:property:: action_space :type: gymnasium.spaces.Space .. py:attribute:: build_separate :value: False .. py:property:: control_mode Get the currently activated controller uid. .. py:property:: controller :type: mani_skill.agents.controllers.base_controller.BaseController Get currently activated controller. .. py:attribute:: controllers :type: dict[str, mani_skill.agents.controllers.base_controller.BaseController] The controllers of the robot. .. py:property:: device .. py:attribute:: disable_self_collisions :type: bool :value: False Whether to disable self collisions. This is generally not recommended as you should be defining a SRDF file to exclude specific collisions. However for some robots/tasks it may be easier to disable all self collisions between links in the robot to increase simulation speed .. py:attribute:: fix_root_link :type: bool :value: True Whether to fix the root link of the robot in place. .. py:attribute:: keyframes :type: dict[str, Keyframe] a dict of predefined keyframes similar to what Mujoco does that you can use to reset the agent to that may be of interest .. py:attribute:: load_multiple_collisions :type: bool :value: False Whether the referenced collision meshes of a robot definition should be loaded as multiple convex collisions .. py:attribute:: mjcf_path :type: Union[str, None] :value: None path to a MJCF .xml file defining a robot. This will only load the articulation defined in the XML and nothing else. One of urdf_path or mjcf_path must be provided. .. py:attribute:: robot :type: mani_skill.utils.structs.Articulation The robot object, which is an Articulation. Data like pose, qpos etc. can be accessed from this object. .. py:attribute:: scene .. py:attribute:: sensors :type: dict[str, mani_skill.sensors.base_sensor.BaseSensor] The sensors that come with the robot. .. py:property:: single_action_space :type: gymnasium.spaces.Space .. py:attribute:: supported_control_modes :value: ['pd_joint_pos', 'pd_joint_delta_pos'] List of all possible control modes for this robot. .. py:attribute:: uid :type: str unique identifier string of this .. py:attribute:: urdf_config :type: Union[str, dict, None] :value: None Optional provide a urdf_config to further modify the created articulation .. py:attribute:: urdf_path :type: Union[str, None] :value: None path to the .urdf file describe the agent's geometry and visuals. One of urdf_path or mjcf_path must be provided. .. py:class:: MultiAgent(agents) Bases: :py:obj:`mani_skill.agents.base_agent.BaseAgent`, :py:obj:`Generic`\ [\ :py:obj:`T`\ ] Base class for agents/robots, forming an interface of an articulated robot (SAPIEN's physx.PhysxArticulation). Users implementing their own agents/robots should inherit from this class. A tutorial on how to build your own agent can be found in :doc:`its tutorial ` :param scene: simulation scene instance. :type scene: ManiSkillScene :param control_freq: control frequency (Hz). :type control_freq: int :param control_mode: uid of controller to use :type control_mode: str | None :param fix_root_link: whether to fix the robot root link :type fix_root_link: bool :param agent_idx: an index for this agent in a multi-agent task setup If None, the task should be single-agent :type agent_idx: str | None :param initial_pose: the initial pose of the robot. Important to set for GPU simulation to ensure robot :type initial_pose: sapien.Pose | Pose | None :param does not collide with other objects in the scene during GPU initialization which occurs before `env._initialize_episode` is called: .. py:method:: before_simulation_step() Code that runs before each simulation step. By default it calls the controller's before_simulation_step method. .. py:method:: get_controller_state() Get the state of the controller. .. py:method:: get_proprioception() Get the proprioceptive state of the agent, default is the qpos and qvel of the robot and any controller state. .. py:method:: reset(init_qpos=None) Reset the robot to a rest position or a given q-position .. py:method:: set_action(action) Set the agent's action which is to be executed in the next environment timestep .. py:method:: set_control_mode(control_mode = None) Set the controller, drive properties, and reset for each agent. If given control mode is None, will set defaults .. py:method:: set_controller_state(state) Set the state of the controller. .. py:attribute:: _sensor_config_agent_map :type: dict[str, int] .. py:property:: _sensor_configs :type: list[mani_skill.sensors.base_sensor.BaseSensorConfig] Returns a list of sensor configs for this agent. It contains the sensor configs of the individual agents. .. py:property:: action_space .. py:attribute:: agents :type: T .. py:attribute:: agents_dict :type: dict[str, mani_skill.agents.base_agent.BaseAgent] .. py:property:: control_mode Get the currently activated controller uid of each robot .. py:property:: controller Get currently activated controller. .. py:attribute:: scene .. py:attribute:: sensor_configs :value: [] .. py:property:: single_action_space .. py:function:: register_agent(asset_download_ids = [], override=False) A decorator to register agents into ManiSkill so they can be used easily by string uid. :param uid: unique id of the agent. :type uid: str :param override: whether to override the agent if it is already registered. :type override: bool .. py:data:: REGISTERED_AGENTS :type: dict[str, AgentSpec]