The Vector SDK Alpha was just released. Great news. So I looked at the docs and found something to try. It worked! Rainbow eyes on Vector.
Vector’s Beautiful Eyes
This video was very much unplanned and unedited. So please be forgiving. I’m still sweaty from a run and my 2 month old son is pretty happy upstairs. Not even going to bother with sound editing.
Though Cozmo’s eyes were pretty awesome, you’ve gotta love that you can change the colors of Vector’s eyes.
We actually compare the screens in a bit of detail in Cozmo vs Vector.
In the app you could change to a few different colors.
Here, we make Vector’s eyes all the colors of the rainbow in two simple for loops.
The Functions Behind Those Eyes
I love when you look at me like that Vector. So I’ll program you to. What commands will I use?
Pretty straight forward. After all, I wanted to quick get something out immediately after hearing about the Alpha release. So I chose something quick and sweet. We have both of those here.
Vector’s Eyes with robot.behavior.set_eye_color()
We do our imports as usual. First anki_vectorand then time. Kinvert likes to do imports alphabetically – because why not.
We define our function, aptly named main.
The first for loop is just telling the program to run through the rainbow 10 times.
The second for loop is basically dividing the hue wheel in to 100 parts. This way we can smoothly go through many colors.
I’ll write another article on HSV (Hue Saturation Intensity), and yes, the V is for intensity or brightness. Don’t ask me why.
""" Copyright Kinvert All Rights Reserved If you would like to use this code for business or education please contact us for permission at: www.kinvert.com/ Free for personal use """ import anki_vector import time def main(): args = anki_vector.util.parse_command_args() with anki_vector.Robot(args.serial) as robot: for i in range(10): for j in range(100): robot.behavior.set_eye_color(hue=j/100.0, saturation=0.99) time.sleep(0.01) if __name__ == '__main__': main()
What would you change in the code if you wanted Vector to change the colors of his eyes much faster?
How could you make the color transitions even smoother?
What does Saturation do as you change that value?
Why Change Vector’s Eye Colors?
Plenty of reasons. Maybe to show if he’s curious or mad. Maybe just because.
One cool project would be to get Vector to change his eye color to the primary color he sees through his camera.
That might be one we do here pretty soon at Kinvert
In Conclusion – Vector Alpha and Rainbow Eyes
Again, this was very much impromptu. I just wanted to quick get something out to celebrate the Alpha release of the Anki Vector SDK.
We help schools create amazing STEM programs and makerspaces. If you’re interested in knowing more please go to our Contact Page.
Want to stay up to date with Cozmo and Vector? We send a lot of cool stuff to our mailing list and you can unsubscribe at any time.