Nao Module

From Intelligent Materials and Systems Lab

How to create a module

module_generator

The easiest way to create a new module, is by using the module_generator script. For some reason, however, it is not included with NAOqi C++ SDK 1.14.1, but it still available in the 1.12.5 SDK package (can be downloaded from http://users.aldebaran-robotics.com/). It is not clear, why the module_generator was dropped, but it seems to be working with the newer version as well.

To use the module_generator, you do not have to keep the whole old SDK package, you only need the python scipt /path/to/sdk/bin/module_generator.py and the template files /path/to/sdk/share/module_generator/templates/module/.

The module_generator generates some skeleton code that can be used to create your own module. Keep in mind to use the cross-toolchain, as the module is going to work in the Nao.


Loading the module

When you have managed to build the module .so file, you also need to place it inside the Nao and make sure the Nao will load your module. According to this page (about older version, some mismatch), it is neccessary to place the module files in /home/nao/naoqi/lib/naoqi/. The directories might not exist yet. Now you need to tell NAOqi to load your module. You can do it by adding the module's name with its full path to the /home/nao/naoqi/preferences/autoload.ini file under the "[user]" tag.

Actually it is probable that the modules could be located anywhere, as long as their full paths are given, but at the time when our team was trying to solve the module-loading problem, we found the aforenamed webpage and used its suggestion. It should be tested to be sure.

The NAOqi loads all the modules at startup. Unfortunately, our team hasn't found a way to load a single module at a time yet, so we just restart the whole NAOqi using the command nao restart. If something fails and you would like to find out the error message, then the easiest way is to execute NAOqi manually with the command naoqi. These messages can most likely be found in some log files as well.


Possible problems

Module loading fails

The easiest way to track down the problem, is to stop NAOqi with nao stop and enter naoqi. It shows information about the full module-loading sequence and is most likely to give you some error message about you own module. That way you can narrow your problem down to something more specific.

Blinking green light

The blinking green light on the stomach means that the NAOqi is not working. It might easily happen during a module development proccess. It turns out that the NAOqi error-handling is not very good, an accidental error in your code might cause the NAOqi to crash during the module loading proccess. The obvious solution is removing or fixing the module and restarting the NAOqi with nao restart.

It can also happen when you overwrite the old module with the new one inside the Nao. As the NAOqi has already loaded the module into its memory, overwriting it will cause a crash in most cases. The solution is to just restart the NAOqi.