我想让sphero向前移动一定量的厘米,但到目前为止我还没有设法让任何东西正常工作这是我现在的代码:
EditText distanceText = (EditText) findViewById(R.id.distanceText);
int inputMSec = Integer.parseInt(distanceText.getText().toString());
int time = (inputMSec - inputMSec/2);
// The ball is given the RollCommand at half speed.
RollCommand.sendCommand(mRobot, heading,0.5f);
// A handler is created to delay the Stop command.
final Handler handler = new Handler();
handler.postDelayed(new Runnable(){
@Override
public void run() {
// Makes the ball stop
RollCommand.sendStop(mRobot);
}
// The variable 'time' defines how long the ball rolls until it is told to stop.
}, time);
Run Code Online (Sandbox Code Playgroud)
有没有其他命令我可以发送到球而不是RollCommand?或者任何人都可以从EditText中找到对输入做什么,以便距离变得正确?