Using Flow Control boxes

Here is an example of the use of 2 Flow Control boxes: For and Wait For Signals.
Flow Control boxes are very useful when you want to create more complex behaviors.

Create the following behavior: while introducing himself, NAO nods two times, then when both are done, NAO starts to wave.

Step Action

Drag and drop a Audio> Voice > Say box.

Write NAO‘s introduction sentence (e.g. “Hello I am NAO the little robot and I am ready to serve you, master!”)

Connect its input to the main input of the behavior.

For further details, see: How to make NAO say something.

Create a new Timeline box, call it “Nod”.

Create a simple nodding movement behavior with its Motion Timeline.

Connect its input to the main input of the behavior.

For further details, see: How to create a Timeline box and Tutorial about movements.

Test

If you use a real robot, you have to stiffen your robot first.

For further details, see: How to wake up your NAO.

Click the play-buttonPlay button: NAO nods once and introduces himself.

Add a Flow Control > For box to your behavior.

Set its Final value parameter to 2.

Connect it to your “Nod” box as below (outputs with inputs):

/sites/default/files/repository/69_html_nao/_images/chore_tuto_loop.png
Test

NAO nods two times and talk.

It’s not bad but we also want NAO to start waving after he has finished nodding and talking. This is quite simple: a Wait For Signals box should be used.

Add a Flow Control > Wait For Signals box.

Connect the onStopped output of Say box to its Signal 1 input and the onStopped output of For to its Signal 2 input.

The Wait For Signals box stimulates its output once the two inputs are stimulated.

Add a Motions > Animations > Hello box.

/sites/default/files/repository/69_html_nao/_images/chore_tuto_motionloopwaitwalk.png
Test NAO starts waving after he has finished nodding and talking!

As a final exercise, you could create a single box that perform all these actions.

For further details, see: How to group several boxes into a single one.