Step forward — Animate ¶
In this tutorial, we will play a trajectory on Pepper, using the Animate action.
Before stepping in this tutorial, you should:
- Know how to use Android resources.
- Be familiar with the Action notion. For further details, see: Running Actions on Pepper.
Let’s start a new project
- Start a new project, let’s call it TrajectoryPepper.
- Robotify it and make sure it implements the QiSDK & the Robot Life Cycle.
For further details, see: Creating a robot application.
Adding a trajectory resource¶
Create a new trajectory from scratch, using the Trajectory editor.
|Choose File > New > Animation Trajectory.|
Enter the name of the file to create. Let’s say “dance”.
After clicking OK, the file will be created under the raw resource directory “/res/raw”.
|The created file will be opened automatically through trajectory tool.|
|Use the tool to define your robot’s movement and click OK to store the movement to your file.|
For further details, see: Trajectory Editor.
Building the animation¶
From this trajectory file we must now build an
To do this, we use the
onRobotFocusGained method, add the following code:
Using the animation¶
We will animate Pepper by using the
Animate field in your
Create it with an
AnimateBuilder in the
We used the previously created
Animation to set the animation Pepper will perform.
Running the animation¶
We can now run the
Adding some log¶
To be notified when the
Animateaction starts, let’s use the
Add this before the run:
Do not forget to remove this listener on
To display a log trace indicating that the animation finished with success or error, add after the run:
Let’s try it¶
The sources for this tutorial are available on GitHub.
Install and run the application.
For further details, see: Running an application.
You should observe the following:
That’s it! You can now animate Pepper!