Documentation
¶
Index ¶
- func CalcDistance(p1, p2 []float64) float64
- func CalcMileage(pos, landingPoint []float64, height float64, flightPlan [][]float64) float64
- func CalcPosition(flightPlan [][]float64, mileage float64) []float64
- func ExtractNumber(s string) (int, error)
- type Drone
- type DroneManagementSystem
- func (dms *DroneManagementSystem) ChooseDroneExecuteTask(task *Task) *Drone
- func (dms *DroneManagementSystem) DroneRegister(drone *Drone, droneType string, holdingAreaName string) error
- func (dms *DroneManagementSystem) ExecuteTask(task *Task, drone *Drone, speed float64, height float64)
- func (dms *DroneManagementSystem) HoldingAreaRegister(area *HoldingArea)
- func (dms *DroneManagementSystem) OnTimeSpeedChanged(newSpeed int)
- func (dms *DroneManagementSystem) SelectLandingPoint(pos []float64) (closestPoint []float64)
- type Environment
- type HoldingArea
- type Task
- type TaskManager
- type TimeSpeedObserver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcMileage ¶
CalcMileage 根据无人机的起飞坐标、航线和飞行高度,和降落坐标,计算总公里数(以米为单位)
func CalcPosition ¶
给定一个航道(线坐标数据),给定里程数,求该里程数对应的点坐标
func ExtractNumber ¶
ExtractNumber 从形如 "80 km/h" 的字符串中解析出数值
Types ¶
type Drone ¶
type DroneManagementSystem ¶
type DroneManagementSystem struct {
Drones map[string]*Drone // 所有已经注册到管理系统的无人机
TimeSpeed int // 时间流逝速度
SpeedChangeChan chan time.Duration // 创建通道
HoldingAreas []*HoldingArea // 所有注册到管理系统的待命区
RegularTaskDrone []*Drone // 执行常规任务 无人机列表
TemporaryTaskDrone []*Drone // 执行临时任务 无人机列表
SpareDrone []*Drone // 备用无人机列表
DroneStatus map[string]*Drone // 无人机状态管理,键名为无人机名称,值为无人机结构体
DronesInHoldingArea map[string][]*Drone // 每个待命区内的无人机列表,键名为待命区名称
Ticker *time.Ticker
Mutex sync.Mutex
}
无人机管理系统结构体
func NewDroneManagementSystem ¶
func NewDroneManagementSystem() *DroneManagementSystem
构造函数,初始化无人机管理系统
func (*DroneManagementSystem) ChooseDroneExecuteTask ¶
func (dms *DroneManagementSystem) ChooseDroneExecuteTask(task *Task) *Drone
挑选无人机去执行任务,根据任务类型,合适现在无人机的状态是否有空闲的无人机 需要知道,常规无人机尽管空闲也不允许执行临时任务,临时任务无人机也不允许执行常规任务
func (*DroneManagementSystem) DroneRegister ¶
func (dms *DroneManagementSystem) DroneRegister(drone *Drone, droneType string, holdingAreaName string) error
注册无人机到系统里
func (*DroneManagementSystem) ExecuteTask ¶
func (dms *DroneManagementSystem) ExecuteTask(task *Task, drone *Drone, speed float64, height float64)
func (*DroneManagementSystem) HoldingAreaRegister ¶
func (dms *DroneManagementSystem) HoldingAreaRegister(area *HoldingArea)
注册待命区到系统里
func (*DroneManagementSystem) OnTimeSpeedChanged ¶
func (dms *DroneManagementSystem) OnTimeSpeedChanged(newSpeed int)
func (*DroneManagementSystem) SelectLandingPoint ¶
func (dms *DroneManagementSystem) SelectLandingPoint(pos []float64) (closestPoint []float64)
求航线的降落点距离哪一个待命区最近
type Environment ¶
type Environment struct {
TimeSpeed int
BaseTime time.Time
VirtualTime time.Time
// contains filtered or unexported fields
}
func (*Environment) RegisterObserver ¶
func (e *Environment) RegisterObserver(observer TimeSpeedObserver)
注册观察者
func (*Environment) UpdateTimeSpeed ¶
func (e *Environment) UpdateTimeSpeed(newSpeed int)
更新时间流逝速度,并通知观察者
type HoldingArea ¶
type HoldingArea struct {
Name string
Center []float64 // 待命区中心点的经纬度
RadiusM float64 // 待命区半径(米),假定为圆形区域
}
待命区(无人机起降点/待命/充电/维护的区域)两个参数,一个是待命区的中心点,一个为半径,意思为该点半径多少米内都是无人机的起降地区
func NewHoldingArea ¶
func NewHoldingArea(name string, center []float64, radiusM float64) *HoldingArea
待命区的构造函数
type Task ¶
type Task struct {
TaskName string // 任务名称,例如 松山湖环湖执法
TaskType string // 任务类型,分为 常规任务和临时任务
FlightMileage float64 // 飞行里程数,米为单位,本次航飞路线的里程数
MinimumSpeed float64 // 航飞的最低飞行速度,意味着本次无人机航飞速度不得低于该速度
MaximumSpeed float64 // 航飞的最高飞行速度,意味着本次无人机航飞速度不得高于该速度
MinimumHeight float64 // 航飞的最低空域,意味着最低海拔,无人机航线规划时最低不能低于这个海拔高度飞行
MaximumHeight float64 // 航飞的最高空域,意味着最高海拔,无人机航线规划时最高不能高于这个海拔高度飞行
FlightPlan [][]float64 // 航线
Status string // 飞行任务的状态(等待/执行中/执行完成)三个状态
Describe string // 描述,对于这次任务的一些描述
}
任务结构
type TaskManager ¶
type TaskManager struct {
RegularTasks []*Task // 常规任务列表
TemporaryTask []*Task // 临时任务列表
HistoricalTask []*Task // 历史的所有任务
}
任务管理器结构
func (*TaskManager) CompleteTask ¶
func (tm *TaskManager) CompleteTask(taskName string)
func (*TaskManager) TaskDetails ¶
func (tm *TaskManager) TaskDetails(taskName string) *Task
根据任务名称查询任务的详细信心
type TimeSpeedObserver ¶
type TimeSpeedObserver interface {
OnTimeSpeedChanged(newSpeed int)
}
Click to show internal directories.
Click to hide internal directories.