anki_vector.animation

Animation related classes, functions, events and values.

Animations represent a sequence of highly coordinated movements, faces, lights, and sounds used to demonstrate an emotion or reaction.

Animations can control the following tracks: head, lift, treads, face, audio and backpack lights.

There are two ways to play an animation on Vector: play_animation_trigger and play_animation. For play_animation_trigger, you select a pre-defined group of animations, and the robot will choose which animation from the group to run when you execute the method. When calling play_animation, you select the specific animation you want the robot to run. We advise you to use play_animation_trigger instead of play_animation, since individual animations can be deleted between Vector OS versions.

By default, when an SDK program starts, the SDK will request a list of known animation triggers and animations from the robot, which will be loaded and available from anim_list_triggers and anim_list, respectively, in the AnimationComponent.

Classes

AnimationComponent(robot)

Play animations on the robot

class anki_vector.animation.AnimationComponent(robot)

Play animations on the robot

anim_list

Holds the set of animation names (strings) returned from the robot.

Animation names are dynamically retrieved from the robot when the Python script connects to it.

Warning: Specific animations may be renamed or removed in future updates of the app. If you want your program to work more reliably across all versions we recommend using anim_trigger_list and play_animation_trigger() instead.

import anki_vector

with anki_vector.Robot() as robot:
    print("List all animation names:")
    anim_names = robot.anim.anim_list
    for anim_name in anim_names:
        print(anim_name)
anim_trigger_list

Holds the set of animation trigger names (strings) returned from the robot.

Animation trigger names are dynamically retrieved from the robot when the Python script connects to it.

Playing an animation trigger causes the robot to play an animation of a particular type.

The robot may pick one of a number of actual animations to play based on Vector’s mood or emotion, or with random weighting. Thus playing the same trigger twice may not result in the exact same underlying animation playing twice.

To play an exact animation, use play_animation().

This property holds the set of defined animations triggers to pass to play_animation_trigger().

import anki_vector

with anki_vector.Robot() as robot:
    print("List all animation trigger names:")
    anim_trigger_names = robot.anim.anim_trigger_list
    for anim_trigger_name in anim_trigger_names:
        print(anim_trigger_name)
load_animation_list()

Request the list of animations from the robot.

When the request has completed, anim_list will be populated with the list of animations the robot knows how to run.

Warning: Specific animations may be renamed or removed in future updates of the app. If you want your program to work more reliably across all versions we recommend using animation triggers instead. See play_animation_trigger().

import anki_vector

with anki_vector.AsyncRobot() as robot:
    anim_request = robot.anim.load_animation_list()
    anim_request.result()
    anim_names = robot.anim.anim_list
    for anim_name in anim_names:
        print(anim_name)
load_animation_trigger_list()

Request the list of animation triggers from the robot.

When the request has completed, anim_trigger_list will be populated with the list of animation triggers the robot knows how to run.

Playing a trigger requests that an animation of a certain class starts playing, rather than an exact animation name.

import anki_vector

with anki_vector.AsyncRobot() as robot:
    anim_trigger_request = robot.anim.load_animation_trigger_list()
    anim_trigger_request.result()
    anim_trigger_names = robot.anim.anim_trigger_list
    for anim_trigger_name in anim_trigger_names:
        print(anim_trigger_name)
play_animation(anim, loop_count=1, ignore_body_track=False, ignore_head_track=False, ignore_lift_track=False)

Starts an animation playing on a robot.

Vector must be off of the charger to play an animation.

Warning: Specific animations may be renamed or removed in future updates of the app.

If you want your program to work more reliably across all versions we recommend using play_animation_trigger() instead.

import anki_vector

with anki_vector.Robot() as robot:
    robot.anim.play_animation('anim_turn_left_01')
Parameters
  • anim (str) – The animation to play. Can be of type str or anki_vector.protocol.Animation.

  • loop_count (int) – Number of times to play the animation.

  • ignore_body_track (bool) – True to ignore the animation track for Vector’s body (i.e. the wheels / treads).

  • ignore_head_track (bool) – True to ignore the animation track for Vector’s head.

  • ignore_lift_track (bool) – True to ignore the animation track for Vector’s lift.

play_animation_trigger(anim_trigger, loop_count=1, use_lift_safe=False, ignore_body_track=False, ignore_head_track=False, ignore_lift_track=False)

Starts an animation trigger playing on a robot.

Playing a trigger requests that an animation of a certain class starts playing, rather than an exact animation name.

Vector must be off of the charger to play an animation.

import anki_vector

with anki_vector.Robot() as robot:
    robot.anim.play_animation_trigger('GreetAfterLongTime')
Parameters
  • trigger – The animation trigger to play. Can be of type str or anki_vector.protocol.AnimationTrigger.

  • loop_count (int) – Number of times to play the animation.

  • use_lift_safe (bool) – True to automatically ignore the lift track if Vector is currently carrying an object.

  • ignore_body_track (bool) – True to ignore the animation track for Vector’s body (i.e. the wheels / treads).

  • ignore_head_track (bool) – True to ignore the animation track for Vector’s head.

  • ignore_lift_track (bool) – True to ignore the animation track for Vector’s lift.