我也不知道这算什么,姑且称之为——走个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)