DJI Mobile SDK为开发者提供了丰富的API接口,可以供用户按自身需求开发出不同的移动应用软件。根据移动设备平台的不同,Mobile SDK又主要分为IOS SDK与Android SDK,此文主要就Android SDK进行讨论,内容来源于DJI官网。
一:SDK架构
官方给出架构图如下所示:
图 DJI Mobile SDK 架构图
由上述架构图可以看出,Mobile SDK 主要包含5部分,其主要功能概述依据大疆官网给出的如下:
SDK Manager: Manages registration of the SDK, product connection and provides access to the product itself.
Product: The aircraft or handheld product, this class holds basic product properties and contains the main product components.
Component: Component classes describe the gimbal, camera, flight controller, remote controller and wireless link. The classes provide component control, state information and contain subcomponents.
Mission: Classes that describe different missions such as Waypoint and ActiveTrack missions and hold their setup properties and status.
Mission Control: Mission Control handles execution of missions. Either single missions can be run through dedicated mission operators, or a series of missions and actions can be run serially using the Timeline.
更为具体的SDK类描述如下:
图 组件详细描述
图 任务详细描述
二:SDK 任务介绍
2.1 Waypoint Mission
官方概述如下:A waypoint mission is a series of pre-defined locations (waypoints) the aircraft will fly to. A location is a latitude, longitude and altitude. Aircraft heading and altitude between waypoints can change either gradually or at the waypoint itself. A series of actions (such as take photo) can be executed at each waypoint.
依据官方介绍,waypoint mission可直接编辑航点使无人机按规划路线从一个航点向另一个航点进行飞行,在飞行过程中可以进行拍照,视频录制等工作。但最多航点数不超过99个。官方给出示意图如下图所示:
图 waypoint mission 示意图
2.2 Hot Point Mission
官方概述如下:In a Hot Point Mission, the aircraft will repeatedly fly circles of a constant radius around a specified point called a Hot Point. Altitude, velocity, the Hot Point location, aircraft heading and flight direction can all be defined as part of the mission.Altitude, heading and radius can also be adjusted manually using the remote controller control sticks during the mission.
依据官方介绍,Hot Point Mission功能让无人机按照提前设置好的环绕半径绕 “热点”进行飞行。在任务进行中可以控制其环绕的高度和飞机朝向等的设置。其示意图如下:
图 Hot Point Mission
2.3 Follow Me Mission
官方概述如下:In a Follow Me Mission, the aircraft will follow GPS coordinates continually sent to the aircraft maintaining separation and a constant altitude.The aircraft will hover in place if it hasn’t received a new GPS coordinate for more than 6 seconds.
依据官方介绍,该任务模式下无人机将按物体分享的GPS信息实时的对物体进行跟踪。任务示意图如下:
图 Follow Me Mission 示意图
2.4 ActiveTrack Mission
官方概述如下:The ActiveTrack Mission allows an aircraft to track a moving subject using the vision system and without a GPS tracker on the subject.
依据官方介绍,该任务模式可以利用无人机自身的视觉系统对指定物体进行跟踪拍摄。该任务模式示意图如下:
图 ActiveTrack Mission 示意图
2.5 TapFly Mission
官方概述如下:The TapFly mission flies the aircraft in the direction of a point on the live video stream that the user chooses. The mission is initialized with a position target from the live video stream. The 3D direction of the coordinate is calculated, and the aircraft proceeds to fly in that direction.
该模式下,用户在给出一个具体位置的经纬度,以及高度信息后,无人机便可以自动飞行前往。带有自主避障系统的无人机将在飞行途中自动躲避障碍物。
图 TapFly mission 示意图
2.6 Panorama Mission
官方概述如下:The Panorama Mission rotates the camera 180 or 360 degrees while taking photos which can then be downloaded to render a panorama. In full circle mode, 8 photos are taken. In half circle mode, 5 photos are taken. Other commands cannot be sent to the camera until the mission is finished. The Panorama Mission does not support the image stitching feature, so the images must be stitched manually. All the images will be stored on the SD card.
该任务模式下,用户可以针对区域进行全景的拍摄。
三:SDK 详细介绍
3.1 SDK 类的分类
在Mobile Android SDK中包含有 Manager Class、Base Class、Product Class、Component Class、Mission Class、MSC Class等6个大类。其中每个大类下包含许多子类,分别进行相应的管理操作。
3.1.1 Manager Class
Manager Class类下设的子类包含如下:DJISDKManager、KeyManager、FlyZoneManager、AppActivationManager、UserAccountManager、DataProtectionManager、LDMManager、FlightHubManager。分别可以用于对SDK、App密匙以及用户账号等一系列的管理。
3.1.2 Base Class
Base Class类下包含BaseProduct、BaseComponent两个子类,分别是产品买描述类与组件类的基类。
3.1.3 product Class
产品类包含有Aircraft、HandHeld两个子类,分别用于描述无人机与手持云台设备。
3.1.4 Component Classes
组件类包含以下子类FlightController、Battery、Camera、Gimbal、AirLink、RemoteController、HandheldController、MobileRemoteController、Payload。
3.1.5 Mission Classes
Mission Classes主要包含以下类:MissionControl 、MissionAction 、TimelineMission 、Trigger 、WaypointMissionOperator 、FollowMeMissionOperator、
PanoramaMissionOperator、 HotpointMissionOperator 、TapFlyMissionOperator、 ActiveTrackOperator。用于对各个任务进行管理。
3.1.6 Misc Classes
Misc Classes 主要包含以下类:CommonCallbacks、 DJIParamCapability、DJIError 、DJIDiagnostics 、DJICodecManager。
3.2 Component Class 中的常用组件类介绍
加粗字体对应一级子类、不加粗字体为其二级子类(包含在对应一级子类中)
3.2.1 FlightController
FlightControllerState
Attitude
LocationCoordinate3D
GoHomeAssessment
Compass
RTK
RTKState
ReceiverInfo
LandingGear
Intelligent Flight Assistant
VisionDetectionState
Detection Sector
Detection State
Smart Capture State
Simulator
InitializationData
SimulatorState
IMUState
MultipleOrientationCalibrationHint
FlightControlData
LocationCoordinate2D
AirSenseSystemInformation
AirSenseAirplaneState
Limits
上述类及类中的方法可以供开发者获取当前飞机的飞行姿态,GPS信息等,还可以通过控制俯仰、偏航以及旋转角控制飞机的飞行等。详细参考官方API。地址如下:https://developer.dji.com/api-reference/android-api/Components/FlightController/DJIFlightController_DJIVirtualStickFlightControlData.html
3.2.3 Camera
SystemState
FocusState
StorageState
SSDState
MediaManager
MediaFile
VideoPlaybackState
FetchMediaTaskScheduler
FetchMediaTask
PlaybackManager
PlaybackState
Capabilities
SettingsDefinitions
ExposureSettings
OpticalZoomSpec
PhotoTimeIntervalSettings
ThermalProfile
ThermalAreaTemperatureAggregations
ThermalExternalSceneSettings
WhiteBalance
SSDClipFileName
FocusAssistantSettings
PhotoTimeLapseSettings
ResolutionAndFrameRate
PictureStylePreset
CameraLiveView
ColorWaveformSettings
StabilizationState
上述类及类中的方法可以供开发者获取以及设置相机的基本参数。
3.2.3 Gimbal
GimbalState
MovementSettings
Attitude
Rotation
Builder
上述类及类中的方法可以供开发者控制云台相对无人机的俯仰、偏航以及旋转角等,还可以设置云台转动速度等参数。