Loading, unloading, starting and stopping a behavior, a box, a diagram or a Timeline

Behavior

When a behavior is loaded :

  1. All boxes contained in the behavior are constructed . So the constructor of each box __init__ is called.
  2. Its diagram is loaded .

When it is unloaded :

  1. Its diagram is unloaded .
  2. All boxes contained in the behavior are destroyed .

When it is started (or played ):

  1. The behavior is loaded .
  2. Its onStart input is stimulated .

When it is stopped , it is unloaded .

Box

When a box is loaded , the onLoad function of its script is called. For further details about this kind of built-in functions, see the section: Built-in functions in the script of a box .

When it is unloaded :

  1. The onUnload function of its script is called.
  2. Its diagram or its Timeline is unloaded .

When it is started (with an onStart input ):

  1. The onInput_<input_name> function of its script is called.

  2. Its diagram or its Timeline is loaded .

  3. If it is a flow diagram box , then the signal received on the onStart input is transmitted to the diagram of the box.

    If it is a Timeline box , then its time cursor is played. So it starts being regularly incremented.

When it is started but its resources are not available and even after the timeout specified they are still unavailable:

  • If a function named onResourceError is defined in the box script , it is called.
  • Else, the output named onStopped is stimulated (if any).

When it is stopped with an onStop input :

  1. The onInput_<input_name> function of its script is called.
  2. Its diagram or its Timeline is unloaded .

When it is stopped with an onStopped output :

  1. Its diagram or its Timeline is unloaded .
  2. The signal received on the onStopped output is transmitted to the parent diagram .

When it is stopped because its resources are set to Stop on demand and they are asked by another box:

  1. If a function named onResourceLost is defined in the box script , it is called.
  2. The diagram or the Timeline of the box is unloaded .
  3. If there was no onResourceLost function defined in the script, the output named onStopped is stimulated (if any).

Note

Sometimes it can take some time for a behavior to stop. For instance, if NAO is walking, the “Walk” behavior you want to stop will wait for NAO’s feet to be stable before stopping, so that the robot doesn’t fall down.

Flow diagram

When a diagram is loaded :

  1. The boxes within the diagram are loaded .
  2. The links between these boxes are activated. Note that before this step the stimulation of any I/O within the diagram would be inefficient.
  3. The onLoad input of the diagram (if any) is stimulated.

When it is unloaded :

  1. The links between the boxes within the diagram are broken. Note that after this step the stimulation of any I/O within the diagram would be inefficient.
  2. These boxes are unloaded .
Timeline

When a Timeline is loaded :

  1. The time cursor is set to the start frame .
  2. The diagrams of the Behavior keyframes present on this frame are loaded .

When it is unloaded :

  1. The time cursor is paused. So it stops being incremented.
  2. The diagrams of the Behavior keyframes present on this frame are unloaded .
  3. The time cursor is set to -1.