diff --git a/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj b/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj index 8057a93af5..3a699f7fa9 100644 --- a/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj +++ b/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj @@ -274,12 +274,6 @@ FlightPlanner.cs - - UserControl - - - test.cs - Form @@ -509,9 +503,6 @@ Terminal.cs - - test.cs - HUD.cs diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs index 0367a47c15..1177d7baab 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs @@ -706,7 +706,7 @@ namespace ArdupilotMega.GCSViews DateTime startwait = DateTime.Now; - while ((DateTime.Now - startwait).TotalSeconds < 90) + while ((DateTime.Now - startwait).TotalSeconds < 75) { try { @@ -714,7 +714,7 @@ namespace ArdupilotMega.GCSViews } catch { } System.Threading.Thread.Sleep(1000); - progress.Value = (int)((DateTime.Now - startwait).TotalSeconds / 90.0 * 100); + progress.Value = (int)((DateTime.Now - startwait).TotalSeconds / 75 * 100); progress.Refresh(); } try diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.Designer.cs index 3726f280f9..33a007d093 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.Designer.cs @@ -31,14 +31,14 @@ { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FlightPlanner)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle21 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle22 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle23 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle24 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); this.CHK_altmode = new System.Windows.Forms.CheckBox(); this.CHK_holdalt = new System.Windows.Forms.CheckBox(); this.Commands = new System.Windows.Forms.DataGridView(); @@ -118,14 +118,15 @@ this.addPolygonPointToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.clearPolygonToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.clearMissionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.geoFenceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.GeoFenceuploadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.GeoFencedownloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.trackBar1 = new ArdupilotMega.MyTrackBar(); this.label11 = new System.Windows.Forms.Label(); this.panelBASE = new System.Windows.Forms.Panel(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components); - this.geoFenceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.GeoFenceuploadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.GeoFencedownloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.setReturnLocationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.Commands)).BeginInit(); this.panel5.SuspendLayout(); this.panel1.SuspendLayout(); @@ -157,14 +158,14 @@ // this.Commands.AllowUserToAddRows = false; resources.ApplyResources(this.Commands, "Commands"); - dataGridViewCellStyle17.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle17.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle17.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dataGridViewCellStyle17.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle17.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle17.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle17.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.Commands.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle17; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.Commands.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.Commands.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Command, this.Param1, @@ -178,17 +179,17 @@ this.Up, this.Down}); this.Commands.Name = "Commands"; - dataGridViewCellStyle21.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle21.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle21.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dataGridViewCellStyle21.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle21.Format = "N0"; - dataGridViewCellStyle21.NullValue = "0"; - dataGridViewCellStyle21.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle21.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - this.Commands.RowHeadersDefaultCellStyle = dataGridViewCellStyle21; - dataGridViewCellStyle22.ForeColor = System.Drawing.Color.Black; - this.Commands.RowsDefaultCellStyle = dataGridViewCellStyle22; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle5.Format = "N0"; + dataGridViewCellStyle5.NullValue = "0"; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + this.Commands.RowHeadersDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.Black; + this.Commands.RowsDefaultCellStyle = dataGridViewCellStyle6; this.Commands.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.Commands_CellContentClick); this.Commands.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.Commands_CellEndEdit); this.Commands.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.Commands_DataError); @@ -200,9 +201,9 @@ // // Command // - dataGridViewCellStyle18.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(67)))), ((int)(((byte)(68)))), ((int)(((byte)(69))))); - dataGridViewCellStyle18.ForeColor = System.Drawing.Color.White; - this.Command.DefaultCellStyle = dataGridViewCellStyle18; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(67)))), ((int)(((byte)(68)))), ((int)(((byte)(69))))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.White; + this.Command.DefaultCellStyle = dataGridViewCellStyle2; this.Command.DisplayStyle = System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox; resources.ApplyResources(this.Command, "Command"); this.Command.Name = "Command"; @@ -268,7 +269,7 @@ // // Up // - this.Up.DefaultCellStyle = dataGridViewCellStyle19; + this.Up.DefaultCellStyle = dataGridViewCellStyle3; resources.ApplyResources(this.Up, "Up"); this.Up.Image = global::ArdupilotMega.Properties.Resources.up; this.Up.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Stretch; @@ -276,8 +277,8 @@ // // Down // - dataGridViewCellStyle20.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.Down.DefaultCellStyle = dataGridViewCellStyle20; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.Down.DefaultCellStyle = dataGridViewCellStyle4; resources.ApplyResources(this.Down, "Down"); this.Down.Image = global::ArdupilotMega.Properties.Resources.down; this.Down.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Stretch; @@ -421,8 +422,8 @@ // // dataGridViewImageColumn1 // - dataGridViewCellStyle23.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.dataGridViewImageColumn1.DefaultCellStyle = dataGridViewCellStyle23; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.dataGridViewImageColumn1.DefaultCellStyle = dataGridViewCellStyle7; resources.ApplyResources(this.dataGridViewImageColumn1, "dataGridViewImageColumn1"); this.dataGridViewImageColumn1.Image = global::ArdupilotMega.Properties.Resources.up; this.dataGridViewImageColumn1.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Stretch; @@ -430,8 +431,8 @@ // // dataGridViewImageColumn2 // - dataGridViewCellStyle24.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.dataGridViewImageColumn2.DefaultCellStyle = dataGridViewCellStyle24; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.dataGridViewImageColumn2.DefaultCellStyle = dataGridViewCellStyle8; resources.ApplyResources(this.dataGridViewImageColumn2, "dataGridViewImageColumn2"); this.dataGridViewImageColumn2.Image = global::ArdupilotMega.Properties.Resources.down; this.dataGridViewImageColumn2.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Stretch; @@ -827,6 +828,27 @@ resources.ApplyResources(this.clearMissionToolStripMenuItem, "clearMissionToolStripMenuItem"); this.clearMissionToolStripMenuItem.Click += new System.EventHandler(this.clearMissionToolStripMenuItem_Click); // + // geoFenceToolStripMenuItem + // + this.geoFenceToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.GeoFenceuploadToolStripMenuItem, + this.GeoFencedownloadToolStripMenuItem, + this.setReturnLocationToolStripMenuItem}); + this.geoFenceToolStripMenuItem.Name = "geoFenceToolStripMenuItem"; + resources.ApplyResources(this.geoFenceToolStripMenuItem, "geoFenceToolStripMenuItem"); + // + // GeoFenceuploadToolStripMenuItem + // + this.GeoFenceuploadToolStripMenuItem.Name = "GeoFenceuploadToolStripMenuItem"; + resources.ApplyResources(this.GeoFenceuploadToolStripMenuItem, "GeoFenceuploadToolStripMenuItem"); + this.GeoFenceuploadToolStripMenuItem.Click += new System.EventHandler(this.GeoFenceuploadToolStripMenuItem_Click); + // + // GeoFencedownloadToolStripMenuItem + // + this.GeoFencedownloadToolStripMenuItem.Name = "GeoFencedownloadToolStripMenuItem"; + resources.ApplyResources(this.GeoFencedownloadToolStripMenuItem, "GeoFencedownloadToolStripMenuItem"); + this.GeoFencedownloadToolStripMenuItem.Click += new System.EventHandler(this.GeoFencedownloadToolStripMenuItem_Click); + // // trackBar1 // resources.ApplyResources(this.trackBar1, "trackBar1"); @@ -863,25 +885,11 @@ this.timer1.Interval = 1000; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // - // geoFenceToolStripMenuItem + // setReturnLocationToolStripMenuItem // - this.geoFenceToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.GeoFenceuploadToolStripMenuItem, - this.GeoFencedownloadToolStripMenuItem}); - this.geoFenceToolStripMenuItem.Name = "geoFenceToolStripMenuItem"; - resources.ApplyResources(this.geoFenceToolStripMenuItem, "geoFenceToolStripMenuItem"); - // - // GeoFenceuploadToolStripMenuItem - // - this.GeoFenceuploadToolStripMenuItem.Name = "GeoFenceuploadToolStripMenuItem"; - resources.ApplyResources(this.GeoFenceuploadToolStripMenuItem, "GeoFenceuploadToolStripMenuItem"); - this.GeoFenceuploadToolStripMenuItem.Click += new System.EventHandler(this.GeoFenceuploadToolStripMenuItem_Click); - // - // GeoFencedownloadToolStripMenuItem - // - this.GeoFencedownloadToolStripMenuItem.Name = "GeoFencedownloadToolStripMenuItem"; - resources.ApplyResources(this.GeoFencedownloadToolStripMenuItem, "GeoFencedownloadToolStripMenuItem"); - this.GeoFencedownloadToolStripMenuItem.Click += new System.EventHandler(this.GeoFencedownloadToolStripMenuItem_Click); + this.setReturnLocationToolStripMenuItem.Name = "setReturnLocationToolStripMenuItem"; + resources.ApplyResources(this.setReturnLocationToolStripMenuItem, "setReturnLocationToolStripMenuItem"); + this.setReturnLocationToolStripMenuItem.Click += new System.EventHandler(this.setReturnLocationToolStripMenuItem_Click); // // FlightPlanner // @@ -1000,5 +1008,6 @@ private System.Windows.Forms.ToolStripMenuItem geoFenceToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem GeoFenceuploadToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem GeoFencedownloadToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem setReturnLocationToolStripMenuItem; } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs index b8370b6608..91c67c324e 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs @@ -660,6 +660,11 @@ namespace ArdupilotMega.GCSViews isonline = false; } + + List polygonPoints = new List(); + gf = new GMapPolygon(polygonPoints, "geofence"); + gf.Stroke = new Pen(Color.Pink, 5); + updateCMDParams(); // mono @@ -2958,6 +2963,7 @@ namespace ArdupilotMega.GCSViews private void GeoFenceuploadToolStripMenuItem_Click(object sender, EventArgs e) { + polygongridmode = false; //FENCE_TOTAL if (MainV2.comPort.param["FENCE_ACTION"] == null) { @@ -2965,33 +2971,101 @@ namespace ArdupilotMega.GCSViews return; } - if (MainV2.comPort.param["FENCE_ACTION"].ToString() != "0") - MainV2.comPort.setParam("FENCE_ACTION", 0); - if (drawnpolygon == null) { MessageBox.Show("No polygon to upload"); return; } - MainV2.comPort.setParam("FENCE_TOTAL", drawnpolygon.Points.Count); + if (geofence.Markers.Count == 0) + { + MessageBox.Show("No return location set"); + return; + } + + if (drawnpolygon.Points.Count == 0) + { + MessageBox.Show("No polygon drawn"); + return; + } + + string minalts = (int.Parse(MainV2.comPort.param["FENCE_MINALT"].ToString()) * MainV2.cs.multiplierdist).ToString("0"); + Common.InputBox("Min Alt", "Box Minimum Altitude?", ref minalts); + + string maxalts = (int.Parse(MainV2.comPort.param["FENCE_MAXALT"].ToString()) * MainV2.cs.multiplierdist).ToString("0"); + Common.InputBox("Max Alt", "Box Maximum Altitude?", ref maxalts); + + int minalt = 0; + int maxalt = 0; + + if (!int.TryParse(minalts,out minalt)) + { + MessageBox.Show("Bad Min Alt"); + return; + } + + if (!int.TryParse(maxalts,out maxalt)) + { + MessageBox.Show("Bad Max Alt"); + return; + } + + try + { + MainV2.comPort.setParam("FENCE_MINALT", minalt); + MainV2.comPort.setParam("FENCE_MAXALT", maxalt); + } + catch { + MessageBox.Show("Failed to set min/max fence alt"); + return; + } + + try + { + if (MainV2.comPort.param["FENCE_ACTION"].ToString() != "0") + MainV2.comPort.setParam("FENCE_ACTION", 0); + } + catch + { + MessageBox.Show("Failed to set FENCE_ACTION"); + return; + } + + // points + return + close + byte pointcount = (byte)(drawnpolygon.Points.Count + 2); + + MainV2.comPort.setParam("FENCE_TOTAL", pointcount); byte a = 0; + // add return loc + MainV2.comPort.setFencePoint(a, new PointLatLngAlt(geofence.Markers[0].Position), pointcount); + a++; + + // add points foreach (var pll in drawnpolygon.Points) { - MainV2.comPort.setFencePoint(a, new PointLatLngAlt(pll), (byte)drawnpolygon.Points.Count); + MainV2.comPort.setFencePoint(a, new PointLatLngAlt(pll), pointcount); a++; } + // add polygon close + MainV2.comPort.setFencePoint(a, new PointLatLngAlt(drawnpolygon.Points[0]), pointcount); drawnpolygons.Polygons.Clear(); drawnpolygons.Markers.Clear(); + gf.Points.Clear(); + gf.Points.AddRange(drawnpolygon.Points); + + drawnpolygon.Points.Clear(); + + MainMap.UpdatePolygonLocalPosition(gf); MainMap.Invalidate(); } private void GeoFencedownloadToolStripMenuItem_Click(object sender, EventArgs e) { + polygongridmode = false; int count = 1; if (MainV2.comPort.param["FENCE_ACTION"] == null || MainV2.comPort.param["FENCE_TOTAL"] == null) @@ -3000,18 +3074,16 @@ namespace ArdupilotMega.GCSViews return; } - if (int.Parse(MainV2.comPort.param["FENCE_TOTAL"].ToString()) == 0) + if (int.Parse(MainV2.comPort.param["FENCE_TOTAL"].ToString()) <= 1) { MessageBox.Show("Nothing to download"); return; } geofence.Polygons.Clear(); + geofence.Markers.Clear(); - List polygonPoints = new List(); - - gf = new GMapPolygon(polygonPoints, "geofence"); - gf.Stroke = new Pen(Color.Pink, 5); + gf.Points.Clear(); geofence.Polygons.Add(gf); FlightData.geofence.Polygons.Clear(); @@ -3023,9 +3095,21 @@ namespace ArdupilotMega.GCSViews gf.Points.Add(new PointLatLng(plla.Lat, plla.Lng)); } + // do return location + geofence.Markers.Add(new GMapMarkerGoogleRed(new PointLatLng(gf.Points[0].Lat, gf.Points[0].Lng)) { ToolTipMode = MarkerTooltipMode.OnMouseOver, ToolTipText = "GeoFence Return" }); + gf.Points.RemoveAt(0); + MainMap.UpdatePolygonLocalPosition(gf); MainMap.Invalidate(); } + + private void setReturnLocationToolStripMenuItem_Click(object sender, EventArgs e) + { + geofence.Markers.Clear(); + geofence.Markers.Add(new GMapMarkerGoogleRed(start)); + + MainMap.Invalidate(); + } } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.resx b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.resx index f711edf4d9..0dcf3a930a 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.resx +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.resx @@ -537,75 +537,6 @@ Bottom, Right - - BUT_write - - - ArdupilotMega.MyButton, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc - - - panel5 - - - 0 - - - BUT_read - - - ArdupilotMega.MyButton, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc - - - panel5 - - - 1 - - - SaveFile - - - ArdupilotMega.MyButton, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc - - - panel5 - - - 2 - - - BUT_loadwpfile - - - ArdupilotMega.MyButton, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc - - - panel5 - - - 3 - - - 8, 250 - - - 117, 114 - - - 29 - - - panel5 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panelAction - - - 1 - NoControl @@ -714,113 +645,29 @@ 3 - - Bottom, Right + + 8, 250 - - label4 + + 117, 114 - - System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 29 - - panel1 + + panel5 - - 0 - - - label3 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 1 - - - label2 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 2 - - - Label1 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 3 - - - TXT_homealt - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 4 - - - TXT_homelng - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 5 - - - TXT_homelat - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 6 - - - 8, 365 - - - 117, 89 - - - 31 - - - panel1 - - + System.Windows.Forms.Panel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + panelAction - - 2 + + 1 + + + Bottom, Right True @@ -1005,6 +852,27 @@ 6 + + 8, 365 + + + 117, 89 + + + 31 + + + panel1 + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panelAction + + + 2 + Up @@ -1044,111 +912,6 @@ Bottom, Right - - label7 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel2 - - - 0 - - - label8 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel2 - - - 1 - - - label9 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel2 - - - 2 - - - label10 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel2 - - - 3 - - - TXT_mousealt - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel2 - - - 4 - - - TXT_mouselong - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel2 - - - 5 - - - TXT_mouselat - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel2 - - - 6 - - - 8, 130 - - - 114, 79 - - - 38 - - - panel2 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panelAction - - - 3 - True @@ -1332,9 +1095,27 @@ 6 - - 172, 17 - + + 8, 130 + + + 114, 79 + + + 38 + + + panel2 + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panelAction + + + 3 + Bottom, Right @@ -1347,6 +1128,9 @@ 42 + + 172, 17 + Change the current map type @@ -1821,12 +1605,42 @@ Delete WP + + 113, 22 + + + Forever + + + 113, 22 + + + Time + + + 113, 22 + + + Circles + 167, 22 Loiter + + 102, 22 + + + Start + + + 102, 22 + + + WP # + 167, 22 @@ -1848,6 +1662,18 @@ Rotate Map + + 174, 22 + + + Add Polygon Point + + + 174, 22 + + + Clear Polygon + 167, 22 @@ -1861,17 +1687,23 @@ Clear Mission - 152, 22 + 177, 22 Upload - 152, 22 + 177, 22 Download + + 177, 22 + + + Set Return Location + 167, 22 @@ -2143,48 +1975,6 @@ 1 - - 113, 22 - - - Forever - - - 113, 22 - - - Time - - - 113, 22 - - - Circles - - - 102, 22 - - - Start - - - 102, 22 - - - WP # - - - 174, 22 - - - Add Polygon Point - - - 174, 22 - - - Clear Polygon - Fill @@ -2209,9 +1999,6 @@ 1 - - 172, 17 - 269, 17 @@ -2395,18 +2182,6 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - toolTip1 - - - System.Windows.Forms.ToolTip, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - timer1 - - - System.Windows.Forms.Timer, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - geoFenceToolStripMenuItem @@ -2425,6 +2200,24 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + toolTip1 + + + System.Windows.Forms.ToolTip, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + timer1 + + + System.Windows.Forms.Timer, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + setReturnLocationToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + FlightPlanner diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs index bd7adc8fff..7c22c69fa8 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs @@ -318,7 +318,7 @@ namespace ArdupilotMega.GCSViews /// true/false private void xmlconfig(bool write) { - int fixme; + int fixme; // add profiles? if (write) { ArdupilotMega.MainV2.config["REV_roll"] = CHKREV_roll.Checked.ToString(); diff --git a/Tools/ArdupilotMegaPlanner/MAVLinkTypes.cs b/Tools/ArdupilotMegaPlanner/MAVLinkTypes.cs index 3001bb8d4f..2f855af568 100644 --- a/Tools/ArdupilotMegaPlanner/MAVLinkTypes.cs +++ b/Tools/ArdupilotMegaPlanner/MAVLinkTypes.cs @@ -8,7 +8,30 @@ namespace ArdupilotMega #if MAVLINK10 partial class MAVLink { - + + public const byte MAVLINK_MSG_ID_FENCED_POINT_LEN = 10; + public const byte MAVLINK_MSG_ID_FENCE_FETCH_POINT = 161; + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct __mavlink_fence_fetch_point_t + { + public byte target_system; /// System ID + public byte target_component; /// Component ID + public byte idx; /// point index (first point is 1, 0 is for return point) + }; + + public const byte MAVLINK_MSG_ID_FENCE_FETCH_POINT_LEN = 3; + public const byte MAVLINK_MSG_ID_FENCE_POINT = 160; + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct __mavlink_fence_point_t + { + public byte target_system; /// System ID + public byte target_component; /// Component ID + public byte idx; /// point index (first point is 1, 0 is for return point) + public byte count; /// total number of points (for sanity checking) + public float lat; /// Latitude of point + public float lng; /// Longitude of point + }; + public byte[] MAVLINK_MESSAGE_LENGTHS = new byte[] {9, 31, 12, 0, 14, 28, 3, 32, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 20, 2, 25, 23, 30, 101, 22, 26, 16, 14, 28, 32, 28, 28, 22, 22, 21, 6, 6, 37, 4, 4, 2, 2, 4, 2, 2, 3, 13, 12, 19, 17, 15, 15, 27, 25, 18, 18, 20, 20, 0, 0, 26, 0, 36, 0, 6, 4, 0, 21, 18, 0, 0, 0, 20, 0, 33, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 42, 33, 0, 0, 0, 0, 0, 0, 0, 18, 32, 32, 20, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 8, 4, 12, 15, 13, 6, 15, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 30, 18, 18, 51, 9, 3}; public byte[] MAVLINK_MESSAGE_CRCS = new byte[] {50, 124, 137, 0, 237, 217, 104, 119, 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, 0, 0, 214, 159, 220, 168, 24, 23, 170, 144, 67, 115, 39, 246, 185, 104, 237, 244, 222, 212, 9, 254, 230, 28, 28, 132, 221, 232, 11, 153, 41, 39, 214, 223, 141, 33, 15, 3, 100, 24, 239, 238, 0, 0, 183, 0, 130, 0, 148, 21, 0, 52, 124, 0, 0, 0, 20, 0, 152, 143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 183, 63, 54, 0, 0, 0, 0, 0, 0, 0, 19, 102, 158, 208, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 134, 219, 208, 188, 84, 22, 19, 21, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 204, 49, 170, 44, 83, 46, 247}; public enum MAV_MOUNT_MODE diff --git a/Tools/ArdupilotMegaPlanner/MainV2.cs b/Tools/ArdupilotMegaPlanner/MainV2.cs index 3ec6f59792..06686a8136 100644 --- a/Tools/ArdupilotMegaPlanner/MainV2.cs +++ b/Tools/ArdupilotMegaPlanner/MainV2.cs @@ -1860,25 +1860,6 @@ namespace ArdupilotMega return base.ProcessCmdKey(ref msg, keyData); } - private void starttest() - { - MyView.Controls.Clear(); - - UserControl temp = new GCSViews.test(); - - fixtheme(temp); - - temp.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; - - temp.Dock = DockStyle.Fill; - - MyView.Controls.Add(temp); - - temp.ForeColor = Color.White; - - temp.BackColor = Color.FromArgb(0x26, 0x27, 0x28); - } - public void changelanguage(CultureInfo ci) { if (ci != null && !Thread.CurrentThread.CurrentUICulture.Equals(ci)) diff --git a/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs b/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs index 4a441af67c..3fac338c3e 100644 --- a/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs +++ b/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs @@ -34,5 +34,5 @@ using System.Resources; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.1.10")] +[assembly: AssemblyFileVersion("1.1.11")] [assembly: NeutralResourcesLanguageAttribute("")] diff --git a/Tools/ArdupilotMegaPlanner/Setup/Setup.cs b/Tools/ArdupilotMegaPlanner/Setup/Setup.cs index 91d69bc42e..b2c3d6edb6 100644 --- a/Tools/ArdupilotMegaPlanner/Setup/Setup.cs +++ b/Tools/ArdupilotMegaPlanner/Setup/Setup.cs @@ -811,11 +811,11 @@ namespace ArdupilotMega.Setup } catch (Exception ex) { MainV2.givecomport = false; MessageBox.Show("Invalid Comport Settings : " + ex.Message); return; } - BUT_reset.Text = "Rebooting (60 sec)"; + BUT_reset.Text = "Rebooting (75 sec)"; BUT_reset.Refresh(); Application.DoEvents(); - Sleep(60000, comPortT); // wait for boot/reset + Sleep(75000, comPortT); // wait for boot/reset comPortT.DtrEnable = false; diff --git a/Tools/ArdupilotMegaPlanner/georefimage.cs b/Tools/ArdupilotMegaPlanner/georefimage.cs index 2b5060b7e3..7da4176f80 100644 --- a/Tools/ArdupilotMegaPlanner/georefimage.cs +++ b/Tools/ArdupilotMegaPlanner/georefimage.cs @@ -9,6 +9,10 @@ using System.Windows.Forms; using com.drew.imaging.jpg; using com.drew.metadata; +using SharpKml.Base; +using SharpKml.Dom; +using SharpKml.Dom.GX; + namespace ArdupilotMega { class georefimage : Form @@ -25,6 +29,8 @@ namespace ArdupilotMega private TextBox TXT_outputlog; private MyButton BUT_estoffset; + int latpos = 5, lngpos = 4, altpos = 7; + internal georefimage() { InitializeComponent(); } @@ -117,7 +123,7 @@ namespace ArdupilotMega return list; } - public void dowork(string logFile, string dirWithImages, float offsetseconds,bool dooffset) + public void dowork(string logFile, string dirWithImages, float offsetseconds, bool dooffset) { DateTime localmin = DateTime.MaxValue; DateTime localmax = DateTime.MinValue; @@ -132,6 +138,10 @@ namespace ArdupilotMega string[] files = Directory.GetFiles(dirWithImages); + Document kml = new Document(); + + StreamWriter sw3 = new StreamWriter(dirWithImages + Path.DirectorySeparatorChar + "location.kml"); + StreamWriter sw2 = new StreamWriter(dirWithImages + Path.DirectorySeparatorChar + "location.txt"); StreamWriter sw = new StreamWriter(dirWithImages + Path.DirectorySeparatorChar + "location.tel"); @@ -174,18 +184,18 @@ namespace ArdupilotMega DateTime crap = startTime.AddMilliseconds(int.Parse(arr[1])).AddSeconds(offsetseconds); - - if (first == 0) - { - TXT_outputlog.AppendText("Photo " + Path.GetFileNameWithoutExtension(file) + " " + dt + " vs Log " + crap + "\r\n"); - TXT_outputlog.AppendText("offset should be about " + (dt -crap).TotalSeconds + "\r\n"); + if (first == 0) + { + TXT_outputlog.AppendText("Photo " + Path.GetFileNameWithoutExtension(file) + " " + dt + " vs Log " + crap + "\r\n"); - if (dooffset) - return; + TXT_outputlog.AppendText("offset should be about " + (dt - crap).TotalSeconds + "\r\n"); - first++; - } + if (dooffset) + return; + + first++; + } //Console.Write("ph " + dt + " log " + crap + " \r"); @@ -195,25 +205,41 @@ namespace ArdupilotMega matchs++; - sw2.WriteLine(Path.GetFileNameWithoutExtension(file) + " " + arr[5] + " " + arr[4] + " " + arr[7]); - sw.WriteLine(Path.GetFileNameWithoutExtension(file) + "\t" + crap.ToString("yyyy:MM:dd HH:mm:ss") +"\t"+ arr[5] + "\t" + arr[4] + "\t" + arr[7]); + kml.AddFeature( + new Placemark() + { + Name = Path.GetFileNameWithoutExtension(file), + Geometry = new SharpKml.Dom.Point() + { + Coordinate = new Vector(double.Parse(arr[lngpos]), double.Parse(arr[latpos]), double.Parse(arr[altpos])) + } + } + ); + + sw2.WriteLine(Path.GetFileNameWithoutExtension(file) + " " + arr[lngpos] + " " + arr[latpos] + " " + arr[altpos]); + sw.WriteLine(Path.GetFileNameWithoutExtension(file) + "\t" + crap.ToString("yyyy:MM:dd HH:mm:ss") + "\t" + arr[lngpos] + "\t" + arr[latpos] + "\t" + arr[altpos]); sw.Flush(); sw2.Flush(); - Console.WriteLine(Path.GetFileNameWithoutExtension(file) + " " + arr[5] + " " + arr[4] + " " + arr[7] + " "); + Console.WriteLine(Path.GetFileNameWithoutExtension(file) + " " + arr[lngpos] + " " + arr[latpos] + " " + arr[altpos] + " "); break; } //Console.WriteLine(crap); } } - + } + Serializer serializer = new Serializer(); + serializer.Serialize(kml); + sw3.Write(serializer.Xml); + sw3.Close(); + + sw2.Close(); sw.Close(); MessageBox.Show("Done " + matchs + " matchs"); - } private void InitializeComponent()