diff --git a/Tools/ArdupilotMegaPlanner/ArduinoComms.cs b/Tools/ArdupilotMegaPlanner/ArduinoComms.cs index 7ea102e1baa..a685523550a 100644 --- a/Tools/ArdupilotMegaPlanner/ArduinoComms.cs +++ b/Tools/ArdupilotMegaPlanner/ArduinoComms.cs @@ -6,7 +6,7 @@ using System.IO; namespace ArdupilotMega { - public delegate void ProgressEventHandler(int progress); + public delegate void ProgressEventHandler(int progress,string status); /// /// Arduino STK interface diff --git a/Tools/ArdupilotMegaPlanner/ArduinoDetect.cs b/Tools/ArdupilotMegaPlanner/ArduinoDetect.cs index eabd5a73419..82d49c690b0 100644 --- a/Tools/ArdupilotMegaPlanner/ArduinoDetect.cs +++ b/Tools/ArdupilotMegaPlanner/ArduinoDetect.cs @@ -196,6 +196,47 @@ namespace ArdupilotMega return ""; } + public enum ap_var_type + { + AP_PARAM_NONE = 0, + AP_PARAM_INT8, + AP_PARAM_INT16, + AP_PARAM_INT32, + AP_PARAM_FLOAT, + AP_PARAM_VECTOR3F, + AP_PARAM_VECTOR6F, + AP_PARAM_MATRIX3F, + AP_PARAM_GROUP + }; + + static string[] type_names = new string[] { + "NONE", "INT8", "INT16", "INT32", "FLOAT", "VECTOR3F", "VECTOR6F","MATRIX6F", "GROUP" +}; + + static byte type_size(ap_var_type type) +{ + switch (type) { + case ap_var_type.AP_PARAM_NONE: + case ap_var_type.AP_PARAM_GROUP: + return 0; + case ap_var_type.AP_PARAM_INT8: + return 1; + case ap_var_type.AP_PARAM_INT16: + return 2; + case ap_var_type.AP_PARAM_INT32: + return 4; + case ap_var_type.AP_PARAM_FLOAT: + return 4; + case ap_var_type.AP_PARAM_VECTOR3F: + return 3*4; + case ap_var_type.AP_PARAM_VECTOR6F: + return 6*4; + case ap_var_type.AP_PARAM_MATRIX3F: + return 3*3*4; + } + return 0; +} + /// /// return the software id from eeprom /// @@ -223,7 +264,7 @@ namespace ArdupilotMega byte[] buffer = port.download(1024 * 4); port.Close(); - if (buffer[0] != 'A' || buffer[1] != 'P') // this is the apvar header + if (buffer[0] != 'A' && buffer[0] != 'P' || buffer[1] != 'P' && buffer[1] != 'A') // this is the apvar header { return -1; } @@ -263,6 +304,46 @@ namespace ArdupilotMega Console.WriteLine(); } } + + if (buffer[0] == 'P' && buffer[1] == 'A' && buffer[2] == 5) // ap param + { + int pos = 4; + byte key = 0; + while (pos < (1024 * 4)) + { + key = buffer[pos]; + pos++; + int group = buffer[pos]; + pos++; + int type = buffer[pos]; + pos++; + + int size = type_size((ap_var_type)Enum.Parse(typeof(ap_var_type), type.ToString())); + + + Console.Write("{0:X4}: type {1} ({2}) key {3} group {4} size {5}\n ", pos - 2, type, type_names[type], key, group, size); + + if (key == 0xff) + { + Console.WriteLine("end sentinal at {0}", pos - 2); + break; + } + + if (key == 0) + { + //Array.Reverse(buffer, pos, 2); + return BitConverter.ToUInt16(buffer, pos); + } + + + for (int i = 0; i < size; i++) + { + Console.Write(" {0:X2}", buffer[pos]); + pos++; + } + Console.WriteLine(); + } + } } return -1; } diff --git a/Tools/ArdupilotMegaPlanner/ArduinoSTK.cs b/Tools/ArdupilotMegaPlanner/ArduinoSTK.cs index 30a0e3182d7..d16ab575a10 100644 --- a/Tools/ArdupilotMegaPlanner/ArduinoSTK.cs +++ b/Tools/ArdupilotMegaPlanner/ArduinoSTK.cs @@ -219,7 +219,7 @@ namespace ArdupilotMega if (Progress != null) - Progress((int)(((float)startaddress / (float)length) * 100)); + Progress((int)(((float)startaddress / (float)length) * 100),""); if (!sync()) { diff --git a/Tools/ArdupilotMegaPlanner/ArduinoSTKv2.cs b/Tools/ArdupilotMegaPlanner/ArduinoSTKv2.cs index a55251322b1..3483695ff38 100644 --- a/Tools/ArdupilotMegaPlanner/ArduinoSTKv2.cs +++ b/Tools/ArdupilotMegaPlanner/ArduinoSTKv2.cs @@ -262,7 +262,7 @@ namespace ArdupilotMega if (Progress != null) - Progress((int)(((float)startaddress / (float)length) * 100)); + Progress((int)(((float)startaddress / (float)length) * 100),""); if (command[1] != 0) { @@ -354,7 +354,7 @@ namespace ArdupilotMega if (Progress != null) - Progress((int)(((float)startaddress / (float)length) * 100)); + Progress((int)(((float)startaddress / (float)length) * 100),""); if (command[1] != 0) { diff --git a/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj b/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj index e00cfbd8f9c..a061f091453 100644 --- a/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj +++ b/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj @@ -22,7 +22,7 @@ Background 7 Days - false + true false false en-US @@ -242,7 +242,7 @@ - Component + UserControl ImageLabel.cs @@ -250,12 +250,20 @@ UserControl + + Form + + + ProgressReporter.cs + Form XorPlus.cs + + Form @@ -301,7 +309,6 @@ JoystickSetup.cs - Component @@ -312,7 +319,7 @@ Component - + UserControl @@ -438,9 +445,54 @@ ImageLabel.cs + + ProgressReporter.cs + XorPlus.cs + + Configuration.cs + + + Firmware.cs + + + FlightData.cs + + + FlightPlanner.cs + + + Help.cs + + + Simulation.cs + + + Terminal.cs + + + JoystickSetup.cs + + + Log.cs + + + LogBrowse.cs + + + MavlinkLog.cs + + + RAW_Sensor.cs + + + SerialInput.cs + + + SerialInput.cs + SerialInput.cs @@ -713,6 +765,9 @@ SerialOutput.cs + + Setup.cs + Setup.cs diff --git a/Tools/ArdupilotMegaPlanner/CommsSerialPort.cs b/Tools/ArdupilotMegaPlanner/CommsSerialPort.cs index 2eeb4cea1bd..8b4101039fc 100644 --- a/Tools/ArdupilotMegaPlanner/CommsSerialPort.cs +++ b/Tools/ArdupilotMegaPlanner/CommsSerialPort.cs @@ -12,9 +12,15 @@ namespace ArdupilotMega public void toggleDTR() { - DtrEnable = false; - System.Threading.Thread.Sleep(100); - DtrEnable = true; + base.DtrEnable = false; + base.RtsEnable = false; + + System.Threading.Thread.Sleep(50); + + base.DtrEnable = true; + base.RtsEnable = true; + + System.Threading.Thread.Sleep(50); } } } diff --git a/Tools/ArdupilotMegaPlanner/CommsTCPSerial.cs b/Tools/ArdupilotMegaPlanner/CommsTCPSerial.cs index 006f3f34391..8bfe204897c 100644 --- a/Tools/ArdupilotMegaPlanner/CommsTCPSerial.cs +++ b/Tools/ArdupilotMegaPlanner/CommsTCPSerial.cs @@ -81,11 +81,11 @@ namespace System.IO.Ports string host = "127.0.0.1"; if (Windows.Forms.DialogResult.Cancel == ArdupilotMega.Common.InputBox("remote host", "Enter host name/ip (ensure remote end is already started)", ref host)) { - return; + throw new Exception("Canceled by request"); } if (Windows.Forms.DialogResult.Cancel == ArdupilotMega.Common.InputBox("remote Port", "Enter remote port", ref dest)) { - return; + throw new Exception("Canceled by request"); } Port = dest; @@ -94,6 +94,8 @@ namespace System.IO.Ports client.NoDelay = true; client.Client.NoDelay = true; + VerifyConnected(); + return; } diff --git a/Tools/ArdupilotMegaPlanner/Controls/ImageLabel.cs b/Tools/ArdupilotMegaPlanner/Controls/ImageLabel.cs index a5524d2cd48..2b16d6337d7 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/ImageLabel.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/ImageLabel.cs @@ -9,7 +9,7 @@ using System.Windows.Forms; namespace ArdupilotMega { - public partial class ImageLabel : ContainerControl + public partial class ImageLabel : UserControl //ContainerControl { public new event EventHandler Click; @@ -18,6 +18,9 @@ namespace ArdupilotMega public ImageLabel() { + text = ""; + picture = new Bitmap(640,480); + InitializeComponent(); } diff --git a/Tools/ArdupilotMegaPlanner/Controls/MyButton.cs b/Tools/ArdupilotMegaPlanner/Controls/MyButton.cs index 82f28d7e56c..d95acf2373a 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/MyButton.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/MyButton.cs @@ -17,56 +17,97 @@ namespace ArdupilotMega bool mouseover = false; bool mousedown = false; + bool inOnPaint = false; + protected override void OnPaint(PaintEventArgs pevent) { //base.OnPaint(pevent); - Graphics gr = pevent.Graphics; + if (inOnPaint) + return; - Rectangle outside = new Rectangle(0,0,this.Width,this.Height); + inOnPaint = true; - LinearGradientBrush linear = new LinearGradientBrush(outside,Color.FromArgb(0x94,0xc1,0x1f),Color.FromArgb(0xcd,0xe2,0x96),LinearGradientMode.Vertical); - - Pen mypen = new Pen(Color.FromArgb(0x79,0x94,0x29),2); - - gr.FillRectangle(linear,outside); - - gr.DrawRectangle(mypen,outside); - - SolidBrush mybrush = new SolidBrush(Color.FromArgb(0x40,0x57,0x04)); - - if (mouseover) + try { - SolidBrush brush = new SolidBrush(Color.FromArgb(73, 0x2b, 0x3a, 0x03)); + Graphics gr = pevent.Graphics; - gr.FillRectangle(brush, 0, 0, this.Width, this.Height); - } - if (mousedown) - { - SolidBrush brush = new SolidBrush(Color.FromArgb(73, 0x2b, 0x3a, 0x03)); + // gr.SmoothingMode = SmoothingMode.AntiAlias; - gr.FillRectangle(brush, 0, 0, this.Width, this.Height); - } + Rectangle outside = new Rectangle(0, 0, this.Width, this.Height); - if (!this.Enabled) - { - SolidBrush brush = new SolidBrush(Color.FromArgb(150, 0x2b, 0x3a, 0x03)); + LinearGradientBrush linear = new LinearGradientBrush(outside, Color.FromArgb(0x94, 0xc1, 0x1f), Color.FromArgb(0xcd, 0xe2, 0x96), LinearGradientMode.Vertical); - gr.FillRectangle(brush, 0, 0, this.Width, this.Height); + Pen mypen = new Pen(Color.FromArgb(0x79, 0x94, 0x29), 2); + /* + gr.FillRectangle(new SolidBrush(Color.FromArgb(0x26, 0x27, 0x28)), outside); + + GraphicsPath outline = new GraphicsPath(); + + float wid = this.Height / 5f; + float widright = wid + 1; + + // tl + outline.AddArc(0, 0, wid, wid, 180, 90); + // top line + outline.AddLine(wid, 0, this.Width - widright, 0); + // tr + outline.AddArc(this.Width - widright, 0, wid, wid, 270, 90); + // br + outline.AddArc(this.Width - widright, this.Height - widright, wid, wid, 0, 90); + // bottom line + outline.AddLine(wid, this.Height - 1, this.Width - widright, this.Height - 1); + // bl + outline.AddArc(0, this.Height - widright, wid, wid, 90, 90); + + + gr.FillPath(linear, outline); + + gr.DrawPath(mypen, outline); + + */ + + gr.FillRectangle(linear, outside); + gr.DrawRectangle(mypen, outside); + + + SolidBrush mybrush = new SolidBrush(Color.FromArgb(0x40, 0x57, 0x04)); + + if (mouseover) + { + SolidBrush brush = new SolidBrush(Color.FromArgb(73, 0x2b, 0x3a, 0x03)); + + gr.FillRectangle(brush, 0, 0, this.Width, this.Height); + } + if (mousedown) + { + SolidBrush brush = new SolidBrush(Color.FromArgb(73, 0x2b, 0x3a, 0x03)); + + gr.FillRectangle(brush, 0, 0, this.Width, this.Height); + } + + if (!this.Enabled) + { + SolidBrush brush = new SolidBrush(Color.FromArgb(150, 0x2b, 0x3a, 0x03)); + + gr.FillRectangle(brush, 0, 0, this.Width, this.Height); + } + + + StringFormat stringFormat = new StringFormat(); + stringFormat.Alignment = StringAlignment.Center; + stringFormat.LineAlignment = StringAlignment.Center; + + string display = this.Text; + int amppos = display.IndexOf('&'); + if (amppos != -1) + display = display.Remove(amppos, 1); + + gr.DrawString(display, this.Font, mybrush, outside, stringFormat); } - - - StringFormat stringFormat = new StringFormat(); - stringFormat.Alignment = StringAlignment.Center; - stringFormat.LineAlignment = StringAlignment.Center; - - string display = this.Text; - int amppos = display.IndexOf('&'); - if (amppos != -1) - display = display.Remove(amppos,1); - - gr.DrawString(display, this.Font, mybrush, outside, stringFormat); - + catch { } + + inOnPaint = false; } protected override void OnClick(EventArgs e) diff --git a/Tools/ArdupilotMegaPlanner/MyUserControl.cs b/Tools/ArdupilotMegaPlanner/Controls/MyUserControl.cs similarity index 95% rename from Tools/ArdupilotMegaPlanner/MyUserControl.cs rename to Tools/ArdupilotMegaPlanner/Controls/MyUserControl.cs index 83213fe8b7f..0a7a7647935 100644 --- a/Tools/ArdupilotMegaPlanner/MyUserControl.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/MyUserControl.cs @@ -1,19 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace System.Windows.Forms -{ - public class MyUserControl : System.Windows.Forms.UserControl - { - protected override void WndProc(ref Message m) - { - try - { - base.WndProc(ref m); - } - catch { } - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace System.Windows.Forms +{ + public class MyUserControl : System.Windows.Forms.UserControl + { + protected override void WndProc(ref Message m) + { + try + { + base.WndProc(ref m); + } + catch { } + } + } +} diff --git a/Tools/ArdupilotMegaPlanner/Controls/ProgressReporter.cs b/Tools/ArdupilotMegaPlanner/Controls/ProgressReporter.cs new file mode 100644 index 00000000000..33389e8c03a --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/Controls/ProgressReporter.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace ArdupilotMega +{ + public partial class ProgressReporter : Form + { + bool cancel = false; + + public ProgressReporter() + { + InitializeComponent(); + cancel = false; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + cancel = true; + this.Close(); + } + + public void updateProgressAndStatus(int progress, string status) + { + //Console.WriteLine(progress + " " + status); + + if (cancel) + { + throw new Exception("User Canceled"); + } + + if (this.IsDisposed) + { + return; + } + + try + { + this.Invoke((MethodInvoker)delegate + { + + lblProgressMessage.Text = status; + if (progress == -1) + { + this.progressBar1.Style = ProgressBarStyle.Marquee; + } + else + { + this.progressBar1.Style = ProgressBarStyle.Continuous; + this.progressBar1.Value = progress; + } + }); + } + catch { } + + System.Windows.Forms.Application.DoEvents(); + } + } +} diff --git a/Tools/ArdupilotMegaPlanner/Controls/ProgressReporter.designer.cs b/Tools/ArdupilotMegaPlanner/Controls/ProgressReporter.designer.cs new file mode 100644 index 00000000000..d24768765ec --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/Controls/ProgressReporter.designer.cs @@ -0,0 +1,94 @@ +using System.Windows.Forms; + +namespace ArdupilotMega +{ + partial class ProgressReporter + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.lblProgressMessage = new System.Windows.Forms.Label(); + this.btnCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // progressBar1 + // + this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.progressBar1.Location = new System.Drawing.Point(12, 82); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(277, 13); + this.progressBar1.TabIndex = 0; + // + // lblProgressMessage + // + this.lblProgressMessage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lblProgressMessage.Location = new System.Drawing.Point(13, 13); + this.lblProgressMessage.Name = "lblProgressMessage"; + this.lblProgressMessage.Size = new System.Drawing.Size(276, 66); + this.lblProgressMessage.TabIndex = 1; + this.lblProgressMessage.Text = "label1"; + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(213, 109); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 2; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // ProgressReporter + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(306, 144); + this.ControlBox = false; + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.lblProgressMessage); + this.Controls.Add(this.progressBar1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ProgressReporter"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Progress"; + this.ResumeLayout(false); + + } + + #endregion + + private ProgressBar progressBar1; + private System.Windows.Forms.Label lblProgressMessage; + private Button btnCancel; + } +} \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/test.resx b/Tools/ArdupilotMegaPlanner/Controls/ProgressReporter.resx similarity index 97% rename from Tools/ArdupilotMegaPlanner/GCSViews/test.resx rename to Tools/ArdupilotMegaPlanner/Controls/ProgressReporter.resx index 5ea0895e324..7080a7d118e 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/test.resx +++ b/Tools/ArdupilotMegaPlanner/Controls/ProgressReporter.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/Controls/myGMAP.cs b/Tools/ArdupilotMegaPlanner/Controls/myGMAP.cs index 8af08373f73..38e37a84be3 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/myGMAP.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/myGMAP.cs @@ -7,15 +7,19 @@ namespace ArdupilotMega { class myGMAP : GMap.NET.WindowsForms.GMapControl { - public bool inOnPaint = false; + public bool inOnPaint = false; + string otherthread = ""; protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { if (inOnPaint) { - Console.WriteLine("Was in onpaint Gmap th:" + System.Threading.Thread.CurrentThread.Name); + Console.WriteLine("Was in onpaint Gmap th:" + System.Threading.Thread.CurrentThread.Name + " in " + otherthread); return; } + + otherthread = System.Threading.Thread.CurrentThread.Name; + inOnPaint = true; try diff --git a/Tools/ArdupilotMegaPlanner/CurrentState.cs b/Tools/ArdupilotMegaPlanner/CurrentState.cs index fa106366018..af78701f3f9 100644 --- a/Tools/ArdupilotMegaPlanner/CurrentState.cs +++ b/Tools/ArdupilotMegaPlanner/CurrentState.cs @@ -2,10 +2,11 @@ using System.Collections.Generic; using System.Text; using System.ComponentModel; +using ArdupilotMega.Mavlink; namespace ArdupilotMega { - public class CurrentState: ICloneable + public class CurrentState : ICloneable { // multipliers public float multiplierdist = 1; @@ -61,13 +62,13 @@ namespace ArdupilotMega public float altd100 { get { return (alt / 100) % 10; } } // accel - public float ax { get; set; } - public float ay { get; set; } - public float az { get; set; } + public float ax { get; set; } + public float ay { get; set; } + public float az { get; set; } // gyro - public float gx { get; set; } - public float gy { get; set; } - public float gz { get; set; } + public float gx { get; set; } + public float gy { get; set; } + public float gz { get; set; } // mag public float mx { get; set; } public float my { get; set; } @@ -77,14 +78,14 @@ namespace ArdupilotMega public float turnrate { get { if (groundspeed <= 1) return 0; return (roll * 9.8f) / groundspeed; } } //radio - public float ch1in { get; set; } - public float ch2in { get; set; } - public float ch3in { get; set; } - public float ch4in { get; set; } - public float ch5in { get; set; } - public float ch6in { get; set; } - public float ch7in { get; set; } - public float ch8in { get; set; } + public float ch1in { get; set; } + public float ch2in { get; set; } + public float ch3in { get; set; } + public float ch4in { get; set; } + public float ch5in { get; set; } + public float ch6in { get; set; } + public float ch7in { get; set; } + public float ch8in { get; set; } // motors public float ch1out { get; set; } @@ -95,8 +96,10 @@ namespace ArdupilotMega public float ch6out { get; set; } public float ch7out { get; set; } public float ch8out { get; set; } - public float ch3percent { - get { + public float ch3percent + { + get + { try { if (MainV2.comPort.param.ContainsKey("RC3_MIN")) @@ -108,10 +111,11 @@ namespace ArdupilotMega return 0; } } - catch { + catch + { return 0; } - } + } } //nav state @@ -121,7 +125,7 @@ namespace ArdupilotMega public float target_bearing { get; set; } public float wp_dist { get { return (_wpdist * multiplierdist); } set { _wpdist = value; } } public float alt_error { get { return _alt_error * multiplierdist; } set { _alt_error = value; } } - public float ber_error { get { return (target_bearing - yaw); } set { } } + public float ber_error { get { return (target_bearing - yaw); } set { } } public float aspd_error { get { return _aspd_error * multiplierspeed; } set { _aspd_error = value; } } public float xtrack_error { get; set; } public float wpno { get; set; } @@ -132,10 +136,10 @@ namespace ArdupilotMega float _alt_error; public float targetaltd100 { get { return ((alt + alt_error) / 100) % 10; } } - public float targetalt { get { return (float)Math.Round(alt + alt_error,0); } } + public float targetalt { get { return (float)Math.Round(alt + alt_error, 0); } } //airspeed_error = (airspeed_error - airspeed); - public float targetairspeed { get { return (float)Math.Round(airspeed + aspd_error / 100,0); } } + public float targetairspeed { get { return (float)Math.Round(airspeed + aspd_error / 100, 0); } } //message @@ -187,7 +191,6 @@ namespace ArdupilotMega public ushort rcoverridech8 { get; set; } internal PointLatLngAlt HomeLocation = new PointLatLngAlt(); - public float DistToMAV { get @@ -238,7 +241,6 @@ namespace ArdupilotMega return (float)bearing; } } - // current firmware public MainV2.Firmwares firmware = MainV2.Firmwares.ArduPlane; public float freemem { get; set; } @@ -259,6 +261,7 @@ namespace ArdupilotMega // reference public DateTime datetime { get; set; } + public CurrentState() { mode = ""; @@ -277,7 +280,7 @@ namespace ArdupilotMega private DateTime lastupdate = DateTime.Now; private DateTime lastwindcalc = DateTime.Now; - + public void UpdateCurrentSettings(System.Windows.Forms.BindingSource bs) { UpdateCurrentSettings(bs, false, MainV2.comPort); @@ -311,28 +314,22 @@ namespace ArdupilotMega try { - while (messages.Count > 5) - { - messages.RemoveAt(0); - } - + while (messages.Count > 5) + { + messages.RemoveAt(0); + } messages.Add(logdata + "\n"); } catch { } - mavinterface.packets[MAVLink.MAVLINK_MSG_ID_STATUSTEXT] = null; } - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_RC_CHANNELS_SCALED] != null) // hil + byte[] bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_RC_CHANNELS_SCALED]; + + if (bytearray != null) // hil { - var hil = new ArdupilotMega.MAVLink.__mavlink_rc_channels_scaled_t(); - - object temp = hil; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_RC_CHANNELS_SCALED], ref temp, 6); - - hil = (MAVLink.__mavlink_rc_channels_scaled_t)(temp); + var hil = bytearray.ByteArrayToStructure(6); hilch1 = hil.chan1_scaled; hilch2 = hil.chan2_scaled; @@ -346,15 +343,11 @@ namespace ArdupilotMega //MAVLink.packets[MAVLink.MAVLINK_MSG_ID_RC_CHANNELS_SCALED] = null; } - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT] != null) + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT]; + + if (bytearray != null) { - MAVLink.__mavlink_nav_controller_output_t nav = new MAVLink.__mavlink_nav_controller_output_t(); - - object temp = nav; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT], ref temp, 6); - - nav = (MAVLink.__mavlink_nav_controller_output_t)(temp); + var nav = bytearray.ByteArrayToStructure(6); nav_roll = nav.nav_roll; nav_pitch = nav.nav_pitch; @@ -368,15 +361,12 @@ namespace ArdupilotMega //MAVLink.packets[MAVLink.MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT] = null; } #if MAVLINK10 - if (mavinterface.packets[ArdupilotMega.MAVLink.MAVLINK_MSG_ID_HEARTBEAT] != null) + + + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_HEARTBEAT]; + if (bytearray != null) { - ArdupilotMega.MAVLink.__mavlink_heartbeat_t hb = new ArdupilotMega.MAVLink.__mavlink_heartbeat_t(); - - object temp = hb; - - MAVLink.ByteArrayToStructure(mavinterface.packets[ArdupilotMega.MAVLink.MAVLINK_MSG_ID_HEARTBEAT], ref temp, 6); - - hb = (ArdupilotMega.MAVLink.__mavlink_heartbeat_t)(temp); + var hb = bytearray.ByteArrayToStructure(6); string oldmode = mode; @@ -465,15 +455,10 @@ namespace ArdupilotMega } - if (mavinterface.packets[ArdupilotMega.MAVLink.MAVLINK_MSG_ID_SYS_STATUS] != null) + bytearray = mavinterface.packets[ArdupilotMega.MAVLink.MAVLINK_MSG_ID_SYS_STATUS]; + if (bytearray != null) { - ArdupilotMega.MAVLink.__mavlink_sys_status_t sysstatus = new ArdupilotMega.MAVLink.__mavlink_sys_status_t(); - - object temp = sysstatus; - - MAVLink.ByteArrayToStructure(mavinterface.packets[ArdupilotMega.MAVLink.MAVLINK_MSG_ID_SYS_STATUS], ref temp, 6); - - sysstatus = (ArdupilotMega.MAVLink.__mavlink_sys_status_t)(temp); + var sysstatus = bytearray.ByteArrayToStructure(6); battery_voltage = sysstatus.voltage_battery; battery_remaining = sysstatus.battery_remaining; @@ -484,15 +469,11 @@ namespace ArdupilotMega } #else - if (mavinterface.packets[ArdupilotMega.MAVLink.MAVLINK_MSG_ID_SYS_STATUS] != null) + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_SYS_STATUS]; + + if (bytearray != null) { - ArdupilotMega.MAVLink.__mavlink_sys_status_t sysstatus = new ArdupilotMega.MAVLink.__mavlink_sys_status_t(); - - object temp = sysstatus; - - MAVLink.ByteArrayToStructure(mavinterface.packets[ArdupilotMega.MAVLink.MAVLINK_MSG_ID_SYS_STATUS], ref temp, 6); - - sysstatus = (ArdupilotMega.MAVLink.__mavlink_sys_status_t)(temp); + var sysstatus = bytearray.ByteArrayToStructure(6); armed = sysstatus.status; @@ -603,34 +584,21 @@ namespace ArdupilotMega } //MAVLink.packets[ArdupilotMega.MAVLink.MAVLINK_MSG_ID_SYS_STATUS] = null; - } + } #endif - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_SCALED_PRESSURE] != null) + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_SCALED_PRESSURE]; + if (bytearray != null) { - var pres = new ArdupilotMega.MAVLink.__mavlink_scaled_pressure_t(); - - object temp = pres; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_SCALED_PRESSURE], ref temp, 6); - - pres = (MAVLink.__mavlink_scaled_pressure_t)(temp); - + var pres = bytearray.ByteArrayToStructure(6); press_abs = pres.press_abs; - - press_temp = pres.temperature; - + press_temp = pres.temperature; } - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_SENSOR_OFFSETS] != null) + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_SENSOR_OFFSETS]; + if (bytearray != null) { - var sensofs = new ArdupilotMega.MAVLink.__mavlink_sensor_offsets_t(); - - object temp = sensofs; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_SENSOR_OFFSETS], ref temp, 6); - - sensofs = (MAVLink.__mavlink_sensor_offsets_t)(temp); + var sensofs = bytearray.ByteArrayToStructure(6); mag_ofs_x = sensofs.mag_ofs_x; mag_ofs_y = sensofs.mag_ofs_y; @@ -650,15 +618,11 @@ namespace ArdupilotMega } - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_ATTITUDE] != null) + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_ATTITUDE]; + + if (bytearray != null) { - var att = new ArdupilotMega.MAVLink.__mavlink_attitude_t(); - - object temp = att; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_ATTITUDE], ref temp, 6); - - att = (MAVLink.__mavlink_attitude_t)(temp); + var att = bytearray.ByteArrayToStructure(6); roll = att.roll * rad2deg; pitch = att.pitch * rad2deg; @@ -669,15 +633,10 @@ namespace ArdupilotMega //MAVLink.packets[MAVLink.MAVLINK_MSG_ID_ATTITUDE] = null; } #if MAVLINK10 - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GPS_RAW_INT] != null) + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GPS_RAW_INT]; + if (bytearray != null) { - var gps = new MAVLink.__mavlink_gps_raw_int_t(); - - object temp = gps; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GPS_RAW_INT], ref temp, 6); - - gps = (MAVLink.__mavlink_gps_raw_int_t)(temp); + var gps = bytearray.ByteArrayToStructure(6); lat = gps.lat * 1.0e-7f; lng = gps.lon * 1.0e-7f; @@ -693,17 +652,12 @@ namespace ArdupilotMega //MAVLink.packets[MAVLink.MAVLINK_MSG_ID_GPS_RAW] = null; } - #else +#else - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GPS_RAW] != null) + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GPS_RAW]; + if (bytearray != null) { - var gps = new MAVLink.__mavlink_gps_raw_t(); - - object temp = gps; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GPS_RAW], ref temp, 6); - - gps = (MAVLink.__mavlink_gps_raw_t)(temp); + var gps = bytearray.ByteArrayToStructure(6); lat = gps.lat; lng = gps.lon; @@ -717,48 +671,33 @@ namespace ArdupilotMega groundspeed = gps.v; groundcourse = gps.hdg; - //MAVLink.packets[MAVLink.MAVLINK_MSG_ID_GPS_RAW] = null; - } + } #endif - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GPS_STATUS] != null) + + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GPS_STATUS]; + if (bytearray != null) { - var gps = new MAVLink.__mavlink_gps_status_t(); - - object temp = gps; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GPS_STATUS], ref temp, 6); - - gps = (MAVLink.__mavlink_gps_status_t)(temp); - + var gps = bytearray.ByteArrayToStructure(6); satcount = gps.satellites_visible; } - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GLOBAL_POSITION_INT] != null) + + + byte[] bytes = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GLOBAL_POSITION_INT]; + if (bytes != null) { - var loc = new MAVLink.__mavlink_global_position_int_t(); - - object temp = loc; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GLOBAL_POSITION_INT], ref temp, 6); - - loc = (MAVLink.__mavlink_global_position_int_t)(temp); + var loc = bytearray.ByteArrayToStructure(6); //alt = loc.alt / 1000.0f; lat = loc.lat / 10000000.0f; lng = loc.lon / 10000000.0f; - } #if MAVLINK10 - if (mavinterface.packets[ArdupilotMega.MAVLink.MAVLINK_MSG_ID_MISSION_CURRENT] != null) + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_MISSION_CURRENT]; + if (bytearray != null) { - ArdupilotMega.MAVLink.__mavlink_mission_current_t wpcur = new ArdupilotMega.MAVLink.__mavlink_mission_current_t(); - - object temp = wpcur; - - MAVLink.ByteArrayToStructure(mavinterface.packets[ArdupilotMega.MAVLink.MAVLINK_MSG_ID_MISSION_CURRENT], ref temp, 6); - - wpcur = (ArdupilotMega.MAVLink.__mavlink_mission_current_t)(temp); - + var wpcur = bytearray.ByteArrayToStructure(6); + int oldwp = (int)wpno; wpno = wpcur.seq; @@ -770,31 +709,21 @@ namespace ArdupilotMega //MAVLink.packets[ArdupilotMega.MAVLink.MAVLINK_MSG_ID_WAYPOINT_CURRENT] = null; } - #else - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GLOBAL_POSITION] != null) +#else + + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GLOBAL_POSITION]; + if (bytearray != null) { - var loc = new MAVLink.__mavlink_global_position_t(); - - object temp = loc; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_GLOBAL_POSITION], ref temp, 6); - - loc = (MAVLink.__mavlink_global_position_t)(temp); - + var loc = bytearray.ByteArrayToStructure(6); alt = loc.alt; lat = loc.lat; lng = loc.lon; - } - if (mavinterface.packets[ArdupilotMega.MAVLink.MAVLINK_MSG_ID_WAYPOINT_CURRENT] != null) + + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_WAYPOINT_CURRENT]; + if (bytearray != null) { - ArdupilotMega.MAVLink.__mavlink_waypoint_current_t wpcur = new ArdupilotMega.MAVLink.__mavlink_waypoint_current_t(); - - object temp = wpcur; - - MAVLink.ByteArrayToStructure(mavinterface.packets[ArdupilotMega.MAVLink.MAVLINK_MSG_ID_WAYPOINT_CURRENT], ref temp, 6); - - wpcur = (ArdupilotMega.MAVLink.__mavlink_waypoint_current_t)(temp); + var wpcur = bytearray.ByteArrayToStructure(6); int oldwp = (int)wpno; @@ -806,18 +735,13 @@ namespace ArdupilotMega } //MAVLink.packets[ArdupilotMega.MAVLink.MAVLINK_MSG_ID_WAYPOINT_CURRENT] = null; - } - + } + #endif - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_RC_CHANNELS_RAW] != null) + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_RC_CHANNELS_RAW]; + if (bytearray != null) { - var rcin = new MAVLink.__mavlink_rc_channels_raw_t(); - - object temp = rcin; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_RC_CHANNELS_RAW], ref temp, 6); - - rcin = (MAVLink.__mavlink_rc_channels_raw_t)(temp); + var rcin = bytearray.ByteArrayToStructure(6); ch1in = rcin.chan1_raw; ch2in = rcin.chan2_raw; @@ -831,15 +755,10 @@ namespace ArdupilotMega //MAVLink.packets[MAVLink.MAVLINK_MSG_ID_RC_CHANNELS_RAW] = null; } - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_SERVO_OUTPUT_RAW] != null) + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_SERVO_OUTPUT_RAW]; + if (bytearray != null) { - var servoout = new MAVLink.__mavlink_servo_output_raw_t(); - - object temp = servoout; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_SERVO_OUTPUT_RAW], ref temp, 6); - - servoout = (MAVLink.__mavlink_servo_output_raw_t)(temp); + var servoout = bytearray.ByteArrayToStructure(6); ch1out = servoout.servo1_raw; ch2out = servoout.servo2_raw; @@ -853,15 +772,11 @@ namespace ArdupilotMega //MAVLink.packets[MAVLink.MAVLINK_MSG_ID_SERVO_OUTPUT_RAW] = null; } - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_RAW_IMU] != null) + + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_RAW_IMU]; + if (bytearray != null) { - var imu = new MAVLink.__mavlink_raw_imu_t(); - - object temp = imu; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_RAW_IMU], ref temp, 6); - - imu = (MAVLink.__mavlink_raw_imu_t)(temp); + var imu = bytearray.ByteArrayToStructure(6); gx = imu.xgyro; gy = imu.ygyro; @@ -878,15 +793,10 @@ namespace ArdupilotMega //MAVLink.packets[MAVLink.MAVLINK_MSG_ID_RAW_IMU] = null; } - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_SCALED_IMU] != null) + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_SCALED_IMU]; + if (bytearray != null) { - var imu = new MAVLink.__mavlink_scaled_imu_t(); - - object temp = imu; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_SCALED_IMU], ref temp, 6); - - imu = (MAVLink.__mavlink_scaled_imu_t)(temp); + var imu = bytearray.ByteArrayToStructure(6); gx = imu.xgyro; gy = imu.ygyro; @@ -899,30 +809,17 @@ namespace ArdupilotMega //MAVLink.packets[MAVLink.MAVLINK_MSG_ID_RAW_IMU] = null; } - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_VFR_HUD] != null) + + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_VFR_HUD]; + if (bytearray != null) { - MAVLink.__mavlink_vfr_hud_t vfr = new MAVLink.__mavlink_vfr_hud_t(); - - object temp = vfr; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_VFR_HUD], ref temp, 6); - - vfr = (MAVLink.__mavlink_vfr_hud_t)(temp); + var vfr = bytearray.ByteArrayToStructure(6); groundspeed = vfr.groundspeed; airspeed = vfr.airspeed; alt = vfr.alt; // this might include baro - /* - if (vfr.throttle > 150 || vfr.throttle < 0) - { - Console.WriteLine(0); - } - else - { - Console.WriteLine(vfr.throttle); - } - */ + //climbrate = vfr.climb; if ((DateTime.Now - lastalt).TotalSeconds >= 0.1 && oldalt != alt) @@ -938,22 +835,15 @@ namespace ArdupilotMega //MAVLink.packets[MAVLink.MAVLINK_MSG_ID_VFR_HUD] = null; } - if (mavinterface.packets[MAVLink.MAVLINK_MSG_ID_MEMINFO] != null) // hil + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_MEMINFO]; + if (bytearray != null) { - var mem = new ArdupilotMega.MAVLink.__mavlink_meminfo_t(); - - object temp = mem; - - MAVLink.ByteArrayToStructure(mavinterface.packets[MAVLink.MAVLINK_MSG_ID_MEMINFO], ref temp, 6); - - mem = (MAVLink.__mavlink_meminfo_t)(temp); - + var mem = bytearray.ByteArrayToStructure(6); freemem = mem.freemem; brklevel = mem.brkval; - } - } + //Console.WriteLine(DateTime.Now.Millisecond + " start "); // update form try @@ -994,7 +884,7 @@ namespace ArdupilotMega We_fgo = We_fgo + Kw * We_error; double wind_dir = (Math.Atan2(We_fgo, Wn_fgo) * (180 / Math.PI)); - double wind_vel = (Math.Sqrt(Math.Pow(We_fgo,2) + Math.Pow(Wn_fgo,2))); + double wind_vel = (Math.Sqrt(Math.Pow(We_fgo, 2) + Math.Pow(Wn_fgo, 2))); wind_dir = (wind_dir + 360) % 360; diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.Designer.cs index 168229d9c27..4c0332e32bd 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.Designer.cs @@ -1137,7 +1137,8 @@ resources.GetString("TUNE.Items16"), resources.GetString("TUNE.Items17"), resources.GetString("TUNE.Items18"), - resources.GetString("TUNE.Items19")}); + resources.GetString("TUNE.Items19"), + resources.GetString("TUNE.Items20")}); resources.ApplyResources(this.TUNE, "TUNE"); this.TUNE.Name = "TUNE"; // diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.cs index ecd2272dec7..6970e2567d2 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.cs @@ -67,26 +67,30 @@ namespace ArdupilotMega.GCSViews // fix for dup name //XTRK_ANGLE_CD1.Name = "XTRK_ANGLE_CD"; XTRK_GAIN_SC1.Name = "XTRK_GAIN_SC"; + + // enable disable relevbant hardware tabs + if (MainV2.APMFirmware == MainV2.Firmwares.ArduPlane) + { + this.ConfigTabs.SuspendLayout(); + ConfigTabs.SelectedIndex = 0; + TabAP.Enabled = true; + TabAC.Enabled = false; + this.ConfigTabs.ResumeLayout(); + } + else + { + this.ConfigTabs.SuspendLayout(); + ConfigTabs.SelectedIndex = 1; + TabAP.Enabled = false; + TabAC.Enabled = true; + this.ConfigTabs.ResumeLayout(); + } } private void Configuration_Load(object sender, EventArgs e) { startup = true; - // enable disable relevbant hardware tabs - if (MainV2.APMFirmware == MainV2.Firmwares.ArduPlane) - { - ConfigTabs.SelectedIndex = 0; - TabAP.Enabled = true; - TabAC.Enabled = false; - } - else - { - ConfigTabs.SelectedIndex = 1; - TabAP.Enabled = false; - TabAC.Enabled = true; - } - // read tooltips if (tooltips.Count == 0) readToolTips(); @@ -167,7 +171,7 @@ namespace ArdupilotMega.GCSViews // setup language selection CultureInfo ci = null; - foreach (string name in new string[] { "en-US", "zh-Hans", "zh-TW", "ru-RU", "Fr", "Pl", "it-IT" }) + foreach (string name in new string[] { "en-US", "zh-Hans", "zh-TW", "ru-RU", "Fr", "Pl", "it-IT", "es-ES" }) { ci = MainV2.getcultureinfo(name); if (ci != null) @@ -931,10 +935,16 @@ namespace ArdupilotMega.GCSViews ((MyButton)sender).Enabled = false; try { + MainV2.comPort.getParamList(); + + + + } catch { MessageBox.Show("Error: getting param list"); } + ((MyButton)sender).Enabled = true; startup = true; Configuration_Load(null, null); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.es-ES.resx b/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.es-ES.resx new file mode 100644 index 00000000000..8ac89af4e79 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.es-ES.resx @@ -0,0 +1,600 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Advertencia Altitud + + + HUD + + + Parar + + + INT_MAX + + + D + + + Advertencia Batería + + + Permitir Habla + + + IMAX + + + P + + + D + + + IMAX + + + D + + + IMAX + + + I + + + Ganancia + + + IMAX + + + P + + + P a T + + + I + + + Ganancia (cm) + + + Valor + + + I + + + Compensación de Cabeceo + + + P + + + I + + + Longitud de Pista + + + P + + + P + + + Waypoints + + + IMAX + + + Intervalo de Tiempo + + + FBW max + + + P + + + Ch6 Opt + + + D + + + FBW min + + + Formato Video + + + Posición + + + Pid Servo Alabeo + + + INT_MAX + + + D + + + Actitud + + + Pid Servo Cabeceo + + + P + + + Proporción + + + IMAX + + + Rates de Telemetría + + + Cruce de corrección de la pista + + + Ch7 Opt + + + Max + + + I + + + D + + + Mantener Altitud + + + D + + + Min + + + RC + + + Nav WP + + + Crucero + + + INT_MAX + + + Rate de Acelerador + + + FS Valor + + + OpenGL = DesactivadoGDI + = Activado + + + Angulos de Navegación + + + I + + + Modo/Estado + + + Activar HUD superposición + + + Acelerador 0-100% + + + Cargar + + + Crucero + + + Velocidad Aire m/s + + + m/s + + + Comando + + + Reiniciar APM + + + D + + + Cargar waypoints en la conexión? + + + P + + + INT_MAX + + + Actualizar parametros del dispositivo + + + I + + + D + + + I + + + P + + + INT_MAX + + + Unidad Velocidad + + + D + + + Waypoint + + + I + + + Parámetros de carga de archivo + + + Otras Mezclas + + + Perder el Tiempo + + + NOTA: La pestaña de configuración no se muestran estas unidades, ya que son valores brutos. + + + Energía / Alt Pid + + + Cabeceo de navegación como PID + + + Dispositivo de Video + + + P + + + Ajustes + + + Defecto + + + Xtrack Pids + + + INT_MAX + + + I + + + Pid Servo Guiñada + + + I + + + Alt Nav Pid Cabeceo + + + Idioma de interfaz de usuario + + + IMAX + + + Joystick + + + GDI+ (tipo antiguo) + + + P + + + Alabeo Pid Nav + + + P + + + I + + + Color OSD + + + Unidad Distancia + + + IMAX + + + P + + + Habla + + + Cabeceo Max + + + Banco Max + + + Rate Cabeceo + + + Joystick Setup + + + Rate Alabeo + + + Cabeceo Min + + + Mavlink mensaje depuración + + + Estabilizar Guiñada + + + Estabilizar Cabeceo + + + Estabilizar Alabeo + + + Rate Guiñada + + + D + + + P + + + Guardar + + + Escribir parametros cambiados en el dispositivo + + + I + + + D + + + Estabilizar D + + + I + + + P + + + Bloquear los valores de cabeceo y Alabeo + + + I + + + INT_MAX + + + Planificador + + + Escribir Parámetros + + + ArduPlane + + + Mezcla de Timón + + + En la ficha de datos de vuelo + + + Angulo de Entrada + + + Reiniciar APM al Conectar al USB + + + mavScale + + + ArduCopter + + + Modo + + + Valores Raw + + + Comparar Parametros + + + Guardar parametros a archivo + + + P + + + IMAX + + + I + + + P + + + IMAX + + + I + + + Actualizar Parametros + + + Iniciar + + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.resx b/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.resx index 881a79be9f7..b0a640427bc 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.resx +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.resx @@ -2703,6 +2703,9 @@ CH6_OPTFLOW_KD + + CH6_NAV_I + 417, 336 diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs index f3a3d9adf29..94e42f21fe4 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs @@ -580,7 +580,7 @@ namespace ArdupilotMega.GCSViews MainV2.givecomport = false; } - void port_Progress(int progress) + void port_Progress(int progress,string status) { Console.WriteLine("Progress {0} ", progress); this.progress.Value = progress; diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.es-ES.resx b/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.es-ES.resx new file mode 100644 index 00000000000..f894ebeb281 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.es-ES.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Images by Max Levine + + + Por favor, haga clic en las imágenes de arriba para "versiones de vuelo" + + + Estado + + + APM programa de instalación (plano y quad + + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs index 5094e64519f..b0424f888c6 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs @@ -302,14 +302,7 @@ namespace ArdupilotMega.GCSViews { if (threadrun == 0) { return; } - this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() -{ - try - { - BUT_playlog.Text = "Pause"; - } - catch { } -}); + updatePlayPauseButton(true); if (comPort.BaseStream.IsOpen) MainV2.comPort.logreadmode = false; @@ -355,17 +348,11 @@ namespace ArdupilotMega.GCSViews } else { - if (threadrun == 0) { return; } - try - { - this.Invoke((System.Windows.Forms.MethodInvoker)delegate() - { - BUT_playlog.Text = "Play"; - }); - } - catch { } + updatePlayPauseButton(false); } + + try { //Console.WriteLine(DateTime.Now.Millisecond); @@ -406,7 +393,7 @@ namespace ArdupilotMega.GCSViews { System.Threading.Thread.Sleep(1); } - + if (trackPoints.Count > int.Parse(MainV2.config["NUM_tracklength"].ToString())) { trackPoints.RemoveRange(0, trackPoints.Count - int.Parse(MainV2.config["NUM_tracklength"].ToString())); @@ -426,10 +413,13 @@ namespace ArdupilotMega.GCSViews FlightPlanner.pointlist.AddRange(MainV2.comPort.wps); } - - routes.Markers.Clear(); - routes.Routes.Clear(); + while (gMapControl1.inOnPaint == true) + { + System.Threading.Thread.Sleep(1); + } + + updateClearRoutes(); route = new GMapRoute(trackPoints, "track"); //track.Stroke = Pens.Red; @@ -493,8 +483,6 @@ namespace ArdupilotMega.GCSViews gMapControl1.HoldInvalidation = false; gMapControl1.Invalidate(); - - Application.DoEvents(); } tracklast = DateTime.Now; @@ -505,9 +493,47 @@ namespace ArdupilotMega.GCSViews Console.WriteLine("FD Main loop exit"); } + + // to prevent cross thread calls while in a draw and exception + private void updateClearRoutes() + { + // not async + this.Invoke((System.Windows.Forms.MethodInvoker)delegate() + { + routes.Markers.Clear(); + routes.Routes.Clear(); + }); + } + + private void updatePlayPauseButton(bool playing) + { + if (playing) + { + this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() + { + try + { + BUT_playlog.Text = "Pause"; + } + catch { } + }); + } + else + { + this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() + { + try + { + BUT_playlog.Text = "Play"; + } + catch { } + }); + } + } + private void updateBindingSource() { - this.Invoke((System.Windows.Forms.MethodInvoker)delegate() + this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() { MainV2.cs.UpdateCurrentSettings(bindingSource1); }); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.es-ES.resx b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.es-ES.resx new file mode 100644 index 00000000000..048d6997a7d --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.es-ES.resx @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Punto de Cámara Aquí + + + Los cambios en el modo de la izquierda + + + &Manual + + + Play/Pause + + + Cambia el waypoint de destino actual + + + Cambiar modo a Auto + + + Volar a Aquí + + + Velocidad estimada del Viento + + + Ver Sensor Raw + + + Reinicia la misión desde el principio + + + 0 + + + Despeje el trayecto registrada en el mapa + + + Dirección estimada del Viento + + + Vel: 0 + + + Mostrar el gráfico de la afinación, mostrando actitudes de destino vs real + + + 0 + + + Log > KML + + + Zoom + + + Limpiar Ruta + + + Up + + + Hace que el autopan mapa basado en la ubicación actual + + + Script + + + Cambiar modo a RTL + + + Indicadores + + + Auto Pan + + + Joystick + + + Cambiar nivel de Zoom + + + Tuning + + + Abajo + + + Hacer Acción + + + Reiniciar Misión + + + Cambiar Modo a Manual/Estabilizado + + + Ver Gyro primas y los valores de Accel y complementos primas de Radio y salidas + + + Haga doble clic aquí para cambiar Max + + + 0 + + + Acciones + + + Realizar la acción hacia la izquierda + + + Establecer Altutid Casa + + + Dir: 0 + + + Cargar Log + + + Configurar y habilitar el joystick + + + Ajuste el alt de pantalla actual como 0, es decir, casa alt sea igual a 0 + + + Grabar HUD en AVI + + + Estado + + + &Auto + + + Establecer WP + + + Logs Telemetría + + + 0.00 % + + + Configurar el modo + + + Velocidad de Reproducción + + + Parar Grabación + + + &RTL + + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.es-ES.resx b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.es-ES.resx new file mode 100644 index 00000000000..dcbcfcd3801 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.es-ES.resx @@ -0,0 +1,366 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Obtener ajustes de la cámara de solapamiento + + + Verifique la altura + + + Casa + + + Cuadrícula + + + Lat + + + Descargar + + + Prev + + + Zoom + + + 45 + + + Cambiar el tipo de mapa actual + + + P4 + + + Tiempo + + + Alt Absoluta + + + Obtener ajustes de la cámara de solapamiento + + + Altitud por Defecto + + + P2 + + + Rotar Mapa + + + Lat + + + 1. Connect2. Lea WP si es necesario.3. Asegúrese de que su posición de casa y ALT se ajusta4. Haga clic en el mapa para empezar a añadir WP + + + Guardar WP en Archivo + + + Long + + + Alt (abs) + + + Para Siempre + + + Alt + + + Ubicación del Ratón + + + Arriba + + + Localización de Casa + + + Cargar Archivo WP + + + Radio Perder Tiempo + + + Iniciar + + + Leer WPs + + + Subir + + + Alt + + + Radio WP + + + Long + + + Comandos + + + Lat + + + Estado + + + Ajustar Localización de Retorno + + + panel6 + + + Limpiar Poligono + + + Acción + + + P1 + + + Representar la actual misión contra los datos de Google Earth + + + Pre Almacena en caché una parte del mapa sobre la base de una caja de dibujar + + + Elimina la Fila + + + Obtener ajustes de la cámara de solapamiento + + + Añadir punto Polígono + + + Perder el Tiempo + + + Comando APM + + + Agregar Abajo + + + Distancia + + + Mueve la fila de abajo + + + Escribir WPs + + + Superponer KML + + + Abajo + + + Lon + + + Dibujar Polígono + + + Saltar + + + 100 + + + Geo-Valla + + + Guardar a Archivo + + + 30 + + + Mueve la fila de arriba + + + Arriba + + + Borrar + + + Circulos + + + WP # + + + Borrar WP + + + Waypoints + + + Dibuja una rejilla sobre un área predefinida con un espacio determinado + + + Zoom a + + + Cargar desde archivo + + + Mantener Altitud por defecto + + + Grafico de Elevación + + + Limpiar Misión + + + Agregar una línea a la red de abajo + + + P3 + + + Prefetch + + + Medida de Distancia + + + Camara + + + Abajo + + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Help.es-ES.resx b/Tools/ArdupilotMegaPlanner/GCSViews/Help.es-ES.resx new file mode 100644 index 00000000000..f802ef45215 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Help.es-ES.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + + Mostrar Consola (reiniciar) + + + Comprobar Actualizaciones + + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs index 8c408cb2774..b805771ee82 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs @@ -11,6 +11,7 @@ using System.Xml; // config file using System.Runtime.InteropServices; // dll imports using ZedGraph; // Graphs using ArdupilotMega; +using ArdupilotMega.Mavlink; using System.Reflection; using System.Drawing.Drawing2D; @@ -636,7 +637,7 @@ namespace ArdupilotMega.GCSViews if (hzcounttime.Second != DateTime.Now.Second) { - Console.WriteLine("SIM hz {0}", hzcount); + //Console.WriteLine("SIM hz {0}", hzcount); hzcount = 0; hzcounttime = DateTime.Now; } @@ -873,15 +874,7 @@ namespace ArdupilotMega.GCSViews { //FlightGear - object imudata = new fgIMUData(); - - MAVLink.ByteArrayToStructureEndian(data, ref imudata, 0); - - imudata = (fgIMUData)(imudata); - - - - fgIMUData imudata2 = (fgIMUData)imudata; + fgIMUData imudata2 = data.ByteArrayToStructureBigEndian(0); if (imudata2.magic != 0x4c56414d) return; @@ -931,13 +924,7 @@ namespace ArdupilotMega.GCSViews } else if (receviedbytes == 658) { - aeroin = new TDataFromAeroSimRC(); - - object temp = aeroin; - - MAVLink.ByteArrayToStructure(data, ref temp, 0); - - aeroin = (TDataFromAeroSimRC)(temp); + aeroin = data.ByteArrayToStructure(0); att.pitch = (aeroin.Model_fPitch); att.roll = (aeroin.Model_fRoll * -1); @@ -1005,13 +992,7 @@ namespace ArdupilotMega.GCSViews else if (receviedbytes == 408) { - FGNetFDM fdm = new FGNetFDM(); - - object temp = fdm; - - MAVLink.ByteArrayToStructureEndian(data, ref temp, 0); - - fdm = (FGNetFDM)(temp); + FGNetFDM fdm = data.ByteArrayToStructureBigEndian(0); lastfdmdata = fdm; diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.es-ES.resx b/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.es-ES.resx new file mode 100644 index 00000000000..16bd7710295 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.es-ES.resx @@ -0,0 +1,303 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Alabeo + + + Error Altitud + + + Invertir Alabeo + + + Heli + + + Cabeceo + + + Salida Ardupilot + + + Plane IMU + + + Guiñada + + + Puede hacer Plane/Heli/Quads + + + Frecuencia Actualización GPS + + + Acelerador + + + Estado Piloto Automatico + + + WP + + + Mostrar Alabeo + + + Modo + + + Simulador de Autoridad - Para aviones diff + + + Iniciar FG Quad + + + Banancia Alabeo + + + Ganancia Cabeceo + + + Quad + + + Ganancia Timón + + + Longitud + + + Ganancia Acelerador + + + Altitud + + + Estos + + + son + + + Latitud + + + Solo SIM + + + Ajustes IP Avanzados + + + Cabeceo + + + Nota: + + + Título + + + Plano GPS + + + 10000 + + + Alabeo + + + Enlace Sim Inicio/Paro + + + WPDist + + + Teniendo ERR + + + Mostrar Todo + + + Sensor + + + Guardar Ajustes + + + Inicio Plano FG + + + Mostrar Timón + + + Guiñada + + + Invertir Timón + + + 10000 + + + Puede hacer con el modelo Avión y Quad + + + Intertir Cabeceo + + + Mostrar Acelerador + + + Xplane 10 + + + AeroSimRC + + + Mostrar Cabeceo + + + + + + FlightGear + + + 10000 + + + X-plane + + + JSBSim + + + 10000 + + + Puede hacer de avión / Heli o Quads + + + Iniciat Xplane + + + Puede hacer Plano / Quad con el plugin + + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Terminal.es-ES.resx b/Tools/ArdupilotMegaPlanner/GCSViews/Terminal.es-ES.resx new file mode 100644 index 00000000000..dfed30055da --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Terminal.es-ES.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Tests + + + Descargar Log + + + Ajustar Radio + + + + + + Buscar Log + + + Mostrar Ajustes + + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/test.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/test.Designer.cs deleted file mode 100644 index fccf65b5da6..00000000000 --- a/Tools/ArdupilotMegaPlanner/GCSViews/test.Designer.cs +++ /dev/null @@ -1,152 +0,0 @@ -namespace ArdupilotMega.GCSViews -{ - partial class test - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.panel3 = new BSE.Windows.Forms.Panel(); - this.splitter1 = new BSE.Windows.Forms.Splitter(); - this.panel1 = new BSE.Windows.Forms.Panel(); - this.splitter2 = new BSE.Windows.Forms.Splitter(); - this.SuspendLayout(); - // - // panel3 - // - this.panel3.AssociatedSplitter = this.splitter1; - this.panel3.BackColor = System.Drawing.Color.Transparent; - this.panel3.CaptionFont = new System.Drawing.Font("Segoe UI", 11.75F, System.Drawing.FontStyle.Bold); - this.panel3.CaptionHeight = 27; - this.panel3.CustomColors.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(184)))), ((int)(((byte)(184))))); - this.panel3.CustomColors.CaptionCloseIcon = System.Drawing.SystemColors.ControlText; - this.panel3.CustomColors.CaptionExpandIcon = System.Drawing.SystemColors.ControlText; - this.panel3.CustomColors.CaptionGradientBegin = System.Drawing.Color.FromArgb(((int)(((byte)(252)))), ((int)(((byte)(252)))), ((int)(((byte)(252))))); - this.panel3.CustomColors.CaptionGradientEnd = System.Drawing.SystemColors.ButtonFace; - this.panel3.CustomColors.CaptionGradientMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(248))))); - this.panel3.CustomColors.CaptionSelectedGradientBegin = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(224)))), ((int)(((byte)(255))))); - this.panel3.CustomColors.CaptionSelectedGradientEnd = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(224)))), ((int)(((byte)(255))))); - this.panel3.CustomColors.CaptionText = System.Drawing.SystemColors.ControlText; - this.panel3.CustomColors.CollapsedCaptionText = System.Drawing.SystemColors.ControlText; - this.panel3.CustomColors.ContentGradientBegin = System.Drawing.SystemColors.ButtonFace; - this.panel3.CustomColors.ContentGradientEnd = System.Drawing.Color.FromArgb(((int)(((byte)(252)))), ((int)(((byte)(252)))), ((int)(((byte)(252))))); - this.panel3.CustomColors.InnerBorderColor = System.Drawing.SystemColors.Window; - this.panel3.Dock = System.Windows.Forms.DockStyle.Left; - this.panel3.ForeColor = System.Drawing.SystemColors.ControlText; - this.panel3.Image = null; - this.panel3.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical; - this.panel3.Location = new System.Drawing.Point(0, 0); - this.panel3.MinimumSize = new System.Drawing.Size(27, 27); - this.panel3.Name = "panel3"; - this.panel3.PanelStyle = BSE.Windows.Forms.PanelStyle.Default; - this.panel3.ShowExpandIcon = true; - this.panel3.Size = new System.Drawing.Size(194, 461); - this.panel3.TabIndex = 4; - this.panel3.Text = "panel3"; - this.panel3.ToolTipTextCloseIcon = null; - this.panel3.ToolTipTextExpandIconPanelCollapsed = null; - this.panel3.ToolTipTextExpandIconPanelExpanded = null; - // - // splitter1 - // - this.splitter1.BackColor = System.Drawing.Color.Transparent; - this.splitter1.Location = new System.Drawing.Point(194, 0); - this.splitter1.Name = "splitter1"; - this.splitter1.Size = new System.Drawing.Size(3, 461); - this.splitter1.TabIndex = 6; - this.splitter1.TabStop = false; - // - // panel1 - // - this.panel1.AssociatedSplitter = this.splitter2; - this.panel1.BackColor = System.Drawing.Color.Transparent; - this.panel1.CaptionFont = new System.Drawing.Font("Segoe UI", 11.75F, System.Drawing.FontStyle.Bold); - this.panel1.CaptionHeight = 27; - this.panel1.CustomColors.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(184)))), ((int)(((byte)(184))))); - this.panel1.CustomColors.CaptionCloseIcon = System.Drawing.SystemColors.ControlText; - this.panel1.CustomColors.CaptionExpandIcon = System.Drawing.SystemColors.ControlText; - this.panel1.CustomColors.CaptionGradientBegin = System.Drawing.Color.FromArgb(((int)(((byte)(252)))), ((int)(((byte)(252)))), ((int)(((byte)(252))))); - this.panel1.CustomColors.CaptionGradientEnd = System.Drawing.SystemColors.ButtonFace; - this.panel1.CustomColors.CaptionGradientMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(248))))); - this.panel1.CustomColors.CaptionSelectedGradientBegin = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(224)))), ((int)(((byte)(255))))); - this.panel1.CustomColors.CaptionSelectedGradientEnd = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(224)))), ((int)(((byte)(255))))); - this.panel1.CustomColors.CaptionText = System.Drawing.SystemColors.ControlText; - this.panel1.CustomColors.CollapsedCaptionText = System.Drawing.SystemColors.ControlText; - this.panel1.CustomColors.ContentGradientBegin = System.Drawing.SystemColors.ButtonFace; - this.panel1.CustomColors.ContentGradientEnd = System.Drawing.Color.FromArgb(((int)(((byte)(252)))), ((int)(((byte)(252)))), ((int)(((byte)(252))))); - this.panel1.CustomColors.InnerBorderColor = System.Drawing.SystemColors.Window; - this.panel1.Dock = System.Windows.Forms.DockStyle.Right; - this.panel1.ForeColor = System.Drawing.SystemColors.ControlText; - this.panel1.Image = null; - this.panel1.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical; - this.panel1.Location = new System.Drawing.Point(808, 0); - this.panel1.MinimumSize = new System.Drawing.Size(27, 27); - this.panel1.Name = "panel1"; - this.panel1.PanelStyle = BSE.Windows.Forms.PanelStyle.Default; - this.panel1.ShowExpandIcon = true; - this.panel1.Size = new System.Drawing.Size(200, 461); - this.panel1.TabIndex = 7; - this.panel1.Text = "panel1"; - this.panel1.ToolTipTextCloseIcon = null; - this.panel1.ToolTipTextExpandIconPanelCollapsed = null; - this.panel1.ToolTipTextExpandIconPanelExpanded = null; - // - // splitter2 - // - this.splitter2.BackColor = System.Drawing.Color.Transparent; - this.splitter2.Dock = System.Windows.Forms.DockStyle.Right; - this.splitter2.Location = new System.Drawing.Point(805, 0); - this.splitter2.Name = "splitter2"; - this.splitter2.Size = new System.Drawing.Size(3, 461); - this.splitter2.TabIndex = 8; - this.splitter2.TabStop = false; - // - // test - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.splitter2); - this.Controls.Add(this.panel1); - this.Controls.Add(this.splitter1); - this.Controls.Add(this.panel3); - this.MinimumSize = new System.Drawing.Size(1008, 461); - this.Name = "test"; - this.Size = new System.Drawing.Size(1008, 461); - this.Load += new System.EventHandler(this.test_Load); - this.ResumeLayout(false); - - } - - #endregion - - private BSE.Windows.Forms.Panel panel3; - private BSE.Windows.Forms.Splitter splitter1; - private BSE.Windows.Forms.Panel panel1; - private BSE.Windows.Forms.Splitter splitter2; - - - - } -} diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/test.cs b/Tools/ArdupilotMegaPlanner/GCSViews/test.cs deleted file mode 100644 index d61c4bd19f4..00000000000 --- a/Tools/ArdupilotMegaPlanner/GCSViews/test.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Windows.Forms; - -namespace ArdupilotMega.GCSViews -{ - public partial class test : UserControl - { - public test() - { - InitializeComponent(); - } - - private void test_Load(object sender, EventArgs e) - { - panel3.Expand = false; - panel1.Expand = false; - } - - } -} - diff --git a/Tools/ArdupilotMegaPlanner/HUD.cs b/Tools/ArdupilotMegaPlanner/HUD.cs index 2b01f3242d8..84f01769625 100644 --- a/Tools/ArdupilotMegaPlanner/HUD.cs +++ b/Tools/ArdupilotMegaPlanner/HUD.cs @@ -241,6 +241,7 @@ namespace hud } bool inOnPaint = false; + string otherthread = ""; protected override void OnPaint(PaintEventArgs e) { @@ -265,10 +266,12 @@ namespace hud if (inOnPaint) { - Console.WriteLine("Was in onpaint Hud th:" + System.Threading.Thread.CurrentThread.Name); + Console.WriteLine("Was in onpaint Hud th:" + System.Threading.Thread.CurrentThread.Name + " in " + otherthread); return; } + otherthread = System.Threading.Thread.CurrentThread.Name; + inOnPaint = true; starttime = DateTime.Now; diff --git a/Tools/ArdupilotMegaPlanner/JoystickSetup.es-ES.resx b/Tools/ArdupilotMegaPlanner/JoystickSetup.es-ES.resx new file mode 100644 index 00000000000..700190a0bae --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/JoystickSetup.es-ES.resx @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + CH 7 + + + CH 5 + + + CH 8 + + + CH 6 + + + Joystick + + + Cabeceo + + + Acelerador + + + 0 + + + Alabeo + + + Expo + + + 30 + + + Salida + + + 30 + + + Timón + + + 0 + + + Joystick + + + 0 + + + Controlador Ejes + + + 0 + + + Invertir + + + 30 + + + 0 + + + Guardar + + + Auto Detectar + + + Elevons + + + Auto Detectar + + + Auto Detectar + + + Auto Detectar + + + Auto Detectar + + + Auto Detectar + + + Auto Detectar + + + Auto Detectar + + + Habilitar + + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/Log.es-ES.resx b/Tools/ArdupilotMegaPlanner/Log.es-ES.resx new file mode 100644 index 00000000000..5d92cbf075b --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/Log.es-ES.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Log + + + Descargar todos los Logs + + + Recrear KML + + + Descargar este Log + + + Limpiar Logs + + + KML Primera Persona + + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/LogBrowse.es-ES.resx b/Tools/ArdupilotMegaPlanner/LogBrowse.es-ES.resx new file mode 100644 index 00000000000..fc31e41ec66 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/LogBrowse.es-ES.resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Cargar un Log + + + Mostrar Log + + + Gráfico de estos datos + + + Gráficos de la celda actual puso de relieve + + + Cargar un archivo diferente de Log + + + Borrar todos los datos del gráfico + + + Limpiar Gráfico + + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/MAVLink.cs b/Tools/ArdupilotMegaPlanner/MAVLink.cs index f0aab4b36fa..e24df86b539 100644 --- a/Tools/ArdupilotMegaPlanner/MAVLink.cs +++ b/Tools/ArdupilotMegaPlanner/MAVLink.cs @@ -9,46 +9,99 @@ using System.Reflection; using System.Reflection.Emit; using System.IO; using System.Drawing; - +using ArdupilotMega.Mavlink; +using System.ComponentModel; namespace ArdupilotMega { public partial class MAVLink { - public ICommsSerial BaseStream = new SerialPort(); + private const double CONNECT_TIMEOUT_SECONDS = 30; + + /// + /// Used for progress reporting on all internal functions + /// + public event ProgressEventHandler Progress; + /// + /// progress form to handle connect and param requests + /// + ProgressReporter frm; + /// /// used for outbound packet sending /// byte packetcount = 0; + /// + /// mavlink remote sysid + /// public byte sysid = 0; + /// + /// mavlink remove compid + /// public byte compid = 0; + /// + /// storage for whole paramater list + /// public Hashtable param = new Hashtable(); + /// + /// storage of a previous packet recevied of a specific type + /// public byte[][] packets = new byte[256][]; + /// + /// used to calc packets per second on any single message type - used for stream rate comparaison + /// public double[] packetspersecond = new double[256]; + /// + /// time last seen a packet of a type + /// DateTime[] packetspersecondbuild = new DateTime[256]; + /// + /// used as a serial port write lock + /// object objlock = new object(); + /// + /// used for a readlock on readpacket + /// object readlock = new object(); + /// + /// used for tlog file lock + /// object logwritelock = new object(); + /// + /// time seen of last mavlink packet + /// public DateTime lastvalidpacket = DateTime.Now; + /// + /// old log support + /// bool oldlogformat = false; + /// + /// mavlink version + /// byte mavlinkversion = 0; + /// + /// mavlink ap type + /// public byte aptype = 0; - byte[] readingpacket = new byte[256]; - + /// + /// used as a snapshot of what is loaded on the ap atm. - derived from the stream + /// public PointLatLngAlt[] wps = new PointLatLngAlt[200]; - + /// + /// turns on console packet display + /// public bool debugmavlink = false; - + /// + /// enabled read from file mode + /// public bool logreadmode = false; public DateTime lastlogread = DateTime.MinValue; public BinaryReader logplaybackfile = null; public BinaryWriter logfile = null; - public byte[] streams = new byte[256]; - int bps1 = 0; int bps2 = 0; public int bps = 0; @@ -78,8 +131,22 @@ namespace ArdupilotMega if (BaseStream.IsOpen) return; - System.Windows.Forms.Form frm = Common.LoadingBox("Mavlink Connecting..", "Mavlink Connecting.."); - frm.TopMost = true; + //System.Windows.Forms.Form frm = Common.LoadingBox("Mavlink Connecting..", "Mavlink Connecting.."); + //frm.TopMost = true; + + frm = new ProgressReporter(); + MainV2.fixtheme(frm); + this.Progress += new ProgressEventHandler(MAVLink_Progress); + //(progress, status) => { frm.updateProgressAndStatus(progress, status); }; + + frm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + + frm.Show(); + + frm.Focus(); + + if (Progress != null) + Progress(-1, "Mavlink Connecting..."); // reset sysid = 0; @@ -102,7 +169,13 @@ namespace ArdupilotMega BaseStream.toggleDTR(); // allow 2560 connect timeout on usb - System.Threading.Thread.Sleep(1000); + for (int a = 0; a < 1000; a++ ) { + System.Threading.Thread.Sleep(1); + if (!MainV2.instance.InvokeRequired) + { + System.Windows.Forms.Application.DoEvents(); + } + } } @@ -110,42 +183,48 @@ namespace ArdupilotMega byte[] buffer1; DateTime start = DateTime.Now; + DateTime deadline = start.AddSeconds(CONNECT_TIMEOUT_SECONDS); + + var countDown = new System.Timers.Timer { Interval = 1000, AutoReset = false }; + countDown.Elapsed += (sender, e) => + { + int secondsRemaining = (deadline - e.SignalTime).Seconds; + if (Progress != null) + Progress(-1, string.Format("Trying to connect.\nTimeout in {0}", secondsRemaining)); + if (secondsRemaining > 0) countDown.Start(); + }; + countDown.Start(); int count = 0; while (true) { - System.Windows.Forms.Application.DoEvents(); - // incase we are in setup mode BaseStream.WriteLine("planner\rgcs\r"); - frm.Controls[0].Text = (start.AddSeconds(30) - DateTime.Now).Seconds.ToString("Timeout in 0"); + Console.WriteLine(DateTime.Now.Millisecond + " start "); + + /* + if (Progress != null) + { + int secondsRemaining = (start.AddSeconds(CONNECT_TIMEOUT_SECONDS) - DateTime.Now).Seconds; + Progress(-1, string.Format("Trying to connect.\nTimeout in {0}", secondsRemaining)); + } + */ if (lastbad[0] == '!' && lastbad[1] == 'G' || lastbad[0] == 'G' && lastbad[1] == '!') // waiting for gps lock { - frm.Controls[0].Text = "Waiting for GPS detection.."; + if (Progress != null) + Progress(-1, "Waiting for GPS detection.."); start = start.AddSeconds(5); // each round is 1.1 seconds } - System.Windows.Forms.Application.DoEvents(); - - if (!(start.AddSeconds(30) > DateTime.Now)) + if (DateTime.Now > deadline) { - /* - System.Windows.Forms.DialogResult dr = System.Windows.Forms.MessageBox.Show("Data recevied but no mavlink packets where read from this port\nWhat do you want to do", - "Read Fail", System.Windows.Forms.MessageBoxButtons.RetryCancel); - if (dr == System.Windows.Forms.DialogResult.Retry) - { - port.toggleDTRnow(); // force reset on usb - start = DateTime.Now; - } - else*/ - { - frm.Close(); - this.Close(); - throw new Exception("No Mavlink Heartbeat Packets where read from this port - Verify Baud Rate and setup\nIt might also be waiting for GPS Lock\nAPM Planner waits for 2 valid heartbeat packets before connecting"); - } + if (Progress != null) + Progress(-1, "No Heatbeat Packets"); + this.Close(); + throw new Exception("No Mavlink Heartbeat Packets where read from this port - Verify Baud Rate and setup\nIt might also be waiting for GPS Lock\nAPM Planner waits for 2 valid heartbeat packets before connecting"); } System.Threading.Thread.Sleep(1); @@ -153,23 +232,15 @@ namespace ArdupilotMega // incase we are in setup mode BaseStream.WriteLine("planner\rgcs\r"); - System.Windows.Forms.Application.DoEvents(); - buffer = getHeartBeat(); - System.Windows.Forms.Application.DoEvents(); - // incase we are in setup mode BaseStream.WriteLine("planner\rgcs\r"); System.Threading.Thread.Sleep(1); - System.Windows.Forms.Application.DoEvents(); - buffer1 = getHeartBeat(); - System.Windows.Forms.Application.DoEvents(); - try { Console.WriteLine("MAv Data: len " + buffer.Length + " btr " + BaseStream.BytesToRead); @@ -180,13 +251,7 @@ namespace ArdupilotMega if (buffer.Length > 5 && buffer1.Length > 5 && buffer[3] == buffer1[3] && buffer[4] == buffer1[4]) { - __mavlink_heartbeat_t hb = new __mavlink_heartbeat_t(); - - object temp = hb; - - MAVLink.ByteArrayToStructure(buffer, ref temp, 6); - - hb = (MAVLink.__mavlink_heartbeat_t)(temp); + __mavlink_heartbeat_t hb = buffer.ByteArrayToStructure<__mavlink_heartbeat_t>(6); mavlinkversion = hb.mavlink_version; aptype = hb.type; @@ -194,14 +259,18 @@ namespace ArdupilotMega sysid = buffer[3]; compid = buffer[4]; recvpacketcount = buffer[2]; - Console.WriteLine("ID sys " + sysid + " comp " + compid + " ver" + mavlinkversion); + Console.WriteLine("ID sys {0} comp {1} ver{2}", sysid, compid, mavlinkversion); break; } + } - frm.Controls[0].Text = "Getting Params.. (sysid " + sysid + " compid " + compid + ") "; - frm.Refresh(); - if (getparams == true) + countDown.Stop(); + + if (Progress != null) + Progress(-1, "Getting Params.. (sysid " + sysid + " compid " + compid + ") "); + + if (getparams) getParamList(); } catch (Exception e) @@ -212,132 +281,27 @@ namespace ArdupilotMega } catch { } MainV2.givecomport = false; - frm.Close(); + if (Progress != null) + Progress(-1, "Connect Failed\n" + e.Message); throw e; } - frm.Close(); - MainV2.givecomport = false; - Console.WriteLine("Done open " + sysid + " " + compid); - packetslost = 0; } - byte[] StructureToByteArrayEndian(params object[] list) + void MAVLink_Progress(int progress, string status) { - // The copy is made becuase SetValue won't work on a struct. - // Boxing was used because SetValue works on classes/objects. - // Unfortunately, it results in 2 copy operations. - object thisBoxed = list[0]; // Why make a copy? - Type test = thisBoxed.GetType(); - - int offset = 0; - byte[] data = new byte[Marshal.SizeOf(thisBoxed)]; - - // System.Net.IPAddress.NetworkToHostOrder is used to perform byte swapping. - // To convert unsigned to signed, 'unchecked()' was used. - // See http://stackoverflow.com/questions/1131843/how-do-i-convert-uint-to-int-in-c - - object fieldValue; - TypeCode typeCode; - - byte[] temp; - - // Enumerate each structure field using reflection. - foreach (var field in test.GetFields()) + if (frm != null) { - // field.Name has the field's name. - - fieldValue = field.GetValue(thisBoxed); // Get value - - // Get the TypeCode enumeration. Multiple types get mapped to a common typecode. - typeCode = Type.GetTypeCode(fieldValue.GetType()); - - switch (typeCode) + try { - case TypeCode.Single: // float - { - temp = BitConverter.GetBytes((Single)fieldValue); - Array.Reverse(temp); - Array.Copy(temp, 0, data, offset, sizeof(Single)); - break; - } - case TypeCode.Int32: - { - temp = BitConverter.GetBytes((Int32)fieldValue); - Array.Reverse(temp); - Array.Copy(temp, 0, data, offset, sizeof(Int32)); - break; - } - case TypeCode.UInt32: - { - temp = BitConverter.GetBytes((UInt32)fieldValue); - Array.Reverse(temp); - Array.Copy(temp, 0, data, offset, sizeof(UInt32)); - break; - } - case TypeCode.Int16: - { - temp = BitConverter.GetBytes((Int16)fieldValue); - Array.Reverse(temp); - Array.Copy(temp, 0, data, offset, sizeof(Int16)); - break; - } - case TypeCode.UInt16: - { - temp = BitConverter.GetBytes((UInt16)fieldValue); - Array.Reverse(temp); - Array.Copy(temp, 0, data, offset, sizeof(UInt16)); - break; - } - case TypeCode.Int64: - { - temp = BitConverter.GetBytes((Int64)fieldValue); - Array.Reverse(temp); - Array.Copy(temp, 0, data, offset, sizeof(Int64)); - break; - } - case TypeCode.UInt64: - { - temp = BitConverter.GetBytes((UInt64)fieldValue); - Array.Reverse(temp); - Array.Copy(temp, 0, data, offset, sizeof(UInt64)); - break; - } - case TypeCode.Double: - { - temp = BitConverter.GetBytes((Double)fieldValue); - Array.Reverse(temp); - Array.Copy(temp, 0, data, offset, sizeof(Double)); - break; - } - case TypeCode.Byte: - { - data[offset] = (Byte)fieldValue; - break; - } - default: - { - //System.Diagnostics.Debug.Fail("No conversion provided for this type : " + typeCode.ToString()); - break; - } - }; // switch - if (typeCode == TypeCode.Object) - { - int length = ((byte[])fieldValue).Length; - Array.Copy(((byte[])fieldValue), 0, data, offset, length); - offset += length; + frm.updateProgressAndStatus(progress, status); } - else - { - offset += Marshal.SizeOf(fieldValue); - } - } // foreach - - return data; - } // Swap + catch (Exception ex) { throw ex; } + } + } byte[] getHeartBeat() { @@ -388,11 +352,11 @@ namespace ArdupilotMega if (mavlinkversion == 3) { - data = StructureToByteArray(indata); + data = MavlinkUtil.StructureToByteArray(indata); } else { - data = StructureToByteArrayEndian(indata); + data = MavlinkUtil.StructureToByteArrayBigEndian(indata); } //Console.WriteLine(DateTime.Now + " PC Doing req "+ messageType + " " + this.BytesToRead); @@ -423,11 +387,11 @@ namespace ArdupilotMega i++; } - ushort checksum = crc_calculate(packet, packet[1] + 6); + ushort checksum = MavlinkCRC.crc_calculate(packet, packet[1] + 6); if (mavlinkversion == 3) { - checksum = crc_accumulate(MAVLINK_MESSAGE_CRCS[messageType], checksum); + checksum = MavlinkCRC.crc_accumulate(MAVLINK_MESSAGE_CRCS[messageType], checksum); } byte ck_a = (byte)(checksum & 0xFF); ///< High byte @@ -496,7 +460,7 @@ namespace ArdupilotMega { int value = (int)(float)param[paramname]; - return setParam(paramname,value | (int)flag); + return setParam(paramname, value | (int)flag); } /// @@ -557,13 +521,7 @@ namespace ArdupilotMega { if (buffer[5] == MAVLINK_MSG_ID_PARAM_VALUE) { - __mavlink_param_value_t par = new __mavlink_param_value_t(); - - object tempobj = par; - - ByteArrayToStructure(buffer, ref tempobj, 6); - - par = (__mavlink_param_value_t)tempobj; + __mavlink_param_value_t par = buffer.ByteArrayToStructure<__mavlink_param_value_t>(6); string st = System.Text.ASCIIEncoding.ASCII.GetString(par.param_id); @@ -631,7 +589,7 @@ namespace ArdupilotMega { if (retrys > 0) { - Console.WriteLine("getParamList Retry " + retrys + " sys " + sysid + " comp " + compid); + Console.WriteLine("getParamList Retry {0} sys {1} comp {2}", retrys, sysid, compid); generatePacket(MAVLINK_MSG_ID_PARAM_REQUEST_LIST, req); start = DateTime.Now; retrys--; @@ -659,22 +617,28 @@ namespace ArdupilotMega restart = DateTime.Now; start = DateTime.Now; - __mavlink_param_value_t par = new __mavlink_param_value_t(); - - object temp = par; - - ByteArrayToStructure(buffer, ref temp, 6); - - par = (__mavlink_param_value_t)temp; + __mavlink_param_value_t par = buffer.ByteArrayToStructure<__mavlink_param_value_t>(6); param_total = (par.param_count); + + string paramID = System.Text.ASCIIEncoding.ASCII.GetString(par.param_id); + + int pos = paramID.IndexOf('\0'); + if (pos != -1) + { + paramID = paramID.Substring(0, pos); + } + Console.WriteLine(DateTime.Now.Millisecond + " got param " + (par.param_index) + " of " + (param_total - 1) + " name: " + paramID); + // for out of order udp packets if (BaseStream.GetType() != typeof(UdpSerial)) { if (nextid == (par.param_index)) { nextid++; + if (Progress != null) + Progress((par.param_index * 100) / param_total, "Got param " + paramID); } else { @@ -687,27 +651,15 @@ namespace ArdupilotMega retrys--; continue; } + Console.WriteLine("Out of order packet. Re-requesting list"); missed.Add(nextid); // for later devel MainV2.givecomport = false; throw new Exception("Missed ID expecting " + nextid + " got " + (par.param_index) + "\nPlease try loading again"); } - } - - string st = System.Text.ASCIIEncoding.ASCII.GetString(par.param_id); - - int pos = st.IndexOf('\0'); - - if (pos != -1) - { - st = st.Substring(0, pos); } - Console.WriteLine(DateTime.Now.Millisecond + " got param " + (par.param_index) + " of " + (param_total - 1) + " name: " + st); - - modifyParamForDisplay(true, st, ref par.param_value); - - param[st] = (par.param_value); - + modifyParamForDisplay(true, paramID, ref par.param_value); + param[paramID] = (par.param_value); param_count++; } else @@ -757,12 +709,6 @@ namespace ArdupilotMega req.start_stop = 0; // stop req.req_stream_id = 0; // all - // reset all - if (forget) - { - streams = new byte[streams.Length]; - } - // no error on bad try { @@ -897,13 +843,10 @@ namespace ArdupilotMega { if (buffer[5] == MAVLINK_MSG_ID_COMMAND_ACK) { - __mavlink_command_ack_t ack = new __mavlink_command_ack_t(); - object temp = (object)ack; - ByteArrayToStructure(buffer, ref temp, 6); + var ack = buffer.ByteArrayToStructure<__mavlink_command_ack_t>(6); - ack = (__mavlink_command_ack_t)(temp); if (ack.result == (byte)MAV_RESULT.MAV_RESULT_ACCEPTED) { @@ -1031,8 +974,6 @@ namespace ArdupilotMega public void requestDatastream(byte id, byte hzrate) { - streams[id] = hzrate; - double pps = 0; switch (id) @@ -1204,13 +1145,10 @@ namespace ArdupilotMega { if (buffer[5] == MAVLINK_MSG_ID_MISSION_COUNT) { - __mavlink_mission_count_t count = new __mavlink_mission_count_t(); - object temp = (object)count; - ByteArrayToStructure(buffer, ref temp, 6); - count = (__mavlink_mission_count_t)(temp); + var count = buffer.ByteArrayToStructure<__mavlink_mission_count_t>(6); Console.WriteLine("wpcount: " + count.count); @@ -1320,15 +1258,12 @@ namespace ArdupilotMega if (buffer[5] == MAVLINK_MSG_ID_MISSION_ITEM) { //Console.WriteLine("getwp ans " + DateTime.Now.Millisecond); - __mavlink_mission_item_t wp = new __mavlink_mission_item_t(); - object temp = (object)wp; //Array.Copy(buffer, 6, buffer, 0, buffer.Length - 6); - ByteArrayToStructure(buffer, ref temp, 6); + var wp = buffer.ByteArrayToStructure<__mavlink_mission_item_t>(6); - wp = (__mavlink_mission_item_t)(temp); #else @@ -1370,15 +1305,7 @@ namespace ArdupilotMega if (buffer[5] == MAVLINK_MSG_ID_WAYPOINT) { //Console.WriteLine("getwp ans " + DateTime.Now.Millisecond); - __mavlink_waypoint_t wp = new __mavlink_waypoint_t(); - - object temp = (object)wp; - - //Array.Copy(buffer, 6, buffer, 0, buffer.Length - 6); - - ByteArrayToStructure(buffer, ref temp, 6); - - wp = (__mavlink_waypoint_t)(temp); + __mavlink_waypoint_t wp = buffer.ByteArrayToStructure<__mavlink_waypoint_t>(6); #endif @@ -1499,7 +1426,7 @@ namespace ArdupilotMega object data = Activator.CreateInstance(mavstructs[messid]); - ByteArrayToStructure(datin, ref data, 6); + MavlinkUtil.ByteArrayToStructure(datin, ref data, 6); Type test = data.GetType(); @@ -1580,13 +1507,10 @@ namespace ArdupilotMega { if (buffer[5] == MAVLINK_MSG_ID_MISSION_REQUEST) { - __mavlink_mission_request_t request = new __mavlink_mission_request_t(); - object temp = (object)request; - ByteArrayToStructure(buffer, ref temp, 6); - request = (__mavlink_mission_request_t)(temp); + var request = buffer.ByteArrayToStructure<__mavlink_mission_request_t>(6); if (request.seq == 0) { @@ -1638,13 +1562,7 @@ namespace ArdupilotMega { if (buffer[5] == MAVLINK_MSG_ID_WAYPOINT_REQUEST) { - __mavlink_waypoint_request_t request = new __mavlink_waypoint_request_t(); - - object temp = (object)request; - - ByteArrayToStructure(buffer, ref temp, 6); - - request = (__mavlink_waypoint_request_t)(temp); + __mavlink_waypoint_request_t request = buffer.ByteArrayToStructure<__mavlink_waypoint_request_t>(6); if (request.seq == 0) { @@ -1790,26 +1708,20 @@ namespace ArdupilotMega #if MAVLINK10 if (buffer[5] == MAVLINK_MSG_ID_MISSION_ACK) { - __mavlink_mission_ack_t ans = new __mavlink_mission_ack_t(); - object temp = (object)ans; - ByteArrayToStructure(buffer, ref temp, 6); + var ans = buffer.ByteArrayToStructure<__mavlink_mission_ack_t>(6); - ans = (__mavlink_mission_ack_t)(temp); Console.WriteLine("set wp " + index + " ACK 47 : " + buffer[5] + " ans " + Enum.Parse(typeof(MAV_MISSION_RESULT), ans.type.ToString())); break; } else if (buffer[5] == MAVLINK_MSG_ID_MISSION_REQUEST) { - __mavlink_mission_request_t ans = new __mavlink_mission_request_t(); + var ans = buffer.ByteArrayToStructure<__mavlink_mission_request_t>(6); - object temp = (object)ans; - ByteArrayToStructure(buffer, ref temp, 6); - ans = (__mavlink_mission_request_t)(temp); if (ans.seq == (index + 1)) { @@ -1835,15 +1747,7 @@ namespace ArdupilotMega } else if (buffer[5] == MAVLINK_MSG_ID_WAYPOINT_REQUEST) { - __mavlink_waypoint_request_t ans = new __mavlink_waypoint_request_t(); - - object temp = (object)ans; - - //Array.Copy(buffer, 6, buffer, 0, buffer.Length - 6); - - ByteArrayToStructure(buffer, ref temp, 6); - - ans = (__mavlink_waypoint_request_t)(temp); + __mavlink_waypoint_request_t ans = buffer.ByteArrayToStructure<__mavlink_waypoint_request_t>(6); if (ans.seq == (index + 1)) { @@ -1961,7 +1865,7 @@ namespace ArdupilotMega int readcount = 0; lastbad = new byte[2]; - BaseStream.ReadTimeout = 1100; // 1100 ms between bytes + BaseStream.ReadTimeout = 100; DateTime start = DateTime.Now; @@ -2008,6 +1912,23 @@ namespace ArdupilotMega else { MainV2.cs.datetime = DateTime.Now; + + int to = 0; + + while (BaseStream.BytesToRead <= 0) + { + if (to > BaseStream.ReadTimeout) + { + Console.WriteLine("MAVLINK: wait time out btr {0} len {1}", BaseStream.BytesToRead, length); + throw new Exception("Timeout"); + } + System.Threading.Thread.Sleep(1); + if (!MainV2.instance.InvokeRequired) + { + System.Windows.Forms.Application.DoEvents(); // when connecting this is in the main thread + } + to++; + } if (BaseStream.IsOpen) temp[count] = (byte)BaseStream.ReadByte(); } @@ -2061,7 +1982,10 @@ namespace ArdupilotMega break; } System.Threading.Thread.Sleep(1); - System.Windows.Forms.Application.DoEvents(); // when connecting this is in the main thread + if (!MainV2.instance.InvokeRequired) + { + System.Windows.Forms.Application.DoEvents(); // when connecting this is in the main thread + } to++; //Console.WriteLine("data " + 0 + " " + length + " aval " + BaseStream.BytesToRead); @@ -2114,11 +2038,11 @@ namespace ArdupilotMega return temp;// new byte[0]; } - ushort crc = crc_calculate(temp, temp.Length - 2); + ushort crc = MavlinkCRC.crc_calculate(temp, temp.Length - 2); if (temp.Length > 5 && temp[0] == 254) { - crc = crc_accumulate(MAVLINK_MESSAGE_CRCS[temp[5]], crc); + crc = MavlinkCRC.crc_accumulate(MAVLINK_MESSAGE_CRCS[temp[5]], crc); } if (temp.Length > 5 && temp[1] != MAVLINK_MESSAGE_LENGTHS[temp[5]]) @@ -2235,46 +2159,30 @@ namespace ArdupilotMega /// /// Used to extract mission from log file /// - /// packet - void getWPsfromstream(ref byte[] temp) + /// packet + void getWPsfromstream(ref byte[] buffer) { #if MAVLINK10 - if (temp[5] == MAVLINK_MSG_ID_MISSION_COUNT) + if (buffer[5] == MAVLINK_MSG_ID_MISSION_COUNT) { // clear old wps = new PointLatLngAlt[wps.Length]; } - if (temp[5] == MAVLink.MAVLINK_MSG_ID_MISSION_ITEM) + if (buffer[5] == MAVLink.MAVLINK_MSG_ID_MISSION_ITEM) { - __mavlink_mission_item_t wp = new __mavlink_mission_item_t(); - - object structtemp = (object)wp; - - //Array.Copy(buffer, 6, buffer, 0, buffer.Length - 6); - - ByteArrayToStructure(temp, ref structtemp, 6); - - wp = (__mavlink_mission_item_t)(structtemp); + __mavlink_mission_item_t wp = buffer.ByteArrayToStructure<__mavlink_mission_item_t>(6); #else - if (temp[5] == MAVLINK_MSG_ID_WAYPOINT_COUNT) + if (buffer[5] == MAVLINK_MSG_ID_WAYPOINT_COUNT) { // clear old wps = new PointLatLngAlt[wps.Length]; } - if (temp[5] == MAVLink.MAVLINK_MSG_ID_WAYPOINT) + if (buffer[5] == MAVLink.MAVLINK_MSG_ID_WAYPOINT) { - __mavlink_waypoint_t wp = new __mavlink_waypoint_t(); - - object structtemp = (object)wp; - - //Array.Copy(buffer, 6, buffer, 0, buffer.Length - 6); - - ByteArrayToStructure(temp, ref structtemp, 6); - - wp = (__mavlink_waypoint_t)(structtemp); + __mavlink_waypoint_t wp = buffer.ByteArrayToStructure<__mavlink_waypoint_t>(6); #endif wps[wp.seq] = new PointLatLngAlt(wp.x, wp.y, wp.z, wp.seq.ToString()); @@ -2323,13 +2231,7 @@ namespace ArdupilotMega { MainV2.givecomport = false; - __mavlink_fence_point_t fp = new __mavlink_fence_point_t(); - - object structtemp = (object)fp; - - ByteArrayToStructure(buffer, ref structtemp, 6); - - fp = (__mavlink_fence_point_t)(structtemp); + __mavlink_fence_point_t fp = buffer.ByteArrayToStructure<__mavlink_fence_point_t>(6); plla.Lat = fp.lat; plla.Lng = fp.lng; @@ -2462,206 +2364,7 @@ namespace ArdupilotMega return temp; } - const int X25_INIT_CRC = 0xffff; - const int X25_VALIDATE_CRC = 0xf0b8; - - ushort crc_accumulate(byte b, ushort crc) - { - unchecked - { - byte ch = (byte)(b ^ (byte)(crc & 0x00ff)); - ch = (byte)(ch ^ (ch << 4)); - return (ushort)((crc >> 8) ^ (ch << 8) ^ (ch << 3) ^ (ch >> 4)); - } - } - - ushort crc_calculate(byte[] pBuffer, int length) - { - if (length < 1) - { - return 0xffff; - } - // For a "message" of length bytes contained in the unsigned char array - // pointed to by pBuffer, calculate the CRC - // crcCalculate(unsigned char* pBuffer, int length, unsigned short* checkConst) < not needed - - ushort crcTmp; - int i; - - crcTmp = X25_INIT_CRC; - - for (i = 1; i < length; i++) // skips header U - { - crcTmp = crc_accumulate(pBuffer[i], crcTmp); - //Console.WriteLine(crcTmp + " " + pBuffer[i] + " " + length); - } - - return (crcTmp); - } - byte[] StructureToByteArray(object obj) - { - - int len = Marshal.SizeOf(obj); - - byte[] arr = new byte[len]; - - IntPtr ptr = Marshal.AllocHGlobal(len); - - Marshal.StructureToPtr(obj, ptr, true); - - Marshal.Copy(ptr, arr, 0, len); - - Marshal.FreeHGlobal(ptr); - - return arr; - - } - - public static void ByteArrayToStructure(byte[] bytearray, ref object obj, int startoffset) - { - if (bytearray[0] == 'U') - { - ByteArrayToStructureEndian(bytearray, ref obj, startoffset); - } - else - { - int len = Marshal.SizeOf(obj); - - IntPtr i = Marshal.AllocHGlobal(len); - - // create structure from ptr - obj = Marshal.PtrToStructure(i, obj.GetType()); - - try - { - // copy byte array to ptr - Marshal.Copy(bytearray, startoffset, i, len); - } - catch (Exception ex) { Console.WriteLine("ByteArrayToStructure FAIL: error " + ex.ToString()); } - - obj = Marshal.PtrToStructure(i, obj.GetType()); - - Marshal.FreeHGlobal(i); - } - } - - public static void ByteArrayToStructureEndian(byte[] bytearray, ref object obj, int startoffset) - { - int len = Marshal.SizeOf(obj); - - IntPtr i = Marshal.AllocHGlobal(len); - - byte[] temparray = (byte[])bytearray.Clone(); - - // create structure from ptr - obj = Marshal.PtrToStructure(i, obj.GetType()); - - // do endian swap - - object thisBoxed = obj; - Type test = thisBoxed.GetType(); - - int reversestartoffset = startoffset; - - // Enumerate each structure field using reflection. - foreach (var field in test.GetFields()) - { - // field.Name has the field's name. - - object fieldValue = field.GetValue(thisBoxed); // Get value - - // Get the TypeCode enumeration. Multiple types get mapped to a common typecode. - TypeCode typeCode = Type.GetTypeCode(fieldValue.GetType()); - - if (typeCode != TypeCode.Object) - { - Array.Reverse(temparray, reversestartoffset, Marshal.SizeOf(fieldValue)); - reversestartoffset += Marshal.SizeOf(fieldValue); - } - else - { - reversestartoffset += ((byte[])fieldValue).Length; - } - - } - - try - { - // copy byte array to ptr - Marshal.Copy(temparray, startoffset, i, len); - } - catch (Exception ex) { Console.WriteLine("ByteArrayToStructure FAIL: error " + ex.ToString()); } - - obj = Marshal.PtrToStructure(i, obj.GetType()); - - Marshal.FreeHGlobal(i); - - } - - public short swapend11(short value) - { - int len = Marshal.SizeOf(value); - - byte[] temp = BitConverter.GetBytes(value); - - Array.Reverse(temp); - - return BitConverter.ToInt16(temp, 0); - } - - public ushort swapend11(ushort value) - { - int len = Marshal.SizeOf(value); - - byte[] temp = BitConverter.GetBytes(value); - - Array.Reverse(temp); - - return BitConverter.ToUInt16(temp, 0); - } - - public ulong swapend11(ulong value) - { - int len = Marshal.SizeOf(value); - - byte[] temp = BitConverter.GetBytes(value); - - Array.Reverse(temp); - - return BitConverter.ToUInt64(temp, 0); - } - - public float swapend11(float value) - { - byte[] temp = BitConverter.GetBytes(value); - if (temp[0] == 0xff) - temp[0] = 0xfe; - Array.Reverse(temp); - return BitConverter.ToSingle(temp, 0); - } - - public int swapend11(int value) - { - int len = Marshal.SizeOf(value); - - byte[] temp = BitConverter.GetBytes(value); - - Array.Reverse(temp); - - return BitConverter.ToInt32(temp, 0); - } - - public double swapend11(double value) - { - int len = Marshal.SizeOf(value); - - byte[] temp = BitConverter.GetBytes(value); - - Array.Reverse(temp); - - return BitConverter.ToDouble(temp, 0); - } } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/MAVLinkTypesenum.cs b/Tools/ArdupilotMegaPlanner/MAVLinkTypesenum.cs deleted file mode 100644 index 6f146c83c8d..00000000000 --- a/Tools/ArdupilotMegaPlanner/MAVLinkTypesenum.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Runtime.InteropServices; - -namespace ArdupilotMega -{ - partial class MAVLink - { - - } -} - diff --git a/Tools/ArdupilotMegaPlanner/MainV2.cs b/Tools/ArdupilotMegaPlanner/MainV2.cs index ffbb76efdff..a0a75f0e8fe 100644 --- a/Tools/ArdupilotMegaPlanner/MainV2.cs +++ b/Tools/ArdupilotMegaPlanner/MainV2.cs @@ -760,19 +760,19 @@ namespace ArdupilotMega byte[] buffer = port.download(20); port.Close(); - if (buffer[0] != 'A' || buffer[1] != 'P') // this is the apvar header + if ((buffer[0] == 'A' || buffer[0] == 'P') && (buffer[1] == 'A' || buffer[1] == 'P')) // this is the apvar header + { + Console.WriteLine("Valid eeprom contents"); + } + else { MessageBox.Show("You dont appear to have uploaded a firmware yet,\n\nPlease goto the firmware page and upload one."); return; } - else - { - Console.WriteLine("Valid eeprom contents"); - } } } catch { } - MessageBox.Show("Can not establish a connection\n\n" + ex.ToString()); + //MessageBox.Show("Can not establish a connection\n\n" + ex.ToString()); return; } } @@ -1632,9 +1632,9 @@ namespace ArdupilotMega MainV2.instance.Invoke((MethodInvoker)delegate { loadinglabel.Text = text; - }); - Application.DoEvents(); + Application.DoEvents(); + }); } private static void checkForUpdate() @@ -1881,7 +1881,6 @@ namespace ArdupilotMega while (dataStream.CanRead) { - Application.DoEvents(); try { if (dt.Second != DateTime.Now.Second) diff --git a/Tools/ArdupilotMegaPlanner/Mavlink/MavlinkCRC.cs b/Tools/ArdupilotMegaPlanner/Mavlink/MavlinkCRC.cs new file mode 100644 index 00000000000..93f50fb6916 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/Mavlink/MavlinkCRC.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ArdupilotMega.Mavlink +{ + class MavlinkCRC + { + const int X25_INIT_CRC = 0xffff; + const int X25_VALIDATE_CRC = 0xf0b8; + + public static ushort crc_accumulate(byte b, ushort crc) + { + unchecked + { + byte ch = (byte)(b ^ (byte)(crc & 0x00ff)); + ch = (byte)(ch ^ (ch << 4)); + return (ushort)((crc >> 8) ^ (ch << 8) ^ (ch << 3) ^ (ch >> 4)); + } + } + + public static ushort crc_calculate(byte[] pBuffer, int length) + { + if (length < 1) + { + return 0xffff; + } + // For a "message" of length bytes contained in the unsigned char array + // pointed to by pBuffer, calculate the CRC + // crcCalculate(unsigned char* pBuffer, int length, unsigned short* checkConst) < not needed + + ushort crcTmp; + int i; + + crcTmp = X25_INIT_CRC; + + for (i = 1; i < length; i++) // skips header U + { + crcTmp = crc_accumulate(pBuffer[i], crcTmp); + //Console.WriteLine(crcTmp + " " + pBuffer[i] + " " + length); + } + + return (crcTmp); + } + + } +} diff --git a/Tools/ArdupilotMegaPlanner/Mavlink/MavlinkUtil.cs b/Tools/ArdupilotMegaPlanner/Mavlink/MavlinkUtil.cs new file mode 100644 index 00000000000..0be0d7c6357 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/Mavlink/MavlinkUtil.cs @@ -0,0 +1,246 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; + +namespace ArdupilotMega.Mavlink +{ + /// + /// Static methods and helpers for creation and manipulation of Mavlink packets + /// + public static class MavlinkUtil + { + /// + /// Create a new mavlink packet object from a byte array as recieved over mavlink + /// Endianess will be detetected using packet inspection + /// + /// The type of mavlink packet to create + /// The bytes of the mavlink packet + /// The position in the byte array where the packet starts + /// The newly created mavlink packet + public static TMavlinkPacket ByteArrayToStructure(this byte[] bytearray, int startoffset) where TMavlinkPacket : struct + { + object newPacket = new TMavlinkPacket(); + ByteArrayToStructure(bytearray, ref newPacket, startoffset); + return (TMavlinkPacket)newPacket; + } + + public static TMavlinkPacket ByteArrayToStructureBigEndian(this byte[] bytearray, int startoffset) where TMavlinkPacket : struct + { + object newPacket = new TMavlinkPacket(); + ByteArrayToStructureEndian(bytearray, ref newPacket, startoffset); + return (TMavlinkPacket)newPacket; + } + + public static void ByteArrayToStructure(byte[] bytearray, ref object obj, int startoffset) + { + if (bytearray[0] == 'U') + { + ByteArrayToStructureEndian(bytearray, ref obj, startoffset); + } + else + { + int len = Marshal.SizeOf(obj); + + IntPtr i = Marshal.AllocHGlobal(len); + + // create structure from ptr + obj = Marshal.PtrToStructure(i, obj.GetType()); + + try + { + // copy byte array to ptr + Marshal.Copy(bytearray, startoffset, i, len); + } + catch (Exception ex) + { + Console.WriteLine("ByteArrayToStructure FAIL: error " + ex); + } + + obj = Marshal.PtrToStructure(i, obj.GetType()); + + Marshal.FreeHGlobal(i); + } + } + + public static void ByteArrayToStructureEndian(byte[] bytearray, ref object obj, int startoffset) + { + int len = Marshal.SizeOf(obj); + IntPtr i = Marshal.AllocHGlobal(len); + byte[] temparray = (byte[])bytearray.Clone(); + + // create structure from ptr + obj = Marshal.PtrToStructure(i, obj.GetType()); + + // do endian swap + object thisBoxed = obj; + Type test = thisBoxed.GetType(); + + int reversestartoffset = startoffset; + + // Enumerate each structure field using reflection. + foreach (var field in test.GetFields()) + { + // field.Name has the field's name. + object fieldValue = field.GetValue(thisBoxed); // Get value + + // Get the TypeCode enumeration. Multiple types get mapped to a common typecode. + TypeCode typeCode = Type.GetTypeCode(fieldValue.GetType()); + + if (typeCode != TypeCode.Object) + { + Array.Reverse(temparray, reversestartoffset, Marshal.SizeOf(fieldValue)); + reversestartoffset += Marshal.SizeOf(fieldValue); + } + else + { + reversestartoffset += ((byte[])fieldValue).Length; + } + + } + + try + { + // copy byte array to ptr + Marshal.Copy(temparray, startoffset, i, len); + } + catch (Exception ex) { Console.WriteLine("ByteArrayToStructure FAIL: error " + ex.ToString()); } + + obj = Marshal.PtrToStructure(i, obj.GetType()); + + Marshal.FreeHGlobal(i); + + } + + /// + /// Convert a struct to an array of bytes, struct fields being reperesented in + /// little endian (LSB first) + /// + /// Note - assumes little endian host order + public static byte[] StructureToByteArray(object obj) + { + int len = Marshal.SizeOf(obj); + byte[] arr = new byte[len]; + IntPtr ptr = Marshal.AllocHGlobal(len); + Marshal.StructureToPtr(obj, ptr, true); + Marshal.Copy(ptr, arr, 0, len); + Marshal.FreeHGlobal(ptr); + return arr; + } + + /// + /// Convert a struct to an array of bytes, struct fields being reperesented in + /// big endian (MSB first) + /// + public static byte[] StructureToByteArrayBigEndian(params object[] list) + { + // The copy is made becuase SetValue won't work on a struct. + // Boxing was used because SetValue works on classes/objects. + // Unfortunately, it results in 2 copy operations. + object thisBoxed = list[0]; // Why make a copy? + Type test = thisBoxed.GetType(); + + int offset = 0; + byte[] data = new byte[Marshal.SizeOf(thisBoxed)]; + + object fieldValue; + TypeCode typeCode; + + byte[] temp; + + // Enumerate each structure field using reflection. + foreach (var field in test.GetFields()) + { + // field.Name has the field's name. + + fieldValue = field.GetValue(thisBoxed); // Get value + + // Get the TypeCode enumeration. Multiple types get mapped to a common typecode. + typeCode = Type.GetTypeCode(fieldValue.GetType()); + + switch (typeCode) + { + case TypeCode.Single: // float + { + temp = BitConverter.GetBytes((Single)fieldValue); + Array.Reverse(temp); + Array.Copy(temp, 0, data, offset, sizeof(Single)); + break; + } + case TypeCode.Int32: + { + temp = BitConverter.GetBytes((Int32)fieldValue); + Array.Reverse(temp); + Array.Copy(temp, 0, data, offset, sizeof(Int32)); + break; + } + case TypeCode.UInt32: + { + temp = BitConverter.GetBytes((UInt32)fieldValue); + Array.Reverse(temp); + Array.Copy(temp, 0, data, offset, sizeof(UInt32)); + break; + } + case TypeCode.Int16: + { + temp = BitConverter.GetBytes((Int16)fieldValue); + Array.Reverse(temp); + Array.Copy(temp, 0, data, offset, sizeof(Int16)); + break; + } + case TypeCode.UInt16: + { + temp = BitConverter.GetBytes((UInt16)fieldValue); + Array.Reverse(temp); + Array.Copy(temp, 0, data, offset, sizeof(UInt16)); + break; + } + case TypeCode.Int64: + { + temp = BitConverter.GetBytes((Int64)fieldValue); + Array.Reverse(temp); + Array.Copy(temp, 0, data, offset, sizeof(Int64)); + break; + } + case TypeCode.UInt64: + { + temp = BitConverter.GetBytes((UInt64)fieldValue); + Array.Reverse(temp); + Array.Copy(temp, 0, data, offset, sizeof(UInt64)); + break; + } + case TypeCode.Double: + { + temp = BitConverter.GetBytes((Double)fieldValue); + Array.Reverse(temp); + Array.Copy(temp, 0, data, offset, sizeof(Double)); + break; + } + case TypeCode.Byte: + { + data[offset] = (Byte)fieldValue; + break; + } + default: + { + //System.Diagnostics.Debug.Fail("No conversion provided for this type : " + typeCode.ToString()); + break; + } + }; // switch + if (typeCode == TypeCode.Object) + { + int length = ((byte[])fieldValue).Length; + Array.Copy(((byte[])fieldValue), 0, data, offset, length); + offset += length; + } + else + { + offset += Marshal.SizeOf(fieldValue); + } + } // foreach + + return data; + } // Swap + } +} diff --git a/Tools/ArdupilotMegaPlanner/MavlinkLog.es-ES.resx b/Tools/ArdupilotMegaPlanner/MavlinkLog.es-ES.resx new file mode 100644 index 00000000000..3801d5fc68f --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/MavlinkLog.es-ES.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Log + + + Crear KML + + + Convertir a Texto + + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs b/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs index 3a28cbf8cf3..65f82186b92 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.37")] +[assembly: AssemblyFileVersion("1.1.38")] [assembly: NeutralResourcesLanguageAttribute("")] diff --git a/Tools/ArdupilotMegaPlanner/HUD.resx b/Tools/ArdupilotMegaPlanner/RAW_Sensor.es-ES.resx similarity index 71% rename from Tools/ArdupilotMegaPlanner/HUD.resx rename to Tools/ArdupilotMegaPlanner/RAW_Sensor.es-ES.resx index bef221098e4..31f1917097a 100644 --- a/Tools/ArdupilotMegaPlanner/HUD.resx +++ b/Tools/ArdupilotMegaPlanner/RAW_Sensor.es-ES.resx @@ -1,174 +1,165 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - Fill - - - - 0, 0 - - - 300, 225 - - - - 0 - - - glControl1 - - - OpenTK.GLControl, OpenTK.GLControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4 - - - $this - - - 0 - - - True - - - 300, 225 - - - HUD - - - System.Windows.Forms.MyUserControl, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ff91852278f5092c - - - Bat - - - GPS: 3D Fix - - - GPS: 3D Fix - - - GPS: No Fix - - - GPS: No GPS - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Sensor Raw + + + Sensor RAW + + + Actualiza Velocidad + + + Salida Servo/Motor + + + Nota: Hay un retardo de cuando se ve a través de Xbee @ 50Hz + + + Entrada Radio + + + Accel X + + + Accel Z + + + Accel Y + + + Radio + + + Datos de Vuelo + + + Guardar CSV + + + Gyro Z + + + Gyro X + + + Gyro Y + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/Resources/Welcome_to_Michael_Oborne.rtf b/Tools/ArdupilotMegaPlanner/Resources/Welcome_to_Michael_Oborne.rtf index c537652c1f3..e465a9a5f9e 100644 Binary files a/Tools/ArdupilotMegaPlanner/Resources/Welcome_to_Michael_Oborne.rtf and b/Tools/ArdupilotMegaPlanner/Resources/Welcome_to_Michael_Oborne.rtf differ diff --git a/Tools/ArdupilotMegaPlanner/SerialInput.es-ES.resx b/Tools/ArdupilotMegaPlanner/SerialInput.es-ES.resx new file mode 100644 index 00000000000..4d14dfe4ecc --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/SerialInput.es-ES.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Lo que esto hace. 1. se las actuales coordenadas GPS de un GPS NMEA. 2. envía un WP modo guiado a la AP cada 2 segundos. Como Usar 1. conectar con la AP. 2. el despegue, el modo de prueba guiada está trabajando. 3. abrir este y escoja su puerto com, y la velocidad de su NMEA GPS. 4. ahora debe estar siguiéndote. + + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/Setup/Setup.es-ES.resx b/Tools/ArdupilotMegaPlanner/Setup/Setup.es-ES.resx new file mode 100644 index 00000000000..70ad73f1af8 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/Setup/Setup.es-ES.resx @@ -0,0 +1,315 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 180 + + + Manual + + + PWM 0 - 1230 + + + PWM 1621 - 1749 + + + Modo actual: + + + Habilitar el flujo óptico + + + NOTA: Las imágenes son sólo para su presentación + + + Modo Simple + + + PWM 1750 + + + + Elevons CH1 Rev + + + PWM Actual: + + + APMSetup + + + Swash-Servo posición + + + Activar Compas + + + Modo Simple + + + ArduCopter2 + + + Modo Simple + + + Ajuste Chásis (+ or x) + + + 60 + + + 1 + + + Modo Simple + + + Modo Simple + + + 2 + + + Modos + + + Modo Simple + + + 3 + + + Reset + + + -60 + + + Superior + + + Swash de Viaje + + + Manual + + + Timón de Viaje + + + Calibración del sensor de voltaje:Para calibrar el sensor, use un multímetro para medir la tensión que sale de la CES de la batería-la eliminación del circuito (se trata de cables negro y rojo en el cable de tres hilos que suministra energía a la placa APM).Luego reste 0,3 V de ese valor y entrar en él en el campo # 1 a la izquierda. + + + Calibrar Radio + + + Max + + + Modo de Vuelo 2 + + + Alabeo Max + + + Modo de Vuelo 3 + + + Cabeceo Max + + + por ejemplo, en grados 2 ° 3 'W es -2,3 + + + Modo de Vuelo 1 + + + Nivel tu quad para establecer las compensaciones por defecto acel + + + Modo de Vuelo 6 + + + Capacidad + + + Declinación + + + Activar Sonar + + + PWM 1231 - 1360 + + + Entrada Radio + + + Calibración + + + 1500 + + + Modo de Vuelo 4 + + + Modo de Vuelo 5 + + + Gyro + + + PWM 1361 - 1490 + + + Hardware + + + PWM 1491 - 1620 + + + Sitio Web Declinación + + + 1500 + + + Batería + + + Cero + + + Activar Airspeed + + + 4500 + + + Restablecer los Ajustes de hardware APM + + + 1000 + + + Monitor + + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/bin/Release/ArdupilotMegaPlanner.pdb b/Tools/ArdupilotMegaPlanner/bin/Release/ArdupilotMegaPlanner.pdb index 11b35bd52b6..9be6fd68a9f 100644 Binary files a/Tools/ArdupilotMegaPlanner/bin/Release/ArdupilotMegaPlanner.pdb and b/Tools/ArdupilotMegaPlanner/bin/Release/ArdupilotMegaPlanner.pdb differ diff --git a/Tools/ArdupilotMegaPlanner/bin/Release/Resources/Welcome_to_Michael_Oborne.rtf b/Tools/ArdupilotMegaPlanner/bin/Release/Resources/Welcome_to_Michael_Oborne.rtf index c537652c1f3..e465a9a5f9e 100644 Binary files a/Tools/ArdupilotMegaPlanner/bin/Release/Resources/Welcome_to_Michael_Oborne.rtf and b/Tools/ArdupilotMegaPlanner/bin/Release/Resources/Welcome_to_Michael_Oborne.rtf differ diff --git a/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/Models/Untitled.ac b/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/Models/Untitled.ac new file mode 100644 index 00000000000..5b9e7ed5b7d --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/Models/Untitled.ac @@ -0,0 +1,1094 @@ +AC3Db +MATERIAL "default" rgb 0.72 0.72 0.72 amb 0.8 0.8 0.8 emis 0.08 0.08 0.08 spec 0.2 0.2 0.2 shi 128 trans 0 +MATERIAL "material.006"1"1" rgb 0.0000 0.0000 0.0000 amb 0.0000 0.0000 0.0000 emis 0.0000 0.0000 0.0000 spec 0.2 0.2 0.2 shi 128 trans 0.0000 +OBJECT world +kids 1 +OBJECT poly +name "blah" +numvert 88 +0.008832 0.001373 -0.000873 +0.008506 0.000990 -0.000881 +0.009033 0.001338 -0.000893 +0.008326 0.001009 -0.000823 +0.007376 -0.000207 -0.000850 +0.007229 -0.000460 -0.000812 +0.007268 -0.000476 -0.000806 +0.007489 -0.000258 -0.000838 +0.007554 0.000049 -0.000887 +0.009654 0.002468 -0.000833 +0.009255 0.001925 -0.000848 +0.009734 0.002440 -0.000831 +0.009103 0.001954 -0.000835 +0.009555 0.002483 -0.000837 +0.008591 0.001436 -0.000825 +0.008638 0.001416 -0.000829 +0.009076 0.001982 -0.000840 +0.009396 0.001900 -0.000860 +0.005825 -0.001719 -0.000888 +0.005965 -0.001746 -0.000876 +0.005486 -0.002262 -0.000867 +0.006389 -0.001191 -0.000892 +0.006188 -0.001154 -0.000911 +0.009024 0.001954 -0.000833 +0.009502 0.002462 -0.000841 +0.008560 0.001453 -0.000824 +0.008093 0.000346 -0.000945 +0.007752 0.000090 -0.000908 +0.007754 0.000168 -0.000919 +0.008097 0.000505 -0.000954 +0.008326 0.000640 -0.000974 +0.007883 0.000406 -0.000928 +0.006630 -0.001281 -0.000850 +0.006117 -0.001776 -0.000863 +0.006144 -0.001803 -0.000868 +0.006660 -0.001276 -0.000843 +0.006197 -0.001776 -0.000860 +0.007844 0.000385 -0.000848 +0.007963 0.000343 -0.000869 +0.007663 0.000128 -0.000889 +0.007952 0.000649 -0.000800 +0.007991 0.000634 -0.000806 +0.007731 0.000435 -0.000835 +0.007128 -0.000157 -0.000946 +0.006895 -0.000448 -0.000980 +0.007044 -0.000422 -0.000905 +0.008263 0.001060 -0.000809 +0.008280 0.001025 -0.000814 +0.008638 0.001456 -0.000843 +0.008486 0.001037 -0.000911 +0.008683 0.000994 -0.000933 +0.005665 -0.002304 -0.000873 +0.005718 -0.002283 -0.000876 +0.006714 -0.000807 -0.000893 +0.006894 -0.000833 -0.000835 +0.006735 -0.000851 -0.000924 +0.006934 -0.000873 -0.000832 +0.006582 -0.001277 -0.000862 +0.007030 -0.000596 -0.000896 +0.007305 -0.000350 -0.000868 +0.006583 -0.001239 -0.000848 +0.007180 -0.000444 -0.000827 +0.006957 -0.000886 -0.000822 +0.005693 -0.002293 -0.000875 +0.006097 -0.001829 -0.000868 +0.007124 -0.000315 -0.000958 +0.007515 -0.000219 -0.000874 +0.007519 -0.000149 -0.000909 +0.007338 -0.000219 -0.000930 +0.006538 -0.000807 -0.000946 +0.009124 0.002008 -0.000839 +0.009527 0.002472 -0.000839 +0.007257 -0.000163 -0.000871 +0.007466 0.000089 -0.000906 +0.008176 0.000606 -0.000900 +0.008040 0.000619 -0.000821 +0.008191 0.000779 -0.000888 +0.007915 0.000530 -0.000864 +0.007328 -0.000058 -0.000926 +0.007560 0.000012 -0.000898 +0.007520 -0.000273 -0.000840 +0.007581 0.000176 -0.000871 +0.007657 0.000166 -0.000898 +0.007636 0.000000 -0.000871 +0.005566 -0.002290 -0.000869 +0.007705 0.000400 -0.000873 +0.007656 0.000213 -0.000903 +0.007701 0.000450 -0.000838 +numsurf 166 +SURF 0x30 +mat 1 +refs 3 +0 0 0 +1 0 0 +2 0 0 +SURF 0x30 +mat 1 +refs 3 +0 0 0 +3 0 0 +1 0 0 +SURF 0x30 +mat 1 +refs 3 +4 0 0 +5 0 0 +6 0 0 +SURF 0x30 +mat 1 +refs 3 +4 0 0 +6 0 0 +7 0 0 +SURF 0x30 +mat 1 +refs 3 +8 0 0 +4 0 0 +7 0 0 +SURF 0x30 +mat 1 +refs 3 +9 0 0 +10 0 0 +11 0 0 +SURF 0x30 +mat 1 +refs 3 +9 0 0 +12 0 0 +10 0 0 +SURF 0x30 +mat 1 +refs 3 +13 0 0 +12 0 0 +9 0 0 +SURF 0x30 +mat 1 +refs 3 +12 0 0 +14 0 0 +15 0 0 +SURF 0x30 +mat 1 +refs 3 +16 0 0 +14 0 0 +12 0 0 +SURF 0x30 +mat 1 +refs 3 +10 0 0 +0 0 0 +17 0 0 +SURF 0x30 +mat 1 +refs 3 +10 0 0 +15 0 0 +0 0 0 +SURF 0x30 +mat 1 +refs 3 +18 0 0 +19 0 0 +20 0 0 +SURF 0x30 +mat 1 +refs 3 +21 0 0 +19 0 0 +18 0 0 +SURF 0x30 +mat 1 +refs 3 +22 0 0 +21 0 0 +18 0 0 +SURF 0x30 +mat 1 +refs 3 +16 0 0 +14 0 0 +23 0 0 +SURF 0x30 +mat 1 +refs 3 +24 0 0 +16 0 0 +23 0 0 +SURF 0x30 +mat 1 +refs 3 +23 0 0 +14 0 0 +25 0 0 +SURF 0x30 +mat 1 +refs 3 +26 0 0 +27 0 0 +28 0 0 +SURF 0x30 +mat 1 +refs 3 +29 0 0 +26 0 0 +28 0 0 +SURF 0x30 +mat 1 +refs 3 +30 0 0 +26 0 0 +29 0 0 +SURF 0x30 +mat 1 +refs 3 +29 0 0 +28 0 0 +31 0 0 +SURF 0x30 +mat 1 +refs 3 +32 0 0 +33 0 0 +34 0 0 +SURF 0x30 +mat 1 +refs 3 +35 0 0 +32 0 0 +34 0 0 +SURF 0x30 +mat 1 +refs 3 +35 0 0 +34 0 0 +36 0 0 +SURF 0x30 +mat 1 +refs 3 +37 0 0 +27 0 0 +38 0 0 +SURF 0x30 +mat 1 +refs 3 +37 0 0 +39 0 0 +27 0 0 +SURF 0x30 +mat 1 +refs 3 +40 0 0 +37 0 0 +41 0 0 +SURF 0x30 +mat 1 +refs 3 +40 0 0 +42 0 0 +37 0 0 +SURF 0x30 +mat 1 +refs 3 +42 0 0 +39 0 0 +37 0 0 +SURF 0x30 +mat 1 +refs 3 +43 0 0 +44 0 0 +45 0 0 +SURF 0x30 +mat 1 +refs 3 +46 0 0 +47 0 0 +40 0 0 +SURF 0x30 +mat 1 +refs 3 +14 0 0 +47 0 0 +46 0 0 +SURF 0x30 +mat 1 +refs 3 +48 0 0 +47 0 0 +14 0 0 +SURF 0x30 +mat 1 +refs 3 +49 0 0 +50 0 0 +30 0 0 +SURF 0x30 +mat 1 +refs 3 +0 0 0 +50 0 0 +49 0 0 +SURF 0x30 +mat 1 +refs 3 +0 0 0 +2 0 0 +50 0 0 +SURF 0x30 +mat 1 +refs 3 +33 0 0 +51 0 0 +34 0 0 +SURF 0x30 +mat 1 +refs 3 +36 0 0 +34 0 0 +51 0 0 +SURF 0x30 +mat 1 +refs 3 +36 0 0 +51 0 0 +52 0 0 +SURF 0x30 +mat 1 +refs 3 +53 0 0 +22 0 0 +21 0 0 +SURF 0x30 +mat 1 +refs 3 +53 0 0 +21 0 0 +54 0 0 +SURF 0x30 +mat 1 +refs 3 +55 0 0 +56 0 0 +57 0 0 +SURF 0x30 +mat 1 +refs 3 +58 0 0 +56 0 0 +55 0 0 +SURF 0x30 +mat 1 +refs 3 +6 0 0 +56 0 0 +58 0 0 +SURF 0x30 +mat 1 +refs 3 +59 0 0 +6 0 0 +58 0 0 +SURF 0x30 +mat 1 +refs 3 +44 0 0 +58 0 0 +55 0 0 +SURF 0x30 +mat 1 +refs 3 +54 0 0 +21 0 0 +60 0 0 +SURF 0x30 +mat 1 +refs 3 +61 0 0 +54 0 0 +5 0 0 +SURF 0x30 +mat 1 +refs 3 +5 0 0 +54 0 0 +56 0 0 +SURF 0x30 +mat 1 +refs 3 +5 0 0 +56 0 0 +6 0 0 +SURF 0x30 +mat 1 +refs 3 +6 0 0 +56 0 0 +62 0 0 +SURF 0x30 +mat 1 +refs 3 +54 0 0 +60 0 0 +56 0 0 +SURF 0x30 +mat 1 +refs 3 +25 0 0 +46 0 0 +14 0 0 +SURF 0x30 +mat 1 +refs 3 +17 0 0 +0 0 0 +2 0 0 +SURF 0x30 +mat 1 +refs 3 +34 0 0 +63 0 0 +64 0 0 +SURF 0x30 +mat 1 +refs 3 +65 0 0 +58 0 0 +44 0 0 +SURF 0x30 +mat 1 +refs 3 +66 0 0 +6 0 0 +59 0 0 +SURF 0x30 +mat 1 +refs 3 +67 0 0 +66 0 0 +59 0 0 +SURF 0x30 +mat 1 +refs 3 +67 0 0 +59 0 0 +68 0 0 +SURF 0x30 +mat 1 +refs 3 +45 0 0 +44 0 0 +69 0 0 +SURF 0x30 +mat 1 +refs 3 +45 0 0 +69 0 0 +53 0 0 +SURF 0x30 +mat 1 +refs 3 +45 0 0 +53 0 0 +61 0 0 +SURF 0x30 +mat 1 +refs 3 +61 0 0 +53 0 0 +54 0 0 +SURF 0x30 +mat 1 +refs 3 +69 0 0 +22 0 0 +53 0 0 +SURF 0x30 +mat 1 +refs 3 +44 0 0 +55 0 0 +69 0 0 +SURF 0x30 +mat 1 +refs 3 +69 0 0 +55 0 0 +21 0 0 +SURF 0x30 +mat 1 +refs 3 +13 0 0 +23 0 0 +16 0 0 +SURF 0x30 +mat 1 +refs 3 +13 0 0 +24 0 0 +23 0 0 +SURF 0x30 +mat 1 +refs 3 +13 0 0 +9 0 0 +70 0 0 +SURF 0x30 +mat 1 +refs 3 +70 0 0 +48 0 0 +16 0 0 +SURF 0x30 +mat 1 +refs 3 +71 0 0 +70 0 0 +16 0 0 +SURF 0x30 +mat 1 +refs 3 +48 0 0 +49 0 0 +47 0 0 +SURF 0x30 +mat 1 +refs 3 +65 0 0 +59 0 0 +58 0 0 +SURF 0x30 +mat 1 +refs 3 +68 0 0 +59 0 0 +65 0 0 +SURF 0x30 +mat 1 +refs 3 +72 0 0 +61 0 0 +5 0 0 +SURF 0x30 +mat 1 +refs 3 +72 0 0 +5 0 0 +4 0 0 +SURF 0x30 +mat 1 +refs 3 +73 0 0 +72 0 0 +4 0 0 +SURF 0x30 +mat 1 +refs 3 +73 0 0 +4 0 0 +8 0 0 +SURF 0x30 +mat 1 +refs 3 +73 0 0 +43 0 0 +72 0 0 +SURF 0x30 +mat 1 +refs 3 +43 0 0 +45 0 0 +72 0 0 +SURF 0x30 +mat 1 +refs 3 +72 0 0 +45 0 0 +61 0 0 +SURF 0x30 +mat 1 +refs 3 +74 0 0 +38 0 0 +26 0 0 +SURF 0x30 +mat 1 +refs 3 +75 0 0 +38 0 0 +74 0 0 +SURF 0x30 +mat 1 +refs 3 +30 0 0 +74 0 0 +26 0 0 +SURF 0x30 +mat 1 +refs 3 +49 0 0 +76 0 0 +47 0 0 +SURF 0x30 +mat 1 +refs 3 +47 0 0 +76 0 0 +40 0 0 +SURF 0x30 +mat 1 +refs 3 +76 0 0 +77 0 0 +40 0 0 +SURF 0x30 +mat 1 +refs 3 +49 0 0 +30 0 0 +76 0 0 +SURF 0x30 +mat 1 +refs 3 +76 0 0 +30 0 0 +29 0 0 +SURF 0x30 +mat 1 +refs 3 +76 0 0 +29 0 0 +77 0 0 +SURF 0x30 +mat 1 +refs 3 +73 0 0 +78 0 0 +43 0 0 +SURF 0x30 +mat 1 +refs 3 +78 0 0 +65 0 0 +43 0 0 +SURF 0x30 +mat 1 +refs 3 +43 0 0 +65 0 0 +44 0 0 +SURF 0x30 +mat 1 +refs 3 +78 0 0 +68 0 0 +65 0 0 +SURF 0x30 +mat 1 +refs 3 +11 0 0 +17 0 0 +10 0 0 +SURF 0x30 +mat 1 +refs 3 +10 0 0 +17 0 0 +0 0 0 +SURF 0x30 +mat 1 +refs 3 +17 0 0 +2 0 0 +0 0 0 +SURF 0x30 +mat 1 +refs 3 +79 0 0 +67 0 0 +68 0 0 +SURF 0x30 +mat 1 +refs 3 +79 0 0 +68 0 0 +78 0 0 +SURF 0x30 +mat 1 +refs 3 +73 0 0 +8 0 0 +78 0 0 +SURF 0x30 +mat 1 +refs 3 +66 0 0 +80 0 0 +6 0 0 +SURF 0x30 +mat 1 +refs 3 +56 0 0 +60 0 0 +32 0 0 +SURF 0x30 +mat 1 +refs 3 +56 0 0 +32 0 0 +62 0 0 +SURF 0x30 +mat 1 +refs 3 +62 0 0 +32 0 0 +35 0 0 +SURF 0x30 +mat 1 +refs 3 +56 0 0 +62 0 0 +32 0 0 +SURF 0x30 +mat 1 +refs 3 +56 0 0 +32 0 0 +57 0 0 +SURF 0x30 +mat 1 +refs 3 +42 0 0 +81 0 0 +39 0 0 +SURF 0x30 +mat 1 +refs 3 +31 0 0 +28 0 0 +82 0 0 +SURF 0x30 +mat 1 +refs 3 +9 0 0 +10 0 0 +70 0 0 +SURF 0x30 +mat 1 +refs 3 +70 0 0 +10 0 0 +48 0 0 +SURF 0x30 +mat 1 +refs 3 +10 0 0 +0 0 0 +48 0 0 +SURF 0x30 +mat 1 +refs 3 +9 0 0 +11 0 0 +10 0 0 +SURF 0x30 +mat 1 +refs 3 +8 0 0 +7 0 0 +83 0 0 +SURF 0x30 +mat 1 +refs 3 +79 0 0 +83 0 0 +67 0 0 +SURF 0x30 +mat 1 +refs 3 +15 0 0 +3 0 0 +0 0 0 +SURF 0x30 +mat 1 +refs 3 +3 0 0 +41 0 0 +75 0 0 +SURF 0x30 +mat 1 +refs 3 +47 0 0 +41 0 0 +3 0 0 +SURF 0x30 +mat 1 +refs 3 +47 0 0 +40 0 0 +41 0 0 +SURF 0x30 +mat 1 +refs 3 +46 0 0 +40 0 0 +47 0 0 +SURF 0x30 +mat 1 +refs 3 +15 0 0 +47 0 0 +3 0 0 +SURF 0x30 +mat 1 +refs 3 +14 0 0 +47 0 0 +15 0 0 +SURF 0x30 +mat 1 +refs 3 +14 0 0 +46 0 0 +47 0 0 +SURF 0x30 +mat 1 +refs 3 +16 0 0 +25 0 0 +14 0 0 +SURF 0x30 +mat 1 +refs 3 +16 0 0 +23 0 0 +25 0 0 +SURF 0x30 +mat 1 +refs 3 +13 0 0 +16 0 0 +12 0 0 +SURF 0x30 +mat 1 +refs 3 +26 0 0 +38 0 0 +27 0 0 +SURF 0x30 +mat 1 +refs 3 +64 0 0 +51 0 0 +84 0 0 +SURF 0x30 +mat 1 +refs 3 +19 0 0 +64 0 0 +84 0 0 +SURF 0x30 +mat 1 +refs 3 +57 0 0 +64 0 0 +19 0 0 +SURF 0x30 +mat 1 +refs 3 +21 0 0 +57 0 0 +19 0 0 +SURF 0x30 +mat 1 +refs 3 +19 0 0 +84 0 0 +20 0 0 +SURF 0x30 +mat 1 +refs 3 +77 0 0 +29 0 0 +31 0 0 +SURF 0x30 +mat 1 +refs 3 +41 0 0 +38 0 0 +75 0 0 +SURF 0x30 +mat 1 +refs 3 +41 0 0 +37 0 0 +38 0 0 +SURF 0x30 +mat 1 +refs 3 +32 0 0 +36 0 0 +34 0 0 +SURF 0x30 +mat 1 +refs 3 +36 0 0 +52 0 0 +34 0 0 +SURF 0x30 +mat 1 +refs 3 +22 0 0 +18 0 0 +21 0 0 +SURF 0x30 +mat 1 +refs 3 +21 0 0 +18 0 0 +19 0 0 +SURF 0x30 +mat 1 +refs 3 +21 0 0 +19 0 0 +60 0 0 +SURF 0x30 +mat 1 +refs 3 +60 0 0 +19 0 0 +33 0 0 +SURF 0x30 +mat 1 +refs 3 +18 0 0 +20 0 0 +19 0 0 +SURF 0x30 +mat 1 +refs 3 +69 0 0 +21 0 0 +22 0 0 +SURF 0x30 +mat 1 +refs 3 +55 0 0 +57 0 0 +21 0 0 +SURF 0x30 +mat 1 +refs 3 +57 0 0 +32 0 0 +34 0 0 +SURF 0x30 +mat 1 +refs 3 +48 0 0 +0 0 0 +49 0 0 +SURF 0x30 +mat 1 +refs 3 +16 0 0 +48 0 0 +14 0 0 +SURF 0x30 +mat 1 +refs 3 +6 0 0 +62 0 0 +56 0 0 +SURF 0x30 +mat 1 +refs 3 +19 0 0 +20 0 0 +84 0 0 +SURF 0x30 +mat 1 +refs 3 +19 0 0 +84 0 0 +33 0 0 +SURF 0x30 +mat 1 +refs 3 +33 0 0 +84 0 0 +51 0 0 +SURF 0x30 +mat 1 +refs 3 +60 0 0 +33 0 0 +32 0 0 +SURF 0x30 +mat 1 +refs 3 +12 0 0 +15 0 0 +10 0 0 +SURF 0x30 +mat 1 +refs 3 +11 0 0 +10 0 0 +17 0 0 +SURF 0x30 +mat 1 +refs 3 +85 0 0 +86 0 0 +81 0 0 +SURF 0x30 +mat 1 +refs 3 +40 0 0 +85 0 0 +87 0 0 +SURF 0x30 +mat 1 +refs 3 +40 0 0 +77 0 0 +85 0 0 +SURF 0x30 +mat 1 +refs 3 +77 0 0 +86 0 0 +85 0 0 +SURF 0x30 +mat 1 +refs 3 +77 0 0 +31 0 0 +86 0 0 +SURF 0x30 +mat 1 +refs 3 +50 0 0 +74 0 0 +30 0 0 +SURF 0x30 +mat 1 +refs 3 +50 0 0 +1 0 0 +74 0 0 +SURF 0x30 +mat 1 +refs 3 +35 0 0 +36 0 0 +32 0 0 +SURF 0x30 +mat 1 +refs 3 +57 0 0 +34 0 0 +64 0 0 +SURF 0x30 +mat 1 +refs 3 +1 0 0 +75 0 0 +74 0 0 +SURF 0x30 +mat 1 +refs 3 +3 0 0 +75 0 0 +1 0 0 +SURF 0x30 +mat 1 +refs 3 +2 0 0 +1 0 0 +50 0 0 +kids 0 diff --git a/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/Models/plus_quad2.xml b/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/Models/plus_quad2.xml new file mode 100644 index 00000000000..d4bc4629ef2 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/Models/plus_quad2.xml @@ -0,0 +1,88 @@ + + + + plus_quad2.ac + + 0.0 + 0 + 0.0 + 0 + 180 + + + + noshadow + prop0 + + + spin + prop0 + /controls/engines/engine[0]/throttle + 12000 + + 0.000 + -0.288 + 0.046 + 0.000 + -0.288 + 0.012 + + + + + noshadow + prop1 + + + spin + prop1 + /controls/engines/engine[1]/throttle + 12000 + + 0.000 + 0.288 + 0.046 + 0.000 + 0.288 + 0.012 + + + + + noshadow + prop2 + + + spin + prop2 + /controls/engines/engine[2]/throttle + 12000 + + 0.288 + 0.000 + 0.046 + 0.288 + 0.000 + 0.012 + + + + + noshadow + prop3 + + + spin + prop3 + /controls/engines/engine[3]/throttle + 12000 + + -0.288 + 0.000 + 0.046 + -0.288 + 0.000 + 0.012 + + + diff --git a/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/Models/quad.3ds b/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/Models/quad.3ds new file mode 100644 index 00000000000..2f1e6be165c Binary files /dev/null and b/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/Models/quad.3ds differ diff --git a/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/Models/shareware_output.3ds b/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/Models/shareware_output.3ds new file mode 100644 index 00000000000..f736f7b19db Binary files /dev/null and b/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/Models/shareware_output.3ds differ diff --git a/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/quad.nas b/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/quad.nas new file mode 100644 index 00000000000..016629be1ad --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/bin/Release/aircraft/arducopter/quad.nas @@ -0,0 +1,40 @@ +round10 = func(v) { + if (v == nil) return 0; + return 0.1*int(v*10); +} + +round100 = func(v) { + if (v == nil) return 0; + return 0.01*int(v*100); +} + +var update_quad = func( ) { + asl_ft = getprop("/position/altitude-ft"); + ground = getprop("/position/ground-elev-ft"); + agl_m = (asl_ft - ground) * 0.3048; + + setprop("/apm/altitude", round10(agl_m)); + + setprop("/apm/pitch", round10(getprop("/orientation/pitch-deg"))); + setprop("/apm/roll", round10(getprop("/orientation/roll-deg"))); + setprop("/apm/heading", round10(getprop("/orientation/heading-deg"))); + + # airspeed-kt is actually in feet per second (FDM NET bug) + setprop("/apm/airspeed", round10(0.3048*getprop("/velocities/airspeed-kt"))); + + setprop("/apm/motor_right", round10(getprop("/engines/engine[0]/rpm")/10.0)); + setprop("/apm/motor_left", round10(getprop("/engines/engine[1]/rpm")/10.0)); + setprop("/apm/motor_front", round10(getprop("/engines/engine[2]/rpm")/10.0)); + setprop("/apm/motor_back", round10(getprop("/engines/engine[3]/rpm")/10.0)); +} + +var main_loop = func { + update_quad(); + settimer(main_loop, 0); +} + + +setlistener("/sim/signals/fdm-initialized", + func { + main_loop(); + }); diff --git a/Tools/ArdupilotMegaPlanner/defines.h b/Tools/ArdupilotMegaPlanner/defines.h deleted file mode 100644 index 74760c243c6..00000000000 --- a/Tools/ArdupilotMegaPlanner/defines.h +++ /dev/null @@ -1,346 +0,0 @@ -// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*- - -// Internal defines, don't edit and expect things to work -// ------------------------------------------------------- - -#define DEBUG 0 -#define LOITER_RANGE 30 // for calculating power outside of loiter radius - -// GPS baud rates -// -------------- -#define NO_GPS 38400 -#define NMEA_GPS 38400 -#define EM406_GPS 57600 -#define UBLOX_GPS 38400 -#define ARDU_IMU 38400 -#define MTK_GPS 38400 -#define SIM_GPS 38400 - -// GPS type codes - use the names, not the numbers -#define GPS_PROTOCOL_NONE -1 -#define GPS_PROTOCOL_NMEA 0 -#define GPS_PROTOCOL_SIRF 1 -#define GPS_PROTOCOL_UBLOX 2 -#define GPS_PROTOCOL_IMU 3 -#define GPS_PROTOCOL_MTK 4 - -// Radio channels -// Note channels are from 0! -// -// XXX these should be CH_n defines from RC.h at some point. -#define CH_ROLL 0 -#define CH_PITCH 1 -#define CH_THROTTLE 2 -#define CH_RUDDER 3 -#define CH_1 0 -#define CH_2 1 -#define CH_3 2 -#define CH_4 3 -#define CH_5 4 -#define CH_6 5 -#define CH_7 6 -#define CH_8 7 - -#define WP_START_BYTE 0x130 // where in memory home WP is stored + all other WP -#define WP_SIZE 14 - -// GCS enumeration -#define GCS_PROTOCOL_STANDARD 0 // standard APM protocol -#define GCS_PROTOCOL_SPECIAL 1 // special test protocol (?) -#define GCS_PROTOCOL_LEGACY 2 // legacy ArduPilot protocol -#define GCS_PROTOCOL_XPLANE 3 // X-Plane HIL simulation -#define GCS_PROTOCOL_IMU 4 // ArdiPilot IMU output -#define GCS_PROTOCOL_JASON 5 // Jason's special secret GCS protocol -#define GCS_PROTOCOL_DEBUGTERMINAL 6 // Text-based interactive GCS -#define GCS_PROTOCOL_NONE -1 // No GCS output - -// PID enumeration -// --------------- -#define CASE_SERVO_ROLL 0 -#define CASE_SERVO_PITCH 1 -#define CASE_SERVO_RUDDER 2 -#define CASE_NAV_ROLL 3 -#define CASE_NAV_PITCH_ASP 4 -#define CASE_NAV_PITCH_ALT 5 -#define CASE_TE_THROTTLE 6 -#define CASE_ALT_THROTTLE 7 - -// Feedforward cases -// ---------------- -#define CASE_PITCH_COMP 0 -#define CASE_RUDDER_MIX 1 -#define CASE_P_TO_T 2 -#define CASE_T_TO_P 3 - -// Auto Pilot modes -// ---------------- -#define MANUAL 0 -#define CIRCLE 1 // When flying sans GPS, and we loose the radio, just circle -#define STABILIZE 2 - -#define FLY_BY_WIRE_A 5 // Fly By Wire A has left stick horizontal => desired roll angle, left stick vertical => desired pitch angle, right stick vertical = manual throttle -#define FLY_BY_WIRE_B 6 // Fly By Wire B has left stick horizontal => desired roll angle, left stick vertical => desired pitch angle, right stick vertical => desired airspeed - // Fly By Wire B = Fly By Wire A if you have AIRSPEED_SENSOR 0 -#define AUTO 10 -#define RTL 11 -#define LOITER 12 -#define TAKEOFF 13 -#define LAND 14 - - -// Command IDs - Must -#define CMD_BLANK 0x00 // there is no command stored in the mem location requested -#define CMD_WAYPOINT 0x10 -#define CMD_LOITER 0x11 -#define CMD_LOITER_N_TURNS 0x12 -#define CMD_LOITER_TIME 0x13 -#define CMD_RTL 0x14 -#define CMD_LAND 0x15 -#define CMD_TAKEOFF 0x16 - -// Command IDs - May -#define CMD_DELAY 0x20 -#define CMD_CLIMB 0x21 // NOT IMPLEMENTED -#define CMD_LAND_OPTIONS 0x22 // pitch in deg, airspeed m/s, throttle %, track WP 1 or 0 - -// Command IDs - Now -//#define CMD_AP_MODE 0x30 -#define CMD_RESET_INDEX 0x31 -#define CMD_GOTO_INDEX 0x32 // NOT IMPLEMENTED -#define CMD_GETVAR_INDEX 0x33 -#define CMD_SENDVAR_INDEX 0x34 -#define CMD_TELEMETRY 0x35 - -#define CMD_THROTTLE_CRUISE 0x40 -#define CMD_AIRSPEED_CRUISE 0x41 -#define CMD_RESET_HOME 0x44 - -#define CMD_KP_GAIN 0x60 -#define CMD_KI_GAIN 0x61 -#define CMD_KD_GAIN 0x62 -#define CMD_KI_MAX 0x63 -#define CMD_KFF_GAIN 0x64 - -#define CMD_RADIO_TRIM 0x70 -#define CMD_RADIO_MAX 0x71 -#define CMD_RADIO_MIN 0x72 -#define CMD_RADIO_MIN 0x72 -#define CMD_ELEVON_TRIM 0x73 - -#define CMD_INDEX 0x75 // sets the current Must index -#define CMD_REPEAT 0x80 -#define CMD_RELAY 0x81 -#define CMD_SERVO 0x82 // move servo N to PWM value - -//repeating events -#define NO_REPEAT 0 -#define CH_4_TOGGLE 1 -#define CH_5_TOGGLE 2 -#define CH_6_TOGGLE 3 -#define CH_7_TOGGLE 4 -#define RELAY_TOGGLE 5 -#define STOP_REPEAT 10 - -// GCS Message ID's -#define MSG_ACKNOWLEDGE 0x00 -#define MSG_HEARTBEAT 0x01 -#define MSG_ATTITUDE 0x02 -#define MSG_LOCATION 0x03 -#define MSG_PRESSURE 0x04 -#define MSG_STATUS_TEXT 0x05 -#define MSG_PERF_REPORT 0x06 -#define MSG_COMMAND 0x22 -#define MSG_VALUE 0x32 -#define MSG_PID 0x42 -#define MSG_TRIMS 0x50 -#define MSG_MINS 0x51 -#define MSG_MAXS 0x52 -#define MSG_IMU_OUT 0x53 - -#define SEVERITY_LOW 1 -#define SEVERITY_MEDIUM 2 -#define SEVERITY_HIGH 3 -#define SEVERITY_CRITICAL 4 - -// Logging parameters -#define LOG_ATTITUDE_MSG 0x01 -#define LOG_GPS_MSG 0x02 -#define LOG_MODE_MSG 0X03 -#define LOG_CONTROL_TUNING_MSG 0X04 -#define LOG_NAV_TUNING_MSG 0X05 -#define LOG_PERFORMANCE_MSG 0X06 -#define LOG_RAW_MSG 0x07 -#define LOG_CMD_MSG 0x08 -#define LOG_STARTUP_MSG 0x09 -#define TYPE_AIRSTART_MSG 0x00 -#define TYPE_GROUNDSTART_MSG 0x01 - -#define MASK_LOG_ATTITUDE_FAST 0 -#define MASK_LOG_ATTITUDE_MED 2 -#define MASK_LOG_GPS 4 -#define MASK_LOG_PM 8 -#define MASK_LOG_CTUN 16 -#define MASK_LOG_NTUN 32 -#define MASK_LOG_MODE 64 -#define MASK_LOG_RAW 128 -#define MASK_LOG_CMD 256 - -// Yaw modes -#define YAW_MODE_COORDINATE_TURNS 0 -#define YAW_MODE_HOLD_HEADING 1 -#define YAW_MODE_SLIP 2 - -// Waypoint Modes -// ---------------- -#define ABS_WP 0 -#define REL_WP 1 - -// Command Queues -// --------------- -#define COMMAND_MUST 0 -#define COMMAND_MAY 1 -#define COMMAND_NOW 2 - -// Events -// ------ -#define EVENT_WILL_REACH_WAYPOINT 1 -#define EVENT_SET_NEW_WAYPOINT_INDEX 2 -#define EVENT_LOADED_WAYPOINT 3 -#define EVENT_LOOP 4 - -//GPS_fix -#define VALID_GPS 0x00 -#define BAD_GPS 0x01 -#define FAILED_GPS 0x03 - - - -#define BATTERY_VOLTAGE(x) (x*(INPUT_VOLTAGE/1024.0))*VOLT_DIV_RATIO - -#define AIRSPEED_CH 7 // The external ADC channel for the airspeed sensor -#define BATTERY_PIN1 0 // These are the pins for the voltage dividers -#define BATTERY_PIN2 1 -#define BATTERY_PIN3 2 -#define BATTERY_PIN4 3 -#define RELAY_PIN 47 - -// Hardware Parameters -#define SLIDE_SWITCH_PIN 40 -#define PUSHBUTTON_PIN 41 - -#define A_LED_PIN 37 //36 = B, 37 = A, 35 = C -#define B_LED_PIN 36 -#define C_LED_PIN 35 - -#define HOLD_ALT_ABOVE_HOME 8 // bitmask value - -// IMU Parameters - -#define ADC_CONSTRAINT 900 -#define TRUE 1 -#define FALSE 0 -#define ADC_WARM_CYCLES 200 -#define SPEEDFILT 400 // centimeters/second - -#define GYRO_TEMP_CH 3 // The ADC channel reading the gyro temperature - -// ADC : Voltage reference 3.3v / 12bits(4096 steps) => 0.8mV/ADC step -// ADXL335 Sensitivity(from datasheet) => 330mV/g, 0.8mV/ADC step => 330/0.8 = 412 -// Tested value : 418 -#define GRAVITY 418 //this equivalent to 1G in the raw data coming from the accelerometer -#define Accel_Scale(x) x*(GRAVITY/9.81)//Scaling the raw data of the accel to actual acceleration in meters for seconds square - -#define ToRad(x) (x*0.01745329252) // *pi/180 -#define ToDeg(x) (x*57.2957795131) // *180/pi - -// IDG500 Sensitivity (from datasheet) => 2.0mV/º/s, 0.8mV/ADC step => 0.8/3.33 = 0.4 -// Tested values : 0.4026, ?, 0.4192 -#define Gyro_Gain_X 0.4 //X axis Gyro gain -#define Gyro_Gain_Y 0.41 //Y axis Gyro gain -#define Gyro_Gain_Z 0.41 //Z axis Gyro gain -#define Gyro_Scaled_X(x) x*ToRad(Gyro_Gain_X) //Return the scaled ADC raw data of the gyro in radians for second -#define Gyro_Scaled_Y(x) x*ToRad(Gyro_Gain_Y) //Return the scaled ADC raw data of the gyro in radians for second -#define Gyro_Scaled_Z(x) x*ToRad(Gyro_Gain_Z) //Return the scaled ADC raw data of the gyro in radians for second - -#define Kp_ROLLPITCH 0.0014 // Pitch&Roll Drift Correction Proportional Gain -#define Ki_ROLLPITCH 0.0000003 // Pitch&Roll Drift Correction Integrator Gain -#define Kp_YAW 0.8 // Yaw Drift Correction Porportional Gain -#define Ki_YAW 0.00004 // Yaw Drift CorrectionIntegrator Gain - -/*For debugging purposes*/ -#define OUTPUTMODE 1 //If value = 1 will print the corrected data, 0 will print uncorrected data of the gyros (with drift), 2 Accel only data - - -#define EEPROM_MAX_ADDR 4096 - -// Radio setup -#define EE_TRIM 0x00 -#define EE_MIN 0x10 -#define EE_MAX 0x20 -#define EE_ELEVON1_TRIM 0x30 -#define EE_ELEVON2_TRIM 0x32 - -// user gains -#define EE_XTRACK_GAIN 0x34 -#define EE_XTRACK_ANGLE 0x36 -#define EE_ALT_MIX 0x3B -#define EE_HEAD_MAX 0x38 -#define EE_PITCH_MAX 0x39 -#define EE_PITCH_MIN 0x3A -#define EE_KP 0x40 -#define EE_KI 0x60 -#define EE_KD 0x80 -#define EE_IMAX 0xA0 -#define EE_KFF 0xC0 -#define EE_AN_OFFSET 0xE0 -#define EE_PITCH_TARGET 0x127 - -//mission specific -#define EE_CONFIG 0X0F8 -#define EE_WP_MODE 0x0F9 -#define EE_YAW_MODE 0x0FA // not used -#define EE_WP_TOTAL 0x0FB -#define EE_WP_INDEX 0x0FC -#define EE_WP_RADIUS 0x0FD -#define EE_LOITER_RADIUS 0x0FE -#define EE_ALT_HOLD_HOME 0x0FF - -// user configs -#define EE_AIRSPEED_CRUISE 0x103 -#define EE_AIRSPEED_RATIO 0x104 -#define EE_AIRSPEED_FBW_MIN 0x108 -#define EE_AIRSPEED_FBW_MAX 0x109 -#define EE_THROTTLE_MIN 0x10A -#define EE_THROTTLE_CRUISE 0x10B -#define EE_THROTTLE_MAX 0x10C -#define EE_THROTTLE_FAILSAFE 0x10D -#define EE_THROTTLE_FS_VALUE 0x10E -#define EE_THROTTLE_FAILSAFE_ACTION 0x110 -#define EE_FLIGHT_MODE_CHANNEL 0x112 -#define EE_AUTO_TRIM 0x113 -#define EE_LOG_BITMASK 0x114 -#define EE_REVERSE_SWITCH 0x120 -#define EE_FLIGHT_MODES 0x121 - -// sensors -#define EE_ABS_PRESS_GND 0x116 -#define EE_GND_TEMP 0x11A -#define EE_GND_ALT 0x11C -#define EE_AP_OFFSET 0x11E - -// log -#define EE_LAST_LOG_PAGE 0xE00 -#define EE_LAST_LOG_NUM 0xE02 -#define EE_LOG_1_START 0xE04 - -// bits in log_bitmask -#define LOGBIT_ATTITUDE_FAST (1<<0) -#define LOGBIT_ATTITUDE_MED (1<<1) -#define LOGBIT_GPS (1<<2) -#define LOGBIT_PM (1<<3) -#define LOGBIT_CTUN (1<<4) -#define LOGBIT_NTUN (1<<5) -#define LOGBIT_MODE (1<<6) -#define LOGBIT_RAW (1<<7) -#define LOGBIT_CMD (1<<8) -