我正在尝试通过向平板电脑发送车辆的FollowMe数据包来创建一个自定义的UDP任务。发送是可行的,但是一开始我没有从updateFollowingTarget方法得到任何反馈,然后出现了超时错误。通常,此方法中出现超时的时间是什么时候?我做错了什么?
我使用的是DJI SDK 4.4.1、Phantom 4和三星Galaxy Tab A1 (2016)平板电脑。
private AtomicBoolean isRunning = new AtomicBoolean(false);
private Subscription timerSubscription;
private Observable<Long> timer = Observable.interval(1500, TimeUnit.MILLISECONDS);
private volatile Location mLastLocation = new Location("");
public void startFollowMeMission() {
float height = (float) KeyManager.getInstance().getValue(FlightControllerKey.create(FlightControllerKey.ALTITUDE));
try {
udpSocket = new DatagramSocket(4445);
} catch (SocketException e) {
Log.e(TAG, "SocketException: " + e.getCause());
}
new Thread (new ReceiveLocationUDP()).start();
if (getFollowMeMissionOperator().getCurrentState() == FollowMeMissionState.READY_TO_EXECUTE) {
getFollowMeMissionOperator().startMission(FollowMeMission.getInstance().initUserData(mLastLocation.getLatitude(), mLastLocation.getLongitude(), height), new CommonCallbacks.CompletionCallback() {
@Override
public void onResult(DJIError error) {
if (error == null) {
setResultToToast("Start mission: Success");
Log.e(TAG, "Start mission: Success");
} else {
setResultToToast("Start mission Error: " + error.getDescription());
Log.e(TAG, "Start mission Error: " + error.getDescription());
}
}
});
} else {
setResultToToast("Unable to start mission: Current State not READY_TO_EXECUTE");
Log.e(TAG, "Unable to start mission: Current State not READY_TO_EXECUTE, but " + getFollowMeMissionOperator().getCurrentState());
}
if (!isRunning.get()) {
isRunning.set(true);
timerSubscription = timer.subscribe(new Action1<Long>() {
@Override
public void call(Long aLong) {
Log.i(TAG, "Current device Latitude: " + mLastLocation.getLatitude() + ", Longitude: " + mLastLocation.getLongitude());
if (getFollowMeMissionOperator().getCurrentState() == FollowMeMissionState.EXECUTING) {
if (mLastLocation != null) {
getFollowMeMissionOperator().updateFollowingTarget(new LocationCoordinate2D(mLastLocation.getLatitude(), mLastLocation.getLongitude()), new CommonCallbacks.CompletionCallback() {
@Override
public void onResult(DJIError error) {
if (error == null) {
Log.i(TAG, "updateFollowingTarget: Success");
isRunning.set(false);
} else {
Log.e(TAG, "updateFollowingTarget failed: " + error.getDescription());
unsubscribeTimer();
}
}
});
} else {
Log.e(TAG, "mLastLocation = null !");
unsubscribeTimer();
}
} else {
setResultToToast("FollowMeMission Error: Current State not EXECUTING!");
Log.e(TAG, "FollowMeMission Error: Current State not EXECUTING!");
unsubscribeTimer();
}
}
});
}
}这里是logcat:
02-19 19:23:52.593 27666-27666/com.dji.GSDemo.GoogleMap I/GSDemoActivity: drone lat: 48.0771599999998 lon: 11.639039999998538 mLastLocation lat: 48.07651 lon: 11.63564
02-19 19:23:52.711 27666-28211/com.dji.GSDemo.GoogleMap E/GSDemoActivity: Start mission: Success
02-19 19:23:52.735 2410-2410/? I/SurfaceFlinger: id=224 createSurf (1x1),1 flag=4, Toast
02-19 19:23:54.113 27666-28281/com.dji.GSDemo.GoogleMap I/GSDemoActivity: Current device Latitude: 48.07659, Longitude: 11.63569
02-19 19:23:55.252 2890-2952/? I/WindowManager_SurfaceController: Destroying surface Surface(name=Toast) called by com.android.server.wm.WindowStateAnimator.destroySurface:3070 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:1138 com.android.server.wm.WindowState.destroyOrSaveSurface:2799 com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementInner:509 com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop:284 com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement:232 com.android.server.wm.WindowManagerService$H.handleMessage:9581 android.os.Handler.dispatchMessage:102
02-19 19:23:55.252 2410-3074/? I/SurfaceFlinger: id=224 Removed Toast (5/5)
02-19 19:23:55.252 2410-2415/? I/SurfaceFlinger: id=224 Removed Toast (-2/5)
02-19 19:23:55.612 27666-28281/com.dji.GSDemo.GoogleMap I/GSDemoActivity: Current device Latitude: 48.07668, Longitude: 11.63576
02-19 19:23:56.495 2890-2890/? I/DeviceStorageMonitorService: Posting Message again
02-19 19:23:57.112 27666-28281/com.dji.GSDemo.GoogleMap I/GSDemoActivity: Current device Latitude: 48.07677, Longitude: 11.63582
02-19 19:23:57.117 27666-28206/com.dji.GSDemo.GoogleMap E/GSDemoActivity: updateFollowingTarget failed: Execution of this process has timed out
02-19 19:23:57.117 27666-28206/com.dji.GSDemo.GoogleMap I/GSDemoActivity: Unsubscribed Timer
02-19 19:23:58.614 27666-28211/com.dji.GSDemo.GoogleMap E/GSDemoActivity: updateFollowingTarget failed: Execution of this process has timed out
02-19 19:23:58.640 2890-3518/? E/Watchdog: !@Sync 476 [2018-02-19 19:23:58.639]
02-19 19:23:59.627 27666-27677/com.dji.GSDemo.GoogleMap I/art: Background partial concurrent mark sweep GC freed 133981(8MB) AllocSpace objects, 215(7MB) LOS objects, 31% free, 34MB/50MB, paused 2.631ms total 124.889ms
02-19 19:24:00.114 27666-28186/com.dji.GSDemo.GoogleMap E/GSDemoActivity: updateFollowingTarget failed: Execution of this process has timed out发布于 2018-07-16 15:17:39
我想我通过将updateFollowingTarget()代码块打包到startMission()的onResult()回调中修复了这个问题。
发布于 2018-03-06 19:34:47
我不能给你一个解决方案,因为我这里有同样的超时问题,DJI的SDK-reference说,如果没有GPS数据更新超过sic秒,aircaft将开始在位置上悬停。
我试了很多,一秒钟更新位置10次,每秒,...没有一件事像我预期的那样对我起作用。
https://stackoverflow.com/questions/48872247
复制相似问题