From 771440f64286f4d47dc0aaec7883991889dae379 Mon Sep 17 00:00:00 2001 From: Sergey Sklyarov Date: Tue, 15 Jul 2025 02:16:03 +0300 Subject: [PATCH] +++ --- DroneSimulator/Drone.cs | 13 ++++ DroneSimulator/FormMain.Designer.cs | 101 +++++++++++++++++++++++++++- DroneSimulator/FormMain.cs | 6 ++ 3 files changed, 119 insertions(+), 1 deletion(-) diff --git a/DroneSimulator/Drone.cs b/DroneSimulator/Drone.cs index aad5d2e..36b9594 100644 --- a/DroneSimulator/Drone.cs +++ b/DroneSimulator/Drone.cs @@ -49,6 +49,12 @@ namespace DroneSimulator static public float MaxPower; // Максимальная Тяга всех двигателей (КГ) } + public struct Propeller + { + static public float Diameter; // Диаметр лопостей + static public float MaxRotate; // Максимальнные обороты в секунду + } + private RealMode.Accelerometer RealAcc = new RealMode.Accelerometer(); private RealMode.Gyroscope RealGyr = new RealMode.Gyroscope(); private RealMode.Position RealPos = new RealMode.Position(); @@ -376,6 +382,13 @@ namespace DroneSimulator { ul = Range(ul); ur = Range(ur); dl = Range(dl); dr = Range(dr); + float coef = Area.Wind.Density * MathF.Pow(Propeller.Diameter, 4); + + //ul = MathF.Pow(ul * Propeller.MaxRotate, 2) * coef; // я хз как делать + //ur = MathF.Pow(ur * Propeller.MaxRotate, 2) * coef; + //dl = MathF.Pow(dl * Propeller.MaxRotate, 2) * coef; + //dr = MathF.Pow(dr * Propeller.MaxRotate, 2) * coef; + Power = (ul + ur + dl + dr) / 4; AccPRY.Y = ((ul + dl) - (ur + dr)); diff --git a/DroneSimulator/FormMain.Designer.cs b/DroneSimulator/FormMain.Designer.cs index 1a6a4f7..7cd74ae 100644 --- a/DroneSimulator/FormMain.Designer.cs +++ b/DroneSimulator/FormMain.Designer.cs @@ -198,6 +198,13 @@ label67 = new Label(); label66 = new Label(); tabPage_Drone = new TabPage(); + groupBox6 = new GroupBox(); + label79 = new Label(); + numericUpDown_Propeller_Rotation = new NumericUpDown(); + label39 = new Label(); + numericUpDown_Propeller_Diameter = new NumericUpDown(); + label38 = new Label(); + label37 = new Label(); groupBox_Physics = new GroupBox(); label78 = new Label(); numericUpDown_Physics_Power = new NumericUpDown(); @@ -286,6 +293,9 @@ ((System.ComponentModel.ISupportInitialize)numericUpDown_GPS_Lon).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDown_GPS_Lat).BeginInit(); tabPage_Drone.SuspendLayout(); + groupBox6.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDown_Propeller_Rotation).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDown_Propeller_Diameter).BeginInit(); groupBox_Physics.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)numericUpDown_Physics_Power).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDown_Physics_Length).BeginInit(); @@ -2161,6 +2171,7 @@ // // tabPage_Drone // + tabPage_Drone.Controls.Add(groupBox6); tabPage_Drone.Controls.Add(groupBox_Physics); tabPage_Drone.Location = new Point(4, 24); tabPage_Drone.Name = "tabPage_Drone"; @@ -2170,6 +2181,83 @@ tabPage_Drone.Text = "Drone"; tabPage_Drone.UseVisualStyleBackColor = true; // + // groupBox6 + // + groupBox6.Controls.Add(label79); + groupBox6.Controls.Add(numericUpDown_Propeller_Rotation); + groupBox6.Controls.Add(label39); + groupBox6.Controls.Add(numericUpDown_Propeller_Diameter); + groupBox6.Controls.Add(label38); + groupBox6.Controls.Add(label37); + groupBox6.Dock = DockStyle.Top; + groupBox6.Enabled = false; + groupBox6.Location = new Point(3, 119); + groupBox6.Name = "groupBox6"; + groupBox6.Size = new Size(204, 89); + groupBox6.TabIndex = 1; + groupBox6.TabStop = false; + groupBox6.Text = "Propeller"; + // + // label79 + // + label79.AutoSize = true; + label79.Location = new Point(162, 57); + label79.Name = "label79"; + label79.Size = new Size(32, 15); + label79.TabIndex = 9; + label79.Text = "RPM"; + // + // numericUpDown_Propeller_Rotation + // + numericUpDown_Propeller_Rotation.Increment = new decimal(new int[] { 100, 0, 0, 0 }); + numericUpDown_Propeller_Rotation.Location = new Point(94, 55); + numericUpDown_Propeller_Rotation.Maximum = new decimal(new int[] { 100000, 0, 0, 0 }); + numericUpDown_Propeller_Rotation.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + numericUpDown_Propeller_Rotation.Name = "numericUpDown_Propeller_Rotation"; + numericUpDown_Propeller_Rotation.Size = new Size(62, 23); + numericUpDown_Propeller_Rotation.TabIndex = 8; + numericUpDown_Propeller_Rotation.Value = new decimal(new int[] { 5000, 0, 0, 0 }); + numericUpDown_Propeller_Rotation.ValueChanged += numericUpDown_Propeller_ValueChanged; + // + // label39 + // + label39.AutoSize = true; + label39.Location = new Point(152, 28); + label39.Name = "label39"; + label39.Size = new Size(18, 15); + label39.TabIndex = 7; + label39.Text = "m"; + // + // numericUpDown_Propeller_Diameter + // + numericUpDown_Propeller_Diameter.DecimalPlaces = 2; + numericUpDown_Propeller_Diameter.Location = new Point(94, 26); + numericUpDown_Propeller_Diameter.Maximum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDown_Propeller_Diameter.Minimum = new decimal(new int[] { 5, 0, 0, 131072 }); + numericUpDown_Propeller_Diameter.Name = "numericUpDown_Propeller_Diameter"; + numericUpDown_Propeller_Diameter.Size = new Size(52, 23); + numericUpDown_Propeller_Diameter.TabIndex = 6; + numericUpDown_Propeller_Diameter.Value = new decimal(new int[] { 30, 0, 0, 131072 }); + numericUpDown_Propeller_Diameter.ValueChanged += numericUpDown_Propeller_ValueChanged; + // + // label38 + // + label38.AutoSize = true; + label38.Location = new Point(10, 57); + label38.Name = "label38"; + label38.Size = new Size(78, 15); + label38.TabIndex = 1; + label38.Text = "Max rotation:"; + // + // label37 + // + label37.AutoSize = true; + label37.Location = new Point(30, 28); + label37.Name = "label37"; + label37.Size = new Size(58, 15); + label37.TabIndex = 0; + label37.Text = "Diameter:"; + // // groupBox_Physics // groupBox_Physics.Controls.Add(label78); @@ -2184,7 +2272,7 @@ groupBox_Physics.Dock = DockStyle.Top; groupBox_Physics.Location = new Point(3, 3); groupBox_Physics.Name = "groupBox_Physics"; - groupBox_Physics.Size = new Size(204, 120); + groupBox_Physics.Size = new Size(204, 116); groupBox_Physics.TabIndex = 0; groupBox_Physics.TabStop = false; groupBox_Physics.Text = "Physics"; @@ -2443,6 +2531,10 @@ ((System.ComponentModel.ISupportInitialize)numericUpDown_GPS_Lon).EndInit(); ((System.ComponentModel.ISupportInitialize)numericUpDown_GPS_Lat).EndInit(); tabPage_Drone.ResumeLayout(false); + groupBox6.ResumeLayout(false); + groupBox6.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDown_Propeller_Rotation).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDown_Propeller_Diameter).EndInit(); groupBox_Physics.ResumeLayout(false); groupBox_Physics.PerformLayout(); ((System.ComponentModel.ISupportInitialize)numericUpDown_Physics_Power).EndInit(); @@ -2639,5 +2731,12 @@ private GroupBox groupBox_Lockstep; private Label label_Lockstep_Time; private CheckBox checkBox_Lockstep_Limit; + private GroupBox groupBox6; + private Label label38; + private Label label37; + private Label label79; + private NumericUpDown numericUpDown_Propeller_Rotation; + private Label label39; + private NumericUpDown numericUpDown_Propeller_Diameter; } } diff --git a/DroneSimulator/FormMain.cs b/DroneSimulator/FormMain.cs index a5b6913..cfa8f03 100644 --- a/DroneSimulator/FormMain.cs +++ b/DroneSimulator/FormMain.cs @@ -373,5 +373,11 @@ namespace DroneSimulator { Drone.TimeLimit = checkBox_Lockstep_Limit.Checked; } + + private void numericUpDown_Propeller_ValueChanged(object sender, EventArgs e) + { + Drone.Propeller.Diameter = (float)numericUpDown_Propeller_Diameter.Value; + Drone.Propeller.MaxRotate = ((float)numericUpDown_Propeller_Rotation.Value) / 60; + } } }