public class

UnityFaceManager

extends Object
java.lang.Object
   ↳ com.nuwarobotics.service.facecontrol.UnityFaceManager

Class Overview

Nuwa Face is a Activity which constructed with the Unity engine.
The face control mechanism receives instructions via android service AIDL. It will init and binding service when constructing the new NuwaRobotAPI object, use UnityFaceManager object to call face control instruction.

   // get control object
   mRobotAPI.initFaceControl(mContext, mContext.getClass().getName(), FaceControlConnect);
   UnityFaceManager mFaceManager = mRobotAPI.UnityFaceManager.getInstance();
   ...
   mFaceManager.showUnity();
   mFaceManager.mouthOn(200);
   ...
   //after no more use(ex:activity suspend), release object
   mFaceManager.release();
 
Declare ServiceConnection of Face Service
   ServiceConnectListener FaceControlConnect = new ServiceConnectListener() {
        @Override
        public void onConnectChanged(ComponentName componentName, boolean b) {
            Log.d(TAG, "faceService onbind : " + b);
        }
    };
 
Play a facial expression (json file which pre-define by nuwa)
   String json = "J2_Hug";
   IonCompleteListener.Stub mListener = new IonCompleteListener.Stub() {
        @Override
        public void onComplete(String s) throws RemoteException {
            Log.d("FaceControl", "onMotionComplete:" + s );
        }
    };
  mFaceManager.playMotion(json,mListener);
  
To receive callback of Face Touch
    mController.registerCallback(new UnityFaceCallback());
    class UnityFaceCallback extends UnityFaceCallback {
         @Override
         public void on_touch_left_eye() {
             Log.d("FaceControl", "on_touch_left_eye()");
         }

         @Override
         public void on_touch_right_eye() {
             Log.d("FaceControl", "on_touch_right_eye()");
         }

         @Override
         public void on_touch_nose() {
             Log.d("FaceControl", "on_touch_nose()");
         }

         @Override
         public void on_touch_mouth() {
             Log.d("FaceControl", "on_touch_mouth()");
         }

         @Override
         public void on_touch_head() {
             Log.d("FaceControl", "on_touch_head()");
         }

         @Override
         public void on_touch_left_edge() {
             Log.d("FaceControl", "on_touch_left_edge()");
         }

         @Override
         public void on_touch_right_edge() {
            Log.d("FaceControl", "on_touch_right_edge()");
         }

         @Override
         public void on_touch_bottom() {
            Log.d("FaceControl", "on_touch_bottom()");
         }
     }

Summary

Nested Classes
enum UnityFaceManager.MouthOnType  
Constants
String FACE_CONTROL_ACTION_V1
int FACE_CONTROL_VERSION_NONE ROBOT VERSION NOT SUPPORT FACE CONTROL API
int FACE_CONTROL_VERSION_V1 ROBOT VERSION SUPPORT FACE CONTROL API V1
int FACE_CONTROL_VERSION_V2 ROBOT VERSION SUPPORT FACE CONTROL API V2
Public Methods
static int getDeviceSupport(Context context)
Get Does Robot Version support Face Control API
static UnityFaceManager getInstance()
void hideFace()
hide face from UI foreground
boolean isServiceConnected()
check is app aidl still connected to nuwa face
void mouthEmotionOn(long moveSpeed, int EmotionType)
NOTICE : NOT SUPPORT YET, Under planning.
void mouthOff()
close face mouth
void mouthOn(long speed)
Start face mouth move.
boolean playMotion(String json, IonCompleteListener listener)
play unity face motion method
boolean registerCallback(UnityFaceCallback callback)
register FaceControl listener
void release()
release Face Control module.
void showFace()
show face (bring to foreground UI)
boolean unregisterCallback(UnityFaceCallback callback)
unregister FaceControl listener
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String FACE_CONTROL_ACTION_V1

Constant Value: "com.nuwarobotics.app.facepresenter.support.facecontrol.v1"

public static final int FACE_CONTROL_VERSION_NONE

ROBOT VERSION NOT SUPPORT FACE CONTROL API

Constant Value: 0 (0x00000000)

public static final int FACE_CONTROL_VERSION_V1

ROBOT VERSION SUPPORT FACE CONTROL API V1

Constant Value: 1 (0x00000001)

public static final int FACE_CONTROL_VERSION_V2

ROBOT VERSION SUPPORT FACE CONTROL API V2

Constant Value: 2 (0x00000002)

Public Methods

public static int getDeviceSupport (Context context)

Get Does Robot Version support Face Control API

Returns
  • support level (0 means not support)
         if(mFaceManager.getDeviceSupport(context) != 0){
             //support Face Control
         }else{
             //not support Face control
         }

public static UnityFaceManager getInstance ()

public void hideFace ()

hide face from UI foreground

public boolean isServiceConnected ()

check is app aidl still connected to nuwa face

public void mouthEmotionOn (long moveSpeed, int EmotionType)

NOTICE : NOT SUPPORT YET, Under planning.
Move mouth with a emotion index

Parameters
moveSpeed speed of mouth move
EmotionType index of emotion

public void mouthOff ()

close face mouth

public void mouthOn (long speed)

Start face mouth move. (usually use on speaking)

Parameters
speed Mouth animation speed by millisecond (lower value make faster mouth move)

public boolean playMotion (String json, IonCompleteListener listener)

play unity face motion method

Parameters
json unity face motion key
listener callback for motion complete
Returns
  • call success or fail
See Also
  • IonCompleteListener

public boolean registerCallback (UnityFaceCallback callback)

register FaceControl listener

Parameters
callback callback class
Returns
  • success register or not

public void release ()

release Face Control module.

public void showFace ()

show face (bring to foreground UI)

public boolean unregisterCallback (UnityFaceCallback callback)

unregister FaceControl listener

Parameters
callback callback
Returns
  • success unregister or not