mani_skill.agents#
Submodules#
Attributes#
Classes#
Base class for agents/robots, forming an interface of an articulated robot (SAPIEN's physx.PhysxArticulation). |
|
Base class for agents/robots, forming an interface of an articulated robot (SAPIEN's physx.PhysxArticulation). |
Functions#
|
A decorator to register agents into ManiSkill so they can be used easily by string uid. |
Package Contents#
- class mani_skill.agents.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_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#
- _control_freq#
- property _controller_configs: dict[str, 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.
- Return type:
dict[str, Union[mani_skill.agents.controllers.base_controller.ControllerConfig, DictControllerConfig]]
- _default_control_mode = None#
- property _sensor_configs: list[mani_skill.sensors.base_sensor.BaseSensorConfig]#
Returns a list of sensor configs for this agent. By default this is empty.
- Return type:
- property action_space: gymnasium.spaces.Space#
- Return type:
- build_separate = False#
- property control_mode#
Get the currently activated controller uid.
- property controller: mani_skill.agents.controllers.base_controller.BaseController#
Get currently activated controller.
- controllers: dict[str, mani_skill.agents.controllers.base_controller.BaseController]#
The controllers of the robot.
- property device#
- disable_self_collisions: bool = 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
- fix_root_link: bool = True#
Whether to fix the root link of the robot in place.
- keyframes: 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
- load_multiple_collisions: bool = False#
Whether the referenced collision meshes of a robot definition should be loaded as multiple convex collisions
- mjcf_path: str | None = 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.
- robot: mani_skill.utils.structs.Articulation#
The robot object, which is an Articulation. Data like pose, qpos etc. can be accessed from this object.
- scene#
- sensors: dict[str, mani_skill.sensors.base_sensor.BaseSensor]#
The sensors that come with the robot.
- property single_action_space: gymnasium.spaces.Space#
- Return type:
- supported_control_modes = ['pd_joint_pos', 'pd_joint_delta_pos']#
List of all possible control modes for this robot.
- uid: str#
unique identifier string of this
- urdf_config: str | dict | None = None#
Optional provide a urdf_config to further modify the created articulation
- urdf_path: str | None = None#
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.MultiAgent(agents)[source]#
Bases:
mani_skill.agents.base_agent.BaseAgent,Generic[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 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) –
agents (list[mani_skill.agents.base_agent.BaseAgent]) –
- before_simulation_step()[source]#
Code that runs before each simulation step. By default it calls the controller’s before_simulation_step method.
- get_proprioception()[source]#
Get the proprioceptive state of the agent, default is the qpos and qvel of the robot and any controller state.
- set_action(action)[source]#
Set the agent’s action which is to be executed in the next environment timestep
- set_control_mode(control_mode=None)[source]#
Set the controller, drive properties, and reset for each agent. If given control mode is None, will set defaults
- Parameters:
control_mode (list[str]) –
- _sensor_config_agent_map: dict[str, int]#
- property _sensor_configs: 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.
- Return type:
- property action_space#
- agents: T#
- agents_dict: dict[str, mani_skill.agents.base_agent.BaseAgent]#
- property control_mode#
Get the currently activated controller uid of each robot
- property controller#
Get currently activated controller.
- scene#
- sensor_configs = []#
- property single_action_space#
- mani_skill.agents.register_agent(asset_download_ids=[], override=False)[source]#
A decorator to register agents into ManiSkill so they can be used easily by string uid.
- Parameters:
uid (str) – unique id of the agent.
override (bool) – whether to override the agent if it is already registered.
asset_download_ids (list[str]) –