Anki Vector: Autonomous mini robot with charm and its own SDK put to the test

Page 3: Vector SDK: Programming robots

Contents

If Vector were just a cute toy, the price would actually be quite high. However, thanks to its numerous sensors, Vector also offers a good introduction to (robot) programming.

Since December 2018, the alpha version of the Vector Software Development Kit has been available to everyone (registration required). The SDK is based on that of its predecessor Cozmo, meaning that Vector can also be programmed in the popular Python scripting language. The API currently provides 29 Python objects with numerous classes and functions that can be used to control all motors, sensors and the screen.

Installation is very simple: After installing Python (Download), the command

py -3 -m pip install --user anki_vector

to install all the required packages from the Anki repository. Communication with Vector takes place via HTTPS over the WLAN connection; the computer on which the SDK is running must therefore be in the same WLAN as Vector. A certificate from Anki's servers is required for authentication. The command

py -m anki_vector.configure

asks for the access data of the Anki account created when Vector was set up, the name of the robot and its serial number in order to download the certificate.

Anki provides a dozen or so tutorial scripts as well as four more complex applications for control: a 3D viewer, an interactive shell, the proximity mapper and a Vector remote control. All applications and scripts do not run on Vector itself, but transmit the individual commands via the encrypted network connection. The constant need for authentication with the robot makes this a rather sluggish undertaking.

The first steps are very simple; the following script, for example, has Vector follow an outline of a heart:

#!/usr/bin/env python3

"""-------------------------
   Make Vector drive a heart
   -------------------------"""

import anki_vector
from anki_vector.util import degrees, distance_mm, speed_mmps


def main():
    args = anki_vector.util.parse_command_args()

    # The robot drives straight, stops and then turns around
    with anki_vector.Robot(args.serial) as robot:
        robot.behavior.drive_off_charger()

        robot.behavior.turn_in_place(degrees(-30))
        robot.behavior.drive_straight(distance_mm(200), speed_mmps(100))
        for _ in range(6):
            robot.behavior.turn_in_place(degrees(30))
            robot.behavior.drive_straight(distance_mm(30), speed_mmps(100))
        robot.behavior.turn_in_place(degrees(-120))
        robot.behavior.drive_straight(distance_mm(30), speed_mmps(100))
        for _ in range(6):
            robot.behavior.turn_in_place(degrees(30))
            robot.behavior.drive_straight(distance_mm(30), speed_mmps(100))
        robot.behavior.drive_straight(distance_mm(170), speed_mmps(100))

if __name__ == "__main__":
    main()

Vector has been available in the USA since October 2018: the website Kinvert, which specializes in programming courses for children and young people, explores Vector's possibilities and has published various Python scripts for Cozmo and Vector along with explanations, such as a Pong game. The VectorCloud project can also be found on GitHub: a web interface that has been expanded compared to the "Remote Control" example application, including a demo "app store".

In the Anki Developer Forum (registration required) there are advanced projects such as the Vector Explorer Tool –, a port of the Cozmo Explorer Tool –, with which you can easily try out all the hardware and software features of Vector, including game controller support. With the help of the object recognition system You Only Look Once (YOLO), Vector can also play blackjack with real playing cards, as the VectorCards project shows.

Several robots can also be addressed using their serial numbers via the SDK, so that interactions between them could also be realized in principle.

Ihr exklusiver Zugriff auf das gesamte Wissen der größten unabhängigen IT-Fachredaktion Europas.

Jetzt entdecken!