2016-02-08 19 views
1

我試圖使用SDK 3.0.1,但沒有成功,我的旋轉幻影3我不能讓我的旋轉幻影3 DJI SDK 3.01

我的代碼:

DJIFlightController flightController = ((DJIAircraft) mProduct).getFlightController(); 

flightController.enableVirtualStickControlMode(new DJICompletionCallback() { 
    @Override 
    public void onResult(DJIError error) { 
     if (error == null) { 
      showToast("enableVirtualStickControlMode: success"); 
     } else { 
      showToast(error.getDescription()); 
     } 
    } 
}); 
try { 
    sleep(5000); 
} catch (InterruptedException e) { 
    e.printStackTrace(); 
} 
showToast("Set yaw control mode to angle"); 
flightController.setHorizontalCoordinateSystem(DJIFlightControllerDataType.DJIVirtualStickFlightCoordinateSystem.Body); 
flightController.setRollPitchControlMode(DJIFlightControllerDataType.DJIVirtualStickRollPitchControlMode.Angle); 
flightController.setVerticalControlMode(DJIFlightControllerDataType.DJIVirtualStickVerticalControlMode.Velocity); 
flightController.setYawControlMode(DJIFlightControllerDataType.DJIVirtualStickYawControlMode.Angle); 
try { 
    sleep(5000); 
} catch (InterruptedException e) { 
    e.printStackTrace(); 
} 
DJIFlightControllerDataType.DJIVirtualStickFlightControlData flightControlData = 
     new DJIFlightControllerDataType.DJIVirtualStickFlightControlData(0, 0, 45, 0); 
flightController.sendVirtualStickFlightControlData(flightControlData, new DJICompletionCallback() { 
    @Override 
    public void onResult(DJIError error) { 
     if (error == null) { 
      showToast("Rotation: success"); 
     } else { 
      showToast(error.getDescription()); 
     } 
    } 
}); 
try { 
    sleep(5000); 
} catch (InterruptedException e) { 
    e.printStackTrace(); 
} 


flightController.disableVirtualStickControlMode(new DJICompletionCallback() { 
    @Override 
    public void onResult(DJIError error) { 
     if (error == null) { 
      showToast("disableVirtualStickControlMode: success"); 
     } else { 
      showToast(error.getDescription()); 
     } 
    } 
}); 

我得到消息「旋轉:成功」,但飛機不動。 我做錯了什麼? 我真的很感激任何幫助。

回答

4

我之前就遇到過這個問題。如果您只調用sendVirtualStickFlightControlData一次,則性能是有線的。我發送了一封電子郵件給DJI支持,他們建議我以5Hz的頻率調用此方法。我測試了它,一切都很好。

喜歡的東西:

Timer timer = new Timer(); 

    timer.schedule(new TimerTask() { 

     @Override 
     public void run() { 
      mFlightController.sendVirtualStickFlightControlData(flightControlData, new DJICompletionCallback() { 
       @Override 
       public void onResult(DJIError error) { 
        if (error == null) { 
         showToast("Rotation: success"); 
        } else { 
         showToast(error.getDescription()); 
        } 
       } 
      }); 
     } 
    }, 0, 200);