Anki Vector SDK: A robot with attitude

Ashleigh Bartlett-Needham
7 min readMay 12, 2019

--

Program Anki Vector to be a salty, sassy robot with attitude

If you haven’t met Vector yet, he’s a cute little robot desk companion, developed by Anki. Designed to be a helpful robot assistant, with more personality than an Alexa or Google Assistant, Vector responds to a large range of voice commands. And this robot also has the ability to autonomously explore your desk, find it’s way back to the charger, and play with a toy cube. Pretty neat right? Well there’s more. This robot also has a full SDK for robot enthusiasts and programmers to play around with, modifying behaviours and making this robot even more versatile. This means that if you want your robot sidekick to have a bit more sass, and respond to voice commands with a bit of rebellion, the SDK is the place to start. In fact, there’s even an example code there that is perfect to help you get started. So, read on to find out how to turn Anki’s Vector robot into the most unhelpful robot assistant, even if you don’t know the first thing about programming.

How can you turn Anki Vector into a robot with attitude?

This is a basic guide exploring how you can customize Vector’s responses to a range of voice commands, to create the most unhelpful robotic assistant to date. Well, the idea is that instead of a cute, subservient little robot buddy, Vector is transformed into a robot full of attitude, who absolutely is not here to help. Think Bender…

It’s Vector, but not as you know him!

It all starts with the SDK. You can follow these instructions to get you started, and for a quick look at editing and changing the first three example programs, check out this guide. (If you are completely new to programming, it’s probably worth giving this a read first, before continuing.)

But what about Anki?

Before we go any further, let’s address the elephant in the room. Anki have shutdown. It’s true. Manufacturing of Vector (plus Anki’s other products like Cozmo and Overdrive) has ceased, and the company is no longer operating. Or is it? Well, as Vector owners around the world waited for their trusty companion to take it’s last beeps, Anki released a public statement:

So, for now, it seems our robot buddies will remain connected. But it is worth noting that when/if we lose connection with the cloud, the following code won’t run.

User Intent Example

Getting back to the topic, the team over at Anki have created 18 examples as part of the SDK, to help us get started writing basic programs for Vector. Example 13 is the one we will be using, titled user_intent_subscription. When you open the file, this is what you should see:

You dont need to pay attention to the red lines, but the green writing at the top, before the imports, tells you what this program is for. Essentially, when you run the program, Vector will wait for you to say “Hey Vector” then he will process the command you follow with, e.g. “roll your cube”. The example program is pretty bare. There are no responses programmed to execute the commands that are given. But it does give a good insight into the kind of commands that can be customised.

Vector SDK API

For a better understanding, I went to the Vector SDK API, and delved into the user intent information. This page lists a range of possible voice commands, or user intents, that you can program Vector to respond to, anyway you want.

It’s also worth noting that at the present time, you can’t modify Vectors response to “Go to your charger”, or “Go to sleep”.

Modifying the example code

So, with a couple of the different voice commands in mind, you can navigate back to the example code, save it with a new program name (mine is unhelpful Vector), and start editing. This can be broken down into three steps:

  1. Including the right imports
  2. Adding if statements to respond to user intents
  3. Additional response options to keep Vector’s responses interesting

Including the right imports

For any python program to work correctly, you need to import the right modules. These are the imports included for the example program to run:

To add responses to user intents, you will need to add one more import, UserIntentEvent. This should make your import lines look like this:

Responding to user intents

To respond to user intents, you will need to use an if statement. This means that once your voice command has been processed, and transformed to text, it can be compared to a range of user intent events, like “hello”, or “fistbump”. If the voice command matches the hook for the user intent event, Vector can then execute your specific response.

This guide is all about turning Vector into a robot with attitude. So when someone says “hello” to Vector, I want him to have a bit of sass about him, and maybe even be quite rude. After all, we all have “off days”, right? So, starting with the hello user intent event, I programmed Vector to respond, like this:

Basically, the if statement needs to be added just after the user intent has been received. The beady eyed out there will also note that I added a While True loop near the end of the script. This just keeps the code looping forever, while the example program only looped once.

But what if Vector is asked to play with his cube, or pop a wheelie? Well, as he is normally, he responds cheerfully to any command, when he hears it (which can be temperamental)! But there can be such a thing as too cheerful, so to make Vector push back a little, you could change the code, like so:

You can do the same thing for the full range of user intent events as listed in the API. The imperative_scold, imperative_love, weather_response, show_clock, and names_ask are a lot of fun to play around with.

Adding additional responses

Now you have a Vector with attitude, you could think about adding additional responses. After all, if Vector responds with the same line every time you ask him, he might get a little repetitive. So, to add more responses, one of the possible options is to use a random variable to determine which piece of text Vector should say.

To use the random option in python, you will need to import the random module, adding it to the import options at the top of the program. So now, your imports should look like this:

Once imported, you can create a variable with a random value, and use if statements, to match the random value generated to the line Vector will say. Like this:

Tidying up

Some voice commands are similar to others, like “find your cube”, “fetch your cube” and “Pick up your cube”. In this piece of code it really doesn’t matter what you ask specifically, because Vector isn’t going to do it (spoiler, he’s a robot with attitude). But each different command has a different user intent event associated with it. So to prevent multiple if statements covering similar commands, you can just use or statements to group similar commands together. This means that the code will then look like this:

Anki Vector, programming a robot with attitude

Improvements

For a beginner, this program is a fun way to trick other members of your household, and get started creating customized responses to voice commands. Vector doesn’t have to be a sassbot though. You can use the same code, but change the speech, and Vector could become whatever you want.

Animations and movements could also easily be added to this program, to give Vector’s responses even more oomph. And you could even pair it with Vector’s face recognition to add personal insults for the people in Vector’s life. Or even compliments if a robot with attitude becomes a little too much! The possibilities are endless.

So, if you think you could handle Vector with a rebellious streak, and a bad attitude, try out this basic program. I’m sure you’ll find plenty of areas to improve on :)

--

--