Goal - Make Pepper execute a series of movements with his limbs and head, or follow a predefined trajectory.
// Create an animation object.
val myAnimation: Animation = AnimationBuilder.with(qiContext)
.withResources(R.raw.elephant_a001)
.build()
// Build the action.
val animate: Animate = AnimateBuilder.with(qiContext)
.withAnimation(myAnimation)
.build()
// Run the action asynchronously.
animate.async().run()
// 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.
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:
val animation: Animation = AnimationBuilder.with(qiContext)
.withResources(R.raw.elephant_a001)
.build()
val animate: Animate = AnimateBuilder.with(qiContext)
.withAnimation(animation)
.build()
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.
The Animate
action allows you to add a listener to react when a label is reached:
// Animation containing labels.
val animation: Animation = AnimationBuilder.with(qiContext)
.withResources(R.raw.elephant_a001)
.build()
val animate: Animate = AnimateBuilder.with(qiContext)
.withAnimation(animation)
.build()
animate.addOnLabelReachedListener { label, time ->
// Called 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.
});
You can create an animation file (.qianim) containing a dance, create an
Animation
with it and make Pepper dance.
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.
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.