使用通信模块前的提交

添加速度改变
This commit is contained in:
zxd 2018-08-11 12:13:21 +08:00
parent 54a20e79e6
commit c6de7dc49e
7 changed files with 154 additions and 41 deletions

View File

@ -220,9 +220,9 @@ namespace Plane.FormationCreator.Formation
var newTask = new FlightTask(FlightTaskType.FlyTo); var newTask = new FlightTask(FlightTaskType.FlyTo);
int coptindex = 0; int coptindex = 0;
int colnum = 5; //自动生成列数=4 int colnum = 10; //自动生成列数=4
float coldis = 5;//列相距5米 float coldis = 5f;//列相距5米
float rowdis = 5;//行相距5米 float rowdis = 2.5f;//行相距5米
float matrixdis = 20; //生成方阵距离30米 float matrixdis = 20; //生成方阵距离30米

View File

@ -84,6 +84,28 @@ namespace Plane.FormationCreator.Formation
} }
} }
//应用当前是否是降落点到所选
private ICommand _SetIsChangeCommand;
public ICommand SetIsChangeCommand
{
get
{
return _SetIsChangeCommand ?? (_SetIsChangeCommand = new RelayCommand<double>(async =>
{
foreach (FlightTaskSingleCopterInfo info in _flightTaskManager.SelectedTask.SingleCopterInfos)
{
if (_copterManager.AcceptingControlCopters.Contains(info.Copter))
{
info.IsChangeSpeed = IsChangeSpeed;
info.LevelSpeed = LevelSpeed;
info.UpSpeed = UpSpeed;
info.DownSpeed = DownSpeed;
}
}
}));
}
}
private ICommand _SetSelLandWaitTimeCommand; private ICommand _SetSelLandWaitTimeCommand;
public ICommand SetSelLandWaitTimeCommand public ICommand SetSelLandWaitTimeCommand

View File

@ -42,13 +42,58 @@ namespace Plane.FormationCreator.Formation
} }
private bool _IsLandWaypoint = false; private bool _IsLandWaypoint = false;
//降落前的航点 只有高度有效,自动飞往起飞点写入航点的经纬为1000 飞控自动认为1000是飞往起点 by张旭东
/// <summary>
/// 降落前的航点 只有高度有效,自动飞往起飞点写入航点的经纬为90 180 飞控自动认为90 180是飞往起点
/// </summary>
public bool IsLandWaypoint public bool IsLandWaypoint
{ {
get { return _IsLandWaypoint; } get { return _IsLandWaypoint; }
set { Set(nameof(IsLandWaypoint), ref _IsLandWaypoint, value); } set { Set(nameof(IsLandWaypoint), ref _IsLandWaypoint, value); }
} }
private bool _IsChangeSpeed = false;
/// <summary>
/// 是否在当前航点前修改飞行速度
/// </summary>
public bool IsChangeSpeed
{
get {return _IsChangeSpeed; }
set { Set(nameof(IsChangeSpeed), ref _IsChangeSpeed, value); }
}
private float _LevelSpeed = 5.0f;
/// <summary>
/// 水平速度 IsChangeSpeed为True有效
/// </summary>
public float LevelSpeed
{
get { return _LevelSpeed; }
set { Set(nameof(LevelSpeed), ref _LevelSpeed, value); }
}
private float _UpSpeed = 2.5f;
/// <summary>
/// 上升速度 IsChangeSpeed为True有效
/// </summary>
public float UpSpeed
{
get { return _UpSpeed; }
set { Set(nameof(UpSpeed), ref _UpSpeed, value); }
}
private float _DownSpeed = 1.5f;
/// <summary>
/// 下降速度 IsChangeSpeed为True有效
/// </summary>
public float DownSpeed
{
get { return _DownSpeed; }
set { Set(nameof(DownSpeed), ref _DownSpeed, value); }
}
/* /*
* //同一个任务每一架飞机的FlytoTime和LoiterTime保持统一,已将FlytoTime和LoiterTime改到FlightTask.cs中 * //同一个任务每一架飞机的FlytoTime和LoiterTime保持统一,已将FlytoTime和LoiterTime改到FlightTask.cs中

View File

@ -61,7 +61,7 @@
Click="btnConnect_Click" /> Click="btnConnect_Click" />
<Menu Name="menuTask" VerticalAlignment="Center" > <Menu Name="menuTask" VerticalAlignment="Center" >
<MenuItem Header="导入导出" Foreground="#969696"> <MenuItem Header="导入导出" Margin="0,2,0,0" Foreground="#969696">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition/>

View File

@ -86,7 +86,7 @@ namespace Plane.FormationCreator.ViewModels
{ {
return _SendCommand ?? (_SendCommand = new RelayCommand(async () => return _SendCommand ?? (_SendCommand = new RelayCommand(async () =>
{ {
await SendCommandAsync(); await SendCommandAsync(CopterNum);
} }
)); ));
} }
@ -132,7 +132,7 @@ namespace Plane.FormationCreator.ViewModels
{ {
return _WriteIdCommand ?? (_WriteIdCommand = new RelayCommand(async () => return _WriteIdCommand ?? (_WriteIdCommand = new RelayCommand(async () =>
{ {
await WriteIdCommandAsync(CopterNum, MavComm.COMMANDTYPE4); await WriteIdCommandAsync(CopterNum, MavComm.COMM_SEARCH_MODE);
} }
)); ));
} }
@ -146,7 +146,7 @@ namespace Plane.FormationCreator.ViewModels
{ {
return _ChangeWriteMissionCommand ?? (_ChangeWriteMissionCommand = new RelayCommand(async () => return _ChangeWriteMissionCommand ?? (_ChangeWriteMissionCommand = new RelayCommand(async () =>
{ {
await WriteIdCommandAsync(0, MavComm.COMM_WRITE_MISSION); await WriteIdCommandAsync(0, MavComm.COMM_DOWNLOAD_MODE);
} }
)); ));
} }
@ -279,21 +279,24 @@ namespace Plane.FormationCreator.ViewModels
} }
} }
await WriteCommandAsync(copter, missions);
}
}
bool result = await WriteCommandAsync(copter, missions);
//_copterManager.Copters[i].WriteMissionListAsync(missions); //_copterManager.Copters[i].WriteMissionListAsync(missions);
/*
if (!result) if (!result)
{ {
Message.Show($"飞机:{copter.Name} 任务写入失败!");
Alert.Show($"飞机:{_copterManager.Copters[i].Name} 任务写入失败!");
return;
} }
*/ else
{
Message.Show($"飞机:{copter.Name} 任务写入成功!");
}
} }
Alert.Show($"所有任务写入成功!"); Alert.Show($"写入成!");
})); }));
} }
} }
@ -326,11 +329,11 @@ namespace Plane.FormationCreator.ViewModels
await commModule.GeneratePacketAsync((short)num, messageType); await commModule.GeneratePacketAsync((short)num, messageType);
} }
private async Task SendCommandAsync() private async Task SendCommandAsync(int Count)
{ {
Protocols.MavComm.comm_set_mav_count mavCount = new Protocols.MavComm.comm_set_mav_count(); MavComm.comm_set_mav_count mavCount = new MavComm.comm_set_mav_count();
mavCount.mav_count = 200; mavCount.mav_count = (short)Count;
await commModule.GenerateDataAsync(0, (byte)Protocols.MavComm.COMM_SET_MAV_COUNT, mavCount); await commModule.GenerateDataAsync(0, MavComm.COMM_SET_MAV_COUNT, mavCount);
} }
public async Task<bool> DoCommandAsync(MAVLink.MAV_CMD actionid, float p1, float p2, float p3, float p4, float p5, float p6, float p7) public async Task<bool> DoCommandAsync(MAVLink.MAV_CMD actionid, float p1, float p2, float p3, float p4, float p5, float p6, float p7)
@ -357,7 +360,7 @@ namespace Plane.FormationCreator.ViewModels
await Task.Delay(10); await Task.Delay(10);
return true; return true;
} }
private async Task WriteCommandAsync(ICopter copter, List<IMission> missions) private async Task<bool> WriteCommandAsync(ICopter copter, List<IMission> missions)
{ {
List<MAVLink.mavlink_mission_item_t> mission_list = new List<MAVLink.mavlink_mission_item_t>(); List<MAVLink.mavlink_mission_item_t> mission_list = new List<MAVLink.mavlink_mission_item_t>();
foreach (IMission mission in missions) foreach (IMission mission in missions)
@ -400,7 +403,7 @@ namespace Plane.FormationCreator.ViewModels
mission_list.Add(req); mission_list.Add(req);
} }
await commModule.GeneratePacketAsyncNew(short.Parse(copter.Name), (byte)Protocols.MavComm.COMM_WRITE_MISSION, mission_list.ToArray()); return await commModule.GeneratePacketAsyncNew(short.Parse(copter.Name), (byte)Protocols.MavComm.COMM_DOWNLOAD_MODE, mission_list.ToArray());
} }

View File

@ -426,7 +426,7 @@ namespace Plane.FormationCreator.ViewModels
} }
private string _RTKcomvalue = "COM3"; private string _RTKcomvalue = "COM6";
public string RTKcomvalue public string RTKcomvalue
{ {
get { return _RTKcomvalue; } get { return _RTKcomvalue; }
@ -828,7 +828,14 @@ namespace Plane.FormationCreator.ViewModels
case FlightTaskType.FlyTo: case FlightTaskType.FlyTo:
missions.AddRange(CreateLEDMissions(_flightTaskManager.Tasks[j].SingleCopterInfos[i].LEDInfos)); missions.AddRange(CreateLEDMissions(_flightTaskManager.Tasks[j].SingleCopterInfos[i].LEDInfos));
if (_flightTaskManager.Tasks[j].SingleCopterInfos[i].IsChangeSpeed)
{
missions.Add(Mission.CreateChangeSpeedMission(
_flightTaskManager.Tasks[j].SingleCopterInfos[i].LevelSpeed,
_flightTaskManager.Tasks[j].SingleCopterInfos[i].UpSpeed,
_flightTaskManager.Tasks[j].SingleCopterInfos[i].DownSpeed)
);
}
double Lat = _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLat - _flightTaskManager.OriginLat; double Lat = _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLat - _flightTaskManager.OriginLat;
double Lng = _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLng - _flightTaskManager.OriginLng; double Lng = _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLng - _flightTaskManager.OriginLng;
if (_flightTaskManager.Tasks[j].SingleCopterInfos[i].IsLandWaypoint) if (_flightTaskManager.Tasks[j].SingleCopterInfos[i].IsLandWaypoint)

View File

@ -59,7 +59,7 @@
</StackPanel> </StackPanel>
</TabItem> </TabItem>
<TabItem Header="航点"> <TabItem Header="航点">
<StackPanel Orientation="Vertical" Margin="0,0,0,-30"> <StackPanel Orientation="Vertical" Margin="0,1">
<StackPanel.Resources> <StackPanel.Resources>
<Style TargetType="StackPanel"> <Style TargetType="StackPanel">
<Setter Property="Orientation" Value="Horizontal" /> <Setter Property="Orientation" Value="Horizontal" />
@ -71,7 +71,7 @@
<Button Content="优化路线" Command="{Binding OptimizeRouteCommand}" /> <Button Content="优化路线" Command="{Binding OptimizeRouteCommand}" />
</StackPanel> </StackPanel>
<Separator/> <Separator Margin="0,1"/>
<StackPanel> <StackPanel>
<Button Content="上边对齐" <Button Content="上边对齐"
Margin="0,5,5,0" Margin="0,5,5,0"
@ -166,10 +166,10 @@
<TextBlock Text="度" Margin="0, 10, 5, 0"/> <TextBlock Text="度" Margin="0, 10, 5, 0"/>
</StackPanel> </StackPanel>
<Separator /> <Separator Margin="0,2" />
<Grid Margin="5,10,5,0" <Grid Margin="0,2"
DataContext="{Binding FlightTaskManager.SelectedTask.ModifyingSingleCopterInfo}" DataContext="{Binding FlightTaskManager.SelectedTask.ModifyingSingleCopterInfo}"
IsEnabled="{Binding CanModifySingleCopterInfo}" > IsEnabled="{Binding CanModifySingleCopterInfo}" >
<Grid.RowDefinitions> <Grid.RowDefinitions>
@ -181,34 +181,39 @@
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition /> <ColumnDefinition />
<ColumnDefinition /> <ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Text="纬度: " /> <TextBlock Text="纬度: " />
<TextBox Grid.Column="1" <TextBox Grid.Column="2"
Margin="0,5,10,0" Grid.ColumnSpan="2"
Margin="0,2,0,0"
Text="{Binding TargetLat, UpdateSourceTrigger=PropertyChanged}" /> Text="{Binding TargetLat, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="1" <TextBlock Grid.Row="1"
Text="经度: " /> Text="经度: " />
<TextBox Grid.Row="1" <TextBox Grid.Row="1"
Grid.Column="1" Grid.Column="2"
Margin="0,5,10,0" Grid.ColumnSpan="2"
Margin="0,2,0,0"
Text="{Binding TargetLng, UpdateSourceTrigger=PropertyChanged}" /> Text="{Binding TargetLng, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="2" <TextBlock Grid.Row="2"
Text="高度: " /> Text="高度: " />
<TextBox Grid.Row="2" <TextBox Grid.Row="2"
Grid.Column="1" Grid.Column="2"
Margin="0,5,10,0" Margin="0,2,0,0"
Text="{Binding TargetAlt, UpdateSourceTrigger=PropertyChanged}" /> Text="{Binding TargetAlt, UpdateSourceTrigger=PropertyChanged}" />
<Button Grid.Row="3" <Button Grid.Row="2"
Content="应用高度到所选" Content="应用到所选"
Grid.Column="1" Margin="0,5,10,0" Grid.Column="3" Margin="0,2,0,0"
Command="{Binding SetAllCopterAltCommand}"/> Command="{Binding SetAllCopterAltCommand}"/>
</Grid> </Grid>
<Separator/> <Separator Margin="0,2"/>
<Grid DataContext="{Binding FlightTaskManager.SelectedTask.ModifyingSingleCopterInfo}" <Grid Margin="0,2,0,0"
DataContext="{Binding FlightTaskManager.SelectedTask.ModifyingSingleCopterInfo}"
IsEnabled="{Binding CanModifySingleCopterInfo}" > IsEnabled="{Binding CanModifySingleCopterInfo}" >
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition/> <ColumnDefinition/>
@ -216,8 +221,39 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<CheckBox Margin="5" IsChecked="{Binding IsLandWaypoint,UpdateSourceTrigger=PropertyChanged}" Content="下降点"/> <CheckBox Content="返航点" ToolTip="勾选后航点仅高度有用,经纬度无效,无视原点自动飞回起飞点" Margin="0,2,0,0" IsChecked="{Binding IsLandWaypoint,UpdateSourceTrigger=PropertyChanged}" />
<Button Margin="5" Command="{Binding SetIsLandCommand}" Content="应用到所选" Grid.Column="1"/> <Button Content="应用到所选" Margin="0,2,0,0" Command="{Binding SetIsLandCommand}" Grid.Column="1"/>
</Grid>
<Separator/>
<Grid Margin="0,2"
DataContext="{Binding FlightTaskManager.SelectedTask.ModifyingSingleCopterInfo}"
IsEnabled="{Binding CanModifySingleCopterInfo}" >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<CheckBox Content="改变速度" Margin="0,2"
IsChecked="{Binding IsChangeSpeed, UpdateSourceTrigger=PropertyChanged}"/>
<StackPanel Margin="0,2" Grid.Column="1">
<TextBlock Text="水平"/>
<TextBox Width="45" Margin="5,0,0,5"
Text="{Binding LevelSpeed}"/>
<TextBlock Text="上升" Margin="15,0,0,0"/>
<TextBox Width="45" Margin="5,0,0,5"
Text="{Binding UpSpeed}"/>
<TextBlock Text="下降" Margin="15,0,0,0"/>
<TextBox Width="45" Margin="5,0,0,5"
Text="{Binding DownSpeed}"/>
</StackPanel>
<Button Content="应用到所选" Grid.Row="1" Grid.Column="1" Command="{Binding SetIsChangeCommand}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
</TabItem> </TabItem>