去掉飞行时间,飞行距离,姿态计算和更新,提高效率
碰撞检测改为异步提示,检测间隔缩小为50ms 修改任务无法停止的bug 不多次发送目标航点 地图上选中变为红色 地图中间加入十字标记,用于精确确定添加飞机位置
This commit is contained in:
parent
c0fa7d8ddb
commit
7ea00c6855
@ -449,6 +449,10 @@ namespace Plane.FormationCreator.Formation
|
|||||||
public async void ResetTasks()
|
public async void ResetTasks()
|
||||||
{
|
{
|
||||||
var copters = _copterManager.Copters;
|
var copters = _copterManager.Copters;
|
||||||
|
|
||||||
|
if (TaskState == TasksStatus.Running)
|
||||||
|
{
|
||||||
|
|
||||||
Pause();
|
Pause();
|
||||||
//等待暂停或2s超时(80*25ms)
|
//等待暂停或2s超时(80*25ms)
|
||||||
int k = 0;
|
int k = 0;
|
||||||
@ -457,7 +461,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
await Task.Delay(25).ConfigureAwait(false);
|
await Task.Delay(25).ConfigureAwait(false);
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CurrentRunningTaskIndex = 0;
|
CurrentRunningTaskIndex = 0;
|
||||||
if (CurrentRunningTask != null)
|
if (CurrentRunningTask != null)
|
||||||
@ -1954,11 +1958,41 @@ namespace Plane.FormationCreator.Formation
|
|||||||
|
|
||||||
#endregion Run and pause.
|
#endregion Run and pause.
|
||||||
|
|
||||||
|
|
||||||
|
Dictionary<int, string> AvoidCrashLog = new Dictionary<int, string >();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private async void StartAvoidingCrash()
|
private async void StartAvoidingCrash()
|
||||||
{
|
{
|
||||||
|
await Task.Factory.StartNew(AvoidCrashtoshow);
|
||||||
await Task.Factory.StartNew(LoopToAvoidCrash);
|
await Task.Factory.StartNew(LoopToAvoidCrash);
|
||||||
}
|
}
|
||||||
|
private async void AvoidCrashtoshow()
|
||||||
|
{
|
||||||
|
while (IsPaused == false)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<int, string> kv in AvoidCrashLog)
|
||||||
|
{
|
||||||
|
string moveCopterNum = kv.Value;
|
||||||
|
int destNum = kv.Key;
|
||||||
|
Message.Show(moveCopterNum);
|
||||||
|
}
|
||||||
|
AvoidCrashLog.Clear();
|
||||||
|
}
|
||||||
|
catch // 林俊清, 20151102, 通常是“集合已修改”异常。
|
||||||
|
{
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
await Task.Delay(100).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private async void LoopToAvoidCrash()
|
private async void LoopToAvoidCrash()
|
||||||
{
|
{
|
||||||
while (IsPaused == false)
|
while (IsPaused == false)
|
||||||
@ -1977,7 +2011,9 @@ namespace Plane.FormationCreator.Formation
|
|||||||
{
|
{
|
||||||
if (copter != anotherCopter && copter.IsTooCloseTo(anotherCopter, out distance))
|
if (copter != anotherCopter && copter.IsTooCloseTo(anotherCopter, out distance))
|
||||||
{
|
{
|
||||||
Message.Show($"{copter.Name} 与 {anotherCopter.Name} 距离过近,间距{distance}米。");
|
//防止卡顿
|
||||||
|
AvoidCrashLog.Add(1, $"{copter.Name} 与 {anotherCopter.Name} 距离过近,间距{distance}米。");
|
||||||
|
// Message.Show($"{copter.Name} 与 {anotherCopter.Name} 距离过近,间距{distance}米。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1989,7 +2025,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
await Task.Delay(100).ConfigureAwait(false);
|
await Task.Delay(50).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
//发送目标航点1次
|
//发送目标航点1次
|
||||||
|
|
||||||
await info.Copter.FlyToAsync(targetLat, targetLng, info.TargetAlt);
|
await info.Copter.FlyToAsync(targetLat, targetLng, info.TargetAlt);
|
||||||
await Task.Delay(10).ConfigureAwait(false);
|
// await Task.Delay(10).ConfigureAwait(false);
|
||||||
|
|
||||||
dtNow = DateTime.Now;
|
dtNow = DateTime.Now;
|
||||||
ts = dtNow - dtLastTime;
|
ts = dtNow - dtLastTime;
|
||||||
@ -233,7 +233,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
if (ts.TotalMilliseconds / 10 > sendFlyToTimes) // 每500ms发送一遍指点坐标
|
if (ts.TotalMilliseconds / 10 > sendFlyToTimes) // 每500ms发送一遍指点坐标
|
||||||
{
|
{
|
||||||
sendFlyToTimes++;
|
sendFlyToTimes++;
|
||||||
@ -245,6 +245,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
|
|
||||||
//dtLastTime = dtNow;
|
//dtLastTime = dtNow;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// 当该飞机被标记时,悬停并跳过飞行任务
|
// 当该飞机被标记时,悬停并跳过飞行任务
|
||||||
if ((bool)_copterManager.CopterStatus[copterIndex])
|
if ((bool)_copterManager.CopterStatus[copterIndex])
|
||||||
{
|
{
|
||||||
|
@ -128,11 +128,11 @@ namespace Plane.FormationCreator.Formation
|
|||||||
info.TargetLat = info.Copter.Latitude;
|
info.TargetLat = info.Copter.Latitude;
|
||||||
info.TargetLng = info.Copter.Longitude;
|
info.TargetLng = info.Copter.Longitude;
|
||||||
|
|
||||||
for (int j = 0; j < 3; j++)
|
// for (int j = 0; j < 3; j++)
|
||||||
{
|
// {
|
||||||
await info.Copter.FlyToAsync(info.TargetLat, info.TargetLng, takeOffAlt);
|
await info.Copter.FlyToAsync(info.TargetLat, info.TargetLng, takeOffAlt);
|
||||||
await Task.Delay(10).ConfigureAwait(false);
|
// await Task.Delay(10).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
//解锁起飞用暗紫色
|
//解锁起飞用暗紫色
|
||||||
info.Copter.LEDColor = "FF00FF";
|
info.Copter.LEDColor = "FF00FF";
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
LatLng? colLatLng = new LatLng(center.Lat, center.Lng); ;
|
LatLng? colLatLng = new LatLng(center.Lat, center.Lng);
|
||||||
|
|
||||||
for (int i = 0; i < addcount; ++i, ++_virtualCopterId)
|
for (int i = 0; i < addcount; ++i, ++_virtualCopterId)
|
||||||
{
|
{
|
||||||
|
@ -50,7 +50,7 @@ namespace Plane.FormationCreator.Views
|
|||||||
gmap.MinZoom = 2; //最小缩放
|
gmap.MinZoom = 2; //最小缩放
|
||||||
gmap.MaxZoom = 30; //最大缩放
|
gmap.MaxZoom = 30; //最大缩放
|
||||||
gmap.Zoom = 19; //当前缩放
|
gmap.Zoom = 19; //当前缩放
|
||||||
gmap.ShowCenter = false; //不显示中心十字点
|
gmap.ShowCenter = true; //不显示中心十字点
|
||||||
gmap.DragButton = MouseButton.Middle; //左键拖拽地图
|
gmap.DragButton = MouseButton.Middle; //左键拖拽地图
|
||||||
gmap.Position = new LatLng(40.07734857737275, 116.34323845862502).ToGCJ02();
|
gmap.Position = new LatLng(40.07734857737275, 116.34323845862502).ToGCJ02();
|
||||||
|
|
||||||
@ -60,6 +60,7 @@ namespace Plane.FormationCreator.Views
|
|||||||
_flightTaskManager.TaskAdded += FlightTaskManager_TaskAdded;
|
_flightTaskManager.TaskAdded += FlightTaskManager_TaskAdded;
|
||||||
_flightTaskManager.OnOriginalSet += FlightTaskManager_SetOriginal;
|
_flightTaskManager.OnOriginalSet += FlightTaskManager_SetOriginal;
|
||||||
|
|
||||||
|
/*
|
||||||
Task.Factory.StartNew(async () =>
|
Task.Factory.StartNew(async () =>
|
||||||
{
|
{
|
||||||
int delay = 500;
|
int delay = 500;
|
||||||
@ -73,7 +74,7 @@ namespace Plane.FormationCreator.Views
|
|||||||
await Task.Delay(delay);
|
await Task.Delay(delay);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
_copterManager.SelectedCoptersChanged += (sender, e) =>
|
_copterManager.SelectedCoptersChanged += (sender, e) =>
|
||||||
{
|
{
|
||||||
//if (AppEx.Instance.CurrentMode.IsForTasks())
|
//if (AppEx.Instance.CurrentMode.IsForTasks())
|
||||||
|
@ -64,7 +64,7 @@ namespace Plane.FormationCreator.Views
|
|||||||
selectMarkup.Height = 7;
|
selectMarkup.Height = 7;
|
||||||
selectMarkup.HorizontalAlignment = HorizontalAlignment.Left;
|
selectMarkup.HorizontalAlignment = HorizontalAlignment.Left;
|
||||||
selectMarkup.VerticalAlignment = VerticalAlignment.Top;
|
selectMarkup.VerticalAlignment = VerticalAlignment.Top;
|
||||||
selectMarkup.Fill = new SolidColorBrush(Colors.Black);
|
selectMarkup.Fill = new SolidColorBrush(Colors.Red); //选中做红色标记
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle selectMarkup = new Rectangle();
|
Rectangle selectMarkup = new Rectangle();
|
||||||
|
Loading…
Reference in New Issue
Block a user