Compare commits
15 Commits
c22f4d825d
...
main
Author | SHA1 | Date | |
---|---|---|---|
3565372ffc | |||
a67275b402 | |||
e30f1f0f35 | |||
1f8bde2370 | |||
12e518af0e | |||
39c81a227b | |||
c763581ebb | |||
f4044e3939 | |||
0d8b03ef9a | |||
4b78b7d146 | |||
3e4973a129 | |||
15d4fa5011 | |||
4ff3c2c5da | |||
b4f2ecb18e | |||
fdbfd85180 |
@ -7,14 +7,13 @@ namespace DroneSimulator
|
|||||||
internal class Drone
|
internal class Drone
|
||||||
{
|
{
|
||||||
public int ID;
|
public int ID;
|
||||||
public float Mass; // Масса
|
|
||||||
public bool Active; // Живой?
|
public bool Active; // Живой?
|
||||||
public float Length; // Длинна лучей
|
|
||||||
public const float Dynamic = 10; // Динамика вращения
|
public const float Dynamic = 10; // Динамика вращения
|
||||||
public Vector3 PosXYZ, SpdXYZ, AccXYZ; // Положение в пространстве: Позиция, Скорость, Ускорение
|
public Vector3 PosXYZ, SpdXYZ, AccXYZ; // Положение в пространстве: Позиция, Скорость, Ускорение
|
||||||
public Quaternion Quat; // Основной кватернион
|
public Quaternion Quat; // Основной кватернион
|
||||||
public float Power = 0; // Тяга всех двигателей (0-1)
|
public float Power = 0; // Тяга всех двигателей (0-1)
|
||||||
public float MaxPower; // Максимальная Тяга всех двигателей (КГ)
|
|
||||||
public Vector3 SpdPRY, AccPRY; // Поворот в пространстве: pitch roll yaw
|
public Vector3 SpdPRY, AccPRY; // Поворот в пространстве: pitch roll yaw
|
||||||
|
|
||||||
public Vector3 Acc, Gyr; // Имитация: Акселерометр, Гироскоп
|
public Vector3 Acc, Gyr; // Имитация: Акселерометр, Гироскоп
|
||||||
@ -34,12 +33,19 @@ namespace DroneSimulator
|
|||||||
|
|
||||||
private Vector2 MoveOF = Vector2.Zero;
|
private Vector2 MoveOF = Vector2.Zero;
|
||||||
|
|
||||||
RealMode.Accelerometer RealAcc = new RealMode.Accelerometer();
|
public struct Physics
|
||||||
RealMode.Gyroscope RealGyr = new RealMode.Gyroscope();
|
{
|
||||||
RealMode.Position RealPos = new RealMode.Position();
|
static public float Mass; // Масса
|
||||||
RealMode.Barometer RealBar = new RealMode.Barometer();
|
static public float Length; // Длинна лучей
|
||||||
RealMode.Range RealRange = new RealMode.Range();
|
static public float MaxPower; // Максимальная Тяга всех двигателей (КГ)
|
||||||
RealMode.OpticalFlow RealOF = new RealMode.OpticalFlow();
|
}
|
||||||
|
|
||||||
|
private RealMode.Accelerometer RealAcc = new RealMode.Accelerometer();
|
||||||
|
private RealMode.Gyroscope RealGyr = new RealMode.Gyroscope();
|
||||||
|
private RealMode.Position RealPos = new RealMode.Position();
|
||||||
|
private RealMode.Barometer RealBar = new RealMode.Barometer();
|
||||||
|
private RealMode.Range RealRange = new RealMode.Range();
|
||||||
|
private RealMode.OpticalFlow RealOF = new RealMode.OpticalFlow();
|
||||||
|
|
||||||
public static byte[] getBytes(object data)
|
public static byte[] getBytes(object data)
|
||||||
{
|
{
|
||||||
@ -129,12 +135,8 @@ namespace DroneSimulator
|
|||||||
DroneThread.Start();
|
DroneThread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Create(float power, float mass, float len)
|
public int Create()
|
||||||
{
|
{
|
||||||
Mass = mass;
|
|
||||||
Length = len;
|
|
||||||
MaxPower = power;
|
|
||||||
|
|
||||||
Active = true;
|
Active = true;
|
||||||
|
|
||||||
return ID;
|
return ID;
|
||||||
@ -226,10 +228,10 @@ namespace DroneSimulator
|
|||||||
AccPRY.X -= wind_p; AccPRY.Y -= wind_r; AccPRY.Z -= wind_w;
|
AccPRY.X -= wind_p; AccPRY.Y -= wind_r; AccPRY.Z -= wind_w;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpdPRY += AccPRY * (Dynamic * time / (Mass * Length));
|
SpdPRY += AccPRY * (Dynamic * time / (Physics.Mass * Physics.Length));
|
||||||
|
|
||||||
Quaternion pow = Quaternion.Inverse(Quat) * new Quaternion(0, 0, flow, 0) * Quat;
|
Quaternion pow = Quaternion.Inverse(Quat) * new Quaternion(0, 0, flow, 0) * Quat;
|
||||||
AccXYZ = new Vector3(pow.X + wind_x, pow.Y + wind_y, pow.Z + wind_z) * (Gravity / Mass);
|
AccXYZ = new Vector3(pow.X + wind_x, pow.Y + wind_y, pow.Z + wind_z) * (Gravity / Physics.Mass);
|
||||||
SpdXYZ += (AccXYZ + new Vector3(0, 0, -Gravity)) * time;
|
SpdXYZ += (AccXYZ + new Vector3(0, 0, -Gravity)) * time;
|
||||||
PosXYZ += SpdXYZ * time;
|
PosXYZ += SpdXYZ * time;
|
||||||
|
|
||||||
@ -308,7 +310,7 @@ namespace DroneSimulator
|
|||||||
if (pow > 1) pow = 1;
|
if (pow > 1) pow = 1;
|
||||||
if (pow < 0) pow = 0;
|
if (pow < 0) pow = 0;
|
||||||
|
|
||||||
return pow * MaxPower;
|
return pow * Physics.MaxPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetQadroPow(float ul, float ur, float dl, float dr)
|
public void SetQadroPow(float ul, float ur, float dl, float dr)
|
||||||
|
1027
DroneSimulator/FormMain.Designer.cs
generated
1027
DroneSimulator/FormMain.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -32,6 +32,7 @@ namespace DroneSimulator
|
|||||||
checkBox_Area_Freeze_CheckedChanged(null, null);
|
checkBox_Area_Freeze_CheckedChanged(null, null);
|
||||||
numericUpDown_Area_Wind_Update(null, null);
|
numericUpDown_Area_Wind_Update(null, null);
|
||||||
numericUpDown_GPS_ValueChanged(null, null);
|
numericUpDown_GPS_ValueChanged(null, null);
|
||||||
|
numericUpDown_Physics_ValueChanged(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClientConnectionCallback(object o)
|
private void ClientConnectionCallback(object o)
|
||||||
@ -46,7 +47,7 @@ namespace DroneSimulator
|
|||||||
if (data.Connect)
|
if (data.Connect)
|
||||||
{
|
{
|
||||||
Drone drone = new Drone(data.ID);
|
Drone drone = new Drone(data.ID);
|
||||||
drone.Create(1.0f, 0.5f, 1.0f);
|
drone.Create();
|
||||||
|
|
||||||
screen2D.CreateDrone(Color.Red, data.ID);
|
screen2D.CreateDrone(Color.Red, data.ID);
|
||||||
|
|
||||||
@ -178,7 +179,7 @@ namespace DroneSimulator
|
|||||||
|
|
||||||
Invoke((MethodInvoker)delegate
|
Invoke((MethodInvoker)delegate
|
||||||
{
|
{
|
||||||
label_Clients_Num.Text = data.Count.ToString();
|
label_Visual_Num.Text = data.Count.ToString();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data.Connect)
|
if (data.Connect)
|
||||||
@ -344,5 +345,12 @@ namespace DroneSimulator
|
|||||||
GPS.State.Vdop = (float)numericUpDown_GPS_VDOP.Value;
|
GPS.State.Vdop = (float)numericUpDown_GPS_VDOP.Value;
|
||||||
GPS.State.Pdop = (float)numericUpDown_GPS_PDOP.Value;
|
GPS.State.Pdop = (float)numericUpDown_GPS_PDOP.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void numericUpDown_Physics_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Drone.Physics.Mass = (float)numericUpDown_Physics_Mass.Value;
|
||||||
|
Drone.Physics.Length = (float)numericUpDown_Physics_Length.Value;
|
||||||
|
Drone.Physics.MaxPower = (float)numericUpDown_Physics_Power.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,9 +117,6 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="menuStrip_Menu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="timer_Test.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="timer_Test.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>162, 5</value>
|
<value>162, 5</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
Reference in New Issue
Block a user