OmniSimulator.agent.agent.Agent

class OmniSimulator.agent.agent.Agent(agent_id: str, name: str, location_id: str, max_grasp_limit: int = 2, properties: Dict[str, Any] | None = None)[source]

智能体类 - 表示模拟环境中的智能体

__init__(agent_id: str, name: str, location_id: str, max_grasp_limit: int = 2, properties: Dict[str, Any] | None = None)[source]

初始化智能体

Parameters:
  • agent_id – 智能体唯一ID

  • name – 智能体名称

  • location_id – 智能体初始位置ID (房间ID)

  • max_grasp_limit – 最大可抓取物体数量

  • properties – 其他属性字典,包含max_length/width/height/weight等

Methods

__init__(agent_id, name, location_id[, ...])

初始化智能体

add_ability_from_object(ability, object_id)

从物体获取能力

can_carry(object_properties)

Check if agent can carry the object (weight limit only) Cooperative mode has no weight limit

can_grab()

检查智能体是否还能抓取更多物体(数量限制)

drop_object(object_id, object_properties)

放下物体

from_dict(data)

从字典创建智能体对象

grab_object(object_id, object_properties)

抓取物体

has_ability(ability)

检查是否拥有特定能力

move_to(new_location_id)

移动到新位置

remove_ability_from_object(ability, object_id)

移除来自特定物体的能力

to_dict()

将智能体转换为字典表示

update_near_objects([near_id, env_manager])

更新智能体可交互的物体集合

__init__(agent_id: str, name: str, location_id: str, max_grasp_limit: int = 2, properties: Dict[str, Any] | None = None)[source]

初始化智能体

Parameters:
  • agent_id – 智能体唯一ID

  • name – 智能体名称

  • location_id – 智能体初始位置ID (房间ID)

  • max_grasp_limit – 最大可抓取物体数量

  • properties – 其他属性字典,包含max_length/width/height/weight等

can_grab() bool[source]

检查智能体是否还能抓取更多物体(数量限制)

Returns:

是否可以抓取

Return type:

bool

can_carry(object_properties: Dict[str, Any]) Tuple[bool, str][source]

Check if agent can carry the object (weight limit only) Cooperative mode has no weight limit

Parameters:

object_properties – 物体属性字典,包含weight等

Returns:

(是否可以承载, 原因)

Return type:

Tuple[bool, str]

grab_object(object_id: str, object_properties: Dict[str, Any]) Tuple[bool, str][source]

抓取物体

Parameters:
  • object_id – 物体ID

  • object_properties – 物体属性

Returns:

(是否成功抓取, 原因)

Return type:

Tuple[bool, str]

drop_object(object_id: str, object_properties: Dict[str, Any]) Tuple[bool, str][source]

放下物体

Parameters:
  • object_id – 物体ID

  • object_properties – 物体属性

Returns:

(是否成功放下, 原因)

Return type:

Tuple[bool, str]

move_to(new_location_id: str) None[source]

移动到新位置

Parameters:

new_location_id – 新位置ID

update_near_objects(near_id: str | None = None, env_manager=None)[source]

更新智能体可交互的物体集合

Parameters:
  • near_id – 靠近的物体ID,如果为None则只保留库存和位置

  • env_manager – 环境管理器实例,用于查询物体关系

add_ability_from_object(ability: str, object_id: str) None[source]

从物体获取能力

Parameters:
  • ability – 能力名称

  • object_id – 提供能力的物体ID

remove_ability_from_object(ability: str, object_id: str) None[source]

移除来自特定物体的能力

Parameters:
  • ability – 能力名称

  • object_id – 提供能力的物体ID

has_ability(ability: str) bool[source]

检查是否拥有特定能力

Parameters:

ability – 能力名称

Returns:

是否拥有该能力

Return type:

bool

to_dict() Dict[str, Any][source]

将智能体转换为字典表示

Returns:

智能体数据字典

Return type:

Dict

classmethod from_dict(data: Dict[str, Any]) Agent[source]

从字典创建智能体对象

Parameters:

data – 智能体数据字典

Returns:

智能体对象

Return type:

Agent