VisualNavigation--3D 环境 ai2thor 例子

本博客旨在提供开始使用AI2-THOR的基本入门示例。

1. MoveAhead

一个简单的示例,将智能体向前移动一步并返回相应的图像和元数据。

from ai2thor.controller import Controller

# Kitchens: FloorPlan1 - FloorPlan30
# Living rooms: FloorPlan201 - FloorPlan230
# Bedrooms: FloorPlan301 - FloorPlan330
# Bathrooms: FloorPLan401 - FloorPlan430

controller = Controller(scene='FloorPlan28', gridSize=0.25)

event = controller.step(action='MoveAhead')

# Numpy Array - shape (width, height, channels), channels are in RGB order
event.frame

# Numpy Array in BGR order suitable for use with OpenCV
event.cv2image

# current metadata dictionary that includes the state of the scene
event.metadata

# shuts down the controller
controller.stop()

2. Context Managers

初始化controller的另一种方法是使用上下文管理器。这里,前面的MoveAhead示例可以写成:

from ai2thor.controller import Controller

with Controller(scene='FloorPlan28', gridSize=0.25) as c:
    event =  c.step(action='MoveAhead')
    event.frame
    event.cv2image
    event.metadata

如果with命令内部存在错误或with命令内部的所有内容都已执行,则controller将立即停止。

3. Object interaction

我们的目标是拿起杯子,然后打开微波炉,然后将杯子放入微波炉中。 要拾取物体,智能体必须首先导航到存在可拾取/可见物体的区域。 通常,应通过一系列MoveAhead,RotateLeft,RotateRight命令完成此操作。 在这里,我们将直接移动到存在杯子的已知位置。

from ai2thor.controller import Controller

controller = Controller(scene='FloorPlan28', gridSize=0.25)

# change starting loca
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值