Loading, unloading, starting and stopping a behavior, a box, a diagram or a Timeline¶
- Behavior
When a behavior is loaded:
- All boxes contained in the behavior are constructed.
So the constructor of each box
__init__
is called. - Its diagram is loaded.
When it is unloaded:
When it is started (or played):
- The behavior is loaded.
- Its onStart input is stimulated.
When it is stopped, it is unloaded.
- All boxes contained in the behavior are constructed.
So the constructor of each box
- 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:
When it is started (with an onStart input):
The
onInput_<input_name>
function of its script is called.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:
When it is stopped with an onStopped output:
- Its diagram or its Timeline is unloaded.
- 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:
- If a function named
onResourceLost
is defined in the box script, it is called. - The diagram or the Timeline of the box is unloaded.
- If there was no
onResourceLost
function defined in the script, the output namedonStopped
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:
- The boxes within the diagram are loaded.
- The links between these boxes are activated. Note that before this step the stimulation of any I/O within the diagram would be inefficient.
- The onLoad input of the diagram (if any) is stimulated.
When it is unloaded:
- 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.
- These boxes are unloaded.
- Timeline
When a Timeline is loaded:
- The time cursor is set to the start frame.
- The diagrams of the Behavior keyframes present on this frame are loaded.
When it is unloaded:
- The time cursor is paused. So it stops being incremented.
- The diagrams of the Behavior keyframes present on this frame are unloaded.
- The time cursor is set to -1.