Difference between revisions of "Nao troubleshooting"
(Página nueva: You may run into annoying problems while developing for Nao (I certainly did), some easier to solve than others. I will try to explain how to fix the most common ones. If you have any...) |
m |
||
(22 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | Go to root: [[TFM-Nao-Goalkeeper]] | ||
+ | |||
+ | ---- | ||
+ | ---- | ||
+ | |||
+ | |||
You may run into annoying problems while developing for Nao (I certainly did), some easier to solve than others. I will try to explain how to fix the most common ones. If you have any questions regarding this subject or know of a different bug, feel free to send me an email describing it, and I will add it to this section. Just remember to try Google first! | You may run into annoying problems while developing for Nao (I certainly did), some easier to solve than others. I will try to explain how to fix the most common ones. If you have any questions regarding this subject or know of a different bug, feel free to send me an email describing it, and I will add it to this section. Just remember to try Google first! | ||
− | =Python fails to run= | + | <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> |
+ | |||
+ | ==Python fails to run== | ||
Using Naoqi in a Python program requires some environment variables to be set. Also, forgetting to remove them before running "normal" programs may give an error. Read this section to know which variables you should declare, among other things. | Using Naoqi in a Python program requires some environment variables to be set. Also, forgetting to remove them before running "normal" programs may give an error. Read this section to know which variables you should declare, among other things. | ||
− | ==Imports== | + | ===Imports=== |
If you get an error like <span style="color:#FF1493">"ImportError: No module named naoqi"</span> while trying to run a test, do the following. Open your <span style="color:#1E90FF">''.bashrc''</span> file: | If you get an error like <span style="color:#FF1493">"ImportError: No module named naoqi"</span> while trying to run a test, do the following. Open your <span style="color:#1E90FF">''.bashrc''</span> file: | ||
− | < | + | <syntaxhighlight lang=Bash>nano ~/.bashrc</syntaxhighlight> |
Go to the end (<span style="color:#228B22">'''Page Down'''</span>) and add this, changing the first path so it points to the location where your SDK is: | Go to the end (<span style="color:#228B22">'''Page Down'''</span>) and add this, changing the first path so it points to the location where your SDK is: | ||
− | < | + | <syntaxhighlight lang=Bash>export AL_DIR=/media/data/naoqi-sdk-1.10.10-linux |
export LD_LIBRARY_PATH=$AL_DIR/lib | export LD_LIBRARY_PATH=$AL_DIR/lib | ||
export PATH=$AL_DIR/bin:$PATH | export PATH=$AL_DIR/bin:$PATH | ||
export PYTHONHOME=$AL_DIR | export PYTHONHOME=$AL_DIR | ||
− | export PYTHONPATH=.:$AL_DIR/lib:$PYTHONPATH</ | + | export PYTHONPATH=.:$AL_DIR/lib:$PYTHONPATH</syntaxhighlight> |
Save, close, exit the terminal and open it again so the changes are applied. Check it with this if you want: | Save, close, exit the terminal and open it again so the changes are applied. Check it with this if you want: | ||
− | < | + | <syntaxhighlight lang=Bash>echo $PYTHONHOME</syntaxhighlight> |
− | You can try now rerunning the test. | + | You can try now rerunning the test. Please mind that "normal" Python programs (not for Nao) may fail with something like <span style="color:#FF1493">"ImportError: No module named os"</span>. This means that you will have to comment the two last exports (the Python ones) and reopen the terminal. It is a bit tiring, but necessary: |
− | ==Libraries== | + | <syntaxhighlight lang=Bash>export AL_DIR=/media/data/naoqi-sdk-1.10.10-linux |
+ | export LD_LIBRARY_PATH=$AL_DIR/lib | ||
+ | export PATH=$AL_DIR/bin:$PATH | ||
+ | #export PYTHONHOME=$AL_DIR | ||
+ | #export PYTHONPATH=.:$AL_DIR/lib:$PYTHONPATH</syntaxhighlight> | ||
+ | |||
+ | ===Libraries=== | ||
If you get an error like <span style="color:#FF1493">"ImportError: libtk8.5.so: cannot open shared object file: No such file or directory"</span>, it is because Python is trying to access that library using the wrong name. The following will fix it in a "brute force" way. First, locate the library in your system: | If you get an error like <span style="color:#FF1493">"ImportError: libtk8.5.so: cannot open shared object file: No such file or directory"</span>, it is because Python is trying to access that library using the wrong name. The following will fix it in a "brute force" way. First, locate the library in your system: | ||
− | < | + | <syntaxhighlight lang=Bash>sudo updatedb |
− | locate libtk8.5.so</ | + | locate libtk8.5.so</syntaxhighlight> |
This will tell you the real location, mine was <span style="color:#1E90FF">''/usr/lib/libtk8.5.so.0''</span>. Python expects it to be just <span style="color:#1E90FF">''/usr/lib/libtk8.5.so''</span>. Let's fix it in an unglamorous fashion: | This will tell you the real location, mine was <span style="color:#1E90FF">''/usr/lib/libtk8.5.so.0''</span>. Python expects it to be just <span style="color:#1E90FF">''/usr/lib/libtk8.5.so''</span>. Let's fix it in an unglamorous fashion: | ||
− | < | + | <syntaxhighlight lang=Bash>sudo cp /usr/lib/libtk8.5.so.0 /usr/lib/libtk8.5.so</syntaxhighlight> |
And rerun the test. It is possible that you get the same error relating to <span style="color:#1E90FF">''libtcl8.5.so''</span>. It is fixed the same way, I just had to change the names. Of course, we could create symbolic links or adapt some files here and there, but I am not in the mood. | And rerun the test. It is possible that you get the same error relating to <span style="color:#1E90FF">''libtcl8.5.so''</span>. It is fixed the same way, I just had to change the names. Of course, we could create symbolic links or adapt some files here and there, but I am not in the mood. | ||
− | =Cmake fails to run= | + | ==Cmake fails to run== |
Cmake is easier to get running in Debian than in Ubuntu, where it tends to complain a lot about undefined variables. If this happens to you, try to pass them as -D parameters, using absolute paths for files or directories. This is the only advice I can give to you. | Cmake is easier to get running in Debian than in Ubuntu, where it tends to complain a lot about undefined variables. If this happens to you, try to pass them as -D parameters, using absolute paths for files or directories. This is the only advice I can give to you. | ||
− | =Can't compile my module= | + | ==Can't compile my module== |
Have you installed all dependencies? If you did, this issue may be similar to the one with Python: the compiler is looking for libraries that have the wrong name. For example, when compiling for Geode I got this: <span style="color:#FF1493">"error while loading shared libraries: libmpfr.so.1: cannot open shared object file: No such file or directory"</span>. | Have you installed all dependencies? If you did, this issue may be similar to the one with Python: the compiler is looking for libraries that have the wrong name. For example, when compiling for Geode I got this: <span style="color:#FF1493">"error while loading shared libraries: libmpfr.so.1: cannot open shared object file: No such file or directory"</span>. | ||
Line 48: | Line 62: | ||
I solved it using the solution exposed [[Nao troubleshooting#Libraries | before]]. I issued: | I solved it using the solution exposed [[Nao troubleshooting#Libraries | before]]. I issued: | ||
− | < | + | <syntaxhighlight lang=Bash>sudo cp /usr/lib/libmpfr.so /usr/lib/libmpfr.so.1</syntaxhighlight> |
And tried again to compile. | And tried again to compile. | ||
− | =Nao doesn't load my module= | + | ==Nao doesn't load my module== |
Probably your code has some error that allowed it to compile, but is making it crash when Nao tries to load it. Check Nao's OS logs, and try to debug your application using the common tools ([http://www.gnu.org/software/gdb/ GDB], etc). | Probably your code has some error that allowed it to compile, but is making it crash when Nao tries to load it. Check Nao's OS logs, and try to debug your application using the common tools ([http://www.gnu.org/software/gdb/ GDB], etc). | ||
Line 58: | Line 72: | ||
It is wise to test your applications in Naoqi before moving them to the real robot (that is, if it is feasible, because Naoqi does not implement all features, like movement), as the debugging will be easier to carry out (and you can easily check the output, too). | It is wise to test your applications in Naoqi before moving them to the real robot (that is, if it is feasible, because Naoqi does not implement all features, like movement), as the debugging will be easier to carry out (and you can easily check the output, too). | ||
− | =Proxy fails to connect= | + | ==ALSpeechRecognition not found== |
+ | |||
+ | If you are trying to work with Nao's [http://doc.aldebaran.com/2-1/naoqi/audio/alspeechrecognition.html#alspeechrecognition speech recognition] but it can't find the module, either it hasn't been added to <span style="color:#1E90FF">''autoload.ini''</span>, or you own the [http://en.wikipedia.org/wiki/RoboCup RoboCup] edition of Nao. Only the Academics edition has this module available. | ||
+ | |||
+ | ==Proxy fails to connect== | ||
In 99% of the cases, you provided the wrong IP address and/or port. Is Nao up and running, and is your module listed as loaded? | In 99% of the cases, you provided the wrong IP address and/or port. Is Nao up and running, and is your module listed as loaded? | ||
Line 64: | Line 82: | ||
If not, check if the Python call uses the right module and function names. | If not, check if the Python call uses the right module and function names. | ||
− | =How to create your own broker= | + | ==How to create your own broker== |
+ | |||
+ | I already told you a few times how important using your own brokers is. If your application hangs while it is "hooked" to Nao's default MainBroker, it will hang too, and the robot may fall to the ground. It is an undesirable situation, believe me. | ||
+ | |||
+ | Creating your own broker is so easy that it hurts. Connect to Nao via SSH as root and edit the module's file: | ||
+ | |||
+ | <syntaxhighlight lang=Bash>nano /home/nao/naoqi/preferences/autoload.ini</syntaxhighlight> | ||
+ | |||
+ | Then, seek the line where your module is, and prepend <span style="color:#FF1493">''"[broker name]"''</span> to it, like: | ||
+ | |||
+ | <syntaxhighlight lang=Bash>[mybroker]</syntaxhighlight> | ||
+ | |||
+ | This tells Nao to create a new module with that name, that will load the module(s) specified next. Be aware that any other module(s) situated after yours will also be associated to this new broker, unless there is another <span style="color:#FF1493">''"[broker name]"''</span> line before it/them. | ||
+ | |||
+ | Now you must reboot Nao. Then, before testing your new broker using a Python example, you must find the port it has binded to (it is no longer 9559). This can be easily done with Nmap (use your robot's IP address): | ||
+ | |||
+ | <syntaxhighlight lang=Bash>sudo nmap 192.168.1.102 -p9500-10000 -sV</syntaxhighlight> | ||
+ | |||
+ | The output will say something like <span style="color:#FF1493">''"9561/tcp open unknown"''</span>. That's the port of your new broker. Edit the Python code and you are a go. | ||
+ | |||
+ | ==How to flash Nao== | ||
+ | |||
+ | Did you break something? Have you edited so many files of your Nao that there is no way you can make him run again? Fear not, as you can flash his USB unit anytime to return it to factory state. I will show you how, you just need a bit of patience. After this, he will boot without problems and you will be able to configure him again. | ||
+ | |||
+ | <span style="color:#FF0000">'''''WARNING: Flashing Nao's USB drive will delete forever any file or configuration you uploaded to him. Be sure to back them up before you proceed.'''''</span> | ||
+ | |||
+ | The first thing is to download the OS image from [https://community.aldebaran-robotics.com/ here]. Downloads section, <span style="color:#228B22">"All Downloads"</span>, select your SDK's version (1.10.10 as I write this), <span style="color:#228B22">"NAO OS"</span>, and download <span style="color:#228B22">"NAOos RoboCup Image v1.10.10"</span> (124 MB). '''Do not extract it!''' The file <span style="color:#1E90FF">''nao-system-image-robocup-1.10.10.gz''</span> must remain as it is. | ||
+ | |||
+ | Remove Nao's USB stick and plug it to your computer. Go to the <span style="color:#FF8C00">''bin/''</span> subdirectory of your SDK's directory, where a script named <span style="color:#1E90FF">''flash-usbstick''</span> lies. Open a terminal here and issue this, giving the path to the OS image: | ||
+ | |||
+ | <syntaxhighlight lang=Bash>sudo ./flash-usbstick ../../nao-system-image-robocup-1.10.10.gz</syntaxhighlight> | ||
+ | |||
+ | The script will try to detect and use a good enough removable USB drive, that is: | ||
+ | |||
+ | * Not specially big (512 MB-2 GB). | ||
+ | * Named <span style="color:#FF1493">''"Kingmax"''</span>. | ||
+ | |||
+ | The script will tell you to <span style="color:#FF1493">''"Please umount: /dev/sdb1"''</span> (the device name may vary). You have to umount both partitions of the device: | ||
+ | |||
+ | <syntaxhighlight lang=Bash>sudo umount /dev/sdb1 | ||
+ | sudo umount /dev/sdb2</syntaxhighlight> | ||
+ | |||
+ | And retry the script. Now it should take some minutes to format the drive and copy the files. After this, you can remove the stick and plug it back on Nao. | ||
+ | |||
+ | <span style="color:#606060">'''''NOTE: You can force the script to use a certain drive with -d<device> (like "sda"), and -f (as in "force").'''''</span> | ||
+ | |||
+ | |||
+ | ---- | ||
+ | ---- | ||
+ | |||
+ | Go to root: [[TFM-Nao-Goalkeeper]] | ||
+ | |||
+ | Links to articles: | ||
+ | |||
+ | [[Nao tutorial 1: First steps]] | ||
+ | |||
+ | [[Nao tutorial 2: First module]] | ||
− | + | [[Nao troubleshooting]] |
Latest revision as of 20:25, 1 November 2015
Go to root: TFM-Nao-Goalkeeper
You may run into annoying problems while developing for Nao (I certainly did), some easier to solve than others. I will try to explain how to fix the most common ones. If you have any questions regarding this subject or know of a different bug, feel free to send me an email describing it, and I will add it to this section. Just remember to try Google first!
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.
Contents
Python fails to run
Using Naoqi in a Python program requires some environment variables to be set. Also, forgetting to remove them before running "normal" programs may give an error. Read this section to know which variables you should declare, among other things.
Imports
If you get an error like "ImportError: No module named naoqi" while trying to run a test, do the following. Open your .bashrc file:
nano ~/.bashrc
Go to the end (Page Down) and add this, changing the first path so it points to the location where your SDK is:
export AL_DIR=/media/data/naoqi-sdk-1.10.10-linux
export LD_LIBRARY_PATH=$AL_DIR/lib
export PATH=$AL_DIR/bin:$PATH
export PYTHONHOME=$AL_DIR
export PYTHONPATH=.:$AL_DIR/lib:$PYTHONPATH
Save, close, exit the terminal and open it again so the changes are applied. Check it with this if you want:
echo $PYTHONHOME
You can try now rerunning the test. Please mind that "normal" Python programs (not for Nao) may fail with something like "ImportError: No module named os". This means that you will have to comment the two last exports (the Python ones) and reopen the terminal. It is a bit tiring, but necessary:
export AL_DIR=/media/data/naoqi-sdk-1.10.10-linux
export LD_LIBRARY_PATH=$AL_DIR/lib
export PATH=$AL_DIR/bin:$PATH
#export PYTHONHOME=$AL_DIR
#export PYTHONPATH=.:$AL_DIR/lib:$PYTHONPATH
Libraries
If you get an error like "ImportError: libtk8.5.so: cannot open shared object file: No such file or directory", it is because Python is trying to access that library using the wrong name. The following will fix it in a "brute force" way. First, locate the library in your system:
sudo updatedb
locate libtk8.5.so
This will tell you the real location, mine was /usr/lib/libtk8.5.so.0. Python expects it to be just /usr/lib/libtk8.5.so. Let's fix it in an unglamorous fashion:
sudo cp /usr/lib/libtk8.5.so.0 /usr/lib/libtk8.5.so
And rerun the test. It is possible that you get the same error relating to libtcl8.5.so. It is fixed the same way, I just had to change the names. Of course, we could create symbolic links or adapt some files here and there, but I am not in the mood.
Cmake fails to run
Cmake is easier to get running in Debian than in Ubuntu, where it tends to complain a lot about undefined variables. If this happens to you, try to pass them as -D parameters, using absolute paths for files or directories. This is the only advice I can give to you.
Can't compile my module
Have you installed all dependencies? If you did, this issue may be similar to the one with Python: the compiler is looking for libraries that have the wrong name. For example, when compiling for Geode I got this: "error while loading shared libraries: libmpfr.so.1: cannot open shared object file: No such file or directory".
I solved it using the solution exposed before. I issued:
sudo cp /usr/lib/libmpfr.so /usr/lib/libmpfr.so.1
And tried again to compile.
Nao doesn't load my module
Probably your code has some error that allowed it to compile, but is making it crash when Nao tries to load it. Check Nao's OS logs, and try to debug your application using the common tools (GDB, etc).
It is wise to test your applications in Naoqi before moving them to the real robot (that is, if it is feasible, because Naoqi does not implement all features, like movement), as the debugging will be easier to carry out (and you can easily check the output, too).
ALSpeechRecognition not found
If you are trying to work with Nao's speech recognition but it can't find the module, either it hasn't been added to autoload.ini, or you own the RoboCup edition of Nao. Only the Academics edition has this module available.
Proxy fails to connect
In 99% of the cases, you provided the wrong IP address and/or port. Is Nao up and running, and is your module listed as loaded?
If not, check if the Python call uses the right module and function names.
How to create your own broker
I already told you a few times how important using your own brokers is. If your application hangs while it is "hooked" to Nao's default MainBroker, it will hang too, and the robot may fall to the ground. It is an undesirable situation, believe me.
Creating your own broker is so easy that it hurts. Connect to Nao via SSH as root and edit the module's file:
nano /home/nao/naoqi/preferences/autoload.ini
Then, seek the line where your module is, and prepend "[broker name]" to it, like:
[mybroker]
This tells Nao to create a new module with that name, that will load the module(s) specified next. Be aware that any other module(s) situated after yours will also be associated to this new broker, unless there is another "[broker name]" line before it/them.
Now you must reboot Nao. Then, before testing your new broker using a Python example, you must find the port it has binded to (it is no longer 9559). This can be easily done with Nmap (use your robot's IP address):
sudo nmap 192.168.1.102 -p9500-10000 -sV
The output will say something like "9561/tcp open unknown". That's the port of your new broker. Edit the Python code and you are a go.
How to flash Nao
Did you break something? Have you edited so many files of your Nao that there is no way you can make him run again? Fear not, as you can flash his USB unit anytime to return it to factory state. I will show you how, you just need a bit of patience. After this, he will boot without problems and you will be able to configure him again.
WARNING: Flashing Nao's USB drive will delete forever any file or configuration you uploaded to him. Be sure to back them up before you proceed.
The first thing is to download the OS image from here. Downloads section, "All Downloads", select your SDK's version (1.10.10 as I write this), "NAO OS", and download "NAOos RoboCup Image v1.10.10" (124 MB). Do not extract it! The file nao-system-image-robocup-1.10.10.gz must remain as it is.
Remove Nao's USB stick and plug it to your computer. Go to the bin/ subdirectory of your SDK's directory, where a script named flash-usbstick lies. Open a terminal here and issue this, giving the path to the OS image:
sudo ./flash-usbstick ../../nao-system-image-robocup-1.10.10.gz
The script will try to detect and use a good enough removable USB drive, that is:
- Not specially big (512 MB-2 GB).
- Named "Kingmax".
The script will tell you to "Please umount: /dev/sdb1" (the device name may vary). You have to umount both partitions of the device:
sudo umount /dev/sdb1
sudo umount /dev/sdb2
And retry the script. Now it should take some minutes to format the drive and copy the files. After this, you can remove the stick and plug it back on Nao.
NOTE: You can force the script to use a certain drive with -d<device> (like "sda"), and -f (as in "force").
Go to root: TFM-Nao-Goalkeeper
Links to articles:
Nao troubleshooting