These are chat archives for dronekit/dronekit-android

9th
Dec 2015
buqing2009
@buqing2009
Dec 09 2015 08:34
Hi, i want to use the method called manualControl in class com.o3dr.android.client.apis.ControlApi.java, but when i send the velocity, it has no response in SITL. Here is my code:

State vehicleState = this.drone.getAttribute(AttributeType.STATE);
if (vehicleState.isFlying()) {

            this.guide.manualControl((float) pitch_val, (float) roll_val, (float) throttle_val, new AbstractCommandListener() {
                @Override
                public void onSuccess() {
                    Log.e("bluking", "Controller successfully");
                }

                @Override
                public void onError(int executionError) {

                }

                @Override
                public void onTimeout() {

                }
            });

// this.guide.turnTo((float)yaw_val,);

        }
three float values are all in the right range [-1.0f, 1.0f]
Fredia Huya-Kouadio
@ne0fhyk
Dec 09 2015 08:54
@buqing2009 you need to enable it first by calling enableManualControl
buqing2009
@buqing2009
Dec 09 2015 08:58
@ne0fhyk I have enable it before, here is my code:
This message was deleted
This message was deleted
buqing2009
@buqing2009
Dec 09 2015 09:05
float vx = 0.0f;
        float vy = 0.0f;
        float vz = 1.0f;

        this.guide.enableManualControl(true, new ControlApi.ManualControlStateListener() {
            @Override
            public void onManualControlToggled(boolean isEnabled) {
                alertUser("Manual Control Toggled!");
                Log.e("bluking", Boolean.toString(isEnabled));
            }
        });

        this.guide.manualControl(vx, vy, vz, new AbstractCommandListener() {
            @Override
            public void onSuccess() {
                Log.e("bluking","manualControl successful");
            }

            @Override
            public void onError(int executionError) {

            }

            @Override
            public void onTimeout() {

            }
        });
Fredia Huya-Kouadio
@ne0fhyk
Dec 09 2015 09:07
you should be calling manualControl within the onManualControlToggled callback, only when isEnabled is true.
buqing2009
@buqing2009
Dec 09 2015 09:08
@ne0fhyk OK, i got you. I will try it again later, thank you!
buqing2009
@buqing2009
Dec 09 2015 11:48
@ne0fhyk
 final float vx = 0.0f;
        final float vy = 0.0f;
        final float vz = 1.0f;
        final ControlApi controller;
        controller = this.guide;

        this.guide.enableManualControl(true, new ControlApi.ManualControlStateListener() {
            @Override
            public void onManualControlToggled(boolean isEnabled) {
                alertUser("Manual Control Toggled!");
                Log.e("bluking", Boolean.toString(isEnabled));
                if (isEnabled) {
                    controller.manualControl(vx, vy, vz, new AbstractCommandListener() {
                        @Override
                        public void onSuccess() {
                            Log.e("bluking","Controller Successfully");
                        }

                        @Override
                        public void onError(int executionError) {

                        }

                        @Override
                        public void onTimeout() {

                        }
                    });
                }
            }
        });
@ne0fhyk it also didn't work