NUWA Robot SDK Tutorial

ver 1.0

NUWA SDK

What is NUWA Robot SDK?

"NUWA Robot SDK" is an application development kit for robots made by NUWA Robotics. It is based on Android P, and it is possible to create apps using Android Studio.

Development environment and related materials

The NUWA Robot SDK supports the following development environments:

The latest information is available on the official website.

In addition to the Android Archive (aar) that includes the NUWA Robot API, sample code, tutorials, etc. are provided.

Role of this document

This document explains how to use the NUWA Robot SDK easily. For an overview of the NUWA Robot SDK, see the NUWA Robot SDK Manual, and for API details, see the NUWA Robot SDK Javadoc.

About the development equipment of this document

Kebbi's apps can be developed on both Windows and Mac. This document is developed on Mac.

Preparation of development environment

Android Studio is required for development. Please prepare the latest version of Android Studio.

Android Studio

Put Kebbi in developer mode

First, set Kebbi to developer mode by following the steps below.

Open the Kebbi settings screen and select "About Kebbi" at the bottom.

setting

If you hit "About Kebbi" in the menu 10 times in a row, the settings for developers will be added.

setting_end

Press "HOME SETTING" to move to "Default App".

default_app

Press the arrow (←) on the upper left to move to the Android setting screen.

android_setting

From this screen, look for "build settings" in "device information" and hit "build number" repeatedly. "Developer options" is added to "Advanced" of "System".

Turn on the developer options to enable USB debugging. You can now connect your computer to Kebbi.

debug_on

Kebbi and PC connection

Connect Kebbi with a USB cable.

Create an Android app

Now let's create a simple app for Kebbi.

Start Android Studio and create a project.

Select Start a new Android Studio project to create a new project.

NewProject1

Select the project type.

Select "Empty Activity".

NewProject2

Decide on a project name

This time, I named it "Hello Kebbi".

NewProject3

Library settings

Set the library to use the NUWA Robot API.

Copy AAR file

First, select "Project" from the menu on the upper left.

aar1

Then copy the latest .aar file of the NUWA SDK to the libs folder inside the app folder.

aar2

If the copy is successful, it will look like this.

aar3

Add the following description to the very end of "build.gradle" in the app folder.

repositories { flatDir { dirs'libs' } }
aar4

Finally, add the following to the end of the dependencies of "build.gradle".

// include Nuwa Robot SDK in / libs implementation (name:'KiwiSDK_RPC_2019-10-03_v1.0.1.9.54caff0', ext:'aar')
aar5

API initialization

Now let's create a program.

Look for MainActivity.java in the src folder inside the app folder.

main1

Add the following line to AppCompatActivity. (The import for using the NuwaRobot API is automatically added. The same applies below.)

private NuwaRobotAPI mRobot;
main2

Describe the initial processing for using the API in onCreate. Also, prepare a function to handle the event. Rewrite onCreate as follows.

@Override protected void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); setContentView (R.layout.activity_main); // init kiwi sdk String your_app_package_name = getPackageName (); IClientId id = new IClientId (your_app_package_name); mRobot = new NuwaRobotAPI (this, id); // register Nuwa Robot Listener registerNuwaRobotListener (); } void registerNuwaRobotListener () { }
main3

Event listener

Next, let's define a listener for events that originate from Kebbi.

Please do not copy and paste the following in the "void register NuwaRobotListener" created earlier.

mRobot.registerRobotEventListener (new RobotEventListener)

Then, input assistance will appear like this, so select it.

event1

Because there is an error in the closing parenthesis

event2

Fix it like this.

event3

After fixing it, try adding the following programs as well.

mRobot.registerVoiceEventListener (new VoiceEventListener)

Finally, the registerNuwaRobotListener looks like this: If you are having trouble with input assistance, try copying the following sources.

void registerNuwaRobotListener () { mRobot.registerRobotEventListener (new RobotEventListener () { @Override public void onWikiServiceStart () { } @Override public void onWikiServiceStop () { } @Override public void onWikiServiceCrash () { } @Override public void onWikiServiceRecovery () { } @Override public void onStartOfMotionPlay (String s) { } @Override public void onPauseOfMotionPlay (String s) { } @Override public void onStopOfMotionPlay (String s) { } @Override public void onCompleteOfMotionPlay (String s) { } @Override public void onPlayBackOfMotionPlay (String s) { } @Override public void onErrorOfMotionPlay (int i) { } @Override public void onPrepareMotion (boolean b, String s, float v) { } @Override public void onCameraOfMotionPlay (String s) { } @Override public void onGetCameraPose (float v, float v1, float v2, float v3, float v4, float v5, float v6, float v7, float v8, float v9, float v10, float v11) { } @Override public void onTouchEvent (int i, int i1) { } @Override public void onPIREvent (int i) { } @Override public void onTap (int i) { } @Override public void onLongPress (int i) { } @Override public void onWindowSurfaceReady () { } @Override public void onWindowSurfaceDestroy () { } @Override public void onTouchEyes (int i, int i1) { } @Override public void onRawTouch (int i, int i1, int i2) { } @Override public void onFaceSpeaker (float v) { } @Override public void onActionEvent (int i, int i1) { } @Override public void onDropSensorEvent (int i) { } @Override public void onMotorErrorEvent (int i, int i1) { } }); mRobot.registerVoiceEventListener (new VoiceEventListener () { @Override public void onWakeup (boolean b, String s, float v) { } @Override public void onTTSComplete (boolean b) { } @Override public void onSpeechRecognizeComplete (boolean b, ResultType resultType, String s) { } @Override public void onSpeech2TextComplete (boolean b, String s) { } @Override public void onMixUnderstandComplete (boolean b, ResultType resultType, String s) { } @Override public void onSpeechState (ListenType listenType, SpeechState speechState) { } @Override public void onSpeakState (SpeakType speakType, SpeakState speakState) { } @Override public void onGrammarState (boolean b, String s) { } @Override public void onListenVolumeChanged (ListenType listenType, int i) { } @Override public void onHotwordChange (HotwordState hotwordState, HotwordType hotwordType, String s) { } }); }

The program is now ready!

Hello! Kebbi!

Thank you for waiting! Let Kebbi speak. From the event listeners you added earlier, find onWikiServiceStart and modify it as follows. This event is an event that will be called after the API has been initialized.

@Override public void onWikiServiceStart() { Log.d("KEBBI", "onWikiServiceStart"); mRobot.startTTS("Hello, I'm Kebbi."); }

Finally, let's log one more thing to the event listener.

@Override public void onTTSComplete (boolean b) { Log.d ("KEBBI", "onTTSComplete:" + b); }

onTTSComplete is an event that is called when Kebbi's utterance is over. This is useful if you want Kebbi to speak and move continuously. This is the first time, so let's check the log.

Let's run the program!

Now let's run the program. If Kebbi is connected to your computer, Kebbi should be displayed in the upper left corner of the model name. Press the play button and the program will run!

run1

How is it? Did Kebbi talk to you? By the way, let's check the log as well. It is convenient to enter "KEBBI" in the log search because unnecessary logs will not be displayed.

run2

Exit the app

To close the app, press the stop button in Android Studio. Even if you press the button on Kebbi's head, it looks like it's finished, but the app is actually working.

end1

The run app will be automatically added to Kebbi's menu. From the next time onwards, you can also start the app from here.

end2

Just like any other app, you can specify the program name or change the icon to a nice one, and you will have your own original app!

Tutorial completed!

Thank you for your support, this completes the tutorial. I hope you understand the basic flow of creating a Kebbi app. However, there are still many things I would like to try, right?

First of all

[NUWA Robot SDK Manual] NUWA Developer

Let's read. This document is a complete introduction to how to use the API to create Kebby apps. Also, sample programs etc. are published on the official website, so please refer to them.

For example ...

There are some simple example for your reference.

[NUWA SDK Example Github] Sample Code

You will be able to do such things!