Hello World 4 - using Python
|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.
Before starting ¶
Let’s do it ¶
Your robot says “Hello, world!”.
How it works ¶
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 is the name we gave to the object instance (could have been myspeechmodule or speakingmodule ).
- ALProxy() is a class of objects, allowing you to have acces to all the methods of a module.
- ALTextToSpeech is the name of the module of NAOqi we want to use.
- IP and Port (9559) of the robot are also specified (it was not the case with Choregraphe ).
This line uses the object tts to send an instruction to the NAOqi module.
- tts is the object we use.
- say() is the method.
- “Hello, world!” is the parameter.
What you have learned ¶
To make the robot do something, you have to:
- Import the module ALProxy .
- Create an object giving access to one of the NAOqi modules.
- Call one of its available methods.
Outside Choregraphe , IP and Port are mandatory parameters of proxy() .