robotemi/sdk

skidJoy does not work in my Java-Code

MohmadFadiAldrobi opened this issue · 1 comments

Hi, I'm working on an Java-App in Androidstudio for Temi. The app should be able to remotely control Temi with the method "skidJoy(x,y,false)" (i.e. forward, backward, right, left). The problem is that Temi does not move when calling the corresponding method (see code) unless I set the method in a While(true) loop. can someone help me with this ?

public class MainActivity extends AppCompatActivity implements OnRobotReadyListener {

    private static Robot sRobot;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onStart() {
        super.onStart();
        this.sRobot = Robot.getInstance();
        this.sRobot.addOnRobotReadyListener(this);
    }

    @Override
    protected void onStop() {
        super.onStop();
        this.sRobot.removeOnRobotReadyListener(this);
    }

    @Override
    public void onRobotReady(boolean isReady) {
        if (isReady) {
            TemiGoForward(); 
        }
    }

    public void TemiGoleft(){
        sRobot.skidJoy(0,1,false);
    }

    public void TemiGoReight(){
        sRobot.skidJoy(0,-1,false);
    }

    public void TemiGoForward(){
        sRobot.skidJoy(1,0,false);
    }

    public void TemiGoBack(){
        sRobot.skidJoy(-1,0,false);
    }

}

skidJoy request needs to be constantly sent to robot.

Your can add some arrow buttons in your app, and keep sending the skidJoy request when the button is pressed.