Animate


level_1


Goal - Make Pepper execute a series of movements with his limbs and head, or follow a predefined trajectory.

// Create an animation object.
Animation myAnimation = AnimationBuilder.with(qiContext)
                                      .withResources(R.raw.elephant_a001)
                                      .build();

// Build the action.
Animate animate = AnimateBuilder.with(qiContext)
                                .withAnimation(myAnimation)
                                .build();

// Run the action asynchronously.
animate.async().run();

Typical usage - You want Pepper to execute a dance or mimic an animal.


How it works

Creating animations

To configure how Pepper should animate, use an Animation. Typically, these animations are created from .qianim and .pmt files.

Create an Animation from a .qianim file and build the animate action with it:

Animation animation = AnimationBuilder.with(qiContext)
                                      .withResources(R.raw.elephant_a001)
                                      .build();

Animate animate = AnimateBuilder.with(qiContext)
                                .withAnimation(animation)
                                .build();

To create a .qianim file, refer to Animation Editor or Animation Browser / Viewer.

How to know when a label is reached

The Animate action allows you to add a listener to react when a label is reached:

// Animation containing labels.
Animation animation = AnimationBuilder.with(qiContext)
                                      .withResources(R.raw.elephant_a001)
                                      .build();

Animate animate = AnimateBuilder.with(qiContext)
                                .withAnimation(animation)
                                .build();

animate.addOnLabelReachedListener((label, time) -> {
    // Called when a label is reached.
});

Use cases

Make Pepper dance

You can create an animation file (.qianim) containing a dance, create an Animation with it and make Pepper dance.

Follow a trajectory

You can make Pepper follow a precise trajectory by creating an animation trajectory file (.pmt). As with .qianim files, you can create an Animation object with it.

To create a .pmt file, refer to Trajectory Editor.

Performance & Limitations

Obstacle avoidance

Pepper is able to avoid obstacles when performing an animation.

If Pepper animates his joints but an obstacle prevents him to do the entire animation safely, the animation will only be partially performed.

When performing a trajectory, if Pepper encounters an obstacle on his way, he will avoid it and try to perform the trajectory as accurately as possible. However, the total animation time remains unchanged: Pepper may not have enough time to reach his destination while avoiding obstacles. In this case, he will stop moving without finishing the entire trajectory.

Animate or GoTo?

You can make Pepper move with both Animate and GoTo.

  • Use Animate to perform a constant trajectory with no variation except for obstacle avoidance.
  • Use GoTo to create a dynamically adaptive trajectory based on a target.

Animate or LookAt?

You can make Pepper move his head with both Animate and LookAt.

  • Use Animate to perform a constant movement with no variation except for obstacle avoidance.
  • Use LookAt to create a dynamically adaptive movement based on a target.

Getting started

See also