0

我目前正在使 DJI 产品能够自主执行航点任务,改编自 DJI 教程 ( https://developer.dji.com/mobile-sdk/documentation/ios-tutorials/GSDemo.html )。所以我试图将所有流程整合到一个功能中。这是我必须集成的两个完成块:

[[self missionOperator] uploadMissionWithCompletion:^(NSError * _Nullable error) {
    if (error){
        ShowMessage(@"Upload Mission failed", error.description, @"", nil, @"OK");
    }else {
        ShowMessage(@"Upload Mission Finished", @"", @"", nil, @"OK");
    }
}];

和:

[[self missionOperator] startMissionWithCompletion:^(NSError * _Nullable error) {
    if (error){
        ShowMessage(@"Start Mission Failed", error.description, @"", nil, @"OK");
    }else
    {
        ShowMessage(@"Mission Started", @"", @"", nil, @"OK");
    }
}];

为了使第二个成功运行,第一个必须首先完全执行。这似乎不是一个难题,但在尝试添加延迟或调度后我无法弄清楚。

任何帮助表示赞赏。谢谢。

4

2 回答 2

1

您链接的文档的 iOS 版本中,文档-[DJIWaypointMissionOperator uploadMissionWithCompletion:]说:

如果启动成功,用于addListenerToUploadEvent:withQueue:andBlock接收详细进度。

所以,你会做这样的事情:

[[self missionOperator] uploadMissionWithCompletion:^(NSError * _Nullable error) {
    if (error)
    {
        ShowMessage(@"Upload Mission failed", error.description, @"", nil, @"OK");
    }
    else
    {
        ShowMessage(@"Upload Mission Started", @"", @"", nil, @"OK");

        [[self missionOperator] addListenerToUploadEvent:self
                                               withQueue:nil
                                                andBlock:^(DJIWaypointMissionUploadEvent *event){
            if (event.currentState == DJIWaypointMissionStateReadyToExecute)
            {
                [[self missionOperator] startMissionWithCompletion:^(NSError * _Nullable error) {
                    if (error)
                    {
                        ShowMessage(@"Start Mission Failed", error.description, @"", nil, @"OK");
                    }
                    else
                    {
                        ShowMessage(@"Mission Started", @"", @"", nil, @"OK");
                    }
                }];
            }
            else if (event.error)
            {
                ShowMessage(@"Upload Mission failed", event.error.description, @"", nil, @"OK");
            }
        }];
    }
}];
于 2018-05-25T20:00:02.983 回答
0

您的代码看起来正确。我遇到了同样的问题,在我的任务完成上传后,我的任务操作员currentState将恢复为DJIWaypointMissionStateReadyToUpload而不是DJIWaypointMissionStateReadyToExecute. cornerRadiusInMeters该任务已通过有效性检查,但实际上由于个别航路点(属性)上的无效曲线要求而无效。

从文档中:

/**
 *  Corner radius of the waypoint. When the flight path mode  is
 *  `DJIWaypointMissionFlightPathCurved` the flight path near a waypoint will be  a
 *  curve (rounded corner) with radius [0.2,1000]. When there is a corner radius,
 *  the aircraft will never  go through the waypoint. By default, the radius is 0.2
 *  m. If the corner is made of three adjacent waypoints (Short for A,B,C)  . Then
 *  the radius of A(short for Ra) plus radius of B(short for Rb) must be smaller
 *  than the distance between  A and B. The radius of the first and the last
 *  waypoint in a mission does not affect the flight path and it should keep the
 *  default value (0.2m).
 */

希望这可以帮助某人。

于 2018-09-01T20:11:33.787 回答