|人工智能基础(中小学版)实践平台| Cozmo人工智能机器人SDK使用笔记(X)-总结-
Cozmo的SDK包括了使用其开发的大部分功能示例,全部内容参考如下链接:
----https://blog.csdn.net/zhangrelay/article/category/7739166----
更多精彩的开发内容参考forums.anki.com,例如:Vector机器人的Scratch 3.0扩展;Vector和Leap Motion。
总结:
1. SDK能做什么?
Cozmo SDK平台的主要优势是软硬件的多功能和可扩展性。
2. 丰富的工具和实用程序
SDK提供从有限状态机到三维可视化等全部内容。
3. 项目研究
Cozmo独特的硬件、软件和角色组合使其成为人机交互、行为和计算机视觉等领域研究项目的理想选择。
4. 物联网
使用Cozmo控制家居中Hue灯光,提供有关FitBit数据的反馈或在Nest摄像头检测到移动时做出提醒。
5. 原型测试
通过Cozmo这个紧凑、高效、多功能的测试平台,快速轻松地迭代新算法并完善项目设计。
6. 寓教于乐(游戏)
从经典的棋盘游戏到创新的Twich体验,SDK充分激活无限想象力,构建丰富多彩的游戏项目。
7. 表演展示
数百种无以伦比的世界级动态表情(呆、萌、酷、炫)并支持全手动硬件控制,使Cozmo成为目前最受欢迎的机器人演员。
Anki Cozmo和Vector全部SDK内容均为开源,可以在github和anki官网找到丰富的资源,进行系统的学习。
之后博客中内容会以ROS机器人操作系统1.0和2.0介绍使用为主(高校版本);
外挂ROS插件可以使Cozmo或Vector支持中文等更多功能。
SDK中还有四个文件夹没有介绍,分别是face_images、lib、multi_robot和tools。
multi robot independent:
import asyncio
import sys
import cozmo
from cozmo.util import degrees
async def turn_left(sdk_conn):
robot = await sdk_conn.wait_for_robot()
cozmo.logger.info("Turning robot 1")
await robot.turn_in_place(degrees(90)).wait_for_completed()
async def turn_right(sdk_conn):
robot = await sdk_conn.wait_for_robot()
cozmo.logger.info("Turning robot 2")
await robot.turn_in_place(degrees(-90)).wait_for_completed()
if __name__ == '__main__':
cozmo.setup_basic_logging()
loop = asyncio.get_event_loop()
# Connect to both robots
try:
conn1 = cozmo.connect_on_loop(loop)
conn2 = cozmo.connect_on_loop(loop)
except cozmo.ConnectionError as e:
sys.exit("A connection error occurred: %s" % e)
# Run two independent coroutines concurrently, one on each connection
task1 = asyncio.ensure_future(turn_left(conn1), loop=loop)
task2 = asyncio.ensure_future(turn_right(conn2), loop=loop)
multi robot unified:
import asyncio
import sys
import cozmo
from cozmo.util import degrees
async def run(sdk_conn1, sdk_conn2):
robot1 = await sdk_conn1.wait_for_robot()
robot2 = await sdk_conn2.wait_for_robot()
# First have one turn left and one turn right, one after the other
cozmo.logger.info("Turning robot 1")
await robot1.turn_in_place(degrees(90)).wait_for_completed()
cozmo.logger.info("Turning robot 2")
await robot2.turn_in_place(degrees(-90)).wait_for_completed()
# Then have them both turn back to the original position at the same time
cozmo.logger.info("Turning both robots")
turn1 = robot1.turn_in_place(degrees(-90))
turn2 = robot2.turn_in_place(degrees(90))
await turn1.wait_for_completed()
await turn2.wait_for_completed()
if __name__ == '__main__':
cozmo.setup_basic_logging()
loop = asyncio.get_event_loop()
# Connect to both robots
# NOTE: to connect to a specific device with a specific serial number,
# create a connector (eg. `cozmo.IOSConnector(serial='abc')) and pass it
# explicitly to `connect` or `connect_on_loop`
try:
conn1 = cozmo.connect_on_loop(loop)
conn2 = cozmo.connect_on_loop(loop)
except cozmo.ConnectionError as e:
sys.exit("A connection error occurred: %s" % e)
# Run a coroutine controlling both connections
loop.run_until_complete(run(conn1, conn2))
Fin