18 KiB
飞行控制
端点: /flight
- 方法:
GET&SET - 描述: 飞行控制
请求
起飞请求
{
"action": 0
}
强制降落
{
"action": "1"
}
其余action请求数字代号:
返航:2
取消返航:3
着陆:4
取消着陆:5
确认着陆:6
设置返航点:7 (以飞行器当前位置为返航点)
电机急停:8
开启电机:9
关闭电机:10
飞行拦截:11
取消悬停:12
紧急悬停:13
取消紧急悬停:14
执行遥控器操作:15
若需要执行遥控器操作,其指令格式为:
{
"action": 15,
"direction": "q\w\e\a\s\d\z\c"
}
数据订阅
端点:/subscription
- 方法:
GET - 描述: 订阅或退订无人机实时数据
请求和响应
请求
{
"action": 1,
"topic": 2,
"hertz": 50
}
action取值:
1 - subscribe
2 - unsubscribe
topic取值:
0 - QUATERNION,姿态四元数
1 - ACCELERATION_GROUND,相对地面加速度
2 - ACCELERATION_BODY,相对机体加速度
3 - ACCELERATION_RAW,原始加速度
4 - VELOCITY,速度
5 - ANGULAR_RATE_FUSIONED,融合角速度
6 - ANGULAR_RATE_RAW,原始角速度
7 - ALTITUDE_FUSED,融合高度
8 - ALTITUDE_BAROMETER,气压计高度
9 - ALTITUDE_OF_HOMEPOINT,Home点高度
10 - HEIGHT_FUSION, 融合相对地面高度
11 - HEIGHT_RELATIVE, 相对地面高度
12 - POSITION_FUSED, 融合位置坐标
13 - GPS_DATE, GPS 日期(年月日)
14 - GPS_TIME, GPS 时间(时分秒)
15 - GPS_POSITION, GPS 位置
16 - GPS_VELOCITY, GPS 速度
17 - GPS_DETAILS, GPS 信息
18 - GPS_SIGNAL_LEVEL, GPS 信号强度
19 - RTK_POSITION, RTK 位置
20 - RTK_VELOCITY, RTK 速度
21 - RTK_YAW, RTK 航向角
22 - RTK_POSITION_INFO, RTK 位置信息
23 - RTK_YAW_INFO, RTK 航向信息
24 - COMPASS, 指南针信息
25 - RC, 遥控摇杆信息
26 - GIMBAL_ANGLES, 云台角度
27 - GIMBAL_STATUS, 云台状态
28 - STATUS_FLIGHT, 飞行状态
29 - STATUS_DISPLAYMODE, 飞行模式状态
30 - STATUS_LANDINGGEAR, 起落架状态
31 - STATUS_MOTOR_START_ERROR, 电机启动错误码
32 - BATTERY_INFO, 电池信息
33 - CONTROL_DEVICE, 设备控制信息
34 - HARD_SYNC, 硬件时钟同步
35 - GPS_CONTROL_LEVEL, GPS 控制等级
36 - RC_WITH_FLAG_DATA, 带标记遥控遥感信息
37 - ESC_DATA, 电调数据
38 - RTK_CONNECT_STATUS, RTK 连接状态
39 - GIMBAL_CONTROL_MODE, 云台控制模式
40 - FLIGHT_ANOMALY, 飞行异常信息
41 - POSITION_VO, 笛卡尔坐标位置
42 - AVOID_DATA, 避障数据
43 - HOME_POINT_SET_STATUS, 返航点设置状态
44 - HOME_POINT_INFO, 返航点信息
45 - THREE_GIMBAL_DATA, 三云台信息(适用M300 RTK与M350 RTK,上下三个云台的信息)
46 - BATTERY_SINGLE_INFO_INDEX1, 1 号电池信息
47 - BATTERY_SINGLE_INFO_INDEX2, 2 号电池信息
hertz取值:
1 - DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ
5 - DJI_DATA_SUBSCRIPTION_TOPIC_5_HZ
10 - DJI_DATA_SUBSCRIPTION_TOPIC_10_HZ
50 - DJI_DATA_SUBSCRIPTION_TOPIC_50_HZ
100 - DJI_DATA_SUBSCRIPTION_TOPIC_100_HZ
200 - DJI_DATA_SUBSCRIPTION_TOPIC_200_HZ
400 - DJI_DATA_SUBSCRIPTION_TOPIC_400_HZ
其中每个topic针对不同机型允许的最大频率请参考大疆官方文档
响应
{
"status": 0,
"description": "description for this response"
}
推送的订阅数据
订阅数据为json格式,其中每个字段的含义,请参考大疆官方文档。
QUATERNION:
{
"topic": 0,
"q0": 3.14,
"q1": 3.21,
"q2": 3.21,
"q3": 3.33,
"pitch": 4.44,
"roll": 5.44,
"yaw": 6.33,
"ms": 100000,
"us": 33339999
}
ACCELERATION_GROUND:
{
"topic": 1,
"x": 3.14,
"y": 3.21,
"z": 3.33,
"ms": 100000,
"us": 33339999
}
ACCELERATION_BODY:
{
"topic": 2,
"x": 3.14,
"y": 3.21,
"z": 3.33,
"ms": 100000,
"us": 33339999
}
ACCELERATION_RAW:
{
"topic": 3,
"x": 3.14,
"y": 3.21,
"z": 3.33,
"ms": 100000,
"us": 33339999
}
VELOCITY:
{
"topic": 4,
"x": 3.14,
"y": 3.21,
"z": 3.33,
"ms": 100000,
"us": 33339999
}
ANGULAR_RATE_FUSIONED:
{
"topic": 5,
"x": 3.14,
"y": 3.21,
"z": 3.33,
"ms": 100000,
"us": 33339999
}
ANGULAR_RATE_RAW:
{
"topic": 6,
"x": 3.14,
"y": 3.21,
"z": 3.33,
"ms": 100000,
"us": 33339999
}
ALTITUDE_FUSED:
{
"topic": 7,
"val": 3.14,
"ms": 100000,
"us": 33339999
}
ALTITUDE_BAROMETER:
{
"topic": 8,
"val": 3.14,
"ms": 100000,
"us": 33339999
}
ALTITUDE_OF_HOMEPOINT:
{
"topic": 9,
"val": 3.14,
"ms": 100000,
"us": 33339999
}
HEIGHT_FUSION:
{
"topic": 10,
"val": 3.14,
"ms": 100000,
"us": 33339999
}
HEIGHT_RELATIVE:
{
"topic": 11,
"val": 3.14,
"ms": 100000,
"us": 33339999
}
POSITION_FUSED:
{
"topic": 12,
"longitude": 3.14,
"latitude": 3.14,
"altitude": 3.14,
"visibleSatelliteNumber": 3,
"ms": 100000,
"us": 33339999
}
GPS_DATE:
{
"topic": 13,
"val": 3000000,
"ms": 100000,
"us": 33339999
}
GPS_TIME:
{
"topic": 14,
"val": 3000000,
"ms": 100000,
"us": 33339999
}
GPS_POSITION:
{
"topic": 15,
"x": 14,
"y": 21,
"z": 33,
"ms": 100000,
"us": 33339999
}
GPS_VELOCITY:
{
"topic": 16,
"x": 3.14,
"y": 3.21,
"z": 3.33,
"ms": 100000,
"us": 33339999
}
GPS_DETAILS:
{
"topic": 17,
"hdop": 3.14,
"pdop": 3.21,
"fixState": 3.33,
"vacc": 3.33,
"hacc": 3.33,
"sacc": 3.33,
"gpsSatelliteNumberUsed": 33,
"glonassSatelliteNumberUsed": 33,
"totalSatelliteNumberUsed": 33,
"gpsCounter": 33,
"ms": 100000,
"us": 33339999
}
GPS_SIGNAL_LEVEL:
{
"topic": 18,
"val": 3000000,
"ms": 100000,
"us": 33339999
}
RTK_POSITION:
{
"topic": 19,
"longitude": 3.14,
"latitude": 3.21,
"hfsl": 3.33,
"ms": 100000,
"us": 33339999
}
RTK_VELOCITY:
{
"topic": 20,
"x": 3.14,
"y": 3.21,
"z": 3.33,
"ms": 100000,
"us": 33339999
}
RTK_YAW:
{
"topic": 21,
"val": 3000000,
"ms": 100000,
"us": 33339999
}
RTK_POSITION_INFO:
{
"topic": 22,
"val": 3000000,
"ms": 100000,
"us": 33339999
}
RTK_YAW_INFO:
{
"topic": 23,
"val": 3000000,
"ms": 100000,
"us": 33339999
}
COMPASS:
{
"topic": 24,
"x": 14,
"y": 21,
"z": 33,
"ms": 100000,
"us": 33339999
}
RC:
{
"topic": 25,
"roll": 14,
"pitch": 21,
"yaw": 33,
"throttle": 33,
"mode": 33,
"gear": 33,
"ms": 100000,
"us": 33339999
}
GIMBAL_ANGLES:
{
"topic": 26,
"x": 14.99,
"y": 21.12,
"z": 33.22,
"ms": 100000,
"us": 33339999
}
GIMBAL_STATUS:
{
"topic": 27,
"mountStatus": 14,
"isBusy": 21,
"pitchLimited": 33,
"rollLimited": 33,
"yawLimited": 33,
"calibrating": 33,
"prevCalibrationgResult": 14,
"installedDirection": 21,
"disabled_mvo": 33,
"gear_show_unable": 33,
"gyroFalut": 33,
"escPitchStatus": 33,
"escRollStatus": 14,
"escYawStatus": 21,
"droneDataRecv": 33,
"initUnfinished": 33,
"FWUpdating": 33,
"reserved2": 33,
"ms": 100000,
"us": 33339999
}
STATUS_FLIGHT:
{
"topic": 28,
"val": 3000000,
"ms": 100000,
"us": 33339999
}
STATUS_DISPLAYMODE:
{
"topic": 29,
"val": 3000000,
"ms": 100000,
"us": 33339999
}
STATUS_LANDINGGEAR:
{
"topic": 30,
"val": 3000000,
"ms": 100000,
"us": 33339999
}
STATUS_MOTOR_START_ERROR:
{
"topic": 31,
"val": 3000000,
"ms": 100000,
"us": 33339999
}
BATTERY_INFO:
{
"topic": 32,
"capacity": 3000000,
"voltage": 3000000,
"current": 3000000,
"percentage": 3000000,
"ms": 100000,
"us": 33339999
}
CONTROL_DEVICE:
{
"topic": 33,
"controlAuthority": 31,
"controlAuthorityChangeReason": 30,
"ms": 100000,
"us": 33339999
}
HARD_SYNC:
{
"topic": 34,
"ts": {
"time2p5ms": 3333333,
"time1ns": 2222,
"resetTime2p5ms": 44444,
"index": 22,
"flag": 22
},
"q": {
"q0": 22.22,
"q1": 33.33,
"q2": 33.33,
"q3": 44.44
},
"a": {
"x": 22.22,
"y": 33.33,
"z": 33.44
},
"w": {
"x": 22.22,
"y": 33.33,
"z": 33.44
},
"ms": 100000,
"us": 33339999
}
GPS_CONTROL_LEVEL:
{
"topic": 35,
"val": 3,
"ms": 100000,
"us": 33339999
}
RC_WITH_FLAG_DATA:
{
"topic": 36,
"roll": 14.21,
"pitch": 21.14,
"yaw": 33.33,
"throttle": 33.44,
"flag": {
"logicConnected": 1,
"skyConnected": 2,
"groundConnected": 2,
"appConnected": 1,
"reserved": 1
},
"ms": 100000,
"us": 33339999
}
ESC_DATA:
{
"topic": 37,
"esc": [
{
"current": 18,
"speed": 100,
"voltage": 200,
"temperature": 30,
"stall": 24,
"empty": 2,
"unbalanced": 1,
"escDisconnected": 2,
"temperatureHigh": 1,
"reserved": 0
},
......数组大小为8
{
"current": 18,
"speed": 100,
"voltage": 200,
"temperature": 30,
"stall": 24,
"empty": 2,
"unbalanced": 1,
"escDisconnected": 2,
"temperatureHigh": 1,
"reserved": 0
}
],
"ms": 100000,
"us": 33339999
}
RTK_CONNECT_STATUS:
{
"topic": 38,
"val": 3,
"ms": 100000,
"us": 33339999
}
GIMBAL_CONTROL_MODE:
{
"topic": 39,
"val": 3,
"ms": 100000,
"us": 33339999
}
FLIGHT_ANOMALY:
{
"topic": 40,
"impactInAir": 3,
"randomFly": 3,
"heightCtrlFail": 3,
"rollPitchCtrlFail": 3,
"yawCtrlFail": 3,
"aircraftIsFalling": 3,
"strongWindLevel1": 3,
"strongWindLevel2": 3,
"compassInstallationError": 3,
"imuInstallationError": 3,
"escTemperatureHigh": 3,
"atLeastOneEscDisconnected": 3,
"gpsYawError": 3,
"reserved": 3,
"ms": 100000,
"us": 33339999
}
POSITION_VO:
{
"topic": 41,
"x": 3.6,
"y": 5.3,
"z": 3.9,
"xHealth": 1,
"yHealth": 1,
"zHealth": 1,
"reserved": 0,
"ms": 100000,
"us": 33339999
}
AVOID_DATA:
{
"topic": 42,
"down": 3.6,
"front": 5.3,
"right": 3.9,
"left": 6.3,
"up": 7.3,
"downHealth": 3,
"frontHealth": 3,
"rightHealth": 3,
"backHealth": 3,
"leftHealth": 3,
"upHealth": 3,
"reserved": 3,
"ms": 100000,
"us": 33339999
}
HOME_POINT_SET_STATUS:
{
"topic": 43,
"val": 3000000,
"ms": 100000,
"us": 33339999
}
HOME_POINT_INFO:
{
"topic": 44,
"latitude": 30.22,
"longitude": 30.33,
"ms": 100000,
"us": 33339999
}
THREE_GIMBAL_DATA:
{
"topic": 45,
"anglesData": [
{
"roll": 18.22,
"pitch": 10.05,
"yaw": 20.07,
},
{
"roll": 18.22,
"pitch": 10.05,
"yaw": 20.07,
},
{
"roll": 18.22,
"pitch": 10.05,
"yaw": 20.07,
}
],
"ms": 100000,
"us": 33339999
}
BATTERY_SINGLE_INFO_INDEX1:
{
"topic": 46,
"reserve": 0,
"batteryIndex": 1,
"currentVoltage": 10,
"currentElectric": 20,
"fullCapacity": 100,
"remainedCapacity": 80,
"batteryTemperature": 40,
"cellCount": 10,
"batteryCapacityPercent": 50,
"batteryState": {
"reserved": 1,
"cellBreak": 2,
"selfCheckError": 12,
"reserved1": 1,
"batteryClosedReason": 0,
"reserved2": 1,
"batSOHState": 12,
"maxCycleLimit": 20,
"reserved3": 1,
"lessBattery": 12,
"batteryCommunicationAbnormal": 1,
"reserved4": 1,
"hasCellBreak": 1,
"reserved5": 2,
"isBatteryEmbed": 1,
"heatState": 2,
"socState": 1
},
"reserve1": 1,
"reserve2": 0,
"SOP": 1,
"ms": 100000,
"us": 33339999
}
BATTERY_SINGLE_INFO_INDEX2:
{
"topic": 47,
"reserve": 0,
"batteryIndex": 2,
"currentVoltage": 10,
"currentElectric": 20,
"fullCapacity": 100,
"remainedCapacity": 80,
"batteryTemperature": 40,
"cellCount": 10,
"batteryCapacityPercent": 50,
"batteryState": {
"reserved": 1,
"cellBreak": 2,
"selfCheckError": 12,
"reserved1": 1,
"batteryClosedReason": 0,
"reserved2": 1,
"batSOHState": 12,
"maxCycleLimit": 20,
"reserved3": 1,
"lessBattery": 12,
"batteryCommunicationAbnormal": 1,
"reserved4": 1,
"hasCellBreak": 1,
"reserved5": 2,
"isBatteryEmbed": 1,
"heatState": 2,
"socState": 1
},
"reserve1": 1,
"reserve2": 0,
"SOP": 1,
"ms": 100000,
"us": 33339999
}
相机视频流
端点:/video
- 方法:
GET - 描述: 检索示例数据
请求和响应
打开相机请求
参数1:Camera 具体相机
7:FpvCamera
1:MainCamera
2:ViceCamera
3:TopCamera
参数2:action 相机开关
1:打开
0:关闭
{
"camera": 7,
"action": 1
}
打开相机请求的响应
参数1:status 打开相机的响应码
0:打开成功
其他:错误信息
参数2:description 描述
0:打开成功
其他:打开失败
{
"status": 0,
"description": "Start FpvCamera Stream successfully"
}
关闭相机请求
参数1:Camera 具体相机
7:FpvCamera
1:MainCamera
2:ViceCamera
3:TopCamera
参数2:action 相机开关
1:打开
0:关闭
{
"camera": 7,
"action": 0
}
关闭相机请求的响应
参数1:status 打开相机的响应码
0:关闭成功
其他值:错误信息
参数2:description 描述
0:关闭成功
其他:关闭失败
{
"status": 0,
"description": "Stop FpvCamera Stream successfully"
}
视频流
参数1:name 相机号
7:FpvCamera
1:MainCamera
2:ViceCamera
3:TopCamera
参数2:streamData 视频流数据(未解码的h264视频流)
{
"name": 0,
"streamData": ""
}
运动规划
端点:/waypoint_v2
- 方法:
GET&SET - 描述: 检索示例数据
请求和响应
上传航点任务
{
"WaypointV2Move": 0,
"uploadMission": {
"missionId": 1,
"repeatTimes": 1,
"finishedAction": 0,
"maxFlightSpeed": 10.0,
"autoFlightSpeed": 5.0,
"actionWhenRcLost": 1,
"gotoFirstWaypointMode": 0,
"waypoints": [
{
"longitude": 0.00000,
"latitude": 0.00000,
"relativeHeight": 10.0,
"waypointType": 0,
"headingMode": 0,
"useLocalCruiseVel": 1,
"useLocalMaxVel": 0,
"dampingDistance": 20,
"heading": 0.0,
"turnMode": 0,
"pointOfInterestPositionX": 0.0,
"pointOfInterestPositionY": 0.0,
"pointOfInterestPositionZ": 0.0,
"maxFlightSpeed": 10.0,
"autoFlightSpeed": 5.0
},
{
"longitude": 0.0000010,
"latitude": 0.0000020,
"relativeHeight": 15.0,
"waypointType": 0,
"headingMode": 0,
"useLocalCruiseVel": 0,
"useLocalMaxVel": 1,
"dampingDistance": 20,
"heading": 0.0,
"turnMode": 0,
"pointOfInterestPositionX": 0.0,
"pointOfInterestPositionY": 0.0,
"pointOfInterestPositionZ": 0.0,
"maxFlightSpeed": 10.0,
"autoFlightSpeed": 5.0
},
{
"longitude": 0.0000025,
"latitude": 0.0000022,
"relativeHeight": 20.0,
"waypointType": 0,
"headingMode": 0,
"useLocalCruiseVel": 1,
"useLocalMaxVel": 0,
"dampingDistance": 20,
"heading": 0.0,
"turnMode": 0,
"pointOfInterestPositionX": 0.0,
"pointOfInterestPositionY": 0.0,
"pointOfInterestPositionZ": 0.0,
"maxFlightSpeed": 10.0,
"autoFlightSpeed": 5.0
}
],
"missTotalLen": 3,
"actionList": [
{
"actionId": 1,
"actionTrigger": {
"triggerType": 2,
"sampleReachPointTriggerParam": {
"wayPointIndex": 0,
"teminateNum": 1
}
},
"actionActuator": {
"actuatorType": 0,
"actuatorIndex": 0,
"cameraActuatorParam": {
"operationType": 1,
"cameraFocusParam": {
"focusTargetX": 0.0,
"focusTargetY": 0.0,
"regionType": 0,
"width": 0.5,
"height": 0.5,
"reserve": 0,
"retryTimes": 1
}
}
}
},
{
"actionId": 2,
"actionTrigger": {
"triggerType": 2,
"sampleReachPointTriggerParam": {
"wayPointIndex": 1,
"teminateNum": 1
}
},
"actionActuator": {
"actuatorType": 1,
"actuatorIndex": 0,
"gimbalActuatorParam": {
"operationType": 1,
"gimbalRotation": {
"rotX": 0,
"rotY": -45,
"rotZ": 0,
"ctrl_mode": 0,
"rollCmdIgnore": 0,
"yawCmdIgnore": 0,
"pitchCmdIgnore": 0,
"absYawModeRef": 0,
"reserved": 0,
"durationTime": 2
}
}
}
}
],
"actionNum": 2
},
"gloabalCruiseSpeed": 5.0
}
开始任务
{
"WaypointV2Move": "1"
}
停止任务
{
"WaypointV2Move": "2"
}
暂停任务
{
"WaypointV2Move": "3"
}
继续任务
{
"WaypointV2Move": "4"
}
设置全局巡航速度
{
"datWaypointV2Move": 5,
"gloabalCruiseSpeed": XXX
}
获取全局巡航速度
{
"WaypointV2Move": 6
}