大疆社区

标题: MSDK中followMe无效 [打印本页]

作者: fans9ecff0f7    时间: 2021-8-18
标题: MSDK中followMe无效
下面这个followmeMission这样写有什么问题吗,为什么精灵4 多光谱是无法执行呢,homeDroneLocation是手机的gps坐标

private FollowMeMissionOperator followMeMissionOperator;
private FollowMeMissionOperator getFollowMeMissionOperator(){
    if(followMeMissionOperator==null)
        followMeMissionOperator=DJISDKManager.getInstance().getMissionControl().getFollowMeMissionOperator();
    return followMeMissionOperator;
}
private void addFollowListener()
{
    if(getFollowMeMissionOperator()!=null) {
        getFollowMeMissionOperator().addListener(followMeMissionOperatorListener);
    }
}
private void removeFollowListener()
{
    if(getFollowMeMissionOperator()!=null){
        getFollowMeMissionOperator().removeListener(followMeMissionOperatorListener);
    }
}
private FollowMeMissionOperatorListener followMeMissionOperatorListener=new FollowMeMissionOperatorListener() {
    @Override
    public void onExecutionUpdate(@NonNull FollowMeMissionEvent followMeMissionEvent) {
        showToast(String.valueOf(followMeMissionEvent.getCurrentState()));
    }

    @Override
    public void onExecutionStart() {

    }

    @Override
    public void onExecutionFinish(@Nullable DJIError djiError) {

    }
};
private sendFollowMeDataTask sendFollowMeDataTask;//模拟油门控制使能
private Timer sendFollowMeDataTimer;//油门量控制定时器
private class sendFollowMeDataTask extends TimerTask{
    @Override
    public void run() {
        getFollowMeMissionOperator().updateFollowingTarget(new LocationCoordinate2D(GCJ2WGSUtils.WGSLat(homeDroneLocationLat,homeDroneLocationLng),GCJ2WGSUtils.WGSLon(homeDroneLocationLat,homeDroneLocationLng)), new CommonCallbacks.CompletionCallback() {
            @Override
            public void onResult(DJIError error) {
                if(error!=null)
                    showToast(error.getDescription());
            }
        });
    }
}
private void startFollowMeMission()
{
    getFollowMeMissionOperator().startMission(new FollowMeMission(FollowMeHeading.TOWARD_FOLLOW_POSITION,GCJ2WGSUtils.WGSLat(homeDroneLocationLat,homeDroneLocationLng),GCJ2WGSUtils.WGSLon(homeDroneLocationLat,homeDroneLocationLng),10), new CommonCallbacks.CompletionCallback() {
        @Override
        public void onResult(DJIError error) {
            if(error!=null)
                showToast(error.getDescription());
        }
    });
    if(null==sendFollowMeDataTimer)
    {
        sendFollowMeDataTask = new sendFollowMeDataTask();
        sendFollowMeDataTimer = new Timer();
        //TODO 模拟遥控发送频率
        sendFollowMeDataTimer.schedule(sendFollowMeDataTask, 0,100L);
    }
}
private void stopFollowMeMission()
{
    getFollowMeMissionOperator().stopMission(new CommonCallbacks.CompletionCallback() {
        @Override
        public void onResult(DJIError error) {

        }
    });
}





欢迎光临 大疆社区 (https://bbs.dji.com/) Powered by Discuz! X3.2