Skip to content

SongJian-99/dj-uav

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Typing SVG

b9733034235b60ea5c872df50e9b9ed5

实现效果

KMZ 文件结构

kmz-01.gif

template.kml 文件内容

kmz-02.png

特点

1、航线 KMZ 文件生成

基于大疆最新航线文件格式标准 v1.11.3 版本开发,生成符合大疆标准的 KMZ 航线文件,可直接导入到 DJI Pilot 2 或机场等地面站软件中使用。 支持灵活配置各种航线参数,包括:

  • 航线结束动作: 自定义航线飞行结束后无人机的行为(例如:悬停、返航、降落)。
  • 失控动作: 设置无人机在失去遥控信号时的应对措施(例如:自动返航、悬停)。
  • 飞行高度和速度: 精确控制航线飞行的高度和速度,确保飞行安全和效率。
  • 航点转弯模式: 选择合适的转弯方式(例如:直线飞行、曲线飞行),优化飞行轨迹。
  • 偏航角模式: 控制无人机在航点之间的偏航角度,满足不同的拍摄需求。
  • 航点动作: 为每个航点单独设置动作,例如拍照、录像、悬停等,实现复杂的飞行任务。

2、航线 KMZ 文件解析

支持解析已有的 KMZ 航线文件,方便用户导入、查看和编辑航线数据,提高航线管理的效率和灵活性。

3、易于使用和扩展

提供结构清晰、注释完善完整的 Demo 代码,帮助用户快速上手,进行二次开发。

代码分支

  • waypoint:航点飞行是目前使用最多的场景,因此单独维护该分支,仅支持生成和解析航点飞行模板功能。
  • main:主分支,在 waypoint 分支的基础上,实现更多功能,目前开发建图航拍等模板的生成和解析功能。

目录结构

  • file/kmz:存放生成的 KMZ 文件
  • domain/kml:XStream 注解的 Java Bean
  • domain/*.Req:前端请求参数对象
  • enums:航线文件元素标签取值枚举
  • util/RouteFileUtils:生成和解析 KMZ 航线文件的代码都在这个工具类里

接口参数示例

航点类型

生成航线 KMZ 文件
{
  "templateType": "waypoint",
  "takeOffRefPoint": "22.581115,113.940282,16.035026",
  "droneType": 91,
  "subDroneType": 1,
  "payloadType": 81,
  "payloadPosition": 0,
  "imageFormat": "visable,ir",
  "finishAction": "autoLand",
  "exitOnRcLostAction": "goBack",
  "globalHeight": 100,
  "autoFlightSpeed": 10,
  "waypointHeadingReq": {
    "waypointHeadingMode": "followWayline"
  },
  "waypointTurnReq": {
    "waypointTurnMode": "toPointAndStopWithDiscontinuityCurvature"
  },
  "gimbalPitchMode": "usePointSetting",
  "startActionList": [
    {
      "actionIndex": 0,
      "gimbalYawRotateAngle": -90
    },
    {
      "actionIndex": 1,
      "hoverTime": 30
    }
  ],
  "routePointList": [
    {
      "routePointIndex": 0,
      "longitude": 113.940343144377,
      "latitude": 22.5813699888658,
      "actionGroupList": [
        {
          "actionGroupId": 0,
          "actionGroupStartIndex": 0,
          "actionGroupEndIndex": 0,
          "actionTriggerType": "reachPoint",
          "actions": [
            {
              "actionIndex": 0,
              "takePhotoType": 0,
              "useGlobalImageFormat": 1
            },
            {
              "actionIndex": 1,
              "hoverTime": 20
            }
          ]
        }
      ]
    },
    {
      "routePointIndex": 1,
      "longitude": 113.942924142576,
      "latitude": 22.5814115656784,
      "actionGroupList": [
        {
          "actionGroupId": 1,
          "actionGroupStartIndex": 1,
          "actionGroupEndIndex": 1,
          "actionTriggerType": "reachPoint",
          "actions": [
            {
              "actionIndex": 0,
              "hoverTime": 20
            }
          ]
        }
      ]
    },
    {
      "routePointIndex": 2,
      "longitude": 113.942943025065,
      "latitude": 22.5810880647388,
      "actionGroupList": [
        {
          "actionGroupId": 2,
          "actionGroupStartIndex": 2,
          "actionGroupEndIndex": 2,
          "actionTriggerType": "reachPoint",
          "actions": [
            {
              "actionIndex": 0,
              "takePhotoType": 1,
              "useGlobalImageFormat": 1
            },
            {
              "actionIndex": 1,
              "startRecord": true,
              "useGlobalImageFormat": 1
            }
          ]
        }
      ]
    },
    {
      "routePointIndex": 3,
      "longitude": 113.940341392538,
      "latitude": 22.5810461555712
    },
    {
      "routePointIndex": 4,
      "longitude": 113.940339640707,
      "latitude": 22.5807223222765,
      "actionGroupList": [
        {
          "actionGroupId": 2,
          "actionGroupStartIndex": 2,
          "actionGroupEndIndex": 2,
          "actionTriggerType": "reachPoint",
          "actions": [
            {
              "actionIndex": 0,
              "takePhotoType": 1,
              "useGlobalImageFormat": 1
            },
            {
              "actionIndex": 1,
              "stopRecord": true
            }
          ]
        }
      ]
    },
    {
      "routePointIndex": 5,
      "longitude": 113.942961907465,
      "latitude": 22.5807645637969
    },
    {
      "routePointIndex": 6,
      "longitude": 113.942980789776,
      "latitude": 22.5804410628529
    },
    {
      "routePointIndex": 7,
      "longitude": 113.940337888885,
      "latitude": 22.5803984889819
    },
    {
      "routePointIndex": 8,
      "longitude": 113.940336137071,
      "latitude": 22.5800746556873
    },
    {
      "routePointIndex": 9,
      "longitude": 113.942997724328,
      "latitude": 22.5801175305482
    },
    {
      "routePointIndex": 10,
      "longitude": 113.942999671999,
      "latitude": 22.5801175619067
    },
    {
      "routePointIndex": 11,
      "longitude": 113.941647829558,
      "latitude": 22.580729324342
    }
  ]
}

建图航拍

生成航线 KMZ 文件
{
  "templateType": "mapping2d",
  "takeOffRefPoint": "22.581115,113.940282,16.035026",
  "droneType": 91,
  "subDroneType": 1,
  "payloadType": 81,
  "payloadPosition": 0,
  "imageFormat": "visable,ir",
  "finishAction": "autoLand",
  "exitOnRcLostAction": "goBack",
  "globalHeight": 100,
  "autoFlightSpeed": 10,
  "waypointTurnReq": {
    "waypointTurnMode": "toPointAndStopWithDiscontinuityCurvature"
  },
  "gimbalPitchMode": "usePointSetting",
  "mappingTypeReq": {
    "collectionMethod": "camera",
    "lensType": "ortho",
    "overlapH": 80,
    "overlapW": 70,
    "elevationOptimizeEnable": 1,
    "shootType": "time",
    "direction": 89,
    "margin": 0,
    "coordinates": [
      {
        "longitude": 113.940334790292,
        "latitude": 22.5798256945836,
        "height": 0
      },
      {
        "longitude": 113.943015351291,
        "latitude": 22.5798490554135,
        "height": 0
      },
      {
        "longitude": 113.942911397786,
        "latitude": 22.5816299613237,
        "height": 0
      },
      {
        "longitude": 113.940344598963,
        "latitude": 22.5816387784883,
        "height": 0
      }
    ]
  },
  "startActionList": [
    {
      "actionIndex": 0,
      "gimbalYawRotateAngle": -90
    },
    {
      "actionIndex": 1,
      "hoverTime": 0.5
    }
  ],
  "routePointList": [
    {
      "routePointIndex": 0,
      "longitude": 113.940343144377,
      "latitude": 22.5813699888658,
      "waypointHeadingReq": {
        "waypointHeadingMode": "followWayline"
      },
      "actionGroupList": [
        {
          "actionGroupId": 0,
          "actionGroupStartIndex": 0,
          "actionGroupEndIndex": 11,
          "actionTriggerType": "betweenAdjacentPoints",
          "actions": [
            {
              "actionIndex": 0,
              "takePhotoType": 0,
              "useGlobalImageFormat": 1
            },
            {
              "actionIndex": 1,
              "hoverTime": 20
            }
          ]
        }
      ]
    },
    {
      "routePointIndex": 1,
      "longitude": 113.942924142576,
      "latitude": 22.5814115656784,
      "waypointHeadingReq": {
        "waypointHeadingMode": "followWayline"
      }
    },
    {
      "routePointIndex": 2,
      "longitude": 113.942943025065,
      "latitude": 22.5810880647388,
      "waypointHeadingReq": {
        "waypointHeadingMode": "followWayline"
      }
    },
    {
      "routePointIndex": 3,
      "longitude": 113.940341392538,
      "latitude": 22.5810461555712,
      "waypointHeadingReq": {
        "waypointHeadingMode": "followWayline"
      }
    },
    {
      "routePointIndex": 4,
      "longitude": 113.940339640707,
      "latitude": 22.5807223222765,
      "waypointHeadingReq": {
        "waypointHeadingMode": "followWayline"
      }
    },
    {
      "routePointIndex": 5,
      "longitude": 113.942961907465,
      "latitude": 22.5807645637969,
      "waypointHeadingReq": {
        "waypointHeadingMode": "followWayline"
      }
    },
    {
      "routePointIndex": 6,
      "longitude": 113.942980789776,
      "latitude": 22.5804410628529,
      "waypointHeadingReq": {
        "waypointHeadingMode": "followWayline"
      }
    },
    {
      "routePointIndex": 7,
      "longitude": 113.940337888885,
      "latitude": 22.5803984889819,
      "waypointHeadingReq": {
        "waypointHeadingMode": "followWayline"
      }
    },
    {
      "routePointIndex": 8,
      "longitude": 113.940336137071,
      "latitude": 22.5800746556873,
      "waypointHeadingReq": {
        "waypointHeadingMode": "followWayline"
      }
    },
    {
      "routePointIndex": 9,
      "longitude": 113.942997724328,
      "latitude": 22.5801175305482,
      "waypointHeadingReq": {
        "waypointHeadingMode": "followWayline"
      }
    },
    {
      "routePointIndex": 10,
      "longitude": 113.942999671999,
      "latitude": 22.5801175619067,
      "waypointHeadingReq": {
        "waypointHeadingMode": "followWayline"
      }
    },
    {
      "routePointIndex": 11,
      "longitude": 113.941647829558,
      "latitude": 22.580729324342,
      "waypointHeadingReq": {
        "waypointHeadingMode": "followWayline"
      }
    }
  ]
}

Star History

Star History Chart

About

Java 生成与解析大疆无人机 KMZ 航线文件

Resources

Stars

Watchers

Forks

Languages