首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >大疆Android-SDK: updateFollowingTarget超时

大疆Android-SDK: updateFollowingTarget超时
EN

Stack Overflow用户
提问于 2018-02-20 02:35:10
回答 2查看 307关注 0票数 0

我正在尝试通过向平板电脑发送车辆的FollowMe数据包来创建一个自定义的UDP任务。发送是可行的,但是一开始我没有从updateFollowingTarget方法得到任何反馈,然后出现了超时错误。通常,此方法中出现超时的时间是什么时候?我做错了什么?

我使用的是DJI SDK 4.4.1、Phantom 4和三星Galaxy Tab A1 (2016)平板电脑。

代码语言:javascript
复制
 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:

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-07-16 15:17:39

我想我通过将updateFollowingTarget()代码块打包到startMission()的onResult()回调中修复了这个问题。

票数 0
EN

Stack Overflow用户

发布于 2018-03-06 19:34:47

我不能给你一个解决方案,因为我这里有同样的超时问题,DJI的SDK-reference说,如果没有GPS数据更新超过sic秒,aircaft将开始在位置上悬停。

我试了很多,一秒钟更新位置10次,每秒,...没有一件事像我预期的那样对我起作用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48872247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档