cozmo玩耍记录1

我也不知道这算什么,姑且称之为——走个T台?


看了cozmo sdk里面01_basics的例子后,可以按头让cozmo做点什么了。

想具体了解01_basics例子的朋友可以移步zhangrelay老师博客,他有整理过。https://zhangrelay.blog.csdn.net/article/details/86096163

我这个走t台就是,小方块闪烁,cozmo自我介绍,走两步招招手,再扭两下转转圈这么个过程,还挺无聊的。

#!/usr/bin/env python3

#edited by jiali zhang, 20190807
#cozmo's runway show

import time
import cozmo
from cozmo.util import degrees, distance_mm, speed_mmps
from cozmo.objects import LightCube1Id, LightCube2Id, LightCube3Id

def cozmo_cube(robot: cozmo.robot.Robot):
    cube1 = robot.world.get_light_cube(LightCube1Id)
    cube2 = robot.world.get_light_cube(LightCube2Id)
    cube3 = robot.world.get_light_cube(LightCube3Id)
    for _ in range(2):
        if cube1 is not None:
            cube1.set_lights(cozmo.lights.red_light)
        else:
            cozmo.logger.warning("Cozmo is not connected to a LightCube1Id cube - check the battery.")
        time.sleep(0.5)

        if cube2 is not None:
            cube2.set_lights(cozmo.lights.green_light)
        else:
            cozmo.logger.warning("Cozmo is not connected to a LightCube2Id cube - check the battery.")
        time.sleep(0.5)

        if cube3 is not None:
            cube3.set_lights(cozmo.lights.blue_light)
        else:
            cozmo.logger.warning("Cozmo is not connected to a LightCube3Id cube - check the battery.")
        time.sleep(0.5)

        if cube1 is not None:
            cube1.set_lights(cozmo.lights.white_light)
        else:
            cozmo.logger.warning("Cozmo is not connected to a LightCube1Id cube - check the battery.")
        time.sleep(0.5)

        if cube2 is not None:
            cube2.set_lights(cozmo.lights.red_light)
        else:
            cozmo.logger.warning("Cozmo is not connected to a LightCube2Id cube - check the battery.")
        time.sleep(0.5)

        if cube3 is not None:
            cube3.set_lights(cozmo.lights.green_light)
        else:
            cozmo.logger.warning("Cozmo is not connected to a LightCube3Id cube - check the battery.")
        time.sleep(0.5)


def cozmo_walk(robot: cozmo.robot.Robot):
    robot.move_head(5)
    robot.move_lift(-5)
    robot.say_text("HEY!!! I am cozmo!").wait_for_completed()

    for _ in range(2):
        robot.set_all_backpack_lights(cozmo.lights.red_light)
        time.sleep(0.1)
        # set all of Cozmo's backpack lights to green, and wait for 2 seconds
        robot.set_all_backpack_lights(cozmo.lights.green_light)
        time.sleep(0.1)
        # set all of Cozmo's backpack lights to blue, and wait for 2 seconds
        robot.set_all_backpack_lights(cozmo.lights.blue_light)
        time.sleep(0.1)
        # set just Cozmo's center backpack lights to white, and wait for 2 seconds
        robot.set_center_backpack_lights(cozmo.lights.white_light)
        time.sleep(0.1)
        # turn off Cozmo's backpack lights and wait for 2 seconds
        robot.set_all_backpack_lights(cozmo.lights.off_light)
        time.sleep(0.1)
    

    robot.drive_wheels(25, 25)
    time.sleep(2)
    robot.move_lift(5)
    time.sleep(2)
    robot.move_lift(-5)
    time.sleep(2)
    robot.drive_wheels(25,50)
    time.sleep(1)
    robot.drive_wheels(50,25)
    time.sleep(3)
    robot.drive_wheels(25,50)
    time.sleep(2)
    robot.drive_wheels(100, -100)
    time.sleep(5)


cozmo.run_program(cozmo_cube)
cozmo.run_program(cozmo_walk)

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhangjiali12011

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值