アニメーション実行中の特定のタイミングで発話や画面遷移をさせる方法
Pepperのアプリ開発中に、アニメーション実行中の特定のタイミングで発話や画面遷移をさせたい場合がありますが、Label機能を使用すると比較的容易に実現することが可能です。
今回はLabel機能の使い方について説明します。
1.qianimファイルの作成
まずはもとになるモーションファイルを作成します。
2.animation editorのAdd groupボタンでLabelグループを追加します。

3.Labelグループ内の処理を行わせたいフレームで右クリックし、コンテキストメニューから「Add a label」を選択し、Labelを追加する

4.追加されたLabelのLabel名をクリックし、適宜修正する。

5.アニメーション実行時にLabel到達の通知を受け取れるようにaddOnLabelReachedListenerでリスナーを設定する
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<code> @Override public void onRobotFocusGained(final QiContext qiContext) { Animation animation = AnimationBuilder.with(qiContext).withResources(R.raw.disco_a001).build(); Animate animate = AnimateBuilder.with(qiContext).withAnimation(animation).build(); animate.addOnLabelReachedListener(new Animate.OnLabelReachedListener() { @Override public void onLabelReached(String label, Long time) { if(label.equals("say")) SayBuilder.with(qiContext) .withText("ここだよ!").build().run(); } }); animate.run(); } </code> |