Vector Examples Tutorials Projects

Anki Vector SDK examples aren’t easy to find as the SDK is very new. So we made this Anki Vector SDK tutorials, projects, and examples page. Let’s get Coding!

The Vector SDK was literally released today. So please keep in mind this is a living Draft that will be constantly updated. As we add more Vector example’s well add them here. If you have any examples please feel free share them via the comments!

If you read this, and it seems a bit over your head, check out our Ultimate Guide to Block Coding. You can program Cozmo in a much simpler format.

Updated Dec 15 2018

Vector Examples, Tutorials, and Projects

We will organize this so you can find Anki Vector SDK projects, examples, and tutorials according to certain categories. For example, we’ll sort the Vector examples, projects, and tutorials separately. We’ll also sort according to Python functions, Vector functions, and Vector features. For example, when sorting for Python we’ll look at examples that use loops, conditionals, etc. When looking at Vector features we’ll look at animations, the lift, etc. When looking at Vector functions we’ll look more at things like say_text() etc.

Examples will be pretty brief, giving a quick description and code for Vector. Tutorials will be much more in depth, and will take more work to write. Projects are ideas for things you can do at home or in the classroom.

Anki Vector Examples – Vector Functions

Here we will look at Anki Vector Python examples looking at specific functions.

anki_vector

anki_vector.anim

Find Vector examples of animations here. We will slowly be adding more and more examples using the anki_vector.anim class.

anki_vector.behavior

For now this seems to be the area that Anki has focused on the most. We have a lot of commands to use in the Vector Behaviors. We have written several examples on how to use some of these behaviors, and more are on the way.

anki_vector.camera

There is a lot of power in Vector’s camera. For now we are just scratching the surface with the possibilities. We will be writing more Vector examples that further utilize the camera. Kinvert loves modules like OpenCV and we’ll have some tutorials on that in the near future. Please stay tuned.

anki_vector.events.Events

Events allow Vector to watch for certain things to happen and then react.

  • audio_send_mode_changed
  • cube_connection_lost
  • nav_map_update
  • object_appeared
  • object_available
  • object_disappeared
  • object_finished_move
  • object_moved
  • object_observed
  • object_stopped_moving
  • object_tapped
  • object_up_axis
  • robot_observed_face
  • robot_observed_object
  • robot_state
  • wake_word

anki_vector.motors

anki_vector.proximity

One of the great features of Vector over Cozmo is the distance sensor. This will help a lot in obstacle avoidance as well as other things like mapping.

anki_vector.screen

Kinvert anticipates more functions becoming available in the future when it comes to Vector’s camera. We have a few Vector SDK examples here and will be adding more.

In particular we are looking forward to when we can draw shapes and text on Vector’s face. This is currently possible in the Cozmo SDK and Anki will almost certainly add similar functions in the future. Check out Cozmo SDK Examples to see what might be possible for Vector in the future.

Anki Vector Examples – Vector Features

Here is a list of Anki Vector examples based on the features of Vector. So for example, we’ve sorted these examples based on things you can control and sense with Vector. This includes Vector examples on the head, lift, backpack light, camera, and more.

Cube

Vector play games fetch tapped Kinvert Python program using Vector SDK

Drive

Anki Vector SDK Drive_Straight() and Turn_In_Place() to make Vector drive a figure 8

Lift

Once Anki releases Custom Markers or improves their dock with cube command we’ll be adding more lift examples. For now the lift just doesn’t seem to do much. It functions fine, but without being able to dock with cubes reliably it’s still sort of meh. Give them time. It’s still Pre-Alpha.

Vector slideshow on face with convert_image_to_screen_data and set_screen_with_image_data

Anki Vector Distance Sensor

We are super excited about this. Cozmo really needed a distance sensor and Vector actually gets one. Kinvert is thrilled to see that Anki included the Proximity sensor in their Pre-Alpha.

Anki Vector distance sensor using proximity to make a verbal ruler Kinvert Vector Example

Backpack Light

I don’t yet see how to control the backpack light in the Pre-Alpha. Once we see this is updated we’ll make sure to add some examples here.

  • Anki Vector Example – Vector’s Backpack Light 1
  • Anki Vector Example – Vector’s Backpack Light 2

Animations

Animations are what brings Vector to life and we’re excited to bring you some Vector examples with animations in them. Check them out below.

Anki Vector Animations in the Python SDK with play_animation command example by Kinvert

Camera

This camera seems much much better than the one in Cozmo. I plan to have some OpenCV examples out in the not too distant future.

Anki Vector Examples showing how to use the Vector SDK to display a camera image on screen

Face

The new color IPS Display opens a lot of possibilities. We can’t draw text and shapes yet but we can display images. Here are some examples that Kinvert wrote using the Vector SDK and the camera.

Anki Vector SDK Python programmable robot Kinvert face screen example

Head

Move the head to change the camera angle, or give Vector a bit of personality. You can find examples below that show you how to move Vector’s head.

Using Anki Vector set_head_motor() command to move Vector's head using the Anki Vector SDK in Python by Kinvert

Touch

Using the capacitive touch sensor in the SDK.

Anki Vector Coding Example using the touch sensor in the Anki Vector SDK with Kinvert

Vector Cube Examples

Not much to see here yet. Coming soon πŸ™‚

Anki Vector Examples – Python Based

Here we will look at using things like for loops, if / else statements, and more in working examples. For example in case TKinter isn’t installed we use a try except to cleanly exit the program. At Kinvert we believe students learn best by seeing real working Vector examples.

For Loops

We have some Vector examples that use for loops which you might find helpful.

While Loops

Here are some Vector examples that use a while loop to make them work.

Lists

To make these programs work we used lists.

PIL Module

Events

Useful Links

https://developer.anki.com/blog/features/interview/from-stem-to-learn/

Anki Vector SDK in Python

Anki Cozmo vs Vector Comparison Chart

How to Replace Cozmo and Vector Cube Battery

Have a Cozmo but not a Vector? Check out the Anki Cozmo SDK and our Anki Cozmo Examples Projects and Tutorials.

Please ask questions and leave feedback in the comments!

If you’re a beginner and Python isn’t your thing take a look at What is Robotics, Block Coding, and Age to Teach Kids Python.

Want to stay up to date with any new Vector example code or tips? Join our mailing list. Unsubscribe at any time if you want. We hate spam as much as you do.

14 responses to “Vector Examples Tutorials Projects

    1. I don’t know exactly when but I should have at least one within a week. I have a newborn so our schedule is all over the place right now so I can’t promise it will be within a week.

      We do have some examples from Cozmo, which should be fairly similar to Vector FYI. In Useful Links above we have a link to the Cozmo SDK.

  1. I’ve tried some animations, and the only one that works is the timer chime (anim_timersup_beep_01). However the loop integer does nothing, because it won’t repeat.
    Here’s my code, and I get no errors. It seems to work, (the Terminal Window says so) but Vector doesn’t show it.
    I’ve tried the example they give us verbatim ‘anim_turn_left_01’ and I get no change in behavior.
    I’ve tried ‘anim_dizzy_reaction_soft_03’, and I get no change in behavior.
    I’ve tried ‘anim_dizzy_shake_stop_01’, and I get no change in behavior.
    What am I doing wrong?
    _____________________________________

    #!/usr/bin/env python3

    “””play_animation()

    Make Vector PERFORM an Animation
    “””

    import anki_vector

    def main():

    with anki_vector.AsyncRobot() as robot:
    robot.anim.play_animation(‘anim_weather_rain_01’,loop_count=1, ignore_body_track=False, ignore_head_track=False, ignore_lift_track=False)
    if __name__ == “__main__”:
    main()

    1. I am actually writing an article on this right now.

      Try this out. It seems to work.

      import anki_vector
      import time

      def main():
      args = anki_vector.util.parse_command_args()
      with anki_vector.Robot(args.serial) as robot:
      robot.behavior.drive_off_charger()

      robot.anim.play_animation(‘anim_greeting_hello_01’)

      if __name__ == “__main__”:
      main()

  2. Hi Keith! Thanks for the reply. What I was trying to do was test the command-line variables for Play_Animation. It seems they don’t work.
    The example file “04_Animation.py” works, UNTIL I try to put in the command-line variables that are documented in the SDK kit’s Index.html file, under “Anki_Vector.Animation”. It says:

    play_animation(anim, loop_count=1, ignore_body_track=False, ignore_head_track=False, ignore_lift_track=False)

    But I don’t believe it works as documented.

    1. Ah I gotcha. Sorry about that. Yeah to get the picture for this article I was trying to ignore the body, head, and lift tracks. When I put those as True, the animation still played but all those motors kept playing.

      Are you seeing the same thing? Or is your behaving a bit differently?

      For now ignore_body_track=True, as well as the others, don’t seem to have any effect currently in this Pre-Alpha version of the SDK.

      We did just publish our Vector Example on Vector Animations by the way πŸ™‚

  3. Keith,

    I’m trying to come up with a program that follows the following pseudo code logic:

    [
    Reminder:

    Storing

    “Hey Vector”,
    “Remind me” or “Take a note”,
    Store audio as string array,
    Have Vector prompt as to whether you need reminded at a specific time.
    If not exit the loop and await for function to retrieve stored reminder.
    If so provide a time to have Vector assign an alarm task for the reminder. Have Vector then prompt if you
    would like a reminder prior to the scheduled time. If so, have him prompt for how long, and schedule an
    additional alarm task for the original time minus the new time value assigned.

    Retrieval

    Hey Vector
    “Did I forget?” or “Do you have any notes?”
    Have Vector prompt as to whether you need reminded at a specific time.
    If not have Vector reply “None that I am aware of.” or “No. Your schedule is clear.” then exit the loop.
    If so retrieve stored string array stored earlier and read it. Otherwise the scheduled alarm task for the
    reminder will have Vector notify me at the scheduled time.
    ]

    My main issues are programmatically how to store a custom audio queue prompt, and store it. Then the scheduling I’m assuming there are existing functions to call for this. Any pointers that you may be able to provide would be deeply appreciated. Thank you for all of the info to date.

    1. Currently I don’t believe audio is supported in the Pre-Alpha SDK.

      Love your idea. Can’t wait until they add this to the SDK so you can make it happen.

  4. Excuse the poor communication/typing. I forgot re: scheduling that having Vector prompt for tasks, if it is a re-occurring/repeating task. Apologies again, and any pointers are welcome.

  5. G’day,
    I learnt to see and control vector through the SDK can we enable the microphone so we can hear too?
    Is there anything for speech recognition too?
    Oh, lastly, after controlling him through SDK he seams to have a fit when he returns to his charger and we have to restart him. Is this a common thing?

    1. Hi Archie,

      Currently the microphone is not supported in the SDK, nor is speech recognition. That said they may be in development and available later.

      I’ve had times where Vector will try to charge while I’m programming him. It’s not super common but I’ve seen it a few times. Not sure if it’s the same as what your describing.

      Thanks,

      Keith

  6. I do the “hey vector” and “set eye color to blue” and the eyes change to blue!
    If I do “hey vector” and “set eye color to white”, they go purple.
    If I do “hey vector” and “set eye color to red, they change to yellow”.

    Is there a problem with my vector’s screen?

    1. Do you have the SDK installed? You could set his screen to certain colors and see if the problem exists or goes away when isolated from speech recognition.

Leave a Reply

Your email address will not be published. Required fields are marked *