mBtn_MoveBody.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { float x = Float.valueOf(mEditTextMoveBodyX.getText().toString()); float y = Float.valueOf(mEditTextMoveBodyY.getText().toString()); float theta = Float.valueOf(mEditTextMoveBodyTheta.getText().toString()); robotAPI.motion.moveBody(x, y, theta); } });
Or you can set speed level
mBtn_moveBodyLevel.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { float x = Float.valueOf(mEditTextMoveBodyLevelX.getText().toString()); float y = Float.valueOf(mEditTextMoveBodyLevelY.getText().toString()); float theta = Float.valueOf(mEditTextMoveBodyLevelTheta.getText().toString()); int selectedLevel = mSpinnerMoveBodyLevel.getSelectedItemPosition() + 1; MotionControl.SpeedLevel.Body level = MotionControl.SpeedLevel.Body.getBody(selectedLevel); robotAPI.motion.moveBody(x, y, theta, level); } });
MoveHead is similar moveBody. You can input yaw, pitch, speed level.
mBtn_moveHead.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { String tmp = mEditText_head_pitch.getText().toString(); float pitch = TextUtils.isEmpty(tmp) ? 0 : (float) Math.toRadians(Float.valueOf(tmp)); tmp = mEditText_head_yaw.getText().toString(); float yaw = TextUtils.isEmpty(tmp) ? 0 : (float) Math.toRadians(Float.valueOf(tmp)); int selectedLevel = mSpinnerMoveHeadLevel.getSelectedItemPosition() + 1; MotionControl.SpeedLevel.Head level = MotionControl.SpeedLevel.Head.getHead(selectedLevel); robotAPI.motion.moveHead(yaw, pitch, level); } });
And you can get result by callback.
public static RobotCallback robotCallback = new RobotCallback() { @Override public void onStateChange(int cmd,int serial,RobotErrorCode err_code,RobotCmdState state) { super.onStateChange(cmd, serial, err_code, state); } }
Finally, you can stop the motion by stopping function.
Button stop = (Button) findViewById(R.id.stopButton); stop.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { robotAPI.motion.stopMoving(); } });