Level | All beginners | Time | 5 min |
OS | Linux - Windows - Mac | Preparation | 5/15 min |
Preparation time is given for the case you have to install tools prior the tutorial.
Make sure you have a robot ready to use, or read the Out of the box section.
Step | Action |
---|---|
Start your favorite editor, let’s say IDLE, the one automatically installed with Python. | |
Open a new window. | |
Copy and paste the following code: from naoqi import ALProxy
tts = ALProxy("ALTextToSpeech", "<IP of your robot>", 9559)
tts.say("Hello, world!")
|
|
Replace <IP of your robot> by the IP of your robot. If you don’t know its IP address, press its Chest button, NAO will say it. |
|
Save the file as a Python file. |
|
Run it. |
Your robot says “Hello, world!”.
Let’s explain the 3 lines you wrote:
from naoqi import ALProxy
This line imports the module ALProxy.
tts = ALProxy("ALTextToSpeech", "<IP of your robot>", 9559)
This line creates an object called tts. This object will send calls to NAOqi.
tts.say("Hello, world!")
This line uses the object tts to send an instruction to the NAOqi module.
To make the robot do something, you have to:
Outside Choregraphe, IP and Port are mandatory parameters of proxy().