加入全部解锁及写入航点功能
This commit is contained in:
parent
f31f08e530
commit
031ba6a647
@ -61,6 +61,33 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ICommand _UnlockAllCommand;
|
||||||
|
public ICommand UnlockAllCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _UnlockAllCommand ?? (_UnlockAllCommand = new RelayCommand(async () =>
|
||||||
|
{
|
||||||
|
// await Task.WhenAll(_copterManager.AcceptingControlCopters.Select(copter => copter.UnlockAsync()));
|
||||||
|
|
||||||
|
await Task.WhenAll(_copterManager.Copters.Select(async c => {
|
||||||
|
await c.UnlockAsync();
|
||||||
|
//解锁间隔一定要超过1s否则导致飞控以后无法解锁
|
||||||
|
for (int i = 0; !c.IsUnlocked; i++)
|
||||||
|
{
|
||||||
|
if (i > 200)
|
||||||
|
break;
|
||||||
|
if (i % (1000 / 25) == 1000 / 25 - 1)
|
||||||
|
{
|
||||||
|
await c.UnlockAsync(); // 每 1000 毫秒重试一次。解锁间隔一定要超过1s否则导致飞控以后无法解锁
|
||||||
|
}
|
||||||
|
await Task.Delay(25).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private ICommand _UnlockCommand;
|
private ICommand _UnlockCommand;
|
||||||
public ICommand UnlockCommand
|
public ICommand UnlockCommand
|
||||||
{
|
{
|
||||||
@ -529,62 +556,42 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
for (int j = 0; j < _flightTaskManager.Tasks.Count; j++)
|
for (int j = 0; j < _flightTaskManager.Tasks.Count; j++)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
switch (_flightTaskManager.Tasks[j].TaskType)
|
||||||
|
|
||||||
if (_flightTaskManager.Tasks[j].TaskType == FlightTaskType.FlyTo)
|
|
||||||
{
|
{
|
||||||
missions[missindex++] = Mission.CreateWaypointMission(_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLat,
|
case FlightTaskType.TakeOff:
|
||||||
_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLng, _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetAlt);
|
|
||||||
|
missions[missindex++] = Mission.CreateTakeoffMission(10,10,_flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetLat,
|
||||||
|
_flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetLng, 3);
|
||||||
|
//要起飞任务
|
||||||
|
|
||||||
|
break;
|
||||||
|
case FlightTaskType.FlyTo:
|
||||||
|
missions[missindex++] = Mission.CreateWaypointMission(10,10,_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLat,
|
||||||
|
_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLng, 3);
|
||||||
|
break;
|
||||||
|
case FlightTaskType.Loiter:
|
||||||
|
// missions[missindex++] = Mission.CreateWaypointMission(10,10,_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLat,
|
||||||
|
// _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLng, _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetAlt);
|
||||||
|
break;
|
||||||
|
case FlightTaskType.ReturnToLand:
|
||||||
|
//降落低空航点
|
||||||
|
// missions[missindex++] = Mission.CreateWaypointMission(_flightTaskManager.Tasks[j - 1].SingleCopterInfos[i].TargetLat,
|
||||||
|
// _flightTaskManager.Tasks[j - 1].SingleCopterInfos[i].TargetLng, 3);
|
||||||
|
//返航
|
||||||
|
missions[missindex++] = Mission.CreateReturnToLaunchMission();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_flightTaskManager.Tasks[j].TaskType == FlightTaskType.TakeOff)
|
|
||||||
{
|
|
||||||
|
|
||||||
//起飞低空航点
|
|
||||||
missions[missindex++] = Mission.CreateWaypointMission(_flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetLat,
|
|
||||||
_flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetLng, 10);
|
|
||||||
//不要起飞任务,在写入时会自动加入
|
|
||||||
//自动起飞10米后,需要飞到第一个航点下方
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_flightTaskManager.Tasks[j].TaskType == FlightTaskType.Loiter)
|
|
||||||
{
|
|
||||||
missions[missindex++] = Mission.CreateWaypointMission(_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLat,
|
|
||||||
_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLng, _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetAlt);
|
|
||||||
|
|
||||||
}
|
|
||||||
if (_flightTaskManager.Tasks[j].TaskType == FlightTaskType.ReturnToLand)
|
|
||||||
{
|
|
||||||
//降落低空航点
|
|
||||||
missions[missindex++] = Mission.CreateWaypointMission(_flightTaskManager.Tasks[j - 1].SingleCopterInfos[i].TargetLat,
|
|
||||||
_flightTaskManager.Tasks[j - 1].SingleCopterInfos[i].TargetLng, 10);
|
|
||||||
//返航
|
|
||||||
missions[missindex++] = Mission.CreateReturnToLaunchMission();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
var result = await _copterManager.Copters[i].WriteMissionListAsync(missions);
|
var result = await _copterManager.Copters[i].WriteMissionListAsync(missions);
|
||||||
//MessageBox.Show($"The result of WriteMissions: {result}");
|
//MessageBox.Show($"The result of WriteMissions: {result}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// var firstCopter = _copterManager.Copters.First();
|
// var firstCopter = _copterManager.Copters.First();
|
||||||
|
|
||||||
// Test TurnAsync.
|
// Test TurnAsync.
|
||||||
|
@ -40,10 +40,8 @@
|
|||||||
Command="{Binding HoverCommand}" />
|
Command="{Binding HoverCommand}" />
|
||||||
<Button Content="手动"
|
<Button Content="手动"
|
||||||
Command="{Binding FloatCommand}" />
|
Command="{Binding FloatCommand}" />
|
||||||
<Button Content="航点"
|
<Button Content="参数"
|
||||||
Command="{Binding WriteMissionCommand}" />
|
Command="{Binding ParamModify}" />
|
||||||
<Button Content="开始"
|
|
||||||
Command="{Binding MissionStartCommand}" />
|
|
||||||
|
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
<WrapPanel>
|
<WrapPanel>
|
||||||
@ -58,13 +56,23 @@
|
|||||||
<Button Content="测试"
|
<Button Content="测试"
|
||||||
|
|
||||||
Command="{Binding TestCommand}" />
|
Command="{Binding TestCommand}" />
|
||||||
<Button Content="参数"
|
|
||||||
Command="{Binding ParamModify}" />
|
|
||||||
<TextBox Width="50"
|
<TextBox Width="50"
|
||||||
Visibility="Hidden"
|
Visibility="Hidden"
|
||||||
Text="{Binding AltP, UpdateSourceTrigger=PropertyChanged}" />
|
Text="{Binding AltP, UpdateSourceTrigger=PropertyChanged}" />
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
|
<WrapPanel>
|
||||||
|
<Button Content="写入航点"
|
||||||
|
Command="{Binding WriteMissionCommand}" />
|
||||||
|
<Button Content="全部解锁"
|
||||||
|
Command="{Binding UnlockAllCommand}" />
|
||||||
|
<Button Content="开始任务"
|
||||||
|
Command="{Binding MissionStartCommand}" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</WrapPanel>
|
||||||
<WrapPanel>
|
<WrapPanel>
|
||||||
<TextBox
|
<TextBox
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
@ -81,6 +89,7 @@
|
|||||||
Text="{Binding Path=RTKState}"
|
Text="{Binding Path=RTKState}"
|
||||||
/>
|
/>
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--// 林俊清, 20150920, 目前不再使用 FormationController,删除相关按钮。
|
<!--// 林俊清, 20150920, 目前不再使用 FormationController,删除相关按钮。
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</StackPanel.Resources>
|
</StackPanel.Resources>
|
||||||
|
|
||||||
<TextBlock Text="任务操作" FontWeight="Bold" />
|
|
||||||
|
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
|
|
||||||
@ -152,7 +152,7 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<Separator />
|
<Separator />
|
||||||
<TextBlock Text="任务属性" Margin="0, 0, 5, 0" FontWeight="Bold" />
|
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
|
|
||||||
<TextBlock Text="起飞数量:" Margin="5,10,5,0" />
|
<TextBlock Text="起飞数量:" Margin="5,10,5,0" />
|
||||||
@ -193,7 +193,7 @@
|
|||||||
Value="2" />
|
Value="2" />
|
||||||
</Style>
|
</Style>
|
||||||
</TabControl.Resources>
|
</TabControl.Resources>
|
||||||
<TabItem Header="飞往">
|
<TabItem Header="航点">
|
||||||
<Grid Margin="5">
|
<Grid Margin="5">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition SharedSizeGroup="TabItem" />
|
<RowDefinition SharedSizeGroup="TabItem" />
|
||||||
@ -268,7 +268,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="转向">
|
<TabItem Header="转向" Visibility="Collapsed">
|
||||||
<Grid Margin="5">
|
<Grid Margin="5">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition SharedSizeGroup="TabItem" />
|
<RowDefinition SharedSizeGroup="TabItem" />
|
||||||
@ -304,7 +304,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="画圈">
|
<TabItem Header="画圈" Visibility="Collapsed">
|
||||||
<Grid Margin="5">
|
<Grid Margin="5">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition SharedSizeGroup="TabItem" />
|
<RowDefinition SharedSizeGroup="TabItem" />
|
||||||
|
Loading…
Reference in New Issue
Block a user