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.

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.

  1. Open the script of a box.

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

    def onLoad(self):
    self.logger.debug("Loaded box %s", self.getName())
    
  3. In the Debug window, select the minimum level of information you want, Debug in our case.

  4. Execute the box.

  5. 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.