Skip to content

"Hello, World!" using Python SDK

Bryce George edited this page Nov 18, 2020 · 7 revisions

Author: ancient-sentinel - Last Updated: 11/17/2020

Linux

For instructions on connecting to the robot and getting its IP address see Using the Robot Settings Application.

<Instructions Pending>

See also Installing the NAO Python SDK on Linux, Setup PyCharm on Linux

 

Mac

For instructions on connecting to the robot and getting its IP address see Using the Robot Settings Application.

Once you have the IP address of the robot, open Terminal and run the following commands (assuming you followed the installation tutorial).

  1. Go to your root directory and open a new Python IDLE window:
cd /
./usr/local/bin/python -m idlelib.idle
  1. In IDLE, import the NAO SDK:
import naoqi

If you don't get any errors from running this command, proceed to the next step. If you get an error saying that the naoqi module cannot be found, run the following commands to see your environment variables:

import os
print(os.environ)

If the values for PYTHONPATH, DYLD_LIBRARY_PATH, and QI_SDK_PREFIX don't point to the location of the Python SDK in your file system, close IDLE and redo steps 2-4 from the installation guide to set your environment variables, then start at step 1 again.

  1. Import the ALProxy module:
from naoqi import ALProxy
  1. Connect to the ALTextToSpeech module:
tts = ALProxy("ALTextToSpeech", "<IP of your robot>", 9559)
  1. Make the robot say "Hello world!":
tts.say("Hello, world!")
  1. Connect to the ALMotion module:
motion = ALProxy("ALMotion", "<IP of your robot>", 9559)
  1. Walk forward half a meter:
motion.moveInit()
motion.moveTo(0.5, 0, 0)

See also Installing the NAO Python SDK on Mac, Setup PyCharm on Mac

 

Windows

For instructions on connecting to the robot and getting its IP address see Using the Robot Settings Application.

<Instructions Needed>

See also Installing the NAO Python SDK on Windows, Setup PyCharm on Windows

Clone this wiki locally