Hello human!

Goal

In this tutorial, we will create a minimal application, making Pepper say “Hello human!”.

Prerequisites

Make sure you have installed Android Studio, the Pepper SDK plugin, the Robot SDK and the related tools.

For further details, see: Installing the Pepper SDK plug-in.

Let’s start a new project

  • Start a new project, let’s call it HelloPepper.
  • Robotify it and make sure it implements the QiSDK & the Robot Life Cycle.

For further details, see: Creating a robot application.

Building and running a Say

To make Pepper talk, we will use the Say interface. This class represents one of the several actions Pepper can perform.

To use the Say interface:

Step Action

Build the Say.

Create a new instance of Say with a SayBuilder in the onRobotFocusGained method:

// Create a new say action.
val say: Say = SayBuilder.with(qiContext) // Create the builder with the context.
                    .withText("Hello human!") // Set the text to say.
                    .build() // Build the say action.
// Create a new say action.
Say say = SayBuilder.with(qiContext) // Create the builder with the context.
                    .withText("Hello human!") // Set the text to say.
                    .build(); // Build the say action.

Run the Say.

Call the run method:

// Execute the action.
say.run()
// Execute the action.
say.run();

The complete code should look like this:

override fun onRobotFocusGained(qiContext: QiContext) {
    // Create a new say action.
    val say: Say = SayBuilder.with(qiContext) // Create the builder with the context.
                        .withText("Hello human!") // Set the text to say.
                        .build() // Build the say action.

    // Execute the action.
    say.run()
}

override fun onRobotFocusLost() {
    // Nothing here.
}
@Override
public void onRobotFocusGained(QiContext qiContext) {
    // Create a new say action.
    Say say = SayBuilder.with(qiContext) // Create the builder with the context.
                        .withText("Hello human!") // Set the text to say.
                        .build(); // Build the say action.

    // Execute the action.
    say.run();
}

@Override
public void onRobotFocusLost() {
    // Nothing here.
}

That’s all you need to make Pepper talk!

Let’s try it

github_icon The sources for this tutorial are available on GitHub.

Step Action

Install and run the application.

For further details, see: Running an application.

Choose “Hello Human”.

../_images/hello_human.png

Congrats! You now have a talking Pepper!