Anki Vector SDK

ertsmal gleich Probleme mit Python

python3 -m pip install --user anki_vector

wirft eine Fehler wegen fehlendem Pket ffi und übersetzt deshalb Paket Cryotography nicht

sudo apt-get install libffi-dev

Die Zeile

python3 -m anki_vector.configure

führt zu

 from . import _methods
  File "/home/dab/.local/lib/python3.6/site-packages/numpy/core/_methods.py", line 158, in <module>
    _NDARRAY_ARRAY_FUNCTION = mu.ndarray.__array_function__
AttributeError: type object 'numpy.ndarray' has no attribute '__array_function__

mehrfaches

pip3 
uninstall numpy
pip3 uninstall numpy
Cannot uninstall requirement numpy, not installed

Dann erneut

pip3 install numpy
Collecting numpy
  Using cached https://files.pythonhosted.org/packages/7b/74/54c5f9bb9bd4dae27a61ec1b39076a39d359b3fb7ba15da79ef23858a9d8/numpy-1.16.0-cp36-cp36m-manylinux1_x86_64.whl
Installing collected packages: numpy
Successfully installed numpy-1.16.0
dab@dab-Alpha:~$ python3 -m anki_vector.configure

Finally:

Enter your email and password. Make sure to use the same account that was used to set up your Vector.
Enter Email: daniel@bachfeld.com
Enter Password: 

Authenticating with Anki Cloud... DONE

Attempting to download guid from Vector-C4M5 at 192.168.2.189:443... DONE

Writing config file to '/home/dab/.anki_vector/sdk_config.ini'...

SUCCESS!

Example Code

import anki_vector


def main():
    args = anki_vector.util.parse_command_args()
    with anki_vector.Robot(args.serial) as robot:
        print("Say 'Hello World'...")
        robot.say_text("Hello World")


if __name__ == "__main__":
    main()
dab@dab-Alpha:~/Downloads/anki_vector_sdk_examples_0.5.1/tutorials$ python3 01_hello_world.py 
2019-01-17 20:59:30,394 anki_vector.robot.Robot WARNING  No serial number provided. Automatically selecting 00505d91
2019-01-17 20:59:30,397 anki_vector.connection.Connection INFO     Connecting to 192.168.2.189:443 for Vector-C4M5 using /home/dab/.anki_vector/Vector-C4M5-00505d91.cert
2019-01-17 20:59:30,853 anki_vector.connection.Connection INFO     control_granted_response {
}

Say 'Hello World'...

Für die App

pip3 install --user "anki_vector[3dviewer]"
pip3 install ipython

Projekte von Kinvert Distance Ruler

Marks für Cozmo/Vector

anki_vector.objects](https://developer.anki.com/vector/docs/generated/anki_vector.objects.html#module-anki_vector.objects



Mehrere Python-Version auf dem PC

Anki Vector läuft prinzipiell nur mit Python 3.6. Auf dem PC waren aber noch 2.7 aus ROS Kinetic und 3.5 von QNAP installiert. Beim Starten von python3.6 01_hello_world.py kam die Fehlermeldung:

cannot import module

der Grund: er sucht im falschen Pfad Im Python-Interpreter

import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type

Warum suchte er in diesem Pfad? Weil

>>> import sys
>>> print (sys.path)
['', '/opt/ros/kinetic/lib/python2.7/dist-packages', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/admin/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']

Den Pfad zu 2.7 ist als erste in der Liste, indem auch das opencv-Modul aus der ROS-Installation liegt, das aber offenbar nicht alle erwarteten Funktionen erhält. Abhilfe: Den Pfad zu 3.6 an erster Stelle setzen!

sys.path.insert(0,"/home/admin/.local/lib/python3.6/site-packages")

dann sieht es folgendermaßen aus:

>>> print(sys.path)
'/home/admin/.local/lib/python3.6/site-packages', '', '/opt/ros/kinetic/lib/python2.7/dist-packages', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/admin/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']

Installation von Modulen

Beim Installieren der Module muss man explizit so vorgehen

python3.6 -m pip --user anki_vector

und

python3.6 -m pip opencv-python

weil pip3 install opencv-python leider unter home/admin/.local/lib/python3.5/site-packages installiert. Python 3.6 als Standard per update-alternatives zu setzen, könnte auch funktionieren.... Einzelheiten auch hier Installing Python Modules

# how to define ROS kinetic to use python3 instead of python2.7?

https://answers.ros.org/question/237613/how-to-define-ros-kinetic-to-use-python3-instead-of-python27/



Sprachkommandos

Starting Off

Say “Hey Vector” to get his attention.

Alternatively you can press the button on his back instead

Introductions

Hey Vector, hello

Hey Vector, good morning

Hey Vector, good afternoon

Hey Vector, good evening

Hey Vector, goodbye

Hey Vector, my name is Luke

Hey Vector, what’s my name?


Utility

Hey Vector, whats the weather like?

Hey Vector, whats the weather in London?

Hey Vector, set a timer for 5 minutes?

Hey Vector, check the timer

Hey Vector, cancel the timer

Hey Vector, what time is it?

Hey Vector, take a picture

Hey Vector, take a picture of me

Hey Vector, take a picture of us


Commands

Hey Vector, come here

Hey Vector, look at me

Hey Vector, start exploring

Hey Vector, stop exploring

Hey Vector, be quiet

Hey Vector, go to sleep

Hey Vector, good night

Hey Vector, good robot

Hey Vector, bad robot

Hey Vector, go to your charger


Fun

Hey Vector, give me a fist bumb

Hey Vector, find your cube

Hey Vector, do a wheelstand

Hey Vector, roll your cube

Hey Vector, listen to the music

Hey Vector, play blackjack

Hey Vector, quit blackjack


Questions

Hey Vector, I have a question –wait– who is Jarvis?

Hey Vector, I have a question –wait– what is the distance between New York and London?

Hey Vector, I have a question –wait– what is the tallest building?

Hey Vector, I have a question –wait– what is the definition of artificial intelligence?

Hey Vector, I have a question –wait– how many calories in an avocado?

Hey Vector, I have a question –wait– what time is it in Sydney?

Hey Vector, I have a question –wait– how many miles in a kilometer?

Hey Vector, I have a question –wait– what is 10 pounds in euros?

Hey Vector, I have a question –wait– what is the square root of 144?

weitere Projekte

https://github.com/OTL/cozmo_driver

https://github.com/unbug/Anki-Vector-AI

https://github.com/betab0t/vector_ros