cozmo-python-sdk icon indicating copy to clipboard operation
cozmo-python-sdk copied to clipboard

Cozmo's rainbow cube

Open Readyornot69 opened this issue 11 months ago • 1 comments

import cozmo from cozmo.util import degrees import time

Rainbow colors (Red, Orange, Yellow, Green, Blue, Indigo, Violet)

rainbow_colors = [ cozmo.lights.Color(red=255, green=0, blue=0), # Red cozmo.lights.Color(red=255, green=165, blue=0), # Orange cozmo.lights.Color(red=255, green=255, blue=0), # Yellow cozmo.lights.Color(red=0, green=255, blue=0), # Green cozmo.lights.Color(red=0, green=0, blue=255), # Blue cozmo.lights.Color(red=75, green=0, blue=130), # Indigo cozmo.lights.Color(red=238, green=130, blue=238) # Violet ]

def cozmo_program(robot: cozmo.robot.Robot): # Find the first available cube cube = robot.world.wait_for_observed_light_cube(timeout=30)

# If no cube is found, exit
if not cube:
    robot.say_text("No cube found").wait_for_completed()
    return

# Cycle through the rainbow colors for the cube's lights
for color in rainbow_colors:
    # Set the cube light color
    cube.set_light(color)
    time.sleep(1)  # Wait for 1 second before changing the color

# After cycling through, turn the lights off
cube.set_light(cozmo.lights.off)
robot.say_text("Rainbow pattern completed!").wait_for_completed()

cozmo.run_program(cozmo_program)

Readyornot69 avatar Dec 31 '24 16:12 Readyornot69

This isn't an issue.

bp88dev avatar Jun 15 '25 17:06 bp88dev