public final class

NuwaRobotAPI

com.nuwarobotics.service.agent.NuwaRobotAPI

Class Overview

A NuwaRobotAPI is a single, focused thing that the NuwaRobot developer can do.
Document for NuwaSDK 2.1.0.08 version.

Topics covered here:

  1. Getting Start with NuwaRobotAPI
  2. Nuwa Motion Player
  3. Window Control
  4. Starting a NuwaRobotAPI and Interact with Voice System
  5. Available Sensing Events
  6. Peripheral Control

Developer Guides

The NuwaRobotAPI class is the most important part of Nuwa robot control system and the way NuwaRobotAPI is granted and used can be referenced on NuwaSDK tutorial .


Getting Start with NuwaRobotAPI

NuwaRobotAPIs in the NuwaRobot system are managed as an HashMap. When a new NuwaRobotAPI is created with client ID, it is put into the HashMap with given client ID and become running. Finally, call release() if current NuwaRobotAPI is no more used.


     // ID name: a unique name register to NuwaSDK
     IClientId id = new IClientId("your_app_package_name");
     NuwaRobotAPI mRobot = new NuwaRobotAPI(android.content.Context, id);

     // release Nuwa SDK resource while App closed.(or Activity in pause/destroy state)
     mRobot.release();

Due to all functions of Nuwa Robot SDK are async(based on AIDL) design, App needs to register a callback to receive all kinds of notifications and results from Robot.
  • The RobotEventListener should register when new NuwaRobotAPI. (usually in onCreate)

  •      mRobot.registerRobotEventListener(new RobotEventListener() {
             @Override
             public void onWikiServiceStart() {
                 // Once mRobot is created, you will receive a callback of onWikiServiceStart()
             }
             @Override
             public void onTouchEvent() {
    
             }
         });
  • The VoiceEventListener should register after receive onWikiServiceStart callback of RobotEventListener

  •      RobotEventListener robotEventListener = new RobotEventListener() {
               @Override
               public void onWikiServiceStart() {
                   // Nuwa Robot SDK is ready now, you call call Nuwa SDK API now.
                   Log.d(TAG, "onWikiServiceStart, robot ready to be control");
                   //Step 3 : Start Control Robot after Service ready.
                   //Register Voice Callback event
                   mRobotAPI.registerVoiceEventListener(voiceEventListener);//listen callback of robot voice related event
               }
         };
         VoiceEventListener voiceEventListener = new VoiceEventListener() {
             @Override
             public void onWakeup(boolean isError, String score, float direction) {
                  //do something
             }
             ...
             ...
         };

Nuwa Motion Player

Before beginning to use Nuwa motion player, here is a brief definition of Nuwa motion

A Nuwa motion is a special, private Robot motion format used to control Robot behavior, and can be composed of following units

  • Face Control Unit(e.g. MP4)
  • Motor Control Unit
  • Timeline Control Unit
  • LED Control Unit

You can just play a named motion , and Nuwa Robot will execute a serials of pre-defined actions.

Window Control

  • Overlap Window Control - While playing a motion, there is a overlap window on the top of screen, you can do show or hide function with the window.
  •       mRobot.showWindow(false);
          mRobot.hideWindow(false);
  • Dynamic Menu - If 3rd party APPs wish to add their APP to Menu List, they need to add following configuration on AndroidManifest.xml
    • This method already deprecated in Kebbi AIR and later product.
    • Please use native android method to show icon in Launcher. Reference link Android Developer
           <meta-data
              android:name="com.nuwarobotics.app.help.THIRD_VALUE"
              android:value="true"
           />

Starting and Interact with Voice System

  • Speech synthesis
  • Local command type speech recognization
  • speech recognization by Cloud

Please See NuwaSDK tutorial for detail.

Available Sensing Events

  • Touch sensor event - A Touch sensor event can be divided into two parts, Touch sensor type and Touch sensor value by #onTouchEvent(int, int)
    • Touch sensor type - describe which touch area is now touched, involve HEAD: 1, CHEST: 2, LEFT_HAND: 3, RIGHT_HAND: 4.
    • Touch sensor value - describe what kind of touch behavior created, involve touched: 1 and untouched: 0.
  • PIR sensor event - A PIR sensor event describe a object detected or not. by #onPIREvent(int)/li>
  • Drop sensor event - A Drop IR sensor event describe a drop behavior detected by #onDropSensorEvent(int)

Peripheral Control

  • LED Control - There are four parts of LEDs on Robot; HEAD, CHEST, RIGHT_HAND and RIGHT_HAND
  • Motor Control - Nuwa Robot has 10 motors to be controlled.

Please See NuwaSDK tutorial for detail.

Summary

Nested Classes
class NuwaRobotAPI.JointMotor System Behavior Service API -- END  
Constants
String CHINESE_CHINA Locale string - China
String CHINESE_HONGKONG Locale string - Hong Kong
String CHINESE_TAIWAN Locale string - Taiwan
String ENGLISH Locale string - English
int ERROR_FW_AIMOTOR
int ERROR_FW_WHEEL
int ERROR_MAINBOARD_COMM_FAIL
int ERROR_MOTOR_VERSION
int ERROR_NONE
String JAPAN Locale string - Japan
int MOTOR_LEFT_ELBOW_Y A constant describing motor left elbow y.
int MOTOR_LEFT_SHOULDER_X A constant describing motor left shoulder x.
int MOTOR_LEFT_SHOULDER_Y A constant describing motor left shoulder y.
int MOTOR_LEFT_SHOULDER_Z A constant describing motor left shoulder z.
int MOTOR_NECK_Y A constant describing motor neck y.
int MOTOR_NECK_Z A constant describing motor neck z.
int MOTOR_RIGHT_ELBOW_Y A constant describing motor right elbow y.
int MOTOR_RIGHT_SHOULDER_X A constant describing motor right shoulder x.
int MOTOR_RIGHT_SHOULDER_Y A constant describing motor right shoulder y.
int MOTOR_RIGHT_SHOULDER_Z A constant describing motor right shoulder z.
int POSITION_CHEST A constant describing position chest.
int POSITION_HEAD A constant describing position head.
int POSITION_LEFT_FACE A constant describing position left face.
int POSITION_LEFT_HAND A constant describing position left hand.
int POSITION_RIGHT_FACE A constant describing position right face.
int POSITION_RIGHT_HAND A constant describing position right hand.
int SENSOR_DROP A constant describing a Drop IR sensor type.
int SENSOR_NONE A constant describing a NONE sensor type, which is used to stop receiving any types of sensor event for current caller.
int SENSOR_PIR A constant describing a Pyro-electric Infrared Detector sensor type.
int SENSOR_RAW_TOUCH A constant describing a Robot Raw Touch sensor type.
int SENSOR_SYSTEM_ERROR A constant describing a Motor Error sensor type.
int SENSOR_TOUCH A constant describing a Robot Touch area.
Public Constructors
NuwaRobotAPI(Context context, IClientId mClientId)
Default constructor with caller ClientID IMPORTMENT : DO NOT USE DUPLICATE ClientId at same package.
Public Methods
SystemBehaviorManager SystemBehaviorManager()
Get SystemBehaviorManager instance to call related API
UnityFaceManager UnityFaceManager()
Get Face Control Manager instance
void controlAlwaysWakeup(boolean enable)
Enable Disable Always wakeup runtime.
void createGrammar(String grammar_id, String grammar_string)
createGrammar : local command grammar Nuwa Local command grammar base on BNF grammar You can use com.nuwarobotics.service.agent.GrammarData or SimpleGrammarData to create BNF object
void ctlMotor(int motor, float degree, float speed)
Control specific motor to request position
boolean disableMotionSto(int id)
This function disables motion STO(smart torque off).
void disablePowerKey()
Target SDK : 2.0.0.08
lock Power key : not allow any function of power key and not allow drop down menu leave current UI.
void disableSystemLED()
Set LED control owner to APP
void enableLed(int id, int onOff)
enable or disable target LED
void enableLedBreath(int id, int interval, int ratio)
Set LED Breathly to target LED.
boolean enableMotionSto(int id, int delay)
This function enables motion STO(smart torque off).
boolean enableMotionSto(int id)
This function enables motion STO(smart torque off).
void enablePowerKey()
unlock Power key : allow any function of power key.
void enableSystemLED()
Set LED control owner to SYSTEM
void faceSpeaker()
Allow trigger robot rotate wheel face to speaker when wakeup
int getDropSensorOfNumber()
Get how many drop sensor on this robot
int getDropSensorState()
Get safe mode status
static NuwaRobotAPI getInst()
Get instance of NuwaRobotAPI; should new NuwaRobotAPI() before use it
List<String> getMotionList()
Get preload motion name list.
int getMotionStoDelay(int id)
This function gets motion STO(smart torque off) delay.
float getMotorPositionInDegree(int mortorid)
float getMotorPresentPositionInDegree(int mortorid)
Get robot present location
float getMotorPresentSpeedInDegreePerSec(int mortorName)
Get specific motor current speed, in degree per second
int getRobotErrorFlag()
Retrieve Robot Error
float getRobotPresentAngularSpeed()
Return Robot present Angular speed in degree per second
float getRobotPresentLinearSpeed()
Return Robot present Linear speed in meter per second
float[] getRobotPresentLocation()
Get robot present location
static String getVersion()
Get Nuwa Robot API version
boolean handleRemoteSDKCallback(Message message)
Use to handle Robot callback event.
void hideFace()
Hide Nuwa kebbi face
Target SDK : 2.1.0.08
void hideWindow(boolean anim)
Hide(close) the motion video window from Display
boolean isKiWiServiceReady()
Check Nuwa Robot SDK engine is ready or not before app calling any Robot SDK API
void lockWheel()
Lock the robot wheel runtime.
void lockWindow(boolean iflock)
Lock the motion video window on Display
float motionCurrentPosition()
Get the current timeline of playing motion
void motionMediaDisable(boolean disable)
Disable motion media player.
String motionName()
Get the name of playing motion
boolean motionPause()
Pause current playing motion
void motionPlay(Uri motionUri, String type, Uri videoUri)
Loads and Starts to play target motion with specific Uri without face.
void motionPlay(String motion, boolean show, String path)
Load Start play motion file which not preload in robot.
boolean motionPlay()
Start play the motion which loading by motionPrepare(String) motionPrepare and motionPlay can be a pair to use.
void motionPlay(String motion, boolean show)
Load and Start play target motion
void motionPrepare(String motion)
Loading target motion file.
void motionPrepare(Uri motionUri, String type, Uri videoUri)
Loading target motion file and video.
void motionReset()
Reset current motion to initial position
boolean motionResume()
Resume the paused motion
boolean motionSeek(float time)
Seek motion timeline to target time position
void motionStop(boolean hide)
Stop current playing motion
float motionTotalDuration()
Get total duration of current prepared motion file
void mouthEmotionOn(long moveSpeed, int mouthOnType)
Control mouth move with specific emotion.
void mouthOff()
Face Control : Control mouth off
void mouthOn(long speed)
Face Control : Control mouth on with speed
void move(float direction_speed)
Control Robot wheel move forward and backward
void playFaceAnimation(String animation)
Play specific face animation
Target SDK : 2.1.0.08
void playFaceAnimation(int id)
Play specific face animation
Target SDK : 2.1.0.08
void playUnityFace(String animation)
[Deprecated] Play specific Unity face.
RobotEventListener registerRobotEventListener(RobotEventListener listener)
Registers a RobotEventListener for receive all kinds of notifications and results from Robot.
VoiceEvaluateListener registerVoiceEvaluateListener(VoiceEvaluateListener listener)
Registers a com.nuwarobotics.service.agent.VoiceEvaluateListener VoiceEvaluateListener for receive all kinds of voice results from Robot.
VoiceEventListener registerVoiceEventListener(VoiceEventListener listener)
Registers a VoiceEventListener for receive all kinds of voice results from Robot.
void release()
Release all Nuwa Robot API resource
void requestMoitonList()
Request nuwa service to load all motion name list.
void requestSensor(int op)
request receive robot sensor event
Example Code :
 mRobotAPI.requestSensor(NuwaRobotAPI.SENSOR_TOUCH | NuwaRobotAPI.SENSOR_PIR | NuwaRobotAPI.SENSOR_DROP)
void resetAudioParameter()
void setDropSensorState(int state)
Set the seneor state
void setLedColor(int id, int brightness, int r, int g, int b)
Set LED color to target LED.
void setListenParameter(VoiceEventListener.ListenType type, String key, String value)
Setup the listen parameter of ASR engine
     //Extra Parameter : Ask ASR engine listen in specific language
     mRobot.setListenParameter(VoiceEventListener.ListenType.RECOGNIZE, "language", "en-US");
     //Function : Ask subtitle force show some string
     mRobot.setListenParameter(VoiceEventListener.ListenType.RECOGNIZE, "subtitle_add", "string want subtitle show");
void setSpeakParameter(VoiceEventListener.SpeakType type, String key, String value)
Setup the speak parameter of TTS engine
     mRobot.setSpeakParameter("isForced", "true"); //set isForced as true
     mRobot.setSpeakParameter("pitch", "80"); //pitch range: 50~200
     mRobot.setSpeakParameter("speed", "120"); //speed range: 50~200
void showFace()
Show Nuwa kebbi face
Target SDK : 2.1.0.08
void showWindow(boolean anim)
Show motion video window on Display
void startLocalCommand()

Start to recognize the local command Prepare grammar by createGrammar(String, String) first.

void startMixUnderstand()

recognize with ASR and local command type, Prepare grammar by createGrammar(String, String) first.

void startRecognize(boolean wakup)
Start to recognize user speech
void startSpeech2Text(boolean wakup)
Start listen speech to text result
void startTTS(String text)
speech synthesis by default locale
If you want speak some string, and show another string to subtitle.
void startTTS(String text, String locale)
speech synthesis with define locale
void startWakeUp(boolean async)
Start monitor wakeup `once` when user trigger robot wakeup.
void stopListen()
Stop current recognize if startRecognize(boolean) call
void stopSensor(int op)
Stop to listen sensor event
Example Code :
 mRobotAPI.stopSensor(NuwaRobotAPI.SENSOR_TOUCH | NuwaRobotAPI.SENSOR_PIR)
void stopTTS()
Stop current speaking if startTTS(String) call
void turn(float angle_speed)
Control Robot wheel turn left or right circularly
void unlockWheel()
Unlock the wheel

Constants

public static final String CHINESE_CHINA

Locale string - China

Constant Value: "zh_CN"

public static final String CHINESE_HONGKONG

Locale string - Hong Kong

Constant Value: "zh_HK"

public static final String CHINESE_TAIWAN

Locale string - Taiwan

Constant Value: "zh_TW"

public static final String ENGLISH

Locale string - English

Constant Value: "en"

public static final int ERROR_FW_AIMOTOR

Constant Value: 16 (0x00000010)

public static final int ERROR_FW_WHEEL

Constant Value: 32 (0x00000020)

public static final int ERROR_MAINBOARD_COMM_FAIL

Constant Value: 64 (0x00000040)

public static final int ERROR_MOTOR_VERSION

Constant Value: 1024 (0x00000400)

public static final int ERROR_NONE

Constant Value: 0 (0x00000000)

public static final String JAPAN

Locale string - Japan

Constant Value: "ja_JP"

public static final int MOTOR_LEFT_ELBOW_Y

A constant describing motor left elbow y.
Target SDK : 2.1.0.08

Constant Value: 10 (0x0000000a)

public static final int MOTOR_LEFT_SHOULDER_X

A constant describing motor left shoulder x.
Target SDK : 2.1.0.08

Constant Value: 9 (0x00000009)

public static final int MOTOR_LEFT_SHOULDER_Y

A constant describing motor left shoulder y.
Target SDK : 2.1.0.08

Constant Value: 8 (0x00000008)

public static final int MOTOR_LEFT_SHOULDER_Z

A constant describing motor left shoulder z.
Target SDK : 2.1.0.08

Constant Value: 7 (0x00000007)

public static final int MOTOR_NECK_Y

A constant describing motor neck y.
Target SDK : 2.1.0.08

Constant Value: 1 (0x00000001)

public static final int MOTOR_NECK_Z

A constant describing motor neck z.
Target SDK : 2.1.0.08

Constant Value: 2 (0x00000002)

public static final int MOTOR_RIGHT_ELBOW_Y

A constant describing motor right elbow y.
Target SDK : 2.1.0.08

Constant Value: 6 (0x00000006)

public static final int MOTOR_RIGHT_SHOULDER_X

A constant describing motor right shoulder x.
Target SDK : 2.1.0.08

Constant Value: 5 (0x00000005)

public static final int MOTOR_RIGHT_SHOULDER_Y

A constant describing motor right shoulder y.
Target SDK : 2.1.0.08

Constant Value: 4 (0x00000004)

public static final int MOTOR_RIGHT_SHOULDER_Z

A constant describing motor right shoulder z.
Target SDK : 2.1.0.08

Constant Value: 3 (0x00000003)

public static final int POSITION_CHEST

A constant describing position chest.
Target SDK : 2.1.0.08

Constant Value: 2 (0x00000002)

public static final int POSITION_HEAD

A constant describing position head.
Target SDK : 2.1.0.08

Constant Value: 1 (0x00000001)

public static final int POSITION_LEFT_FACE

A constant describing position left face.
Target SDK : 2.1.0.08

Constant Value: 5 (0x00000005)

public static final int POSITION_LEFT_HAND

A constant describing position left hand.
Target SDK : 2.1.0.08

Constant Value: 4 (0x00000004)

public static final int POSITION_RIGHT_FACE

A constant describing position right face.
Target SDK : 2.1.0.08

Constant Value: 6 (0x00000006)

public static final int POSITION_RIGHT_HAND

A constant describing position right hand.
Target SDK : 2.1.0.08

Constant Value: 3 (0x00000003)

public static final int SENSOR_DROP

A constant describing a Drop IR sensor type.

Constant Value: 4 (0x00000004)

public static final int SENSOR_NONE

A constant describing a NONE sensor type, which is used to stop receiving any types of sensor event for current caller.

Constant Value: 0 (0x00000000)

public static final int SENSOR_PIR

A constant describing a Pyro-electric Infrared Detector sensor type.

Constant Value: 2 (0x00000002)

public static final int SENSOR_RAW_TOUCH

A constant describing a Robot Raw Touch sensor type.

Constant Value: 16 (0x00000010)

public static final int SENSOR_SYSTEM_ERROR

A constant describing a Motor Error sensor type.

Constant Value: 8 (0x00000008)

public static final int SENSOR_TOUCH

A constant describing a Robot Touch area. (1: HEAD; 2:CHEST; 3: RIGHT_HAND 4: LEFT_HAND)

Constant Value: 1 (0x00000001)

Public Constructors

public NuwaRobotAPI (Context context, IClientId mClientId)

Default constructor with caller ClientID IMPORTMENT : DO NOT USE DUPLICATE ClientId at same package.

Public Methods

public SystemBehaviorManager SystemBehaviorManager ()

Get SystemBehaviorManager instance to call related API

Returns
  • SystemBehaviorManager instance

public UnityFaceManager UnityFaceManager ()

Get Face Control Manager instance

Returns
  • UnityFaceManager object

public void controlAlwaysWakeup (boolean enable)

Enable Disable Always wakeup runtime. NOTICE : Please MUST enable always wakeup when app no more use

Parameters
enable Enable always wakeup or not

public void createGrammar (String grammar_id, String grammar_string)

createGrammar : local command grammar Nuwa Local command grammar base on BNF grammar You can use com.nuwarobotics.service.agent.GrammarData or SimpleGrammarData to create BNF object

Parameters
grammar_id readable grammar id (NOTICE : Please only naming with lower case latter without special character)
grammar_string grammar string

public void ctlMotor (int motor, float degree, float speed)

public boolean disableMotionSto (int id)

This function disables motion STO(smart torque off).

public void disablePowerKey ()

Target SDK : 2.0.0.08
lock Power key : not allow any function of power key and not allow drop down menu leave current UI.
Default Power key behavior, short press go to Nuwa Robot Face, long press to show power off panel.
Notice : Lunch app icon of Drop Down Menu will not available after disablePowerKey
NOTICE : Please must call enablePowerKey() after no more use

See Also

public void disableSystemLED ()

Set LED control owner to APP

public void enableLed (int id, int onOff)

enable or disable target LED

Parameters
id id of LED requested;
1 = LED_ID_HEAD two side of face LED (臉兩側LED燈)
2 = LED_ID_CHEST neck(or chest) LED (胸前LED燈)
3 = LED_ID_RIGHT_HAND Left hand LED (左手LED燈)
4 = LED_ID_LEFT_HAND Right hand LED (右手LED燈)
onOff 0: turn off LED; 1: turn on LED

public void enableLedBreath (int id, int interval, int ratio)

Set LED Breathly to target LED. Please disable system control LED by disableSystemLED() before you use setLedColor

Parameters
id id of LED requested;
1 = LED_ID_HEAD two side of face LED (臉兩側LED燈)
2 = LED_ID_CHEST neck(or chest) LED (胸前LED燈)
3 = LED_ID_RIGHT_HAND Left hand LED (左手LED燈)
4 = LED_ID_LEFT_HAND Right hand LED (右手LED燈)
interval the breath interval

public boolean enableMotionSto (int id, int delay)

This function enables motion STO(smart torque off).

public boolean enableMotionSto (int id)

This function enables motion STO(smart torque off).

public void enablePowerKey ()

unlock Power key : allow any function of power key.
Default Power key behavior, short press go to Nuwa Robot Face, long press to show power off panel.
Target SDK : 2.0.0.08

public void enableSystemLED ()

Set LED control owner to SYSTEM

public void faceSpeaker ()

Allow trigger robot rotate wheel face to speaker when wakeup

public int getDropSensorOfNumber ()

Get how many drop sensor on this robot

Returns
  • number of drop sensor

public int getDropSensorState ()

Get safe mode status

Returns
  • state of seneor mode
    0 : SAFEMODE_NORMAL
    1 : SAFEMODE_MOTOR_RELEASE
    2 : SAFEMODE_DROP
    3 : SAFEMODE_WHEEL_RELEASE
    4 : SAFEMODE_MOTOR_WHEEL_RELEASE

public static NuwaRobotAPI getInst ()

Get instance of NuwaRobotAPI; should new NuwaRobotAPI() before use it

public List<String> getMotionList ()

Get preload motion name list. Please call requestMoitonList() first, before getMotionList.

Returns
  • A List array of motion name.

public int getMotionStoDelay (int id)

This function gets motion STO(smart torque off) delay.

public float getMotorPositionInDegree (int mortorid)

public float getMotorPresentPositionInDegree (int mortorid)

Get robot present location

Parameters
mortorid range from 1 to 10
Returns
  • the motor present degree

public float getMotorPresentSpeedInDegreePerSec (int mortorName)

Get specific motor current speed, in degree per second

Parameters
mortorName motor name
Returns
  • motor speed

public int getRobotErrorFlag ()

Retrieve Robot Error

Returns
  • Robot Error status ERROR_NONE = 0x00 No Error happen ERROR_FW_AIMOTOR = 0x10 Joint Motor corrupted Suggest: Reboot. If this error occurred again, send back for repair ERROR_FW_WHEEL = 0x20 Wheel Safe mode Suggest: Clear any debris from the wheels and reboot. If this error occurred again, send back for repair ERROR_MAINBOARD_COMM_FAIL = 0x40 Motor communication fail Suggest: Reboot. If this error occurred again, send back for repair ERROR_MOTOR_VERSION = 0x400 Motor firmware version incorrect Suggest: Launch firmware update process

public float getRobotPresentAngularSpeed ()

Return Robot present Angular speed in degree per second

Returns
  • present Angular speed

public float getRobotPresentLinearSpeed ()

Return Robot present Linear speed in meter per second

Returns
  • present linear speed

public float[] getRobotPresentLocation ()

Get robot present location

Returns
  • float[3]{x,y,direction} x&y length unit is in meter, direction unit is degree

public static String getVersion ()

Get Nuwa Robot API version

public boolean handleRemoteSDKCallback (Message message)

Use to handle Robot callback event.

Parameters
message connection manager message
Returns
  • did sdk handled this message Example : private ConnectionManager.ReceiveDataCallback mReceiveDataCallback = new ConnectionManager.ReceiveDataCallback() {

public void hideFace ()

Hide Nuwa kebbi face
Target SDK : 2.1.0.08

public void hideWindow (boolean anim)

Hide(close) the motion video window from Display

Parameters
anim play fade in or not when hide the window

public boolean isKiWiServiceReady ()

Check Nuwa Robot SDK engine is ready or not before app calling any Robot SDK API

Returns
  • Returns true if is NuwaRobotAPI is ready to use

public void lockWheel ()

Lock the robot wheel runtime. Please unlock after no more use

See Also

public void lockWindow (boolean iflock)

Lock the motion video window on Display

public float motionCurrentPosition ()

Get the current timeline of playing motion

Returns
  • position of timeline

public void motionMediaDisable (boolean disable)

Disable motion media player.
Some fst motion included the mp4 media, this function allow developer re-use these motion file but not play media.
Target SDK : 2.1.0.02
NOTICE : Please must call #motionMediaDisable(false) after no more use

public String motionName ()

Get the name of playing motion

public boolean motionPause ()

Pause current playing motion

Returns
  • True for instruction call success
See Also

public void motionPlay (Uri motionUri, String type, Uri videoUri)

Loads and Starts to play target motion with specific Uri without face.

Parameters
motionUri is a Uri direct to a motion file(bin/script format)
type is the type of target motion file, one of MOTION_OP_TYPE_BIN or MOTION_OP_TYPE_SCRIPT
videoUri is a Uri direct to a video file

public void motionPlay (String motion, boolean show, String path)

Load Start play motion file which not preload in robot.

Parameters
motion The name of motion.
show If the motion contains a MP4, please set it as true. If you want to implement any view or face for displaying when motion playing, please set it as false.
path The path where you put the motion resource. For example: The folder motion_bin (required, fst files are stored here) and media (not required, mp4 files are stored here) under folder assets. If the assets folder is put at "/storage/emulated/0/assets", please assign "/storage/emulated/0" as path argument.

public boolean motionPlay ()

Start play the motion which loading by motionPrepare(String) motionPrepare and motionPlay can be a pair to use. motionPrepare is used for loading a huge motion file before playing. This design avoids the delay, programmer can prepare motion file ar earlier stage.

Returns
  • True if motion play no error, false for motion loading error

public void motionPlay (String motion, boolean show)

Load and Start play target motion

Parameters
motion The name of motion.
show If the motion contains a MP4, please set it as true. If you want to implement any view or face for displaying when motion playing, please set it as false.
See Also

public void motionPrepare (String motion)

Loading target motion file.
If use this API, please start motion by motionPlay()

Parameters
motion The name of motion.
See Also

public void motionPrepare (Uri motionUri, String type, Uri videoUri)

Loading target motion file and video.
If use this API, please start motion by motionPlay()

Parameters
motionUri is a Uri direct to a motion file(bin/script format)
type is the type of target motion file, one of MOTION_OP_TYPE_BIN or MOTION_OP_TYPE_SCRIPT
videoUri is a Uri direct to a video file

public void motionReset ()

Reset current motion to initial position

public boolean motionResume ()

Resume the paused motion

Returns
  • True for instruction call success
See Also

public boolean motionSeek (float time)

Seek motion timeline to target time position

Parameters
time The time unit is second, such as 3.1759999 seconds.
Returns
  • True for instruction call success.

public void motionStop (boolean hide)

Stop current playing motion

Parameters
hide Stop playing a motion and hide the overlap window, please set it as true. If you want to stay at the moment that MP4 stopped position (keep window showing), please set it as false (please invoke hideWindow, if you want to quit from the MP4 screen).

public float motionTotalDuration ()

Get total duration of current prepared motion file

Returns
  • duration of motion file

public void mouthEmotionOn (long moveSpeed, int mouthOnType)

Control mouth move with specific emotion. Please reset emotion to default before call mouthOff

     private void stopFaceAndCloseMouth() {
         UnityFaceManager.getInstance().playFaceAnimationDefault();
         UnityFaceManager.getInstance().mouthOff();
     }

Parameters
moveSpeed The speed is a duration to change next frame in ms. The suggested value is between 50 (fastest) to 100 (slowest).
mouthOnType The type decides which speak animation will be played.
 off(0), peace_a(1), peace_b(2), joy(3), sadness(4), anger(5), fear(6), disgust(7), surprise(8);
 Mouth preview : animation preview of each MouthOnType
See Also

public void mouthOff ()

Face Control : Control mouth off

See Also

public void mouthOn (long speed)

Face Control : Control mouth on with speed

Parameters
speed The speed is a duration to change next frame in ms. The suggested value is between 50 (fastest) to 100 (slowest).

public void move (float direction_speed)

Control Robot wheel move forward and backward

Parameters
direction_speed Move direction and speed. (cm/sec)
Direction/Speed value range  (AIR-H200 : 0.2 ~ -0.2) (old robot : 0.3 ~ -0.3)
MAX : 0.3   forward
MIN : -0.3   backward

public void playFaceAnimation (String animation)

Play specific face animation
Target SDK : 2.1.0.08

Parameters
animation The name of face animation.
 Face preview : face expression animation preview

public void playFaceAnimation (int id)

Play specific face animation
Target SDK : 2.1.0.08

Parameters
id The id of face animation.

public void playUnityFace (String animation)

[Deprecated] Play specific Unity face.
Please be noticed that this API deprecated, and replaced by playFaceAnimation(int) playFaceAnimation(String)

Parameters
animation face animation file name
 Face preview : face expression animation preview

public RobotEventListener registerRobotEventListener (RobotEventListener listener)

Registers a RobotEventListener for receive all kinds of notifications and results from Robot.

Parameters
listener A RobotEventListener object.
Returns
  • previous registered RobotEventListener if exist

public VoiceEvaluateListener registerVoiceEvaluateListener (VoiceEvaluateListener listener)

Registers a com.nuwarobotics.service.agent.VoiceEvaluateListener VoiceEvaluateListener for receive all kinds of voice results from Robot.

Parameters
listener A com.nuwarobotics.service.agent.VoiceEvaluateListener VoiceEvaluateListener object.
Returns
  • previous registered VoiceEvaluateListener if exist

public VoiceEventListener registerVoiceEventListener (VoiceEventListener listener)

Registers a VoiceEventListener for receive all kinds of voice results from Robot.

Parameters
listener A VoiceEventListener object.
Returns
  • previous registered VoiceEventListener if exist

public void release ()

Release all Nuwa Robot API resource

public void requestMoitonList ()

Request nuwa service to load all motion name list. It need some time to loading.

See Also

public void requestSensor (int op)

request receive robot sensor event
Example Code :

 mRobotAPI.requestSensor(NuwaRobotAPI.SENSOR_TOUCH | NuwaRobotAPI.SENSOR_PIR | NuwaRobotAPI.SENSOR_DROP)

Parameters
op request sensor list

public void resetAudioParameter ()

public void setDropSensorState (int state)

Set the seneor state

Parameters
state control sensor mode
0 : Hardware.SENSOR_DISABLE
1 : Hardware.SENSOR_ENABLE_IR

public void setLedColor (int id, int brightness, int r, int g, int b)

Set LED color to target LED. Please disable system control LED by disableSystemLED() before you use setLedColor

Parameters
id id of LED requested;
1 = LED_ID_HEAD two side of face LED (臉兩側LED燈)
2 = LED_ID_CHEST neck(or chest) LED (胸前LED燈)
3 = LED_ID_RIGHT_HAND Left hand LED (左手LED燈)
4 = LED_ID_LEFT_HAND Right hand LED (右手LED燈)
brightness The brightness value from 0 to 255.
r The RED color value from 0 to 255.
g The GREEN color value from 0 to 255.
b The BLUE color value from 0 to 255.

public void setListenParameter (VoiceEventListener.ListenType type, String key, String value)

Setup the listen parameter of ASR engine

     //Extra Parameter : Ask ASR engine listen in specific language
     mRobot.setListenParameter(VoiceEventListener.ListenType.RECOGNIZE, "language", "en-US");
     //Function : Ask subtitle force show some string
     mRobot.setListenParameter(VoiceEventListener.ListenType.RECOGNIZE, "subtitle_add", "string want subtitle show");

Parameters
type control type VoiceEventListener.ListenType
key the key name of asr parameter (ie. "language")
value the value of key (ie. "en-US")

public void setSpeakParameter (VoiceEventListener.SpeakType type, String key, String value)

Setup the speak parameter of TTS engine

     mRobot.setSpeakParameter("isForced", "true"); //set isForced as true
     mRobot.setSpeakParameter("pitch", "80"); //pitch range: 50~200
     mRobot.setSpeakParameter("speed", "120"); //speed range: 50~200

Parameters
type speak type. (usually use SpeakType.NORMAL )
key the key name of tts parameter "volume" "pitch" "speed" "gain"
value the value of the KEY

public void showFace ()

Show Nuwa kebbi face
Target SDK : 2.1.0.08

public void showWindow (boolean anim)

Show motion video window on Display

Parameters
anim play fade in or not when showing the window

public void startLocalCommand ()

Start to recognize the local command Prepare grammar by createGrammar(String, String) first.
NOTICE : It must call on uithread. (DO NOT CALL IN CALLBACK DIRECTLY)

public void startMixUnderstand ()

recognize with ASR and local command type, Prepare grammar by createGrammar(String, String) first.
NOTICE : It must call on uithread. (DO NOT CALL IN CALLBACK DIRECTLY)

public void startRecognize (boolean wakup)

Start to recognize user speech

Parameters
wakup Need wait wakeup robot or not

public void startSpeech2Text (boolean wakup)

Start listen speech to text result

Parameters
wakup Get the string after wakeup or not

public void startTTS (String text)

speech synthesis by default locale
If you want speak some string, and show another string to subtitle. Here is example.

 // Add special prefix characters // to TTS string, SDK will not show subtitle when speak.
 mRobotAPI.startTTS("//string want kebbi speak");
 // Use a special force show subtitle function to show another string
 mRobotAPI.setListenParameter(VoiceEventListener.ListenType.RECOGNIZE, "subtitle_add", "string want subtitle show");

Parameters
text the request speak string

public void startTTS (String text, String locale)

speech synthesis with define locale

Parameters
text the request speak string
locale String from locale String (for example: ENGLISH, JAPAN, CHINESE_TAIWAN)

public void startWakeUp (boolean async)

Start monitor wakeup `once` when user trigger robot wakeup.
You can say `"Hello Kebbi"` to get a wakeup event callback in your Appication context `ONCE`, and robot system behavior NOT response on this time.
System will not response at this time, if app call startWakeUp.
NOTICE : It must call on uithread. (DO NOT CALL IN CALLBACK DIRECTLY)

Parameters
async asynchronous the wakeup or not

public void stopSensor (int op)

Stop to listen sensor event
Example Code :

 mRobotAPI.stopSensor(NuwaRobotAPI.SENSOR_TOUCH | NuwaRobotAPI.SENSOR_PIR)

Parameters
op stop sensor list

public void stopTTS ()

Stop current speaking if startTTS(String) call

public void turn (float angle_speed)

Control Robot wheel turn left or right circularly

Parameters
angle_speed Turn angle and speed (angle/sec)
Angle/Speed value range (AIR-H200 -50.0 ~ 50.0)  (old robot -30.0 ~ 30.0)
MAX : 50.0 (turn RIGHT)
MIN : -50.0 (turn LEFT)

public void unlockWheel ()

Unlock the wheel

See Also