.. _choregraphe-troubleshooting:

Troubleshooting
===============

.. COMMENT: dont know where backup will be in that version...
            <presentation id="backup">
            <title>Where to find a backup of a project?</title>
            <para>Choregraphe always saves a project in "projects/lastProj.tmp.xar" before sending it on the robot.</para>
            </presentation>

.. _choregraphe-troubleshooting-errorcode:

NAO system update failure
-------------------------

:ref:`Updating the NAO system using Choregraphe <choregraphe-howto-update-nao-system>` may failed
(may occurs only if the current NAO system version is 1.12 or greater).

The error code tab is given hereafter:

+-------+-------------------------+---------------------------------------------+
| Error | Meaning                 | Solution                                    |
| code  |                         |                                             |
+=======+=========================+=============================================+
| 1     | Internal error.         | Retry.                                      |
+-------+-------------------------+---------------------------------------------+
| 2     | Internal error.         | Retry.                                      |
+-------+-------------------------+---------------------------------------------+
| 3     | Internal error.         | Retry.                                      |
+-------+-------------------------+---------------------------------------------+
| 4     | Unknown hardware.       | Make sure the target is a real NAO robot.   |
+-------+-------------------------+---------------------------------------------+
| 5     | Image does not match    | Check the given file is an image,           |
|       | the target hardware,    | then retry.                                 |
|       | ie. NAO v4 (Atom) image |                                             |
|       | on a NAO v3.x (Geode)   |                                             |
|       | robot and vice versa,   |                                             |
|       | or a NAOqi sdk,         |                                             |
|       | or anything else.       |                                             |
+-------+-------------------------+---------------------------------------------+
| 6     | Write error.            | Check that there still is enough freespace  |
|       | Cannot write the image  | on the robot.                               |
|       | on the robot.           | An upgrade needs about 200MB.               |
+-------+-------------------------+---------------------------------------------+
| 7     | Checksum check failed.  | Check the given file, then retry.           |
+-------+-------------------------+---------------------------------------------+

.. COMMENT: raw error code
    EINVAL=1     # invalid args
    ENOENT=2     # no such file or directory
    EREMOTEIO=3  # Remote i/o error (cannot fetch remote file)
    ENOTSUP=4    # Hardware not supported (unknown hardware)
    EILSEQ=5     # Illegal byte sequence (file does not match its target)
    EIO=6        # I/O error (operation error)
    ECHKSUM=7    # Checksum check failure


3D card problem
---------------

Choregraphe does not work with all the 3D card. If it crashes at start up, it probably means that there is a conflict with your 3D card.
Please update your graphics card driver and try again. If it does not work, you will see a pop up with an internet link to the supported graphics card.
You should check it out (`<http://www.ogre3d.org/tikiwiki/Hardware>`_).

Find out why a behavior does not work (debug)
---------------------------------------------

You have created a behavior. It is not yet operational. Here is how you can fix the bugs. That it is only possible if the current behavior is playing.

Testing the boxes one by one
++++++++++++++++++++++++++++

To control a behavior you can: click on Play to load it on the robot.
You can double-click on an input or output to stimulate it.

In timeline mute a layer
++++++++++++++++++++++++

The small eye next to each layer allows you to "mute" a layer: it will be ignored when the behavior is played.
This can be useful when you want to debug your behavior.

Checking the modules running on the robot
+++++++++++++++++++++++++++++++++++++++++

Go to the web page of the robot. The modules running on NAO are listed. You can see the details by clicking on their name.

Following the box execution
+++++++++++++++++++++++++++

Each time the link between 2 boxes is simulated, the color of the link changes. It is a good way to check the execution.

Checking the output value
+++++++++++++++++++++++++

When a box has a value as output, the last value displays in the tooltip.

.. COMMENT: add picture It is easy to check the good execution.

Understand why your box become red
++++++++++++++++++++++++++++++++++

- It becomes red during the execution: an exception raised. It can be because a module cannot be loaded (local NAOqi), does not exist, etc.

- It becomes red before the execution (just after clicking the Play button): the box code contains an error. It can be a typing problem in a Python script.

Using self.logger in a Python script
++++++++++++++++++++++++++++++++++++

self.logger is standard Python logger created with the Python module Logging.

The log information can be categorized by level of severity (each level has its associated font color in the debug window):

- debug (grey)

- info (black)

- warning (orange)

- error (red)

- critical (purple)

In your Python script, we recommend you to add warning, error and critical logs to inform when you behavior dangerous or erroneous state.

You can also use info and debug to trace execution flow of your behavior.

#. Open the script of a box.

#. Add the self.logger line in a function as below:

   .. code-block:: guess

     def onLoad(self):
     self.logger.debug("Loaded box %s", self.getName())

#. In the Debug window, select the minimum level of information you want, Debug in our case.

#. Execute the box.

#. All debug message display in the debug window to let you understand what is going on. The potential debug, info, warning, error and critical messages of other functions also display as the minimum level asked is debug.

   If you choose error, you see only error and critical messages.

.. COMMENT: <chapter id="appendix">
            <title>Appendix</title>
            <presentation id="glossary">
            <title>Glossary</title>
            <para>behavior:</para>
            <para>behavior layer:</para>
            <para>onStopped</para>
            <para>timeline:</para>
            </presentation>
            </chapter>