Say hello with Python SDK (Pepper Tech Fes technical session)

Introducing an example introduced in the technical session of Pepper Tech Festival 2014 held at Bellesalle Shibuya Garden on September 20, 2014.

Overview

In the technical session, I introduced how to use the Python SDK as one of the ways to access Pepper other than Choregraphe. This tutorial summarizes the content.

Pepper Tech Festival 2014 Video

You can play from the relevant part with the link below.

[Pepper Tech Festival 2014 ~ Technical Session (Application)](http://www.youtube.com/watch?v= MjaOWfYWBjA & t = 42m43s)

Python SDK (NAOqi for Python) is an SDK for remote control of Pepper. Using this SDK, you can operate Pepper arbitrarily over the network by executing Python scripts on your own PC.

You can access this API in the same way as you would use it from the code in Choregraphe's Python Box (http://qiita.com/Atelier-Akihabara/items/f6a05ca14be786f9a94c). This section describes how to install NAOqi for Python and how to check the operation easily.

Install Python SDK

Python is required for NAOqi for Python to work. Prepare a Python environment according to the OS of the machine you want to install, and then install NAOqi for Python. The NAOqi for Python installer can be found at the SDKs \ RemotePrograming \ PythonSDK on the USB stick distributed by Pepper Tech Fes.

For details on the installation procedure, refer to the NAOqi Developer Guide> Getting Started> Python SDK Install Guide in the SDK documentation.

We will explain how to install Python and NAOqi for Python for each OS and how to start the Python interpreter to check the operation.

For Windows

Python installation

First, install the Python runtime environment. Download the Python2.7 32bit installer from https://www.python.org/downloads/windows/ and run it.

Install NAOqi for Python

Execute the Windows installer pynaoqi-python2.7- (version) .win32.exe located in the PythonSDK folder in the USB memory.

Running Python interpreter

Execute Python (command line) registered in the start menu by the Python 2.7 installer, or execute the installed python.exe from the command line.

For Mac

Python installation

For Python, please use the Python 2.7 ** that comes standard with OS X. Don't use anything other than Apple, such as Python downloaded from Python.org.

Install NAOqi for Python

Extract the tar.gz archive pynaoqi-python2.7- (version) -mac64.tar.gz in the PythonSDK directory on the USB memory to a suitable file.

Running Python interpreter

Add the path of the directory where you extracted tar.gz to the PYTHONPATH environment variable and the DYLD_LIBRARY_PATH environment variable, and execute the python command.

For example, if tar.gz is extracted to / Users / (your username) / Documents / and a directory called pynaoqi-python2.7-2.0.5.3-mac64 is created there, the terminal By executing the following from, Python will start with the SDK available.

$ export PYTHONPATH=${PYTHONPATH}:/Users/(My username)/Documents/pynaoqi-python2.7-2.0.5.3-mac64
$ export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/Users/(My username)/Documents/pynaoqi-python2.7-2.0.5.3-mac64
$ python

If you write the above two ʻexportcommands in the.bash_profile` file, these environment variables will be set automatically when you use the shell.

Try running a simple script

In this session, I'm trying to give instructions to speak remotely to the ʻALTextToSpeech` API (the API used to implement the Say Text box). For example, enter and execute the following script on the executed Python interpreter.

from naoqi import ALProxy

tts = ALProxy("ALTextToSpeech", "<Pepper IP>", 9559)
tts.say("Hello")

For how to check Pepper's IP, refer to How to know Pepper's IP address. If the installation is only to be successful, you talk is Pepper as "Hello".

####Info.png (Note) Japan depending on the environment Treatment of words In the above example it has been described as an example of the Japanese "Hello", but it may not work properly by setting such as the default encoding of the interpreter. (The above has been confirmed to work on Mac, but it does not seem to work on Windows as it is) If you do not the expected behavior, "Hello" Try to enter, such as "hello" instead of, please try to check the operation.

For more information on programming with NAOqi for Python, see the NAOqi Developer Guide> Programming> Python SDK in the SDK documentation.

In this way, in addition to uploading and executing applications to Pepper using Choregraphe, it is also possible to remotely access Pepper from a PC via API.

Recommended Posts

Say hello with Python SDK (Pepper Tech Fes technical session)
Python Box Concept (Pepper Tech Fes Tech Session)
Say hello to the world with Python with IntelliJ
Debug with PEPPER python interpreter
Python starting with Hello world!
[Note] Hello world output with python
Working with OpenStack using the Python SDK
Register users with Google Admin SDK (python)
Touch virtual robots with Pepper's Python SDK
Connect to pepper with PEPPER Mac's python interpreter