ST Solutions Australia

©Copyright ST Solutions Australia. All rights reserved.

22 May 2017

Please reload

Latest Articles

Using Python SDK

In this tutorial, we will explain how to use Python SDK to access Pepper instead of using Choregraphe. Using Python is one of the easiest ways to program with Pepper.

Python SDK (NAOqi for Python) is the SDK that allows you to control Pepper remotely. By using this SDK and run a Python script on your own PC, you can control Pepper as you wish connecting through the network just like Choregraph.

 

 

Python SDK Installation

 

 

1. Python

 

To use NAOqi for Python, you will first need to install Python 2.7 from http://python.org/download/

For Mac users, make sure to install “Mac OS X 64-bit/32-bit installer” version.

 

 

2. NAOqi for Python

 

Windows: extract pynaoqi-python2.7-2.5.x.x-win32-vs2013.zip

Mac: extract pynaoqi-python-2.7-naoqi-x.x-mac64.tar.gz

 

You can download the latest release of Python SDK from SoftBank Robotics Community website.

Make sure that your robot is registered on your SoftBank Robotics Community user account, and access the software resources: https://community.aldebaran.com/en/resources/software

 

 

3. Set environment variables

 

Windows:

  • Go to Control Panel > System and Security > System

  • Click the Advanced system settings in the left column

  • In the System Properties window, click on the Advanced tab, then click the Environment Variables button near the bottom of that tab

  • In the Environment Variables window, add a new User variable:

    • Set the Variable name as PYTHONPATH

    • Set the Variable value by browsing the extracted Python SDK directory and add \lib at the end.

 

Mac:

  • Open Terminal window and run the following commands:

    • $ export PYTHONPATH=${PYTHONPATH}:(path to Python-SDK directory)/lib/python2.7/site-packages

    • $ export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:(path to Python-SDK directory)/lib

 

 

5. Checking the installation of the Python SDK

 

Windows:

  • Run the default IDE (IDLE) that comes with the python installer.

 

Mac:

  • Make sure to use /usr/local/bin/python

  • Then run:

    • import naoqi

 

If you do not get any error message, congratulations! You are now ready to use the Python SDK.

 

 

 

Running Python Script

 

 

In this tutorial, we will make Pepper speak using the ALTextToSpeech API.

Try to run the following code on Python interpreter:

 

from naoqi import ALProxy

tts = ALProxy(“ALTextToSpeech”, “(your Pepper’s IP Address)”, 9559)

tts.say(“Hello, world!”)

 

ALProxy is an object that gives you access to all the methods or the module you are going to connect to.

 

class ALProxy(name, ip, port)

  • name – the name of the module

  • ip – the IP of your robot

  • port – the port on which NAOqi listens (9559 by default)

 

Every method of the module is directly accessible through the object.

Share on Facebook
Share on Twitter
Please reload

Please reload

Tags

Please reload

Archive