In this article we will show you how to move Cozmo’s lift. We can do this with the Python SDK provided by Anki. This will enable us to move the Cozmo lift.
Why Move Cozmo’s Lift
There are many reasons to move Cozmo’s lift. I guess I’ll just list a few here but there are obviously plenty more.
- Part of motion to make him look more life like
- Lifting cubes
- Preparing to roll cubes
- Stacking cubes
- Lift before tapping cubes
You get the picture. There are plenty of reasons to move Cozmo’s lift so let’s just jump in to it.
Cozmo Move Lift Commands
What commands will we use? Let’s take a look.
Yep, we made this one super simple. We’ll make more in depth examples later but for now we’re trying to make some programs that beginners can write and use.
Cozmo Lift With cozmo.robot.Robot.roll_cube()
First we need our imports. We import cozmo which gives us access to Cozmo’s commands including the move_lift function. Next we import time which gives us access to time.sleep() so we can tell Cozmo how long to do the actions.
We define the function cozmo_lift. This is the function we will call which will actually do the moves we request.
Inside this function are two calls to move_lift() and time.sleep(). The first slowly moves the lift up while the second moves Cozmo’s lift down rapidly.
The time.sleep is long for the first, since the lift is moving slowly, then short for the quick lift jerk downward.
""" 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 cozmo import time def cozmo_lift(robot: cozmo.robot.Robot): '''This is a docstring which says that this function moves Cozmo's lift - Code by Kinvert''' robot.move_lift(0.25) #radians per second time.sleep(3) #3 seconds robot.move_lift(-100) time.sleep(1) cozmo.run_program(cozmo_lift)
How could you modify this program to try to toss a light cube?
What modification would make Cozmo tap a cube more gently?
How could you use this to try to make Cozmo pop a wheelie?
Having Fun Moving Cozmo’s Lift
At Kinvert we like to keep our lessons fun. After you make Cozmo cozmo lift, try having him do a victory dance.
For reference, check out our article on Cozmo Animations Play_Anim_Trigger().
How could you incorporate a bit of what you learn from there to spice this up and have Cozmo do a victory dance?
How can you move the lift to make Cozmo act cuter?
In Conclusion – Cozmo Move Lift Example
With simple commands we can make Cozmo do some pretty cool things. In the future we’ll be using similar commands to do things like roll Cozmo’s cube.
Are You a School?
We help schools create amazing STEM programs and makerspaces. If you’re interested in knowing more please go to our Contact Page.
Are You a Parent or Student?
We have some useful resources I linked above.
If you have any questions or comments please feel free to leave a comment below. Hope you found this helpful and fun!
Interested in reading about how to do similar things with the new Anki Vector? Check out our article on the Anki Vector SDK in Python.
If you want to know the Differences Between Cozmo and Vector check out the link to the left.
Python seem a bit too tough?