我正在尝试使用DJI Phantom 4创建一个FollowMeMission,提供自定义坐标,类似于这篇文章Custom coordinates on Follow me Mission DJI Mobile SDK for android
我当前的代码如下所示:
private double lat = 48.5561726;
private double lng = 12.1138481;
private float initHeight = 10f;
private LocationCoordinate2D location;
if (getFollowMeMissionOperator().getCurrentState().toString().equals(FollowMeMissionState.READY_TO_EXECUTE.toString())){
getFollowMeMissionOperator().updateFollowingTarget(new LocationCoordinate2D(lat + 0.0001d, lng), new CommonCallbacks.CompletionCallback() {
@Override
public void onResult(DJIError djiError) {
setResultToToast("Mission updateFollowingTarget: " + (djiError == null ? "Successfully" : djiError.getDescription()));
}
});
//Toast.makeText(getApplicationContext(), "updateFollowingTarget...", Toast.LENGTH_SHORT).show();
Log.println(Log.INFO,"FOLLOW", "Before");
try{
Thread.sleep(2500);
}catch (InterruptedException e){
setResultToToast("InterruptedException!" + e.getMessage());
}
getFollowMeMissionOperator().startMission(FollowMeMission.getInstance().initUserData(lat + 0.0001d , lng, initHeight), new CommonCallbacks.CompletionCallback() {
@Override
public void onResult(DJIError djiError) {
setResultToToast("Mission Start: " + (djiError == null ? "Successfully" : djiError.getDescription()));
}});
}
else{
Toast.makeText(getApplicationContext(), getFollowMeMissionOperator().getCurrentState().toString(), Toast.LENGTH_SHORT).show();
}
我甚至在调用startMission()之前添加了2.5秒的睡眠,如本主题所述http://forum.dev.dji.com/thread-33716-1-1.html
会发生什么,我调用FollowMe()并在2.5秒后得到消息“Mission Start:Successfull”,但没有来自updateFollowingTarget()的任何回调 . 然后没有任何事情发生,无人机停留在原地 .
我究竟做错了什么?我使用updateFollowingTarget()和startMission()的方式是否正确?
1 回答
这个问题的原因是:1 . 我们需要使用计时器以给定的频率updateFollowingTarget . 2.移动物体(跟随目标)需要提供其动态位置 .
请参考以下代码,根据您的情况对其进行优化: