Difference between revisions of "Nao tutorial 1: First steps"

From robotica.unileon.es
Jump to: navigation, search
m
 
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
Go to root: [[TFM-Nao-Goalkeeper]]
 +
 +
----
 +
----
 +
 +
 
[[Image:Nao_whitebg.jpg|thumb|right|200px|Nao humanoid robot.]]
 
[[Image:Nao_whitebg.jpg|thumb|right|200px|Nao humanoid robot.]]
  
The purpose of this tutorial is to teach you the basic concepts of [http://www.aldebaran-robotics.com/en Nao]. I assume that you are staring at the robot's box after (hopefully) buying it, and that you want to start making cool things with it, like conquering the world. You are wondering how to do that, but you don't even know how to plug the robot.
+
The purpose of this tutorial is to teach you the basic concepts of [https://www.aldebaran.com/en/humanoid-robot/nao-robot Nao]. I assume that you are staring at the robot's box after (hopefully) buying it, and that you want to start making cool things with it, like conquering the world. You are wondering how to do that, but you don't even know how to plug the robot.
  
I will take you, step by step, through the first tasks that you should complete before going serious. Even if I will try to make it easy, certain previous knowledge is required, like basic programming and Linux concepts. Also, I would recommend you to read the official documentation and tutorials found [http://users.aldebaran-robotics.com/ here] (section <span style="color:#228B22">"Software"</span>) before going forth. In case of doubt, always trust them.
+
I will take you, step by step, through the first tasks that you should complete before going serious. Even if I will try to make it easy, certain previous knowledge is required, like basic programming and Linux concepts. Also, I would recommend you to read the [https://community.aldebaran.com/en/resources/documents official documentation] and [https://community.aldebaran.com/en/resources/tutorials tutorials] before going forth. In case of doubt, always trust them.
  
<span style="color:#606060">'''''NOTE: This tutorial is targeted for version 1.10.10 of the SDK and OS. Older versions like 1.8.16 or 1.6.13 are not likely to work.'''''</span>
+
<span style="color:#606060">'''''NOTE: This 2011 tutorial was targeted for version 1.10.10 of the SDK and OS. Newer versions have changed a lot of things, making most of these tutorials deprecated.'''''</span>
  
=Getting everything ready=
+
==Getting everything ready==
  
 
OK, the first thing you should do is to get a testing environment ready. By "testing environment" I mean:
 
OK, the first thing you should do is to get a testing environment ready. By "testing environment" I mean:
Line 21: Line 27:
 
Finally, the Ethernet socket is located behind the head. You may need to open the protective hatch, or completely remove the head's cover, whichever one you prefer.
 
Finally, the Ethernet socket is located behind the head. You may need to open the protective hatch, or completely remove the head's cover, whichever one you prefer.
  
=Connecting to Nao=
+
==Connecting to Nao==
  
 
When everything is set, press Nao's chest button once to turn it on. His eyes will start blinking red, green and blue. Then, some other blue LEDs located on his ears will do the same, and the eyes will stop blinking. Later, both the eyes and chest button will come alive again with a stable white light, and the robot will tell you that it has finished loading his system. The whole process lasts about two minutes (even more, if it is the first time) and you will get soon tired of it, I promise.
 
When everything is set, press Nao's chest button once to turn it on. His eyes will start blinking red, green and blue. Then, some other blue LEDs located on his ears will do the same, and the eyes will stop blinking. Later, both the eyes and chest button will come alive again with a stable white light, and the robot will tell you that it has finished loading his system. The whole process lasts about two minutes (even more, if it is the first time) and you will get soon tired of it, I promise.
Line 27: Line 33:
 
Now, you must connect to Nao to do some first-time configuration. It pays to have a simple router-based LAN with DHCP dynamic addressing, otherwise you will complicate your life, trust me.
 
Now, you must connect to Nao to do some first-time configuration. It pays to have a simple router-based LAN with DHCP dynamic addressing, otherwise you will complicate your life, trust me.
  
==Recovering the IP address==
+
===Recovering the IP address===
  
 
We need to get the IP address Nao has bonded to, before trying to connect to him. There are a couple of ways to do it, some easier than others, and I will enumerate them all:
 
We need to get the IP address Nao has bonded to, before trying to connect to him. There are a couple of ways to do it, some easier than others, and I will enumerate them all:
  
===Using the router===
+
====Using the router====
  
 
This is the hard way. Most routers offer an option to list the clients that are connected to it, through the web interface. But you need the router's IP. Input the following command in your PC (obviously, you must be in the same LAN as Nao):
 
This is the hard way. Most routers offer an option to list the clients that are connected to it, through the web interface. But you need the router's IP. Input the following command in your PC (obviously, you must be in the same LAN as Nao):
  
<pre>sudo ifconfig</pre>
+
<syntaxhighlight lang=Bash>sudo ifconfig</syntaxhighlight>
  
 
Seek your network adapter in the list (usually eth0 for the first Ethernet card, eth1 for the second...) and look for your IP address (mine is 192.168.1.101). Your router's IP will be probably the same, only changing the last number for 1 or 0 (e.g., 192.168.1.1). Open a web browser and input that IP in the address bar. Press Enter and you will be prompted for the router's username and password. You should know them, but if that's not the case go [http://www.routerpasswords.com/ here] for a list of default ones.
 
Seek your network adapter in the list (usually eth0 for the first Ethernet card, eth1 for the second...) and look for your IP address (mine is 192.168.1.101). Your router's IP will be probably the same, only changing the last number for 1 or 0 (e.g., 192.168.1.1). Open a web browser and input that IP in the address bar. Press Enter and you will be prompted for the router's username and password. You should know them, but if that's not the case go [http://www.routerpasswords.com/ here] for a list of default ones.
Line 41: Line 47:
 
When you're in, seek for a menu option that will show you the connected clients. Nao's IP should be next to yours.
 
When you're in, seek for a menu option that will show you the connected clients. Nao's IP should be next to yours.
  
===Mapping the network===
+
====Mapping the network====
  
 
Easier than the previous. You can scan the network for online hosts, using a network mapper program. For example, I will use [http://nmap.org/ nmap]. Install it using the following command if you are using Debian or Ubuntu:
 
Easier than the previous. You can scan the network for online hosts, using a network mapper program. For example, I will use [http://nmap.org/ nmap]. Install it using the following command if you are using Debian or Ubuntu:
  
<pre>sudo apt-get install nmap -y</pre>
+
<syntaxhighlight lang=Bash>sudo apt-get install nmap</syntaxhighlight>
  
 
And then do a ping scan over your network (change the first three numbers of the IP to match your network):
 
And then do a ping scan over your network (change the first three numbers of the IP to match your network):
  
<pre>sudo nmap -sP 192.168.1.1-255</pre>
+
<syntaxhighlight lang=Bash>sudo nmap -sP 192.168.1.1-255</syntaxhighlight>
  
 
Nao will appear in the list, with something like <span style="color:#FF1493">''"Host 192.168.1.102 is up (0.00018s latency)"''</span>. Your own computer will be shown, but with no latency.
 
Nao will appear in the list, with something like <span style="color:#FF1493">''"Host 192.168.1.102 is up (0.00018s latency)"''</span>. Your own computer will be shown, but with no latency.
  
===Asking Nao===
+
====Asking Nao====
  
 
The easier way, but you will need to get up and walk a bit. Just approach Nao and press his chest button once. It will briefly blink in green, and then Nao will beep and speak his name, internet address and battery level. If it says <span style="color:#FF1493">''"I can't connect to the network"''</span>, check the router and Ethernet cable.
 
The easier way, but you will need to get up and walk a bit. Just approach Nao and press his chest button once. It will briefly blink in green, and then Nao will beep and speak his name, internet address and battery level. If it says <span style="color:#FF1493">''"I can't connect to the network"''</span>, check the router and Ethernet cable.
  
==Web interface==
+
===Web interface===
  
 
Open a web browser, enter your Nao's IP as destination and hit Enter. If everything went OK, you should now see the robot's web interface (a login screen) appear. Enter <span style="color:#FF1493">"nao"</span> as both the username and password and press Enter. If this is the first time, you must agree to the user license terms before that.
 
Open a web browser, enter your Nao's IP as destination and hit Enter. If everything went OK, you should now see the robot's web interface (a login screen) appear. Enter <span style="color:#FF1493">"nao"</span> as both the username and password and press Enter. If this is the first time, you must agree to the user license terms before that.
  
[[Image:Nao_web_interface.jpg|thumb|none|600px|Example of Nao's web interface.]]
+
 
 +
[[Image:Nao_web_interface.jpg|thumb|center|700px|Example of Nao's web interface.]]
 +
 
  
 
The <span style="color:#228B22">"About"</span> screen will welcome you. Here you can check a lot of useful data about your robot, like the OS version he is running, which modules has he loaded, etc. Clicking on a module's name will show the available methods that it implements, and their descriptions. Quite handy.
 
The <span style="color:#228B22">"About"</span> screen will welcome you. Here you can check a lot of useful data about your robot, like the OS version he is running, which modules has he loaded, etc. Clicking on a module's name will show the available methods that it implements, and their descriptions. Quite handy.
  
===Connecting to a wifi===
+
====Connecting to a wifi====
  
 
When you're done, go to the <span style="color:#228B22">"Network"</span> menu. Here you will see a list of wireless networks, that Nao has detected using his wifi card. This is your chance to make Nao use a wireless network instead of the Ethernet cable, something very appealing because it will allow him to move freely across the room.
 
When you're done, go to the <span style="color:#228B22">"Network"</span> menu. Here you will see a list of wireless networks, that Nao has detected using his wifi card. This is your chance to make Nao use a wireless network instead of the Ethernet cable, something very appealing because it will allow him to move freely across the room.
Line 71: Line 79:
 
Do not hesitate and click on the name of the network you want. Then choose the <span style="color:#228B22">"Connect"</span> button, give in the password and confirm. That's it, Nao should bind to your router wirelessly from now on. Come back to this menu whenever you want to make him "forget" this network.
 
Do not hesitate and click on the name of the network you want. Then choose the <span style="color:#228B22">"Connect"</span> button, give in the password and confirm. That's it, Nao should bind to your router wirelessly from now on. Come back to this menu whenever you want to make him "forget" this network.
  
===Changing the name===
+
====Changing the name====
  
 
Only one menu remains, <span style="color:#228B22">"Settings"</span> (<span style="color:#228B22">"Advanced"</span> is not important right now). Go there and behold the amount of available options, like name, buddy icon, password, speaker volume... Don't worry, most of them are useless to us. Simply type a new name for the robot in the first field, as the default <span style="color:#FF1493">"Nao"</span> is a somewhat dull name, and click <span style="color:#228B22">"Change"</span>. A message will appear telling you to reboot your Nao to make the change have effect. We will deal with that later. You can now log out (to the right of <span style="color:#228B22">"Advanced"</span>) and close the browser.
 
Only one menu remains, <span style="color:#228B22">"Settings"</span> (<span style="color:#228B22">"Advanced"</span> is not important right now). Go there and behold the amount of available options, like name, buddy icon, password, speaker volume... Don't worry, most of them are useless to us. Simply type a new name for the robot in the first field, as the default <span style="color:#FF1493">"Nao"</span> is a somewhat dull name, and click <span style="color:#228B22">"Change"</span>. A message will appear telling you to reboot your Nao to make the change have effect. We will deal with that later. You can now log out (to the right of <span style="color:#228B22">"Advanced"</span>) and close the browser.
  
==SSH==
+
===SSH===
  
 
SSH means "Secure Shell" and is a protocol that allows you to log in remotely to a computer, in a safe way. No Linux user should die without doing this at least once, and it's pretty much needed for your daily work with Nao. It allows you to make a lot of things without leaving your chair.
 
SSH means "Secure Shell" and is a protocol that allows you to log in remotely to a computer, in a safe way. No Linux user should die without doing this at least once, and it's pretty much needed for your daily work with Nao. It allows you to make a lot of things without leaving your chair.
  
===Logging in===
+
====Logging in====
  
 
Almost every Linux distribution comes with a SSH client by default. If not, issue:
 
Almost every Linux distribution comes with a SSH client by default. If not, issue:
  
<pre>sudo apt-get install ssh -y</pre>
+
<syntaxhighlight lang=Bash>sudo apt-get install ssh</syntaxhighlight>
  
 
Retrieve your Nao's IP address using any of the methods explained in earlier sections, open a terminal or console and enter <span style="color:#228B22">''ssh nao@<IP>''</span>, like:
 
Retrieve your Nao's IP address using any of the methods explained in earlier sections, open a terminal or console and enter <span style="color:#228B22">''ssh nao@<IP>''</span>, like:
  
<pre>ssh nao@192.168.1.102</pre>
+
<syntaxhighlight lang=Bash>ssh nao@192.168.1.102</syntaxhighlight>
  
 
You may be prompted to accept a certificate if this is the first time you connect with the robot (or machine). Enter <span style="color:#FF1493">"yes"</span>. Finally, give <span style="color:#FF1493">"nao"</span> as password and you'll be in (it takes a while, be patient). The robot runs a lite Linux distribution, with most of the commands and features we all know, so I will only explain a few things.
 
You may be prompted to accept a certificate if this is the first time you connect with the robot (or machine). Enter <span style="color:#FF1493">"yes"</span>. Finally, give <span style="color:#FF1493">"nao"</span> as password and you'll be in (it takes a while, be patient). The robot runs a lite Linux distribution, with most of the commands and features we all know, so I will only explain a few things.
  
===Important things===
+
====Important things====
  
====Changing the root's password====
+
=====Changing the root's password=====
  
The user "root" has permissions to do everything he wants in a Linux machine. You can give its account a new password and use it to do login next time, because most files and folders require elevated privileges to be modified. Enter the following in your SSH session
+
The user "root" has permissions to do everything he wants in a Linux machine. You can give its account a new password and use it to do login next time, because most files and directories require elevated privileges to be modified. Enter the following in your SSH session
  
<pre>su</pre>
+
<syntaxhighlight lang=Bash>su</syntaxhighlight>
  
 
to log in as root (there is no password by default). Now enter
 
to log in as root (there is no password by default). Now enter
  
<pre>passwd</pre>
+
<syntaxhighlight lang=Bash>passwd</syntaxhighlight>
  
 
and type and confirm a new password. Use it the next time you need to SSH inside Nao, with:
 
and type and confirm a new password. Use it the next time you need to SSH inside Nao, with:
  
<pre>ssh root@192.168.1.102</pre>
+
<syntaxhighlight lang=Bash>ssh root@192.168.1.102</syntaxhighlight>
  
 
<span style="color:#606060">'''''NOTE: you must be root to complete the following steps.'''''</span>
 
<span style="color:#606060">'''''NOTE: you must be root to complete the following steps.'''''</span>
  
====Name====
+
=====Name=====
  
 
There is a way to change the name of your robot without using the web interface. Now that you are root, edit the following file with:
 
There is a way to change the name of your robot without using the web interface. Now that you are root, edit the following file with:
  
<pre>nano /etc/hostname</pre>
+
<syntaxhighlight lang=Bash>nano /etc/hostname</syntaxhighlight>
  
 
When you are done, save the file with <span style="color:#228B22">'''Ctrl+O'''</span> and Enter, and leave the editor with <span style="color:#228B22">'''Ctrl+X'''</span>. The name change will be applied after rebooting (more on this later).
 
When you are done, save the file with <span style="color:#228B22">'''Ctrl+O'''</span> and Enter, and leave the editor with <span style="color:#228B22">'''Ctrl+X'''</span>. The name change will be applied after rebooting (more on this later).
  
====Network interfaces====
+
=====Network interfaces=====
  
 
If you need to modify the way Nao connects to the network, and you can't access the web interface, then you should edit this file:
 
If you need to modify the way Nao connects to the network, and you can't access the web interface, then you should edit this file:
  
<pre>nano /etc/network/interfaces</pre>
+
<syntaxhighlight lang=Bash>nano /etc/network/interfaces</syntaxhighlight>
  
 
Here you can define which network interfaces Nao should use (it has two, eth0 for Ethernet and wlan0 for wireless) and their properties, like IP address or netmask if your router is configured for static addressing. To see the available options and the correct syntax, do the following in your PC, '''not in Nao''':
 
Here you can define which network interfaces Nao should use (it has two, eth0 for Ethernet and wlan0 for wireless) and their properties, like IP address or netmask if your router is configured for static addressing. To see the available options and the correct syntax, do the following in your PC, '''not in Nao''':
  
<pre>man interfaces</pre>
+
<syntaxhighlight lang=Bash>man interfaces</syntaxhighlight>
  
====Modules====
+
=====Modules=====
  
 
Sooner or later (specially if you decide to follow the next tutorials) you will have to compile code for your Nao. This code is usually assembled in form of dynamic libraries called "modules", that are placed somewhere inside your Nao and loaded at startup. The precise location where you should put your libraries for them to be loaded is <span style="color:#FF8C00">''/home/nao/naoqi/lib/naoqi/''</span> and, because it does not exist by default, you must create it now. Do it by using the commands <span style="color:#228B22">''cd''</span> (travel to a directory) and <span style="color:#228B22">''mkdir''</span> (create directory), like:
 
Sooner or later (specially if you decide to follow the next tutorials) you will have to compile code for your Nao. This code is usually assembled in form of dynamic libraries called "modules", that are placed somewhere inside your Nao and loaded at startup. The precise location where you should put your libraries for them to be loaded is <span style="color:#FF8C00">''/home/nao/naoqi/lib/naoqi/''</span> and, because it does not exist by default, you must create it now. Do it by using the commands <span style="color:#228B22">''cd''</span> (travel to a directory) and <span style="color:#228B22">''mkdir''</span> (create directory), like:
  
<pre>cd /home/nao/naoqi/
+
<syntaxhighlight lang=Bash>cd /home/nao/naoqi/
 
mkdir lib
 
mkdir lib
 
cd lib
 
cd lib
mkdir naoqi</pre>
+
mkdir naoqi</syntaxhighlight>
  
Any modules that you compile (which are named <span style="color:#1E90FF">''lib<name>.so''</span>) should be moved there. But just having them in the folder won't do any good, unless you tell Nao to load them at startup. The list of loadable modules is defined in a file called <span style="color:#1E90FF">''autoload.ini''</span>. Usually, there will be two copies of this file. The first (original) one is in <span style="color:#1E90FF">''/opt/naoqi/preferences/autoload.ini''</span> and should be left unchanged.
+
Any modules that you compile (which are named <span style="color:#1E90FF">''lib<name>.so''</span>) should be moved there. But just having them in the directory won't do any good, unless you tell Nao to load them at startup. The list of loadable modules is defined in a file called <span style="color:#1E90FF">''autoload.ini''</span>. Usually, there will be two copies of this file. The first (original) one is in <span style="color:#1E90FF">''/opt/naoqi/preferences/autoload.ini''</span> and should be left unchanged.
  
The second one you must create manually. It is named the same way, only that it will be saved in <span style="color:#FF8C00">''/home/nao/naoqi/preferences/''</span>. Nao will first look for this file, and revert back to the original in case it does not exist. So, create the folder '''if needed''':
+
The second one you must create manually. It is named the same way, only that it will be saved in <span style="color:#FF8C00">''/home/nao/naoqi/preferences/''</span>. Nao will first look for this file, and revert back to the original in case it does not exist. So, create the directory '''if needed''':
  
<pre>cd /home/nao/naoqi
+
<syntaxhighlight lang=Bash>cd /home/nao/naoqi
mkdir preferences</pre>
+
mkdir preferences</syntaxhighlight>
  
 
And copy the file:
 
And copy the file:
  
<pre>cp /opt/naoqi/preferences/autoload.ini /home/nao/naoqi/preferences/</pre>
+
<syntaxhighlight lang=Bash>cp /opt/naoqi/preferences/autoload.ini /home/nao/naoqi/preferences/</syntaxhighlight>
  
 
It will remain there, ready to be modified for the next tutorials.
 
It will remain there, ready to be modified for the next tutorials.
Line 151: Line 159:
 
<span style="color:#FF0000">'''''WARNING: Trying to create this file from scratch, or copying it from Naoqi SDK instead of Nao's /opt/, may result in the lack of some critical libraries.'''''</span>
 
<span style="color:#FF0000">'''''WARNING: Trying to create this file from scratch, or copying it from Naoqi SDK instead of Nao's /opt/, may result in the lack of some critical libraries.'''''</span>
  
===Ending a session===
+
====Ending a session====
  
 
If you are done toying with Nao through SSH, let's end this tutorial once and for all. There are a couple of options available. First, you could just log out and end your SSH session, with:
 
If you are done toying with Nao through SSH, let's end this tutorial once and for all. There are a couple of options available. First, you could just log out and end your SSH session, with:
  
<pre>exit</pre>
+
<syntaxhighlight lang=Bash>exit</syntaxhighlight>
  
 
If you issued <span style="color:#228B22">''su''</span> to become root, you will need to <span style="color:#228B22">''exit''</span> twice, because the first one will just return you to the normal <span style="color:#FF1493">"nao"</span> account.
 
If you issued <span style="color:#228B22">''su''</span> to become root, you will need to <span style="color:#228B22">''exit''</span> twice, because the first one will just return you to the normal <span style="color:#FF1493">"nao"</span> account.
Line 161: Line 169:
 
But for this occasion, we will do something different. Remember when I said that the changes you made would not be applied until you rebooted the robot? Continue to the next section.
 
But for this occasion, we will do something different. Remember when I said that the changes you made would not be applied until you rebooted the robot? Continue to the next section.
  
=Shutting down=
+
==Shutting down==
  
 
Nao can be turned down or rebooted in a few manners.
 
Nao can be turned down or rebooted in a few manners.
  
==Using SSH==
+
===Using SSH===
  
 
If you did not end your SSH session, this is the most comfortable way.
 
If you did not end your SSH session, this is the most comfortable way.
  
===Reboot===
+
====Reboot====
  
 
Enter the following command, as root:
 
Enter the following command, as root:
  
<pre>reboot</pre>
+
<syntaxhighlight lang=Bash>reboot</syntaxhighlight>
  
 
Complicated, wasn't it? Nao will shutdown completely and restart after, to continue working, using the new configuration.
 
Complicated, wasn't it? Nao will shutdown completely and restart after, to continue working, using the new configuration.
  
===Shutdown===
+
====Shutdown====
  
 
If you no longer need the robot, it is wise to turn it off, as the heating and power consumption are not precisely small. Enter this as root:
 
If you no longer need the robot, it is wise to turn it off, as the heating and power consumption are not precisely small. Enter this as root:
  
<pre>halt</pre>
+
<syntaxhighlight lang=Bash>halt</syntaxhighlight>
  
 
<span style="color:#606060">'''''NOTE: Your SSH session may hang short after issuing reboot or shutdown commands, due to the connection loss. Quickly exit the session to avoid this.'''''</span>
 
<span style="color:#606060">'''''NOTE: Your SSH session may hang short after issuing reboot or shutdown commands, due to the connection loss. Quickly exit the session to avoid this.'''''</span>
  
==Physically==
+
===Physically===
  
 
Approach Nao and press the chest button. Hold it pressed for about 5 seconds. Nao will produce a "shutdown" sound. Release the button and wait for it to turn off. If you need to reboot, just turn it on again pressing once.
 
Approach Nao and press the chest button. Hold it pressed for about 5 seconds. Nao will produce a "shutdown" sound. Release the button and wait for it to turn off. If you need to reboot, just turn it on again pressing once.
  
=Conclusions=
+
==Conclusions==
  
You now know how to work with Nao (read this aloud, three times!). Throughout the next tutorials, I will explain how to develop for the robot, starting with your first, basic examples. Don't forget to read the [http://users.aldebaran-robotics.com/ official documentation], where you will find another introductory tutorial like this one. Also, I encourage you to keep playing with Nao and testing new things. Just remember not to leave him alone near firearms.
+
You now know how to work with Nao (read this aloud, three times!). Throughout the next tutorial, I will explain how to develop for the robot, starting with your first, basic example. Don't forget to read the [https://community.aldebaran.com/en/resources/documents official documentation], where you will find another introductory tutorial like this one. Also, I encourage you to keep playing with Nao and testing new things. Just remember not to leave him alone near firearms.
  
[[Image:Aldebaran_official_documentation.jpg|thumb|none|600px|Aldebaran's official documentation.]]
 
  
 +
[[Image:Aldebaran_official_documentation.jpg|thumb|center|600px|Aldebaran's official documentation.]]
 +
 +
 +
----
 
----
 
----
  
Next tutorial: [[Nao tutorial 2: First module]]
+
Go to root: [[TFM-Nao-Goalkeeper]]
 +
 
 +
Links to articles:
 +
 
 +
[[Nao tutorial 1: First steps]]
 +
 
 +
[[Nao tutorial 2: First module]]
  
FAQ: [[Nao troubleshooting]]
+
[[Nao troubleshooting]]

Latest revision as of 20:19, 1 November 2015

Go to root: TFM-Nao-Goalkeeper




Nao humanoid robot.

The purpose of this tutorial is to teach you the basic concepts of Nao. I assume that you are staring at the robot's box after (hopefully) buying it, and that you want to start making cool things with it, like conquering the world. You are wondering how to do that, but you don't even know how to plug the robot.

I will take you, step by step, through the first tasks that you should complete before going serious. Even if I will try to make it easy, certain previous knowledge is required, like basic programming and Linux concepts. Also, I would recommend you to read the official documentation and tutorials before going forth. In case of doubt, always trust them.

NOTE: This 2011 tutorial was targeted for version 1.10.10 of the SDK and OS. Newer versions have changed a lot of things, making most of these tutorials deprecated.

Getting everything ready

OK, the first thing you should do is to get a testing environment ready. By "testing environment" I mean:

  • A room with enough space.
  • A computer running Linux (Debian or Ubuntu preferably).
  • A simple LAN with a router, connecting Nao and you.

WARNING: Be aware that Nao is very prone to fall should you do something wrong. Don't be afraid, but keep it in mind.

Let's begin. Place Nao somewhere in the middle of the room, so he has freedom of movement. Try to keep it apart from places or objects that could make him fall or get jammed. Also, note that you will eventually need to plug it to the power (whenever you need to recharge his battery), and to the LAN (in case he is not able to connect wirelessly). The power connector is on Nao's back, facing downwards. In fact, you will be plugging it directly to the battery, which is behind the cover (it has 4 screws that you must remove in order to access it).

Finally, the Ethernet socket is located behind the head. You may need to open the protective hatch, or completely remove the head's cover, whichever one you prefer.

Connecting to Nao

When everything is set, press Nao's chest button once to turn it on. His eyes will start blinking red, green and blue. Then, some other blue LEDs located on his ears will do the same, and the eyes will stop blinking. Later, both the eyes and chest button will come alive again with a stable white light, and the robot will tell you that it has finished loading his system. The whole process lasts about two minutes (even more, if it is the first time) and you will get soon tired of it, I promise.

Now, you must connect to Nao to do some first-time configuration. It pays to have a simple router-based LAN with DHCP dynamic addressing, otherwise you will complicate your life, trust me.

Recovering the IP address

We need to get the IP address Nao has bonded to, before trying to connect to him. There are a couple of ways to do it, some easier than others, and I will enumerate them all:

Using the router

This is the hard way. Most routers offer an option to list the clients that are connected to it, through the web interface. But you need the router's IP. Input the following command in your PC (obviously, you must be in the same LAN as Nao):

sudo ifconfig

Seek your network adapter in the list (usually eth0 for the first Ethernet card, eth1 for the second...) and look for your IP address (mine is 192.168.1.101). Your router's IP will be probably the same, only changing the last number for 1 or 0 (e.g., 192.168.1.1). Open a web browser and input that IP in the address bar. Press Enter and you will be prompted for the router's username and password. You should know them, but if that's not the case go here for a list of default ones.

When you're in, seek for a menu option that will show you the connected clients. Nao's IP should be next to yours.

Mapping the network

Easier than the previous. You can scan the network for online hosts, using a network mapper program. For example, I will use nmap. Install it using the following command if you are using Debian or Ubuntu:

sudo apt-get install nmap

And then do a ping scan over your network (change the first three numbers of the IP to match your network):

sudo nmap -sP 192.168.1.1-255

Nao will appear in the list, with something like "Host 192.168.1.102 is up (0.00018s latency)". Your own computer will be shown, but with no latency.

Asking Nao

The easier way, but you will need to get up and walk a bit. Just approach Nao and press his chest button once. It will briefly blink in green, and then Nao will beep and speak his name, internet address and battery level. If it says "I can't connect to the network", check the router and Ethernet cable.

Web interface

Open a web browser, enter your Nao's IP as destination and hit Enter. If everything went OK, you should now see the robot's web interface (a login screen) appear. Enter "nao" as both the username and password and press Enter. If this is the first time, you must agree to the user license terms before that.


Example of Nao's web interface.


The "About" screen will welcome you. Here you can check a lot of useful data about your robot, like the OS version he is running, which modules has he loaded, etc. Clicking on a module's name will show the available methods that it implements, and their descriptions. Quite handy.

Connecting to a wifi

When you're done, go to the "Network" menu. Here you will see a list of wireless networks, that Nao has detected using his wifi card. This is your chance to make Nao use a wireless network instead of the Ethernet cable, something very appealing because it will allow him to move freely across the room.

Do not hesitate and click on the name of the network you want. Then choose the "Connect" button, give in the password and confirm. That's it, Nao should bind to your router wirelessly from now on. Come back to this menu whenever you want to make him "forget" this network.

Changing the name

Only one menu remains, "Settings" ("Advanced" is not important right now). Go there and behold the amount of available options, like name, buddy icon, password, speaker volume... Don't worry, most of them are useless to us. Simply type a new name for the robot in the first field, as the default "Nao" is a somewhat dull name, and click "Change". A message will appear telling you to reboot your Nao to make the change have effect. We will deal with that later. You can now log out (to the right of "Advanced") and close the browser.

SSH

SSH means "Secure Shell" and is a protocol that allows you to log in remotely to a computer, in a safe way. No Linux user should die without doing this at least once, and it's pretty much needed for your daily work with Nao. It allows you to make a lot of things without leaving your chair.

Logging in

Almost every Linux distribution comes with a SSH client by default. If not, issue:

sudo apt-get install ssh

Retrieve your Nao's IP address using any of the methods explained in earlier sections, open a terminal or console and enter ssh nao@<IP>, like:

ssh nao@192.168.1.102

You may be prompted to accept a certificate if this is the first time you connect with the robot (or machine). Enter "yes". Finally, give "nao" as password and you'll be in (it takes a while, be patient). The robot runs a lite Linux distribution, with most of the commands and features we all know, so I will only explain a few things.

Important things

Changing the root's password

The user "root" has permissions to do everything he wants in a Linux machine. You can give its account a new password and use it to do login next time, because most files and directories require elevated privileges to be modified. Enter the following in your SSH session

su

to log in as root (there is no password by default). Now enter

passwd

and type and confirm a new password. Use it the next time you need to SSH inside Nao, with:

ssh root@192.168.1.102

NOTE: you must be root to complete the following steps.

Name

There is a way to change the name of your robot without using the web interface. Now that you are root, edit the following file with:

nano /etc/hostname

When you are done, save the file with Ctrl+O and Enter, and leave the editor with Ctrl+X. The name change will be applied after rebooting (more on this later).

Network interfaces

If you need to modify the way Nao connects to the network, and you can't access the web interface, then you should edit this file:

nano /etc/network/interfaces

Here you can define which network interfaces Nao should use (it has two, eth0 for Ethernet and wlan0 for wireless) and their properties, like IP address or netmask if your router is configured for static addressing. To see the available options and the correct syntax, do the following in your PC, not in Nao:

man interfaces
Modules

Sooner or later (specially if you decide to follow the next tutorials) you will have to compile code for your Nao. This code is usually assembled in form of dynamic libraries called "modules", that are placed somewhere inside your Nao and loaded at startup. The precise location where you should put your libraries for them to be loaded is /home/nao/naoqi/lib/naoqi/ and, because it does not exist by default, you must create it now. Do it by using the commands cd (travel to a directory) and mkdir (create directory), like:

cd /home/nao/naoqi/
mkdir lib
cd lib
mkdir naoqi

Any modules that you compile (which are named lib<name>.so) should be moved there. But just having them in the directory won't do any good, unless you tell Nao to load them at startup. The list of loadable modules is defined in a file called autoload.ini. Usually, there will be two copies of this file. The first (original) one is in /opt/naoqi/preferences/autoload.ini and should be left unchanged.

The second one you must create manually. It is named the same way, only that it will be saved in /home/nao/naoqi/preferences/. Nao will first look for this file, and revert back to the original in case it does not exist. So, create the directory if needed:

cd /home/nao/naoqi
mkdir preferences

And copy the file:

cp /opt/naoqi/preferences/autoload.ini /home/nao/naoqi/preferences/

It will remain there, ready to be modified for the next tutorials.

WARNING: Trying to create this file from scratch, or copying it from Naoqi SDK instead of Nao's /opt/, may result in the lack of some critical libraries.

Ending a session

If you are done toying with Nao through SSH, let's end this tutorial once and for all. There are a couple of options available. First, you could just log out and end your SSH session, with:

exit

If you issued su to become root, you will need to exit twice, because the first one will just return you to the normal "nao" account.

But for this occasion, we will do something different. Remember when I said that the changes you made would not be applied until you rebooted the robot? Continue to the next section.

Shutting down

Nao can be turned down or rebooted in a few manners.

Using SSH

If you did not end your SSH session, this is the most comfortable way.

Reboot

Enter the following command, as root:

reboot

Complicated, wasn't it? Nao will shutdown completely and restart after, to continue working, using the new configuration.

Shutdown

If you no longer need the robot, it is wise to turn it off, as the heating and power consumption are not precisely small. Enter this as root:

halt

NOTE: Your SSH session may hang short after issuing reboot or shutdown commands, due to the connection loss. Quickly exit the session to avoid this.

Physically

Approach Nao and press the chest button. Hold it pressed for about 5 seconds. Nao will produce a "shutdown" sound. Release the button and wait for it to turn off. If you need to reboot, just turn it on again pressing once.

Conclusions

You now know how to work with Nao (read this aloud, three times!). Throughout the next tutorial, I will explain how to develop for the robot, starting with your first, basic example. Don't forget to read the official documentation, where you will find another introductory tutorial like this one. Also, I encourage you to keep playing with Nao and testing new things. Just remember not to leave him alone near firearms.


Aldebaran's official documentation.




Go to root: TFM-Nao-Goalkeeper

Links to articles:

Nao tutorial 1: First steps

Nao tutorial 2: First module

Nao troubleshooting