Objective-C последовательно выполняет два блока завершения - PullRequest
0 голосов
/ 25 мая 2018

В настоящее время я работаю над тем, чтобы дать продукту 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");
    }
}];

Для того, чтобы второй успешно работал, первый должен сначала исполниться полностью.может показаться сложной проблемой, но я не смог разобраться после попытки добавить задержки или отправки.

Любая помощь приветствуется. Спасибо.

Ответы [ 2 ]

0 голосов
/ 01 сентября 2018

Ваш код выглядит правильно.Я столкнулся с той же проблемой, когда после завершения загрузки моей миссии значение 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).
 */

Надеюсь, это кому-нибудь поможет.

0 голосов
/ 25 мая 2018

С версия 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");
            }
        }];
    }
}];
...