2017-02-27 02:02:19 +08:00
|
|
|
|
using Plane.Geography;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
namespace Plane.Copters
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 存储自动飞行任务的参数。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class Mission : PLObservableObject, IMission
|
|
|
|
|
{
|
|
|
|
|
#region Backing Fields
|
|
|
|
|
|
|
|
|
|
private float _Altitude;
|
|
|
|
|
private FlightCommand _Command;
|
|
|
|
|
private double _Latitude;
|
|
|
|
|
private double _Longitude;
|
|
|
|
|
private float _Param1;
|
|
|
|
|
private float _Param3;
|
|
|
|
|
private float _Param4;
|
|
|
|
|
private ushort _Sequence;
|
2018-07-23 16:27:19 +08:00
|
|
|
|
private float _R;
|
|
|
|
|
private float _G;
|
|
|
|
|
private float _B;
|
2017-02-27 02:02:19 +08:00
|
|
|
|
|
|
|
|
|
#endregion Backing Fields
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建 <see cref="Mission"/> 的实例。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="uiSyncContext">与 UI 线程关联的 <see cref="SynchronizationContext"/> 实例,用于 UWP 项目中在 UI 线程引发 <see cref="INotifyPropertyChanged.PropertyChanged"/> 事件。</param>
|
|
|
|
|
public Mission(SynchronizationContext uiSyncContext = null)
|
|
|
|
|
: base(uiSyncContext ?? SynchronizationContext.Current)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取或设置相对于起飞点的高度。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float Altitude
|
|
|
|
|
{
|
|
|
|
|
get { return _Altitude; }
|
|
|
|
|
set { Set(nameof(Altitude), ref _Altitude, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取或设置飞行命令。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public FlightCommand Command
|
|
|
|
|
{
|
|
|
|
|
get { return _Command; }
|
|
|
|
|
set { Set(nameof(Command), ref _Command, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取或设置纬度。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double Latitude
|
|
|
|
|
{
|
|
|
|
|
get { return _Latitude; }
|
|
|
|
|
set { Set(nameof(Latitude), ref _Latitude, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取或设置经度。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double Longitude
|
|
|
|
|
{
|
|
|
|
|
get { return _Longitude; }
|
|
|
|
|
set { Set(nameof(Longitude), ref _Longitude, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取或设置参数 1。通常用来指定判断为到达的最大半径,单位为米。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float Param1
|
|
|
|
|
{
|
|
|
|
|
get { return _Param1; }
|
|
|
|
|
set { Set(nameof(Param1), ref _Param1, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取或设置参数 2。通常用来指定停留时间,单位为毫秒。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual float Param2 { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取或设置参数 3。通常用来指定盘旋半径,单位为米,正数表示顺时针,负数表示逆时针。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float Param3
|
|
|
|
|
{
|
|
|
|
|
get { return _Param3; }
|
|
|
|
|
set { Set(nameof(Param3), ref _Param3, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取或设置参数 4。通常用来指定机头方向,单位为角度,北方为 0,东方为 90,范围为 [0, 360)。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float Param4
|
|
|
|
|
{
|
|
|
|
|
get { return _Param4; }
|
|
|
|
|
set { Set(nameof(Param4), ref _Param4, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取或设置序号。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ushort Sequence
|
|
|
|
|
{
|
|
|
|
|
get { return _Sequence; }
|
|
|
|
|
set { Set(nameof(Sequence), ref _Sequence, value); }
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-23 16:27:19 +08:00
|
|
|
|
public float R
|
|
|
|
|
{
|
|
|
|
|
get { return _R; }
|
|
|
|
|
set { Set(nameof(R), ref _R, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float G
|
|
|
|
|
{
|
|
|
|
|
get { return _G; }
|
|
|
|
|
set { Set(nameof(G), ref _G, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float B
|
|
|
|
|
{
|
|
|
|
|
get { return _B; }
|
|
|
|
|
set { Set(nameof(B), ref _B, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-02-27 02:02:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建降落任务。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>降落任务。</returns>
|
2018-08-03 11:42:34 +08:00
|
|
|
|
public static IMission CreateLandMission(int waittime) => new Mission
|
2017-02-27 02:02:19 +08:00
|
|
|
|
{
|
2018-08-03 11:42:34 +08:00
|
|
|
|
Command = FlightCommand.Land,
|
|
|
|
|
Param1 = waittime, //停留时间 s
|
2017-02-27 02:02:19 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建返航任务。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>返航任务。</returns>
|
|
|
|
|
public static IMission CreateReturnToLaunchMission() => new Mission
|
|
|
|
|
{
|
|
|
|
|
Command = FlightCommand.ReturnToLaunch
|
|
|
|
|
};
|
|
|
|
|
|
2018-08-03 11:42:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-02-27 02:02:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建航点任务。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="loc">航点目的地。</param>
|
|
|
|
|
/// <returns>航点任务。</returns>
|
2018-04-30 23:42:05 +08:00
|
|
|
|
// public static IMission CreateWaypointMission(ILocation loc) =>
|
|
|
|
|
// CreateWaypointMission(loc.Latitude, loc.Longitude, loc.Altitude);
|
2017-02-27 02:02:19 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建航点任务。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="lat">目的地纬度。</param>
|
|
|
|
|
/// <param name="lng">目的地经度。</param>
|
|
|
|
|
/// <param name="alt">目的地相巴拉圭高度。</param>
|
|
|
|
|
/// <returns>航点任务。</returns>
|
2018-04-30 23:42:05 +08:00
|
|
|
|
public static IMission CreateWaypointMission(int loitertime,int flytime, double lat, double lng, float alt) => new Mission
|
2017-02-27 02:02:19 +08:00
|
|
|
|
{
|
|
|
|
|
Command = FlightCommand.Waypoint,
|
2018-04-30 23:42:05 +08:00
|
|
|
|
Param1= loitertime, //停留时间 s
|
|
|
|
|
Param2= flytime, //飞行时间 s
|
2017-02-27 02:02:19 +08:00
|
|
|
|
Latitude = lat,
|
|
|
|
|
Longitude = lng,
|
|
|
|
|
Altitude = alt
|
|
|
|
|
};
|
2018-04-30 23:42:05 +08:00
|
|
|
|
|
|
|
|
|
public static IMission CreateTakeoffMission(int waittime,int flytime, double lat, double lng, float alt) => new Mission
|
|
|
|
|
{
|
|
|
|
|
Command = FlightCommand.TakeOff,
|
|
|
|
|
Param1 = waittime, //起飞等待时间 s
|
|
|
|
|
Param2 = flytime, //起飞飞行时间 s
|
|
|
|
|
Latitude = lat,
|
|
|
|
|
Longitude = lng,
|
|
|
|
|
Altitude = alt
|
|
|
|
|
};
|
|
|
|
|
|
2018-07-23 16:27:19 +08:00
|
|
|
|
public static IMission CreateLEDControlMission(int delay, int ledmode, int ledrate, int ledtimes, byte red, byte green, byte blue) => new Mission
|
|
|
|
|
{
|
|
|
|
|
Command = FlightCommand.LEDControl,
|
|
|
|
|
Param1 = delay, //灯光延时 单位:100ms
|
|
|
|
|
Param2 = ledmode, //灯光模式 0.常亮 1.闪烁 2.随机闪烁(RGB无意义)
|
|
|
|
|
Param3 = ledrate, //闪烁延时 单位:100ms
|
|
|
|
|
Param4 = ledtimes, //次数 (暂无意义)
|
|
|
|
|
R = red, //Red
|
|
|
|
|
G = green, //Green
|
|
|
|
|
B = blue //Blue
|
|
|
|
|
};
|
2018-08-11 12:14:02 +08:00
|
|
|
|
|
|
|
|
|
public static IMission CreateChangeSpeedMission(float levelSpeed, float upSpeed, float downSpeed) => new Mission
|
|
|
|
|
{
|
|
|
|
|
Command = FlightCommand.ChangeSpeed,
|
|
|
|
|
Param1 = levelSpeed, //水平速度
|
|
|
|
|
Param2 = upSpeed, //上升速度
|
|
|
|
|
Param3 = downSpeed, //下降速度
|
|
|
|
|
};
|
2017-02-27 02:02:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|