FAQ
1. How do add online voice commands?
Please contact the technical staff at UBTECH.
2. Interface to detect objects approaching
In a real scenario, if you need to know whether an object is near or far away from the robot, you can pass the human_detect parameter to obtain it in the sensor monitoring, as follows:
public class SensorActivity extends AppCompatActivity { private static final String TAG = SensorActivity.class.getSimpleName(); private SensorManager sensorManager; private SensorListener sensorListener; private boolean mHumanIn = false; public static final String SENSOR_HUMAN_DETECT = "human_detect"; //Human detection sensor ID public static final int HUMAN_CLOSER = 1; // There are objects approaching public static final int HUMAN_AWAY = 2; //There are objects leaving public static final float HUMAN_DETECT_DISTANT_THRESHOLD = 1.3f; // There is people entering the distance threshold @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sensor); GlobalContext robotContext = Robot.globalContext(); sensorManager = robotContext.getSystemService(SensorManager.SERVICE); } public boolean isHumanIn() { return mHumanIn; } @Override protected void onPause() { super.onPause(); sensorManager.unregisterListener(sensorListener); } @Override protected void onResume() { super.onResume(); sensorListener = new SensorListener() { @Override public void onSensorChanged(SensorDevice sensorDevice, SensorEvent sensorEvent) { //check the sensor change event here try { int direction = Math.round(sensorEvent.getValues()[0]); switch (direction) { case HUMAN_AWAY:
3.Demo: Replace speech service to Google service
To satisfy the requirements of replacing speech services, we provide Demo code to make the replacing process easy. Please refer to the file: overriding-speech-service. This Demo code is made for replacing Google Cloud Speech services. Please get the access token json file of speech service(ASR, NLP,TTS) from https://cloud.google.com, and replace it in the corresponding line in the Demo code.