mani_skill.agents.base_agent#

Attributes#

Classes#

BaseAgent

Base class for agents/robots, forming an interface of an articulated robot (SAPIEN's physx.PhysxArticulation).

Keyframe

Module Contents#

class mani_skill.agents.base_agent.BaseAgent(scene, control_freq, control_mode=None, agent_idx=None, initial_pose=None, build_separate=False)[source]#

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 its tutorial

Parameters:
  • scene (ManiSkillScene) – simulation scene instance.

  • control_freq (int) – control frequency (Hz).

  • control_mode (str | None) – uid of controller to use

  • fix_root_link (bool) – whether to fix the robot root link

  • agent_idx (str | None) – an index for this agent in a multi-agent task setup If None, the task should be single-agent

  • initial_pose (sapien.Pose | Pose | None) – the initial pose of the robot. Important to set for GPU simulation to ensure robot

  • called (does not collide with other objects in the scene during GPU initialization which occurs before env._initialize_episode is) –

  • build_separate (bool) –

_after_init()[source]#

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.

_after_loading_articulation()[source]#

Called after loading articulation and before setting up any controllers. By default this is empty.

_load_articulation(initial_pose=None)[source]#

Loads the robot articulation

Parameters:

initial_pose (Optional[Union[sapien.Pose, mani_skill.utils.structs.pose.Pose]]) –

before_simulation_step()[source]#

Code that runs before each simulation step. By default it calls the controller’s before_simulation_step method.

get_controller_state()[source]#

Get the state of the controller.

get_proprioception()[source]#

Get the proprioceptive state of the agent, default is the qpos and qvel of the robot and any controller state.

get_state()[source]#

Get current state, including robot state and controller state

Return type:

dict

abstract is_grasping(object=None)[source]#

Check if this agent is grasping an object or grasping anything at all

Parameters:

object (Actor | None) – 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.

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.

abstract is_static(threshold)[source]#

Check if this robot is static (within the given threshold) in terms of the q velocity

Parameters:

threshold (float) – The threshold before this agent is considered static

Returns:

True if agent is static within the threshold. False otherwise

reset(init_qpos=None)[source]#

Reset the robot to a clean state with zero velocity and forces.

Parameters:

init_qpos (torch.Tensor) – The initial qpos to set the robot to. If None, the robot’s qpos is not changed.

set_action(action)[source]#

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.

set_control_mode(control_mode=None)[source]#

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.

Parameters:

control_mode (str) –

set_controller_state(state)[source]#

Set the state of the controller.

Parameters:

state (mani_skill.utils.structs.Array) –

set_state(state, ignore_controller=False)[source]#

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.

Parameters:

state (dict) –

_agent_idx = None[source]#
_control_freq[source]#
property _controller_configs: dict[str, mani_skill.agents.controllers.base_controller.ControllerConfig | DictControllerConfig][source]#

Returns a dict of controller configs for this agent. By default this is a PDJointPos (delta and non delta) controller for all active joints.

Return type:

dict[str, Union[mani_skill.agents.controllers.base_controller.ControllerConfig, DictControllerConfig]]

_default_control_mode = None[source]#
property _sensor_configs: list[mani_skill.sensors.base_sensor.BaseSensorConfig][source]#

Returns a list of sensor configs for this agent. By default this is empty.

Return type:

list[mani_skill.sensors.base_sensor.BaseSensorConfig]

property action_space: gymnasium.spaces.Space[source]#
Return type:

gymnasium.spaces.Space

build_separate = False[source]#
property control_mode[source]#

Get the currently activated controller uid.

property controller: mani_skill.agents.controllers.base_controller.BaseController[source]#

Get currently activated controller.

Return type:

mani_skill.agents.controllers.base_controller.BaseController

controllers: dict[str, mani_skill.agents.controllers.base_controller.BaseController][source]#

The controllers of the robot.

property device[source]#
disable_self_collisions: bool = False[source]#

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

Whether to fix the root link of the robot in place.

keyframes: dict[str, Keyframe][source]#

a dict of predefined keyframes similar to what Mujoco does that you can use to reset the agent to that may be of interest

load_multiple_collisions: bool = False[source]#

Whether the referenced collision meshes of a robot definition should be loaded as multiple convex collisions

mjcf_path: str | None = None[source]#

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.

robot: mani_skill.utils.structs.Articulation[source]#

The robot object, which is an Articulation. Data like pose, qpos etc. can be accessed from this object.

scene[source]#
sensors: dict[str, mani_skill.sensors.base_sensor.BaseSensor][source]#

The sensors that come with the robot.

property single_action_space: gymnasium.spaces.Space[source]#
Return type:

gymnasium.spaces.Space

supported_control_modes = ['pd_joint_pos', 'pd_joint_delta_pos'][source]#

List of all possible control modes for this robot.

uid: str[source]#

unique identifier string of this

urdf_config: str | dict | None = None[source]#

Optional provide a urdf_config to further modify the created articulation

urdf_path: str | None = None[source]#

path to the .urdf file describe the agent’s geometry and visuals. One of urdf_path or mjcf_path must be provided.

class mani_skill.agents.base_agent.Keyframe[source]#
pose: sapien.Pose[source]#

sapien Pose object describe this keyframe’s pose

qpos: mani_skill.utils.structs.Array | None = None[source]#

the qpos of the robot at this keyframe

qvel: mani_skill.utils.structs.Array | None = None[source]#

the qvel of the robot at this keyframe

mani_skill.agents.base_agent.DictControllerConfig[source]#