1

How to make Nao robot execute functions one after the other? This makes everything happen at same time:

session.service("ALTextToSpeech").done(function (tts) {
    tts.say("Hello world.");
}).fail(function (error) {
    console.log("An error occurred:", error);
});

session.service("ALBehaviorManager").done(function (behavior) {
    behavior.runBehavior("Stand/Emotions/Positive/Winner_1");
}).fail(function (error) {
    console.log("An error occurred:", error);
});

Thank you for help!

Eino Gourdin
  • 4,169
  • 3
  • 39
  • 67
J Nao
  • 11
  • 2

1 Answers1

0

You have to chain your functions with "done" (or "then" in qimessaging js v2), something like this:

session.service("ALTextToSpeech").done(function (tts) {
    tts.say("Hello world.").done(function() {
        session.service("ALBehaviorManager").done(function (behavior) {
            behavior.runBehavior("Stand/Emotions/Positive/Winner_1");
        })
    });
})

See the documentation: http://doc.aldebaran.com/2-5/dev/js/index-1.0.html

Emile
  • 2,946
  • 2
  • 19
  • 22