• 官方链接:http://ai2thor.allenai.org/tutorials/installation
  • 安装:

    • pip install ai2thor
    • Before running the below code, make sure X server with OpenGL is running, and the OpenGL extensions have been installed for your graphics card.
      • import ai2thor.controllercontroller = ai2thor.controller.Controller()
        controller.start()
  • Concepts:

    • 动作:离散的
    • Object Visibility:定义了一个object距离摄像机的distance阈值。当agent和object的距离小于这个特定的阈值时,agent可以和object交互。
    • Receptacle :可以包含一个object的object,比如水槽、冰箱、橱柜和桌面。
  • Scenes:

    • version1.0有120个scenes,主要分为四个大类:厨房、起居室、卧室和浴室。每个房间有可进行操作的obeject。在初始化的时候object可以放在不同的容器,从而在一个相同的场景中有多种配置方式。
    • Kitchens (30 scenes, FloorPlan1 - FloorPlan30)

    • Living Rooms (30 scenes, FloorPlan201 - FloorPlan230)

    • Bedrooms (30 scenes, FloorPlan301 - FloorPlan330)

    • Bathrooms (30 scenes, FloorPlan401 - FloorPlan430)

  • Actions:

    • action被定义在 unity/Assets/Scripts/DiscreteRemoteFPSAgentController.cs 当中。
    • 下面折页定义了可操作的对象的几种状态   http://ai2thor.allenai.org/tutorials/object-types
    • 在下面内容开始前,假设你已经运行了下述命令:
      • import ai2thor.controller
        controller = ai2thor.controller.Controller()
        controller.start()
        # can be any one of the scenes FloorPlan###
        controller.reset('FloorPlan28')
        controller.step(dict(action='Initialize', gridSize=0.25))
        
    • 初始化:重置scene(例如定义gridSize)的时候必须调用“初始化”
      • controller.step(dict(action='Initialize', gridSize=0.25))
      • 初始化的时候还可以定义一些其他的参数:比如
        • gridSize(agent移动的网格尺寸) / renderDepthImage(是否使用深度图像) / renderClassImage(是否启用分类图像) / renderObjectImage(是否启用object segmentation image) / visibilityDistance(定义可视距离) / cameraY(相机高度) / fieldOfView(视椎)
        • 详情见:  http://ai2thor.allenai.org/tutorials/actions
    • 随机化:用来打乱场景同事增加场景中的object。
      • controller.random_initialize(random_seed=None,randomize_open=False,unique_object_types=False,exclude_receptacle_object_pairs=[],max_num_repeats=1,remove_prob=0.5)
      • 参数见链接 : http://ai2thor.allenai.org/tutorials/actions
    • 前后左右移动(视角朝向不变) : 
      • controller.step(dict(action='MoveAhead'))
        # 前后左右 'MoveAhead' 'MoveBack' 'MoveRight' 'MoveLeft'
        
    • 向上看向下看:(30度)
      • controller.step(dict(action='LookUp'))
        # 'LookUp'  'LookDown'
    • 右转&左转 (90度):
      • controller.step(dict(action='RotateRight'))
        # 'RotateRight'  'RotateLeft'
    • 打开/关闭/捡起/放下 object:
      • # obejct必须在阈值范围内
        controller.step(dict(action='OpenObject', objectId="Fridge|0.25|0.75|0.05"))
        # 'OpenObject'  'CloseObject'
      • # 捡起放入仓库  从仓库拿出放在可视范围内  仓库容量为1
        controller.step(dict(action='PickupObject', objectId="Mug|0.25|-0.27|0.95"))
        #  'PickupObject'   "PutObject"
    • 移动agent:
      • controller.step(dict(action='Teleport', x=0.999, y=1.01, z=-0.3541))
        # x y z ???
    • TeleportFull:

      • controller.step(dict(action='TeleportFull',x=0.999, y=1.01, z=-0.3541, rotation=90.0, horizon=30.0))
        
    • Failures:

      • action可能会失败。比如:agent移动过程中发生碰撞 /  object的可见性带来的捡取放置操作的错误

  • Event Metadata:

    • 每次调用 controller.step() 都会返回一个event,包含了环境以及环境中的object的信息。
    • Event :

      • # return object from controller.step()
        event = controller.step(dict(action=<SOME ACTION>))
        
      • event的具体属性: http://ai2thor.allenai.org/tutorials/event-metadata

    • Object:

      • obejct的具体属性: http://ai2thor.allenai.org/tutorials/event-metadata

  • Object Types:

    • 87种可交互的object,以及每个object的
  • Receptacle Object Types:

    • 容器种类 & 每种容器可以包含的object的种类: http://ai2thor.allenai.org/tutorials/receptacle-object-types
  • Examples:

    • 例子:把agent前移一步,同时返回对应的image和metadata。

      • import ai2thor.controller
        controller = ai2thor.controller.Controller()
        controller.start()# Kitchens: FloorPlan1 - FloorPlan30
        # Living rooms: FloorPlan201 - FloorPlan230
        # Bedrooms: FloorPlan301 - FloorPlan330
        # Bathrooms: FloorPLan401 - FloorPlan430controller.reset('FloorPlan28')
        controller.step(dict(action='Initialize', gridSize=0.25))event = controller.step(dict(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
        
    • 例子:调用复杂的动作——捡起杯子,打开微波炉,把杯子放进微波炉
      • 先移动到能看见object的位置,然后执行动作。
      • import ai2thor.controllercontroller = ai2thor.controller.Controller()
        controller.start()
        # 选择要运行的scene
        controller.reset('FloorPlan28')
        # 初始化 同时配置场景参数
        controller.step(dict(action='Initialize', gridSize=0.25))# 让agent移动到特定坐标
        controller.step(dict(action='Teleport', x=-1.25, y=1.00, z=-1.5))
        controller.step(dict(action='LookDown')) # 向下看
        event = controller.step(dict(action='Rotate', rotation=90)) # 有没有rotate这个动作?# In FloorPlan28, the agent should now be looking at a mug
        # 捡起杯子
        for o in event.metadata['objects']: # 遍历视野中所有的object# 如果发现Mugif o['visible'] and o['pickupable'] and o['objectType'] == 'Mug':event = controller.step(dict(action='PickupObject', objectId=o['objectId']), raise_for_failure=True) # 执行捡起Mugmug_object_id = o['objectId']  # Mug的idbreak# the agent now has the Mug in its inventory
        # to put it into the Microwave, we need to open the microwave first# 打开微波炉
        event = controller.step(dict(action='LookUp'))
        for o in event.metadata['objects']:# 找出 视野中 可见的 可打开的 微波炉if o['visible'] and o['openable'] and o['objectType'] == 'Microwave':# 打开 微波炉event = controller.step(dict(action='OpenObject', objectId=o['objectId']), raise_for_failure=True)# 同时提取微波炉的idreceptacle_object_id = o['objectId']break# agent右移
        event = controller.step(dict(action='MoveRight'), raise_for_failure=True)# 执行“放置”动作  容器是微波炉  被放置的东西是杯子
        event = controller.step(dict(action='PutObject',receptacleObjectId=receptacle_object_id,objectId=mug_object_id), raise_for_failure=True)# close the microwave
        # 关闭微波炉
        event = controller.step(dict(action='CloseObject',objectId=receptacle_object_id), raise_for_failure=True)
    • 例子:多线程:
      • 在多线程中运行agent的多个instance:
      • import threading
        import time
        import ai2thor.controllerthread_count = 8def run():env = ai2thor.controller.Controller()env.start()# 100 is an arbritary numberfor _ in range(100):t_start = time.time()env.reset('FloorPlan1')env.step({'action' : 'Initialize', 'gridSize' : 0.25})print('init time', time.time() - t_start)t_start_total = time.time()for _ in range(10):env.step({'action' : 'MoveAhead'})env.step({'action' : 'RotateRight'})total_time = time.time() - t_start_totalprint('total time', total_time, 20 / total_time, 'fps')threads = [threading.Thread(target=run) for _ in range(thread_count)]
        for t in threads:t.daemon = Truet.start()time.sleep(1)for t in threads:# calling join() in a loop/timeout to allow for Python 2.7# to be interrupted with SIGINTwhile t.isAlive():t.join(1)print('done')
        

【AI2 THOR】环境使用说明相关推荐

  1. 【一】AI Studio 项目详解【(一)VisualDL工具、环境使用说明、脚本任务、图形化任务、在线部署及预测】PARL

    相关文章 [一]-环境配置+python入门教学 [二]-Parl基础命令 [三]-Notebook.&pdb.ipdb 调试 [四]-强化学习入门简介 [五]-Sarsa&Qlear ...

  2. 项目通用环境使用说明

    我们的项目经过测试,如果没有特殊要求,一般建采用环境如下: MYSQL5.7 https://pan.baidu.com/s/1ySDfKov7lTcURDsA0LFbtw  提取码:xzw8 Mys ...

  3. 二级python报考资格_二级Python考试环境使用说明

    1. 下载 电脑上打开浏览器,输入www.chinahuben.com/z/down,找到"考试环境""Python"并单击"点击下载",将 ...

  4. Jz2440 环境安装

    目录 Jz2440 环境安装 Ubuntu 设置 烧写工具 交叉编译环境 使用说明 烧写特性 title: Jz2440 环境安装 tags: linux date: 2018-09-20 22:56 ...

  5. code::blocks打造自己的开发环境

    打造自己环境 使用说明: 1.可以自己写Makefile: 在Project的属性中指定使用custom makefile即可.和visual studio一样,可以定义很多编译和link过程中的参数 ...

  6. 支付宝支付学习:蚂蚁沙箱环境是什么?怎样使用蚂蚁沙箱环境?

    沙箱环境使用说明更新时间:2017-09-19 蚂蚁沙箱环境(Beta)是协助开发者进行接口功能开发及主要功能联调的辅助环境.沙箱环境模拟了开放平台部分产品的主要功能和主要逻辑(当前沙箱支持产品请参考 ...

  7. [转] Microsoft AppLocale Utility 使用说明

    今天听 BoyLee(http://boylee.cnblogs.com/) 介绍可以用这个软件在中文系统下模拟日文环境 使用说明: 1.双击安装文件 2.安装完毕后,从"开始菜单" ...

  8. 支付宝沙箱环境对接(当面付)

    支付宝沙箱环境对接(当面付) 第一步: 好好阅读以下的文档: 沙箱登录:https://openhome.alipay.com/platform/appDaily.htm 沙箱环境使用说明:https ...

  9. 【今日CV 计算机视觉论文速览 第99期】Fri, 12 Apr 2019

    今日CS.CV 计算机视觉论文速览 Fri, 12 Apr 2019 Totally 50 papers ?上期速览 ✈更多精彩请移步主页 Interesting: ?DBPN基于深度方向传播的图像超 ...

最新文章

  1. 1.43千米外隔墙透视!这项黑科技已被中科大潘建伟团队实现
  2. AI手机报告 | 揭秘手机行业未来AI之路
  3. FlexboxLayout使用(Google官方实现流式布局控件)
  4. Spring Boot 2.4 对多环境配置的支持更改
  5. Apache Flink 官方文档--概览
  6. css 图片剪裁居中
  7. 网站发布错误“遭遇战”
  8. LeetCode 135 分发糖果
  9. OpenVINO 部署 Mask-RCNN 实例分割
  10. struts1、 struts2所有版本jar包下载地址大全
  11. CNDS-Markdown之公式编辑(一)
  12. 经验:如何做好两台BXP服务器(转)
  13. 十大Excel函数(一)
  14. 颜色的前世今生6·色相环
  15. Gerrit 安装lfs插件
  16. 【记录】win11安装ubuntu子系统教程
  17. python音频加速_python将音频进行变速的操作方法
  18. HP大中华区总裁孙振耀退休感言(上)
  19. Blender赛道建模+Gazebo赛道仿真
  20. vue获取服务器路径图片显示,vue img图片路径和背景图片路径打包问题

热门文章

  1. windows下的python安装scrapy
  2. windows7经典开机音乐_极简之美——网易云音乐云石蓝牙音箱 拆机评测
  3. 一文弄懂Hive中谓词下推(on与where的区别)
  4. 软考有很多70后的人,是什么原因会参加考试呢?
  5. 关于谷歌浏览器被搜狗网址导航恶意劫持解决办法
  6. 如何计算马来西亚的每月PCB所得税
  7. 运维工程师怎么找兼职?什么样的兼职合适?
  8. Windows文件及文件夹命名规则之admini~1≈administrator问题
  9. ReactNative系列之十九表情emoji与文字混排的两种方案实现
  10. php如何把图片铺满,用Dreamweaver8设计网页,怎样使背景图片铺满全屏?