Вставьте логику в DJI Mobile SDK Timeline Mission - PullRequest
0 голосов
/ 09 октября 2019

Я пока безуспешно пытаюсь адаптировать пример TimeLine Mission Objective-C для iOS в DJI Mobile SDK для моего случая использования. В частности, я хотел бы:

  1. Запланировать набор начальных действий на временной шкале (я могу успешно это сделать)
  2. Запустить временную шкалу (я могу успешно сделать это)
  3. Выполнение вызова на внешний URL-адрес (я могу успешно это сделать)
  4. На основе этого результата с внешнего URL-адреса добавьте новое действие в расписание временной шкалы
    [DJIHotpointMissionOperator getMaxAngularVelocityForRadius:radius withCompletion:^(float angularVelocity, NSError * _Nullable error) {
        addTakeOffAction();

        if (!error) {
            addHotpointAction(radius, angularVelocity);
        }

        addShootPhotoAction();
        addRecordVideoAction();
        addWaypointMission();
        addGoToAction();
        addGimbalAttitudeAction(20,20,20);
        addShootPhotoAction();
        addStopRecordVideoAction();
        addGoHomeAction();

        if (completion) {
            completion();
        }
    }];
}

- (IBAction)onPrepareButtonClicked:(id)sender
{
    WeakRef(target);
    [self initializeActionsWithCompletion:^{
        NSError *error = [[DJISDKManager missionControl] scheduleElements:target.actions];
        if (error) {
            ShowResult(@"Schedule Timeline Actions Failed:%@", error.description);
        } else {
            ShowResult(@"Actions schedule succeed!");
        }
    }];
}

- (IBAction)onStartButtonClicked:(id)sender
{

    [[DJISDKManager missionControl] addListener:self
                    toTimelineProgressWithBlock:^(DJIMissionControlTimelineEvent event, id<DJIMissionControlTimelineElement>  _Nullable element, NSError * _Nullable error, id  _Nullable info)
     {
         NSMutableString *statusStr = [NSMutableString new];
         [statusStr appendFormat:@"Current Event:%@\n", [[self class] timelineEventString:event]];
         [statusStr appendFormat:@"Element:%@\n", [element description]];
         [statusStr appendFormat:@"Info:%@\n", info];
         if (error) {
             [statusStr appendFormat:@"Error:%@\n", error.description];
         }
         self.statusLabel.text = statusStr;
         if (error) {
            [[DJISDKManager missionControl] stopTimeline];
             [[DJISDKManager missionControl] unscheduleEverything];
         }
     }];

    [[DJISDKManager missionControl] startTimeline];

    // Make call to external URL (for example)
    // result = http://myresult.com

    // Schedule action to end of timeline
    // DJIGoToAction* gotoAction = [[DJIGoToAction alloc] initWithCoordinate:CLLocationCoordinate2DMake(target.homeLocation.latitude + 40 * ONE_METER_OFFSET, target.homeLocation.longitude + 50 * ONE_METER_OFFSET) altitude:40.0];
    // [[DJISDKManager missionControl] scheduleElement: gotoAction];
}
...