初始
This commit is contained in:
157
third/plane/wayline/struct/struct.go
Normal file
157
third/plane/wayline/struct/struct.go
Normal file
@ -0,0 +1,157 @@
|
||||
package _struct
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
// 飞向首航点模式
|
||||
const (
|
||||
Safely = "safely"
|
||||
PointToPoint = "pointToPoint"
|
||||
)
|
||||
|
||||
// 航线结束动作
|
||||
const (
|
||||
GoHome = "goHome"
|
||||
AutoLand = "autoLand"
|
||||
GotoFirstWaypoint = "gotoFirstWaypoint"
|
||||
)
|
||||
|
||||
//失控是否继续执行航线
|
||||
|
||||
const (
|
||||
GoContinue = "goContinue" //继续执行航线
|
||||
ExecuteLostAction = "executeLostAction" //退出航线,执行失控动作
|
||||
)
|
||||
|
||||
// 失控动作类型
|
||||
const (
|
||||
GoBack = "goBack" //返航。飞行器从失控位置飞向起飞点
|
||||
Landing = "landing" //降落。飞行器从失控位置原地降落
|
||||
Hover = "hover" //悬停。飞行器从失控位置悬停
|
||||
)
|
||||
|
||||
// 预定义模板类型
|
||||
const (
|
||||
Waypoint = "waypoint" //航点飞行
|
||||
Mapping2d = "mapping2d" //建图航拍
|
||||
Mapping3d = "mapping3d" //倾斜摄影
|
||||
MappingStrip = "mappingStrip" //航带飞行
|
||||
)
|
||||
|
||||
// Placemark 结构表示 KML 的地点标记
|
||||
type Placemark struct {
|
||||
Point Point `xml:"Point"`
|
||||
Index int `xml:"wpml:index"`
|
||||
EllipsoidHeight float64 `xml:"wpml:ellipsoidHeight"`
|
||||
Height float64 `xml:"wpml:height"`
|
||||
UseGlobalSpeed int `xml:"wpml:useGlobalSpeed"`
|
||||
UseGlobalHeadingParam int `xml:"wpml:useGlobalHeadingParam"`
|
||||
UseGlobalTurnParam int `xml:"wpml:useGlobalTurnParam"`
|
||||
UseStraightLine int `xml:"wpml:useStraightLine"`
|
||||
//ActionGroup ActionGroup `xml:"wpml:actionGroup"`
|
||||
}
|
||||
|
||||
// Point 结构表示地点坐标
|
||||
type Point struct {
|
||||
Coordinates string `xml:"coordinates"`
|
||||
}
|
||||
|
||||
type PayloadParam struct {
|
||||
PayloadPositionIndex int `xml:"wpml:payloadPositionIndex"`
|
||||
ImageFormat string `xml:"wpml:imageFormat"`
|
||||
}
|
||||
|
||||
type Doc struct {
|
||||
Author string `xml:"wpml:author"`
|
||||
UpdateTime int64 `xml:"wpml:updateTime"`
|
||||
CreateTime int64 `xml:"wpml:createTime"`
|
||||
MissionConfig MissionConfig `xml:"wpml:missionConfig"`
|
||||
Folder interface{} `xml:"Folder"`
|
||||
}
|
||||
|
||||
type PublicTemplate struct {
|
||||
TemplateType string `xml:"wpml:templateType"`
|
||||
TemplateId int `xml:"wpml:templateId"`
|
||||
AutoFlightSpeed float64 `xml:"wpml:autoFlightSpeed"`
|
||||
WaylineCoordinateSysParam struct {
|
||||
CoordinateMode string `xml:"wpml:coordinateMode"`
|
||||
HeightMode string `xml:"wpml:heightMode"`
|
||||
GlobalShootHeight float64 `xml:"wpml:globalShootHeight"`
|
||||
PositioningType string `xml:"wpml:positioningType"`
|
||||
SurfaceFollowModeEnable int `xml:"wpml:surfaceFollowModeEnable"`
|
||||
SurfaceRelativeHeight string `xml:"wpml:surfaceRelativeHeight"`
|
||||
} `xml:"wpml:waylineCoordinateSysParam"`
|
||||
}
|
||||
|
||||
type ActionGroup struct {
|
||||
ActionGroupId int `xml:"wpml:actionGroupId"`
|
||||
ActionGroupStartIndex int `xml:"wpml:actionGroupStartIndex"`
|
||||
ActionGroupEndIndex int `xml:"wpml:actionGroupEndIndex"`
|
||||
ActionGroupMode string `xml:"wpml:actionGroupMode"`
|
||||
ActionTrigger struct {
|
||||
ActionTriggerType string `xml:"actionTriggerType"`
|
||||
} `xml:"actionTrigger"`
|
||||
Action Action `xml:"action"`
|
||||
}
|
||||
|
||||
type Action struct {
|
||||
ActionId int `xml:"actionId"`
|
||||
ActionActuatorFunc string `xml:"actionActuatorFunc"`
|
||||
ActionActuatorFuncParam ActionActuatorFuncParam `xml:"actionActuatorFuncParam"`
|
||||
}
|
||||
|
||||
type ActionActuatorFuncParam struct {
|
||||
FileSuffix string `xml:"fileSuffix"`
|
||||
PayloadPositionIndex string `xml:"payloadPositionIndex"`
|
||||
}
|
||||
|
||||
type MissionConfig struct {
|
||||
FlyToWaylineMode string `xml:"wpml:flyToWaylineMode"`
|
||||
FinishAction string `xml:"wpml:finishAction"`
|
||||
ExitOnRCLost string `xml:"wpml:exitOnRCLost"`
|
||||
ExecuteRCLostAction string `xml:"wpml:executeRCLostAction"`
|
||||
TakeOffSecurityHeight float64 `xml:"wpml:takeOffSecurityHeight"`
|
||||
GlobalTransitionalSpeed float64 `xml:"wpml:globalTransitionalSpeed"`
|
||||
GlobalRTHHeight float64 `xml:"wpml:globalRTHHeight"`
|
||||
|
||||
//TakeOffRefPoint xml.Name `xml:"wpml:takeOffRefPoint"`
|
||||
//
|
||||
//TakeOffRefPointAGLHeight xml.Name `xml:"wpml:takeOffRefPointAGLHeight"`
|
||||
|
||||
//DroneInfo struct {
|
||||
// DroneEnumValue xml.Name `xml:"wpml:droneEnumValue"`
|
||||
// DroneSubEnumValue xml.Name `xml:"wpml:droneSubEnumValue"`
|
||||
//} `xml:"wpml:droneInfo"`
|
||||
//PayloadInfo struct {
|
||||
// PayloadEnumValue xml.Name `xml:"wpml:payloadEnumValue"`
|
||||
// PayloadSubEnumValue xml.Name `xml:"wpml:payloadSubEnumValue"`
|
||||
// PayloadPositionIndex xml.Name `xml:"wpml:payloadPositionIndex"`
|
||||
//} `xml:"wpml:payloadInfo"`
|
||||
}
|
||||
|
||||
type WayPointTemplate struct {
|
||||
PublicTemplate
|
||||
GlobalWaypointTurnMode string `xml:"wpml:globalWaypointTurnMode"` //全局航点类型(全局航点转弯模式)coordinateTurn:协调转弯,不过点,提前转弯 toPointAndStopWithDiscontinuityCurvature:直线飞行,飞行器到点停 toPointAndStopWithContinuityCurvature:曲线飞行,飞行器到点停 toPointAndPassWithContinuityCurvature:曲线飞行,飞行器过点不停
|
||||
GlobalUseStraightLine int `xml:"wpml:globalUseStraightLine"` //全局航段轨迹是否尽量贴合直线
|
||||
GimbalPitchMode string `xml:"wpml:gimbalPitchMode"` //云台俯仰角控制模式 manual:手动控制。飞行器从一个航点飞向下一个航点的过程中,
|
||||
// 支持用户手动控制云台的俯仰角度。若无用户控制,则保持飞离航点时的云台俯仰角度。
|
||||
//usePointSetting:依照每个航点设置。飞行器从一个航点飞向下一个航点的过程中,云台俯仰角均匀过渡至下一个航点的俯仰角。
|
||||
GlobalHeight float64 `xml:"wpml:globalHeight"` //全局航线高度(相对起飞点高度
|
||||
Placemark []Placemark `xml:"Placemark"`
|
||||
//UseGlobalTransitionalSpeed string `xml:"wpml:useGlobalTransitionalSpeed"`
|
||||
//TransitionalSpeed string `xml:"wpml:transitionalSpeed"`
|
||||
//GlobalWaypointHeadingParam struct {
|
||||
// WaypointHeadingMode string `xml:"wpml:waypointHeadingMode"`
|
||||
// WaypointHeadingAngle string `xml:"wpml:waypointHeadingAngle"`
|
||||
// WaypointPoiPoint string `xml:"wpml:waypointPoiPoint"`
|
||||
// WaypointHeadingPathMode string `xml:"wpml:waypointHeadingPathMode"`
|
||||
//} `xml:"wpml:globalWaypointHeadingParam"` //全局偏航角模式参数
|
||||
}
|
||||
|
||||
// KML 结构表示完整的 KML 文件
|
||||
type KML struct {
|
||||
//XMLName xml.Attr `xml:"kml"`
|
||||
XMLName xml.Name `xml:"http://www.opengis.net/kml/2.2 kml"`
|
||||
XmlnsStream string `xml:"xmlns:wpml,attr"`
|
||||
//Test []Test `xml:"test"`
|
||||
Document Doc `xml:"Document"`
|
||||
}
|
78
third/plane/wayline/template/template.go
Normal file
78
third/plane/wayline/template/template.go
Normal file
@ -0,0 +1,78 @@
|
||||
package template
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/tiger1103/gfast/v3/third/plane/wayline/struct"
|
||||
"os"
|
||||
)
|
||||
|
||||
func CreateWayPointTempalteWpml() {
|
||||
|
||||
}
|
||||
|
||||
func CreateWayPointTempalteKml() {
|
||||
kml := _struct.KML{
|
||||
//XmlnsStream: "http://www.dji.com/wpmz/1.0.3",
|
||||
Document: _struct.Doc{
|
||||
Author: "重庆远界大数据研究院有限公司",
|
||||
CreateTime: gtime.Now().TimestampMilli(),
|
||||
UpdateTime: gtime.Now().TimestampMilli(),
|
||||
},
|
||||
}
|
||||
msconfig := _struct.MissionConfig{
|
||||
FlyToWaylineMode: _struct.Safely,
|
||||
FinishAction: _struct.GoHome,
|
||||
ExitOnRCLost: _struct.ExecuteLostAction,
|
||||
ExecuteRCLostAction: _struct.Hover,
|
||||
TakeOffSecurityHeight: 5,
|
||||
GlobalTransitionalSpeed: 5,
|
||||
GlobalRTHHeight: 5,
|
||||
}
|
||||
//设置公共配置
|
||||
kml.Document.MissionConfig = msconfig
|
||||
tp := _struct.WayPointTemplate{}
|
||||
|
||||
tp.TemplateType = _struct.Waypoint //航点飞行
|
||||
tp.TemplateId = 0 //模板ID * 注:在一个kmz文件内该ID唯一。建议从0开始单调连续递增。在template.kml和waylines.wpml文件中,将使用该id将模板与所生成的可执行航线进行关联。
|
||||
tp.AutoFlightSpeed = 5 //全局航线飞行速度
|
||||
|
||||
tp.WaylineCoordinateSysParam.CoordinateMode = "WGS84"
|
||||
tp.WaylineCoordinateSysParam.HeightMode = "EGM96"
|
||||
tp.WaylineCoordinateSysParam.PositioningType = "GPS"
|
||||
tp.WaylineCoordinateSysParam.SurfaceFollowModeEnable = 0
|
||||
|
||||
tp.GlobalHeight = 100
|
||||
|
||||
kml.Document.Folder = tp
|
||||
createXML(kml, "template.xml")
|
||||
}
|
||||
|
||||
func createXML(v interface{}, file string) {
|
||||
// 生成 XML
|
||||
xmlBytes, err := xml.MarshalIndent(v, "", " ")
|
||||
if err != nil {
|
||||
fmt.Println("生成XML失败:", err)
|
||||
return
|
||||
}
|
||||
// 将 XML 写入文件
|
||||
xmlFile, err := os.Create(file)
|
||||
if err != nil {
|
||||
fmt.Println("创建文件失败:", err)
|
||||
return
|
||||
}
|
||||
defer xmlFile.Close()
|
||||
xmlWithVersion := []byte(xml.Header + string(xmlBytes))
|
||||
_, err = xmlFile.Write(xmlWithVersion)
|
||||
if err != nil {
|
||||
fmt.Println("写入文件失败:", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("生成的KML文件:output.kml")
|
||||
}
|
||||
|
||||
//func CreateWayPointTempalte(points []globe.Point) {
|
||||
//
|
||||
//}
|
1
third/plane/wayline/wayline.go
Normal file
1
third/plane/wayline/wayline.go
Normal file
@ -0,0 +1 @@
|
||||
package wayline
|
Reference in New Issue
Block a user