IOS MSDK关于V2 Action的介绍很少,swift没有,oc的只有waypoint没有action的,只好参考android的,但是一直被error code -1999困扰,附上代码,请高手指点下,我要实现的就是到航点停下拍个照再飞往下一个航点
let trigger1 = DJIWaypointV2Trigger() trigger1.actionTriggerType = .reachPoint let reachParam1 = DJIWaypointV2ReachPointTriggerParam() reachParam1.startIndex = 0 reachParam1.waypointCountToTerminate = 0 trigger1.reachPointTriggerParam = reachParam1
let actuator1 = DJIWaypointV2Actuator() actuator1.type = .aircraftControl let controlParam1 = DJIWaypointV2AircraftControlParam() controlParam1.operationType = .flyingControl controlParam1.flyControlParam.isStartFlying = false actuator1.aircraftControlActuatorParam = controlParam1
let action1 = DJIWaypointV2Action() action1.trigger = trigger1 action1.actuator = actuator1 action1.actionId = 0
let trigger2 = DJIWaypointV2Trigger() trigger2.actionTriggerType = .actionAssociated let associateParam = DJIWaypointV2AssociateTriggerParam() associateParam.actionAssociatedType = .afterFinished associateParam.waitingTime = 1 associateParam.actionIdAssociated = 0 trigger2.associateTriggerParam = associateParam
let actuator2 = DJIWaypointV2Actuator() actuator2.type = .camera let gimbalParam2 = DJIWaypointV2CameraActuatorParam() gimbalParam2.operationType = .takePhoto actuator2.cameraActuatorParam = gimbalParam2
let action2 = DJIWaypointV2Action() action2.actionId = 1 action2.trigger = trigger2 action2.actuator = actuator2
let trigger3 = DJIWaypointV2Trigger() trigger3.actionTriggerType = .actionAssociated let associateParam2 = DJIWaypointV2AssociateTriggerParam() associateParam2.actionAssociatedType = .afterFinished associateParam2.waitingTime = 0 associateParam2.actionIdAssociated = 1 trigger3.associateTriggerParam = associateParam2
let actuator3 = DJIWaypointV2Actuator() actuator3.type = .aircraftControl let controlParam3 = DJIWaypointV2AircraftControlParam() controlParam3.operationType = .flyingControl controlParam3.flyControlParam.isStartFlying = true actuator3.aircraftControlActuatorParam = controlParam3
let action3 = DJIWaypointV2Action() action3.actionId = 2 action3.trigger = trigger3 action3.actuator = actuator3
DJISDKManager.missionControl()?.waypointV2MissionOperator().uploadWaypointActions([action1,action2,action3], withCompletion: { (error) in if error != nil{ print("动作上传失败\(error)") }else{ print("动作上传成功")
} })
|