Compare commits
No commits in common. "main" and "main" have entirely different histories.
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,4 +1,3 @@
|
|||||||
.vs/
|
.vs/
|
||||||
obj/
|
obj/
|
||||||
bin/
|
bin/
|
||||||
x64/
|
|
@ -1,5 +1,4 @@
|
|||||||
using System.Diagnostics.Metrics;
|
using System.Drawing;
|
||||||
using System.Drawing;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace DroneClient
|
namespace DroneClient
|
||||||
@ -9,11 +8,8 @@ namespace DroneClient
|
|||||||
|
|
||||||
public float AccX, AccY, AccZ;
|
public float AccX, AccY, AccZ;
|
||||||
public float GyrX, GyrY, GyrZ;
|
public float GyrX, GyrY, GyrZ;
|
||||||
public uint TimeAcc, TimeGyr;
|
|
||||||
|
|
||||||
public float PosX, PosY;
|
public float PosX, PosY;
|
||||||
public float LaserRange;
|
public float LaserRange;
|
||||||
public uint TimeRange;
|
|
||||||
|
|
||||||
public float MotorUL, MotorUR, MotorDL, MotorDR;
|
public float MotorUL, MotorUR, MotorDL, MotorDR;
|
||||||
|
|
||||||
@ -74,44 +70,22 @@ namespace DroneClient
|
|||||||
return getBytes(mot4);
|
return getBytes(mot4);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[]? RecvDataAcc(byte[] data)
|
private byte[]? RecvDataIMU(byte[] data)
|
||||||
{
|
{
|
||||||
DroneData.DataAcc imu = (DroneData.DataAcc)fromBytes(data, typeof(DroneData.DataAcc));
|
DroneData.DataIMU imu = (DroneData.DataIMU)fromBytes(data, typeof(DroneData.DataIMU));
|
||||||
|
|
||||||
AccX = imu.Acc.X; AccY = imu.Acc.Y; AccZ = imu.Acc.Z;
|
AccX = imu.Acc.X; AccY = imu.Acc.Y; AccZ = imu.Acc.Z;
|
||||||
|
|
||||||
TimeAcc= imu.Time;
|
|
||||||
|
|
||||||
return new byte[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[]? RecvDataGyr(byte[] data)
|
|
||||||
{
|
|
||||||
DroneData.DataGyr imu = (DroneData.DataGyr)fromBytes(data, typeof(DroneData.DataGyr));
|
|
||||||
|
|
||||||
GyrX = imu.Gyr.X; GyrY = imu.Gyr.Y; GyrZ = imu.Gyr.Z;
|
GyrX = imu.Gyr.X; GyrY = imu.Gyr.Y; GyrZ = imu.Gyr.Z;
|
||||||
|
|
||||||
TimeGyr = imu.Time;
|
|
||||||
|
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[]? RecvDataRange(byte[] data)
|
private byte[]? RecvDataPos(byte[] data)
|
||||||
{
|
{
|
||||||
DroneData.DataRange pos = (DroneData.DataRange)fromBytes(data, typeof(DroneData.DataRange));
|
DroneData.DataPos pos = (DroneData.DataPos)fromBytes(data, typeof(DroneData.DataPos));
|
||||||
|
|
||||||
LaserRange = pos.LiDAR;
|
|
||||||
|
|
||||||
TimeRange = pos.Time;
|
|
||||||
|
|
||||||
return new byte[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[]? RecvDataLocal(byte[] data)
|
|
||||||
{
|
|
||||||
DroneData.DataLocal pos = (DroneData.DataLocal)fromBytes(data, typeof(DroneData.DataLocal));
|
|
||||||
|
|
||||||
PosX = pos.Local.X; PosY = pos.Local.Y;
|
PosX = pos.Local.X; PosY = pos.Local.Y;
|
||||||
|
LaserRange = pos.LiDAR;
|
||||||
|
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
@ -122,7 +96,7 @@ namespace DroneClient
|
|||||||
|
|
||||||
switch (head.Type)
|
switch (head.Type)
|
||||||
{
|
{
|
||||||
case DroneData.DataType.DataAcc:
|
case DroneData.DataType.DataIMU:
|
||||||
{
|
{
|
||||||
if (head.Mode == DroneData.DataMode.Request)
|
if (head.Mode == DroneData.DataMode.Request)
|
||||||
{
|
{
|
||||||
@ -134,11 +108,11 @@ namespace DroneClient
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Пришли данные
|
// Пришли данные
|
||||||
return RecvDataAcc(body);
|
return RecvDataIMU(body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case DroneData.DataType.DataGyr:
|
case DroneData.DataType.DataPos:
|
||||||
{
|
{
|
||||||
if (head.Mode == DroneData.DataMode.Request)
|
if (head.Mode == DroneData.DataMode.Request)
|
||||||
{
|
{
|
||||||
@ -150,39 +124,7 @@ namespace DroneClient
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Пришли данные
|
// Пришли данные
|
||||||
return RecvDataGyr(body);
|
return RecvDataPos(body);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case DroneData.DataType.DataRange:
|
|
||||||
{
|
|
||||||
if (head.Mode == DroneData.DataMode.Request)
|
|
||||||
{
|
|
||||||
// Запрос данных
|
|
||||||
// ... //
|
|
||||||
//
|
|
||||||
return zero;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Пришли данные
|
|
||||||
return RecvDataRange(body);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case DroneData.DataType.DataLocal:
|
|
||||||
{
|
|
||||||
if (head.Mode == DroneData.DataMode.Request)
|
|
||||||
{
|
|
||||||
// Запрос данных
|
|
||||||
// ... //
|
|
||||||
//
|
|
||||||
return zero;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Пришли данные
|
|
||||||
return RecvDataLocal(body);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,46 +193,24 @@ namespace DroneClient
|
|||||||
|
|
||||||
public byte[] SendReqest()
|
public byte[] SendReqest()
|
||||||
{
|
{
|
||||||
DroneData.DataHead acc = new DroneData.DataHead();
|
DroneData.DataHead imu = new DroneData.DataHead();
|
||||||
acc.Size = DroneData.DataHead.StrLen;
|
imu.Size = DroneData.DataHead.StrLen;
|
||||||
acc.Mode = DroneData.DataMode.Request;
|
imu.Mode = DroneData.DataMode.Request;
|
||||||
acc.Type = DroneData.DataType.DataAcc;
|
imu.Type = DroneData.DataType.DataIMU;
|
||||||
|
|
||||||
DroneData.DataHead gyr = new DroneData.DataHead();
|
DroneData.DataHead pos = new DroneData.DataHead();
|
||||||
gyr.Size = DroneData.DataHead.StrLen;
|
pos.Size = DroneData.DataHead.StrLen;
|
||||||
gyr.Mode = DroneData.DataMode.Request;
|
pos.Mode = DroneData.DataMode.Request;
|
||||||
gyr.Type = DroneData.DataType.DataGyr;
|
pos.Type = DroneData.DataType.DataPos;
|
||||||
|
|
||||||
DroneData.DataHead range = new DroneData.DataHead();
|
byte[] si = getBytes(imu);
|
||||||
range.Size = DroneData.DataHead.StrLen;
|
byte[] sp = getBytes(pos);
|
||||||
range.Mode = DroneData.DataMode.Request;
|
byte[] sm = SendDataMotor4();
|
||||||
range.Type = DroneData.DataType.DataRange;
|
|
||||||
|
|
||||||
DroneData.DataHead local = new DroneData.DataHead();
|
byte[] send = new byte[si.Length + sp.Length + sm.Length];
|
||||||
local.Size = DroneData.DataHead.StrLen;
|
si.CopyTo(send, 0);
|
||||||
local.Mode = DroneData.DataMode.Request;
|
sp.CopyTo(send, si.Length);
|
||||||
local.Type = DroneData.DataType.DataLocal;
|
sm.CopyTo(send, si.Length + sp.Length);
|
||||||
|
|
||||||
List<byte[]> list = new List<byte[]>();
|
|
||||||
|
|
||||||
list.Add(getBytes(acc));
|
|
||||||
list.Add(getBytes(gyr));
|
|
||||||
list.Add(getBytes(range));
|
|
||||||
list.Add(getBytes(local));
|
|
||||||
list.Add(SendDataMotor4());
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
foreach (byte[] d in list) count += d.Length;
|
|
||||||
|
|
||||||
byte[] send = new byte[count];
|
|
||||||
|
|
||||||
count = 0;
|
|
||||||
foreach (byte[] d in list)
|
|
||||||
{
|
|
||||||
d.CopyTo(send, count);
|
|
||||||
count += d.Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
return send;
|
return send;
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,11 @@ namespace DroneData
|
|||||||
};
|
};
|
||||||
|
|
||||||
public enum DataType : ushort
|
public enum DataType : ushort
|
||||||
{
|
{
|
||||||
None = 0, Head = 1,
|
None = 0, Head = 1,
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
DataAcc = 1001, DataGyr = 1002, DataMag = 1003, DataRange = 1004, DataLocal = 1005,
|
DataIMU = 1001, DataPos = 1002,
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
DataMotor4 = 2001, DataMotor6 = 2002
|
DataMotor4 = 2001, DataMotor6 = 2002
|
||||||
@ -25,66 +25,32 @@ namespace DroneData
|
|||||||
public DataMode Mode;
|
public DataMode Mode;
|
||||||
public DataType Type;
|
public DataType Type;
|
||||||
|
|
||||||
public uint Time; // Îáùåå âðåìÿ
|
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataHead));
|
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataHead));
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct XYZ { public float X, Y, Z; }
|
public struct XYZ { public float X, Y, Z; }
|
||||||
|
|
||||||
public struct DataAcc
|
public struct DataIMU
|
||||||
{
|
{
|
||||||
public DataHead Head;
|
public DataHead Head;
|
||||||
public XYZ Acc;
|
public XYZ Acc, Gyr, Mag;
|
||||||
|
|
||||||
public uint Time; // Ïîñëåäíåå âðåìÿ èçìåíåíèÿ äàííûõ
|
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataIMU));
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataAcc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct DataGyr
|
public struct DataPos
|
||||||
{
|
|
||||||
public DataHead Head;
|
|
||||||
public XYZ Gyr;
|
|
||||||
|
|
||||||
public uint Time; // Ïîñëåäíåå âðåìÿ èçìåíåíèÿ äàííûõ
|
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataGyr));
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct DataMag
|
|
||||||
{
|
|
||||||
public DataHead Head;
|
|
||||||
public XYZ Mag;
|
|
||||||
|
|
||||||
public uint Time; // Ïîñëåäíåå âðåìÿ èçìåíåíèÿ äàííûõ
|
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataMag));
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct DataLocal
|
|
||||||
{
|
{
|
||||||
public DataHead Head;
|
public DataHead Head;
|
||||||
public XYZ Local; // Ëîêàëüíûå êîîðäèíàòû
|
public XYZ Local; // Ëîêàëüíûå êîîðäèíàòû
|
||||||
|
|
||||||
public uint Time; // Ïîñëåäíåå âðåìÿ èçìåíåíèÿ äàííûõ
|
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataLocal));
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct DataRange
|
|
||||||
{
|
|
||||||
public DataHead Head;
|
|
||||||
public float LiDAR; // Äàò÷èê ïîñàäêè
|
public float LiDAR; // Äàò÷èê ïîñàäêè
|
||||||
|
|
||||||
public uint Time; // Ïîñëåäíåå âðåìÿ èçìåíåíèÿ äàííûõ
|
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataPos));
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataRange));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct DataMotor4
|
public struct DataMotor4
|
||||||
{
|
{
|
||||||
public DataHead Head;
|
public DataHead Head;
|
||||||
|
public ulong Count;
|
||||||
public float UL, UR, DL, DR;
|
public float UL, UR, DL, DR;
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataMotor4));
|
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataMotor4));
|
||||||
@ -93,6 +59,7 @@ namespace DroneData
|
|||||||
public struct DataMotor6
|
public struct DataMotor6
|
||||||
{
|
{
|
||||||
public DataHead Head;
|
public DataHead Head;
|
||||||
|
public ulong Count;
|
||||||
public float UL, UR, LL, RR, DL, DR;
|
public float UL, UR, LL, RR, DL, DR;
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataMotor6));
|
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataMotor6));
|
||||||
|
43
DroneClient/FormMain.Designer.cs
generated
43
DroneClient/FormMain.Designer.cs
generated
@ -65,9 +65,6 @@
|
|||||||
label_Pow = new Label();
|
label_Pow = new Label();
|
||||||
button_ML = new Button();
|
button_ML = new Button();
|
||||||
button_MR = new Button();
|
button_MR = new Button();
|
||||||
label_time_acc = new Label();
|
|
||||||
label_time_range = new Label();
|
|
||||||
label_time_gyr = new Label();
|
|
||||||
groupBox1.SuspendLayout();
|
groupBox1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDown_Server_Port).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDown_Server_Port).BeginInit();
|
||||||
groupBox2.SuspendLayout();
|
groupBox2.SuspendLayout();
|
||||||
@ -159,7 +156,6 @@
|
|||||||
//
|
//
|
||||||
// groupBox2
|
// groupBox2
|
||||||
//
|
//
|
||||||
groupBox2.Controls.Add(label_time_acc);
|
|
||||||
groupBox2.Controls.Add(label_Acc_Z);
|
groupBox2.Controls.Add(label_Acc_Z);
|
||||||
groupBox2.Controls.Add(label7);
|
groupBox2.Controls.Add(label7);
|
||||||
groupBox2.Controls.Add(label_Acc_Y);
|
groupBox2.Controls.Add(label_Acc_Y);
|
||||||
@ -168,7 +164,7 @@
|
|||||||
groupBox2.Controls.Add(label1);
|
groupBox2.Controls.Add(label1);
|
||||||
groupBox2.Location = new Point(6, 86);
|
groupBox2.Location = new Point(6, 86);
|
||||||
groupBox2.Name = "groupBox2";
|
groupBox2.Name = "groupBox2";
|
||||||
groupBox2.Size = new Size(78, 118);
|
groupBox2.Size = new Size(78, 100);
|
||||||
groupBox2.TabIndex = 5;
|
groupBox2.TabIndex = 5;
|
||||||
groupBox2.TabStop = false;
|
groupBox2.TabStop = false;
|
||||||
groupBox2.Text = "Acc";
|
groupBox2.Text = "Acc";
|
||||||
@ -220,7 +216,6 @@
|
|||||||
//
|
//
|
||||||
// groupBox3
|
// groupBox3
|
||||||
//
|
//
|
||||||
groupBox3.Controls.Add(label_time_gyr);
|
|
||||||
groupBox3.Controls.Add(label_Gyr_Z);
|
groupBox3.Controls.Add(label_Gyr_Z);
|
||||||
groupBox3.Controls.Add(label9);
|
groupBox3.Controls.Add(label9);
|
||||||
groupBox3.Controls.Add(label_Gyr_Y);
|
groupBox3.Controls.Add(label_Gyr_Y);
|
||||||
@ -229,7 +224,7 @@
|
|||||||
groupBox3.Controls.Add(label13);
|
groupBox3.Controls.Add(label13);
|
||||||
groupBox3.Location = new Point(95, 86);
|
groupBox3.Location = new Point(95, 86);
|
||||||
groupBox3.Name = "groupBox3";
|
groupBox3.Name = "groupBox3";
|
||||||
groupBox3.Size = new Size(78, 118);
|
groupBox3.Size = new Size(78, 100);
|
||||||
groupBox3.TabIndex = 6;
|
groupBox3.TabIndex = 6;
|
||||||
groupBox3.TabStop = false;
|
groupBox3.TabStop = false;
|
||||||
groupBox3.Text = "Gyr";
|
groupBox3.Text = "Gyr";
|
||||||
@ -290,7 +285,6 @@
|
|||||||
//
|
//
|
||||||
// groupBox4
|
// groupBox4
|
||||||
//
|
//
|
||||||
groupBox4.Controls.Add(label_time_range);
|
|
||||||
groupBox4.Controls.Add(label_Pos_L);
|
groupBox4.Controls.Add(label_Pos_L);
|
||||||
groupBox4.Controls.Add(label6);
|
groupBox4.Controls.Add(label6);
|
||||||
groupBox4.Controls.Add(label_Pos_Y);
|
groupBox4.Controls.Add(label_Pos_Y);
|
||||||
@ -299,7 +293,7 @@
|
|||||||
groupBox4.Controls.Add(label14);
|
groupBox4.Controls.Add(label14);
|
||||||
groupBox4.Location = new Point(188, 86);
|
groupBox4.Location = new Point(188, 86);
|
||||||
groupBox4.Name = "groupBox4";
|
groupBox4.Name = "groupBox4";
|
||||||
groupBox4.Size = new Size(78, 118);
|
groupBox4.Size = new Size(78, 100);
|
||||||
groupBox4.TabIndex = 7;
|
groupBox4.TabIndex = 7;
|
||||||
groupBox4.TabStop = false;
|
groupBox4.TabStop = false;
|
||||||
groupBox4.Text = "Pos";
|
groupBox4.Text = "Pos";
|
||||||
@ -443,33 +437,6 @@
|
|||||||
button_MR.MouseDown += button_UU_MouseDown;
|
button_MR.MouseDown += button_UU_MouseDown;
|
||||||
button_MR.MouseUp += button_UU_MouseUp;
|
button_MR.MouseUp += button_UU_MouseUp;
|
||||||
//
|
//
|
||||||
// label_time_acc
|
|
||||||
//
|
|
||||||
label_time_acc.AutoSize = true;
|
|
||||||
label_time_acc.Location = new Point(6, 100);
|
|
||||||
label_time_acc.Name = "label_time_acc";
|
|
||||||
label_time_acc.Size = new Size(13, 15);
|
|
||||||
label_time_acc.TabIndex = 25;
|
|
||||||
label_time_acc.Text = "0";
|
|
||||||
//
|
|
||||||
// label_time_range
|
|
||||||
//
|
|
||||||
label_time_range.AutoSize = true;
|
|
||||||
label_time_range.Location = new Point(6, 100);
|
|
||||||
label_time_range.Name = "label_time_range";
|
|
||||||
label_time_range.Size = new Size(13, 15);
|
|
||||||
label_time_range.TabIndex = 27;
|
|
||||||
label_time_range.Text = "0";
|
|
||||||
//
|
|
||||||
// label_time_gyr
|
|
||||||
//
|
|
||||||
label_time_gyr.AutoSize = true;
|
|
||||||
label_time_gyr.Location = new Point(3, 100);
|
|
||||||
label_time_gyr.Name = "label_time_gyr";
|
|
||||||
label_time_gyr.Size = new Size(13, 15);
|
|
||||||
label_time_gyr.TabIndex = 26;
|
|
||||||
label_time_gyr.Text = "0";
|
|
||||||
//
|
|
||||||
// Form_Main
|
// Form_Main
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
@ -542,9 +509,5 @@
|
|||||||
private Label label_Pow;
|
private Label label_Pow;
|
||||||
private Button button_ML;
|
private Button button_ML;
|
||||||
private Button button_MR;
|
private Button button_MR;
|
||||||
private Label label4;
|
|
||||||
private Label label_time_acc;
|
|
||||||
private Label label_time_range;
|
|
||||||
private Label label_time_gyr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,20 +95,14 @@ namespace DroneSimulator
|
|||||||
label_Acc_Y.Text = dataDrone.AccY.ToString();
|
label_Acc_Y.Text = dataDrone.AccY.ToString();
|
||||||
label_Acc_Z.Text = dataDrone.AccZ.ToString();
|
label_Acc_Z.Text = dataDrone.AccZ.ToString();
|
||||||
|
|
||||||
label_time_acc.Text = dataDrone.TimeAcc.ToString();
|
|
||||||
|
|
||||||
label_Gyr_X.Text = dataDrone.GyrX.ToString();
|
label_Gyr_X.Text = dataDrone.GyrX.ToString();
|
||||||
label_Gyr_Y.Text = dataDrone.GyrY.ToString();
|
label_Gyr_Y.Text = dataDrone.GyrY.ToString();
|
||||||
label_Gyr_Z.Text = dataDrone.GyrZ.ToString();
|
label_Gyr_Z.Text = dataDrone.GyrZ.ToString();
|
||||||
|
|
||||||
label_time_gyr.Text = dataDrone.TimeGyr.ToString();
|
|
||||||
|
|
||||||
label_Pos_X.Text = dataDrone.PosX.ToString();
|
label_Pos_X.Text = dataDrone.PosX.ToString();
|
||||||
label_Pos_Y.Text = dataDrone.PosY.ToString();
|
label_Pos_Y.Text = dataDrone.PosY.ToString();
|
||||||
label_Pos_L.Text = dataDrone.LaserRange.ToString();
|
label_Pos_L.Text = dataDrone.LaserRange.ToString();
|
||||||
|
|
||||||
label_time_range.Text = dataDrone.TimeRange.ToString();
|
|
||||||
|
|
||||||
netClient.SendData(dataDrone.SendReqest());
|
netClient.SendData(dataDrone.SendReqest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,106 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Client.h"
|
|
||||||
|
|
||||||
Client::Client(const char* ip, int port) : running(true), Connection(INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
if (!ConnectToServer(ip, port))
|
|
||||||
{
|
|
||||||
std::cerr << "Failed to connect to server!" << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Client::~Client()
|
|
||||||
{
|
|
||||||
Stop();
|
|
||||||
CloseConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Client::ConnectToServer(const char* ip, int port)
|
|
||||||
{
|
|
||||||
WSAData wsaData;
|
|
||||||
WORD DLLVersion = MAKEWORD(2, 2);
|
|
||||||
|
|
||||||
if (WSAStartup(DLLVersion, &wsaData) != 0)
|
|
||||||
{
|
|
||||||
std::cerr << "Error: WSAStartup failed" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SOCKADDR_IN addr;
|
|
||||||
inet_pton(AF_INET, ip, &addr.sin_addr);
|
|
||||||
addr.sin_port = htons(port);
|
|
||||||
addr.sin_family = AF_INET;
|
|
||||||
|
|
||||||
Connection = socket(AF_INET, SOCK_STREAM, 0);
|
|
||||||
if (Connection == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
std::cerr << "Error: Failed to create socket" << std::endl;
|
|
||||||
WSACleanup();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connect(Connection, (SOCKADDR*)&addr, sizeof(addr)) != 0)
|
|
||||||
{
|
|
||||||
std::cerr << "Error: Failed to connect to server" << std::endl;
|
|
||||||
closesocket(Connection);
|
|
||||||
WSACleanup();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Client::CloseConnection()
|
|
||||||
{
|
|
||||||
if (Connection != INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
closesocket(Connection);
|
|
||||||
WSACleanup();
|
|
||||||
Connection = INVALID_SOCKET;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Client::ReceiveHandler()
|
|
||||||
{
|
|
||||||
while (running)
|
|
||||||
{
|
|
||||||
DataIn tempData;
|
|
||||||
int result = recv(Connection, (char*)&tempData, sizeof(tempData), 0);
|
|
||||||
|
|
||||||
if (result <= 0)
|
|
||||||
{
|
|
||||||
std::cerr << "Error: Connection lost (recv failed)" << std::endl;
|
|
||||||
running = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(dataMutex);
|
|
||||||
dataIn = tempData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Client::SendHandler()
|
|
||||||
{
|
|
||||||
while (running)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dataMutex);
|
|
||||||
send(Connection, (char*)&dataOut, sizeof(dataOut), 0);
|
|
||||||
}
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Client::Start()
|
|
||||||
{
|
|
||||||
recvThread = std::thread(&Client::ReceiveHandler, this);
|
|
||||||
sendThread = std::thread(&Client::SendHandler, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Client::Stop()
|
|
||||||
{
|
|
||||||
running = false;
|
|
||||||
if (recvThread.joinable()) recvThread.join();
|
|
||||||
if (sendThread.joinable()) sendThread.join();
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <WinSock2.h>
|
|
||||||
#include <WS2tcpip.h>
|
|
||||||
#include <thread>
|
|
||||||
#include <atomic>
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#pragma comment(lib, "Ws2_32.lib")
|
|
||||||
|
|
||||||
class Client
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Client(const char* ip, int port);
|
|
||||||
~Client();
|
|
||||||
|
|
||||||
void Start(); // Запуск потоков
|
|
||||||
void Stop(); // Остановка потоков
|
|
||||||
struct DataIn
|
|
||||||
{
|
|
||||||
float AccX, AccY, AccZ;
|
|
||||||
float GyrX, GyrY, GyrZ;
|
|
||||||
float PosX, PosY, LaserRange;
|
|
||||||
} dataIn;
|
|
||||||
|
|
||||||
struct DataOut
|
|
||||||
{
|
|
||||||
float MotorUL, MotorUR, MotorDL, MotorDR;
|
|
||||||
} dataOut;
|
|
||||||
bool ConnectToServer(const char* ip, int port);
|
|
||||||
void CloseConnection();
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::atomic<bool> running;
|
|
||||||
std::mutex dataMutex;
|
|
||||||
|
|
||||||
SOCKET Connection;
|
|
||||||
std::thread recvThread;
|
|
||||||
std::thread sendThread;
|
|
||||||
|
|
||||||
void ReceiveHandler();
|
|
||||||
void SendHandler();
|
|
||||||
};
|
|
@ -1,255 +0,0 @@
|
|||||||
#include "Drone.h"
|
|
||||||
|
|
||||||
namespace DroneClient {
|
|
||||||
|
|
||||||
// Реализация статического метода GetBytes
|
|
||||||
array<Byte>^ Drone::GetBytes(Object^ data)
|
|
||||||
{
|
|
||||||
int size = Marshal::SizeOf(data);
|
|
||||||
array<Byte>^ arr = gcnew array<Byte>(size);
|
|
||||||
|
|
||||||
IntPtr ptr = IntPtr::Zero;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ptr = Marshal::AllocHGlobal(size);
|
|
||||||
Marshal::StructureToPtr(data, ptr, true);
|
|
||||||
Marshal::Copy(ptr, arr, 0, size);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Marshal::FreeHGlobal(ptr);
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Реализация статического метода FromBytes
|
|
||||||
Object^ Drone::FromBytes(array<Byte>^ arr, Type^ type)
|
|
||||||
{
|
|
||||||
Object^ mem = gcnew Object();
|
|
||||||
|
|
||||||
int size = Marshal::SizeOf(type);
|
|
||||||
IntPtr ptr = IntPtr::Zero;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ptr = Marshal::AllocHGlobal(size);
|
|
||||||
Marshal::Copy(arr, 0, ptr, size);
|
|
||||||
mem = Marshal::PtrToStructure(ptr, type);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Marshal::FreeHGlobal(ptr);
|
|
||||||
}
|
|
||||||
return mem;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Реализация приватного метода SendDataMotor4
|
|
||||||
array<Byte>^ Drone::SendDataMotor4()
|
|
||||||
{
|
|
||||||
DroneData::DataMotor4 mot4;
|
|
||||||
|
|
||||||
mot4.Head.Size = Marshal::SizeOf(DroneData::DataMotor4::typeid);
|
|
||||||
mot4.Head.Mode = DroneData::DataMode::Response;
|
|
||||||
mot4.Head.Type = DroneData::DataType::DataMotor4;
|
|
||||||
|
|
||||||
mot4.UL = MotorUL;
|
|
||||||
mot4.UR = MotorUR;
|
|
||||||
mot4.DL = MotorDL;
|
|
||||||
mot4.DR = MotorDR;
|
|
||||||
|
|
||||||
return GetBytes(mot4);
|
|
||||||
}
|
|
||||||
|
|
||||||
array<Byte>^ Drone::RecvDataAcc(array<Byte>^ data)
|
|
||||||
{
|
|
||||||
DroneData::DataAcc imu = (DroneData::DataAcc)FromBytes(data, DroneData::DataAcc::typeid);
|
|
||||||
|
|
||||||
AccX = imu.Acc.X; AccY = imu.Acc.Y; AccZ = imu.Acc.Z;
|
|
||||||
TimeAcc = imu.Time;
|
|
||||||
|
|
||||||
return gcnew array<Byte>(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
array<Byte>^ Drone::RecvDataGyr(array<Byte>^ data)
|
|
||||||
{
|
|
||||||
DroneData::DataGyr imu = (DroneData::DataGyr)FromBytes(data, DroneData::DataGyr::typeid);
|
|
||||||
|
|
||||||
GyrX = imu.Gyr.X; GyrY = imu.Gyr.Y; GyrZ = imu.Gyr.Z;
|
|
||||||
TimeGyr = imu.Time;
|
|
||||||
|
|
||||||
return gcnew array<Byte>(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
array<Byte>^ Drone::RecvDataRange(array<Byte>^ data)
|
|
||||||
{
|
|
||||||
DroneData::DataRange pos = (DroneData::DataRange)FromBytes(data, DroneData::DataRange::typeid);
|
|
||||||
|
|
||||||
LaserRange = pos.LiDAR;
|
|
||||||
TimeRange = pos.Time;
|
|
||||||
|
|
||||||
return gcnew array<Byte>(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
array<Byte>^ Drone::RecvDataLocal(array<Byte>^ data)
|
|
||||||
{
|
|
||||||
DroneData::DataLocal pos = (DroneData::DataLocal)FromBytes(data, DroneData::DataLocal::typeid);
|
|
||||||
|
|
||||||
PosX = pos.Local.X; PosY = pos.Local.Y;
|
|
||||||
|
|
||||||
return gcnew array<Byte>(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
array<Byte>^ Drone::ClientRequestResponse(DroneData::DataHead head, array<Byte>^ body)
|
|
||||||
{
|
|
||||||
array<Byte>^ zero = gcnew array<Byte>(0);
|
|
||||||
|
|
||||||
switch (head.Type)
|
|
||||||
{
|
|
||||||
case DroneData::DataType::DataAcc:
|
|
||||||
if (head.Mode == DroneData::DataMode::Request)
|
|
||||||
{
|
|
||||||
return zero; // Запрос данных (не реализовано)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return RecvDataAcc(body); // Пришли данные
|
|
||||||
}
|
|
||||||
|
|
||||||
case DroneData::DataType::DataGyr:
|
|
||||||
if (head.Mode == DroneData::DataMode::Request)
|
|
||||||
{
|
|
||||||
return zero; // Запрос данных (не реализовано)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return RecvDataGyr(body); // Пришли данные
|
|
||||||
}
|
|
||||||
|
|
||||||
case DroneData::DataType::DataRange:
|
|
||||||
if (head.Mode == DroneData::DataMode::Request)
|
|
||||||
{
|
|
||||||
return zero; // Запрос данных (не реализовано)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return RecvDataRange(body); // Пришли данные
|
|
||||||
}
|
|
||||||
|
|
||||||
case DroneData::DataType::DataLocal:
|
|
||||||
if (head.Mode == DroneData::DataMode::Request)
|
|
||||||
{
|
|
||||||
return zero; // Запрос данных (не реализовано)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return RecvDataLocal(body); // Пришли данные
|
|
||||||
}
|
|
||||||
|
|
||||||
case DroneData::DataType::DataMotor4:
|
|
||||||
if (head.Mode == DroneData::DataMode::Request)
|
|
||||||
{
|
|
||||||
return SendDataMotor4(); // Запрос данных
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return zero; // Пришли данные (не реализовано)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Реализация конструктора
|
|
||||||
Drone::Drone()
|
|
||||||
{
|
|
||||||
DroneStreamData = gcnew array<Byte>(DroneStreamCount); // Инициализация массива
|
|
||||||
DroneStreamIndex = 0;
|
|
||||||
DroneStreamHead.Mode = DroneData::DataMode::None;
|
|
||||||
DroneStreamHead.Size = 0;
|
|
||||||
DroneStreamHead.Type = DroneData::DataType::None;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Реализация метода DataStream
|
|
||||||
List<array<Byte>^>^ Drone::DataStream(array<Byte>^ data, int size)
|
|
||||||
{
|
|
||||||
System::Collections::Generic::List<array<Byte>^>^ ret = gcnew System::Collections::Generic::List<array<Byte>^>();
|
|
||||||
|
|
||||||
if (data == nullptr) return ret; // Последовательность не сформирована
|
|
||||||
|
|
||||||
if (size + DroneStreamIndex > DroneStreamCount) return nullptr; // Ошибка переполнения
|
|
||||||
|
|
||||||
Array::Copy(data, 0, DroneStreamData, DroneStreamIndex, size);
|
|
||||||
DroneStreamIndex += size;
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
if (DroneStreamHead.Size == 0) // Заголовок еще не получен
|
|
||||||
{
|
|
||||||
if (DroneStreamIndex < DroneData::DataHead::StrLen) return ret;
|
|
||||||
DroneStreamHead = (DroneData::DataHead)FromBytes(DroneStreamData, DroneData::DataHead::typeid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DroneStreamHead.Size > DroneStreamIndex) break; // Пакет еще не полный
|
|
||||||
|
|
||||||
array<Byte>^ body = gcnew array<Byte>(DroneStreamHead.Size);
|
|
||||||
Array::Copy(DroneStreamData, 0, body, 0, DroneStreamHead.Size);
|
|
||||||
|
|
||||||
int shift = DroneStreamHead.Size;
|
|
||||||
|
|
||||||
DroneStreamIndex -= shift;
|
|
||||||
Array::Copy(DroneStreamData, shift, DroneStreamData, 0, DroneStreamIndex); // Сдвиг массива
|
|
||||||
|
|
||||||
DroneStreamHead.Size = 0; // Сброс заголовка
|
|
||||||
|
|
||||||
ret->Add(ClientRequestResponse(DroneStreamHead, body));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Реализация метода SendRequest
|
|
||||||
array<Byte>^ Drone::SendRequest()
|
|
||||||
{
|
|
||||||
DroneData::DataHead^ acc = gcnew DroneData::DataHead();
|
|
||||||
acc->Size = DroneData::DataHead::StrLen;
|
|
||||||
acc->Mode = DroneData::DataMode::Request;
|
|
||||||
acc->Type = DroneData::DataType::DataAcc;
|
|
||||||
|
|
||||||
DroneData::DataHead^ gyr = gcnew DroneData::DataHead();
|
|
||||||
gyr->Size = DroneData::DataHead::StrLen;
|
|
||||||
gyr->Mode = DroneData::DataMode::Request;
|
|
||||||
gyr->Type = DroneData::DataType::DataGyr;
|
|
||||||
|
|
||||||
DroneData::DataHead^ range = gcnew DroneData::DataHead();
|
|
||||||
range->Size = DroneData::DataHead::StrLen;
|
|
||||||
range->Mode = DroneData::DataMode::Request;
|
|
||||||
range->Type = DroneData::DataType::DataRange;
|
|
||||||
|
|
||||||
DroneData::DataHead^ local = gcnew DroneData::DataHead();
|
|
||||||
local->Size = DroneData::DataHead::StrLen;
|
|
||||||
local->Mode = DroneData::DataMode::Request;
|
|
||||||
local->Type = DroneData::DataType::DataLocal;
|
|
||||||
|
|
||||||
List<array<byte>^>^ list = gcnew List<array<byte>^>();
|
|
||||||
|
|
||||||
list->Add(GetBytes(acc));
|
|
||||||
list->Add(GetBytes(gyr));
|
|
||||||
list->Add(GetBytes(range));
|
|
||||||
list->Add(GetBytes(local));
|
|
||||||
list->Add(SendDataMotor4());
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
for each(array<byte>^ d in list) count += d->Length;
|
|
||||||
|
|
||||||
array<byte>^ send = gcnew array<byte>(count);
|
|
||||||
|
|
||||||
count = 0;
|
|
||||||
for each (array<byte> ^ d in list)
|
|
||||||
{
|
|
||||||
d->CopyTo(send, count);
|
|
||||||
count += d->Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
return send;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "DroneData.h"
|
|
||||||
#include <Windows.h>
|
|
||||||
#include <vcclr.h>
|
|
||||||
|
|
||||||
#using <System.dll>
|
|
||||||
#using <mscorlib.dll>
|
|
||||||
|
|
||||||
using namespace System;
|
|
||||||
using namespace System::Collections::Generic;
|
|
||||||
using namespace System::Runtime::InteropServices;
|
|
||||||
|
|
||||||
namespace DroneClient {
|
|
||||||
|
|
||||||
public ref class Drone
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
float AccX, AccY, AccZ;
|
|
||||||
float GyrX, GyrY, GyrZ;
|
|
||||||
unsigned int TimeAcc, TimeGyr;
|
|
||||||
|
|
||||||
float PosX, PosY;
|
|
||||||
float LaserRange;
|
|
||||||
unsigned int TimeRange;
|
|
||||||
|
|
||||||
float MotorUL, MotorUR, MotorDL, MotorDR;
|
|
||||||
|
|
||||||
static array<Byte>^ GetBytes(Object^ data);
|
|
||||||
static Object^ FromBytes(array<Byte>^ arr, Type^ type);
|
|
||||||
|
|
||||||
private:
|
|
||||||
array<Byte>^ SendDataMotor4();
|
|
||||||
array<Byte>^ RecvDataAcc(array<Byte>^ data);
|
|
||||||
array<Byte>^ RecvDataGyr(array<Byte>^ data);
|
|
||||||
array<Byte>^ RecvDataRange(array<Byte>^ data);
|
|
||||||
array<Byte>^ RecvDataLocal(array<Byte>^ data);
|
|
||||||
array<Byte>^ ClientRequestResponse(DroneData::DataHead head, array<Byte>^ body);
|
|
||||||
|
|
||||||
literal int DroneStreamCount = 512;
|
|
||||||
array<Byte>^ DroneStreamData;
|
|
||||||
int DroneStreamIndex;
|
|
||||||
DroneData::DataHead DroneStreamHead;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Drone(); // Конструктор для инициализации
|
|
||||||
|
|
||||||
System::Collections::Generic::List<array<Byte>^>^ DataStream(array<Byte>^ data, int size);
|
|
||||||
array<Byte>^ SendRequest();
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <Windows.h>
|
|
||||||
#include <vcclr.h>
|
|
||||||
|
|
||||||
#using <System.dll>
|
|
||||||
#using <mscorlib.dll>
|
|
||||||
|
|
||||||
using namespace System;
|
|
||||||
using namespace System::Runtime::InteropServices;
|
|
||||||
|
|
||||||
namespace DroneClient {
|
|
||||||
|
|
||||||
public ref class Drone
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
value struct DataOut
|
|
||||||
{
|
|
||||||
float AccX, AccY, AccZ;
|
|
||||||
float GyrX, GyrY, GyrZ;
|
|
||||||
float PosX, PosY;
|
|
||||||
float LaserRange;
|
|
||||||
};
|
|
||||||
|
|
||||||
value struct DataIn
|
|
||||||
{
|
|
||||||
float MotorUL, MotorUR, MotorDL, MotorDR;
|
|
||||||
};
|
|
||||||
|
|
||||||
static array<Byte>^ GetBytes(Object^ data)
|
|
||||||
{
|
|
||||||
int size = Marshal::SizeOf(data);
|
|
||||||
array<Byte>^ arr = gcnew array<Byte>(size);
|
|
||||||
|
|
||||||
IntPtr ptr = IntPtr::Zero;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ptr = Marshal::AllocHGlobal(size);
|
|
||||||
Marshal::StructureToPtr(data, ptr, true);
|
|
||||||
Marshal::Copy(ptr, arr, 0, size);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Marshal::FreeHGlobal(ptr);
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Object^ FromBytes(array<Byte>^ arr, Type^ type)
|
|
||||||
{
|
|
||||||
int size = Marshal::SizeOf(type);
|
|
||||||
IntPtr ptr = IntPtr::Zero;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ptr = Marshal::AllocHGlobal(size);
|
|
||||||
Marshal::Copy(arr, 0, ptr, size);
|
|
||||||
return Marshal::PtrToStructure(ptr, type);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Marshal::FreeHGlobal(ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 17
|
|
||||||
VisualStudioVersion = 17.12.35527.113
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DroneClientCpp", "DroneClientCpp.vcxproj", "{690C304C-A70B-4B0F-BF61-8C51290BF444}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|x64 = Debug|x64
|
|
||||||
Debug|x86 = Debug|x86
|
|
||||||
Release|x64 = Release|x64
|
|
||||||
Release|x86 = Release|x86
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{690C304C-A70B-4B0F-BF61-8C51290BF444}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{690C304C-A70B-4B0F-BF61-8C51290BF444}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{690C304C-A70B-4B0F-BF61-8C51290BF444}.Debug|x86.ActiveCfg = Debug|Win32
|
|
||||||
{690C304C-A70B-4B0F-BF61-8C51290BF444}.Debug|x86.Build.0 = Debug|Win32
|
|
||||||
{690C304C-A70B-4B0F-BF61-8C51290BF444}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{690C304C-A70B-4B0F-BF61-8C51290BF444}.Release|x64.Build.0 = Release|x64
|
|
||||||
{690C304C-A70B-4B0F-BF61-8C51290BF444}.Release|x86.ActiveCfg = Release|Win32
|
|
||||||
{690C304C-A70B-4B0F-BF61-8C51290BF444}.Release|x86.Build.0 = Release|Win32
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
@ -1,141 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<VCProjectVersion>17.0</VCProjectVersion>
|
|
||||||
<ProjectGuid>{690C304C-A70B-4B0F-BF61-8C51290BF444}</ProjectGuid>
|
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
|
||||||
<Keyword>ManagedCProj</Keyword>
|
|
||||||
<RootNamespace>DroneClientCpp</RootNamespace>
|
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="Shared">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup />
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies />
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies />
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies />
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies />
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Drawing" />
|
|
||||||
<Reference Include="System.Windows.Forms" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="Drone.cpp" />
|
|
||||||
<ClCompile Include="FormMain.cpp" />
|
|
||||||
<ClCompile Include="NetClient.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="Drone.h" />
|
|
||||||
<ClInclude Include="DroneData.h" />
|
|
||||||
<ClInclude Include="FormMain.h">
|
|
||||||
<FileType>CppForm</FileType>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="NetClient.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Include="FormMain.resx">
|
|
||||||
<DependentUpon>FormMain.h</DependentUpon>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
@ -1,42 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="Исходные файлы">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Файлы заголовков">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Файлы ресурсов">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="FormMain.cpp">
|
|
||||||
<Filter>Исходные файлы</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="NetClient.cpp">
|
|
||||||
<Filter>Исходные файлы</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Drone.cpp">
|
|
||||||
<Filter>Исходные файлы</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="FormMain.h">
|
|
||||||
<Filter>Файлы заголовков</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="NetClient.h">
|
|
||||||
<Filter>Файлы заголовков</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="DroneData.h">
|
|
||||||
<Filter>Файлы заголовков</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Drone.h">
|
|
||||||
<Filter>Файлы заголовков</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup />
|
|
||||||
</Project>
|
|
@ -1,117 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <Windows.h>
|
|
||||||
#include <vcclr.h>
|
|
||||||
|
|
||||||
using namespace System;
|
|
||||||
using namespace System::Runtime::InteropServices;
|
|
||||||
|
|
||||||
namespace DroneData {
|
|
||||||
|
|
||||||
public enum class DataMode : unsigned short
|
|
||||||
{
|
|
||||||
None = 0, Response = 1, Request = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
public enum class DataType : unsigned short
|
|
||||||
{
|
|
||||||
None = 0, Head = 1,
|
|
||||||
|
|
||||||
// Output
|
|
||||||
DataAcc = 1001, DataGyr = 1002, DataMag = 1003, DataRange = 1004, DataLocal = 1005,
|
|
||||||
|
|
||||||
// Input
|
|
||||||
DataMotor4 = 2001, DataMotor6 = 2002
|
|
||||||
};
|
|
||||||
|
|
||||||
public value struct DataHead
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
long Size;
|
|
||||||
DataMode Mode;
|
|
||||||
DataType Type;
|
|
||||||
|
|
||||||
unsigned long Time;
|
|
||||||
|
|
||||||
static const int StrLen = sizeof(DataHead);
|
|
||||||
};
|
|
||||||
|
|
||||||
public value struct XYZ
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
float X, Y, Z;
|
|
||||||
};
|
|
||||||
|
|
||||||
public value struct DataAcc
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DataHead Head;
|
|
||||||
XYZ Acc;
|
|
||||||
|
|
||||||
unsigned long Time;
|
|
||||||
|
|
||||||
static const int StrLen = sizeof(DataAcc);
|
|
||||||
};
|
|
||||||
|
|
||||||
public value struct DataGyr
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DataHead Head;
|
|
||||||
XYZ Gyr;
|
|
||||||
|
|
||||||
unsigned long Time;
|
|
||||||
|
|
||||||
static const int StrLen = sizeof(DataGyr);
|
|
||||||
};
|
|
||||||
|
|
||||||
public value struct DataMag
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DataHead Head;
|
|
||||||
XYZ Mag;
|
|
||||||
|
|
||||||
unsigned long Time;
|
|
||||||
|
|
||||||
static const int StrLen = sizeof(DataMag);
|
|
||||||
};
|
|
||||||
|
|
||||||
public value struct DataRange
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DataHead Head;
|
|
||||||
float LiDAR;
|
|
||||||
|
|
||||||
unsigned long Time;
|
|
||||||
|
|
||||||
static const int StrLen = sizeof(DataRange);
|
|
||||||
};
|
|
||||||
|
|
||||||
public value struct DataLocal
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DataHead Head;
|
|
||||||
XYZ Local;
|
|
||||||
|
|
||||||
unsigned long Time;
|
|
||||||
|
|
||||||
static const int StrLen = sizeof(DataLocal);
|
|
||||||
};
|
|
||||||
|
|
||||||
public value struct DataMotor4
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DataHead Head;
|
|
||||||
float UL, UR, DL, DR;
|
|
||||||
|
|
||||||
static const int StrLen = sizeof(DataMotor4);
|
|
||||||
};
|
|
||||||
|
|
||||||
public value struct DataMotor6
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DataHead Head;
|
|
||||||
float UL, UR, LL, RR, DL, DR;
|
|
||||||
|
|
||||||
static const int StrLen = sizeof(DataMotor6);
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
#include "FormMain.h"
|
|
||||||
|
|
||||||
#include <Windows.h>
|
|
||||||
|
|
||||||
using namespace DroneClientCpp;
|
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
|
|
||||||
Application::EnableVisualStyles();
|
|
||||||
Application::SetCompatibleTextRenderingDefault(false);
|
|
||||||
Application::Run(gcnew FormMain);
|
|
||||||
return 0;
|
|
||||||
}
|
|
Binary file not shown.
@ -1,126 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<metadata name="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>310, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
@ -1,12 +0,0 @@
|
|||||||
#include "MyForm.h"
|
|
||||||
|
|
||||||
#include <Windows.h>
|
|
||||||
|
|
||||||
using namespace DroneClientCpp;
|
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
|
|
||||||
Application::EnableVisualStyles();
|
|
||||||
Application::SetCompatibleTextRenderingDefault(false);
|
|
||||||
Application::Run(gcnew MyForm);
|
|
||||||
return 0;
|
|
||||||
}
|
|
Binary file not shown.
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,105 +0,0 @@
|
|||||||
#include "NetClient.h"
|
|
||||||
|
|
||||||
namespace DroneSimulator {
|
|
||||||
|
|
||||||
// Конструктор ConnectData
|
|
||||||
NetClient::ConnectData::ConnectData(bool connect, Socket^ server)
|
|
||||||
{
|
|
||||||
Connect = connect;
|
|
||||||
Server = server;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Конструктор ReceiveData
|
|
||||||
NetClient::ReceiveData::ReceiveData(array<Byte>^ buffer, int size, Socket^ server)
|
|
||||||
{
|
|
||||||
Buffer = buffer;
|
|
||||||
Size = size;
|
|
||||||
Server = server;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Конструктор NetClient
|
|
||||||
NetClient::NetClient()
|
|
||||||
{
|
|
||||||
Connected = false;
|
|
||||||
ServerSocket = nullptr;
|
|
||||||
DataServer = gcnew ServerData(); // Инициализация DataServer
|
|
||||||
}
|
|
||||||
|
|
||||||
// Реализация метода Connect
|
|
||||||
NetClient::ClientState NetClient::Connect(String^ Addr, int Port, ClientCallback^ Connection, ClientCallback^ Receive)
|
|
||||||
{
|
|
||||||
if (Connected)
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
return ClientState::Stop;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConnectionCallback = Connection;
|
|
||||||
ReceiveCallback = Receive;
|
|
||||||
|
|
||||||
IPEndPoint^ ep = gcnew IPEndPoint(IPAddress::Parse(Addr), Port);
|
|
||||||
ServerSocket = gcnew Socket(AddressFamily::InterNetwork, SocketType::Stream, ProtocolType::Tcp);
|
|
||||||
|
|
||||||
try { if (ServerSocket) ServerSocket->Connect(ep); }
|
|
||||||
catch (...) { ServerSocket->Close(); return ClientState::Error; }
|
|
||||||
|
|
||||||
Connected = true;
|
|
||||||
|
|
||||||
ConnectionCallback(gcnew ConnectData(true, ServerSocket));
|
|
||||||
|
|
||||||
ReceiveData^ receiveData = gcnew ReceiveData(DataServer->buffer, ServerData::size, ServerSocket);
|
|
||||||
|
|
||||||
try { if (ServerSocket) ServerSocket->BeginReceive(DataServer->buffer, 0, ServerData::size, SocketFlags::None, gcnew AsyncCallback(this, &NetClient::ReadCallback), receiveData); }
|
|
||||||
catch (...) {}
|
|
||||||
|
|
||||||
return ClientState::Connected;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Реализация метода Close
|
|
||||||
void NetClient::Close()
|
|
||||||
{
|
|
||||||
try { if(ServerSocket) ServerSocket->Shutdown(SocketShutdown::Both); }
|
|
||||||
catch (...) {}
|
|
||||||
if(ServerSocket) ServerSocket->Close();
|
|
||||||
Connected = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Реализация метода Send
|
|
||||||
void NetClient::Send(array<Byte>^ data)
|
|
||||||
{
|
|
||||||
if (ServerSocket != nullptr && Connected)
|
|
||||||
{
|
|
||||||
try { if (ServerSocket) ServerSocket->Send(data); }
|
|
||||||
catch (...) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Реализация метода ReadCallback
|
|
||||||
void NetClient::ReadCallback(IAsyncResult^ ar)
|
|
||||||
{
|
|
||||||
ReceiveData^ cd = (ReceiveData^)ar->AsyncState;
|
|
||||||
if (cd == nullptr) return;
|
|
||||||
|
|
||||||
int bytes = 0;
|
|
||||||
try { bytes = ServerSocket->EndReceive(ar); }
|
|
||||||
catch (...) {}
|
|
||||||
|
|
||||||
if (bytes == 0)
|
|
||||||
{
|
|
||||||
if (ServerSocket) ServerSocket->Close();
|
|
||||||
Connected = false;
|
|
||||||
|
|
||||||
if (ServerSocket != nullptr)
|
|
||||||
{
|
|
||||||
ConnectionCallback(gcnew ConnectData(false, nullptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReceiveCallback(gcnew ReceiveData(cd->Buffer, bytes, ServerSocket));
|
|
||||||
|
|
||||||
try { if (ServerSocket) ServerSocket->BeginReceive(cd->Buffer, 0, ServerData::size, SocketFlags::None, gcnew AsyncCallback(this, &NetClient::ReadCallback), cd); }
|
|
||||||
catch (...) {}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <Windows.h>
|
|
||||||
#include <vcclr.h>
|
|
||||||
|
|
||||||
#using <System.dll>
|
|
||||||
#using <System.Net.dll>
|
|
||||||
|
|
||||||
using namespace System;
|
|
||||||
using namespace System::Net;
|
|
||||||
using namespace System::Net::Sockets;
|
|
||||||
|
|
||||||
namespace DroneSimulator {
|
|
||||||
|
|
||||||
public ref class NetClient
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ref class ConnectData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool Connect;
|
|
||||||
Socket^ Server;
|
|
||||||
|
|
||||||
ConnectData(bool connect, Socket^ server);
|
|
||||||
};
|
|
||||||
|
|
||||||
ref class ReceiveData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
array<Byte>^ Buffer;
|
|
||||||
int Size;
|
|
||||||
Socket^ Server;
|
|
||||||
|
|
||||||
ReceiveData(array<Byte>^ buffer, int size, Socket^ server);
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
ref class ServerData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
literal int size = 1024;
|
|
||||||
array<Byte>^ buffer = gcnew array<Byte>(size);
|
|
||||||
};
|
|
||||||
|
|
||||||
bool Connected;
|
|
||||||
Socket^ ServerSocket;
|
|
||||||
ServerData^ DataServer;
|
|
||||||
|
|
||||||
public:
|
|
||||||
delegate void ClientCallback(Object^ o);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ClientCallback^ ConnectionCallback;
|
|
||||||
ClientCallback^ ReceiveCallback;
|
|
||||||
|
|
||||||
public:
|
|
||||||
NetClient(); // Добавлен конструктор
|
|
||||||
|
|
||||||
enum class ClientState { Error, Connected, Stop };
|
|
||||||
|
|
||||||
ClientState Connect(String^ Addr, int Port, ClientCallback^ Connection, ClientCallback^ Receive);
|
|
||||||
void Close();
|
|
||||||
void Send(array<Byte>^ data);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void ReadCallback(IAsyncResult^ ar);
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
#include "MyForm.h"
|
|
||||||
|
|
||||||
using namespace MyWinFormsApp; // ???????????? ???? ?????? ???????
|
|
||||||
|
|
||||||
[STAThread]
|
|
||||||
int main(array<String^>^ args) {
|
|
||||||
Application::EnableVisualStyles(); // ???????? ??????????? ????? ????????? ??????????
|
|
||||||
Application::SetCompatibleTextRenderingDefault(false); // ????????? ?????????? ??????
|
|
||||||
Application::Run(gcnew MyForm()); // ?????? ?????
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -2,9 +2,6 @@
|
|||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using static DroneSimulator.Drone;
|
|
||||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
||||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
|
|
||||||
|
|
||||||
namespace DroneSimulator
|
namespace DroneSimulator
|
||||||
{
|
{
|
||||||
@ -24,8 +21,6 @@ namespace DroneSimulator
|
|||||||
public Vector3 Acc, Gyr; // Имитация: Акселерометр, Гироскоп
|
public Vector3 Acc, Gyr; // Имитация: Акселерометр, Гироскоп
|
||||||
public float LaserRange; // Имитация: Дальномер
|
public float LaserRange; // Имитация: Дальномер
|
||||||
|
|
||||||
private uint DataTimer;
|
|
||||||
|
|
||||||
private const float Gravity = 9.8f;
|
private const float Gravity = 9.8f;
|
||||||
|
|
||||||
private const float TO_GRAD = 180 / MathF.PI;
|
private const float TO_GRAD = 180 / MathF.PI;
|
||||||
@ -34,13 +29,7 @@ namespace DroneSimulator
|
|||||||
private Thread DroneThread;
|
private Thread DroneThread;
|
||||||
private int Timer;
|
private int Timer;
|
||||||
|
|
||||||
private Random MainRandom = new Random();
|
private static int CounterID = 0;
|
||||||
|
|
||||||
RealMode.Accelerometer RealAcc = new RealMode.Accelerometer();
|
|
||||||
RealMode.Gyroscope RealGyr = new RealMode.Gyroscope();
|
|
||||||
RealMode.Position RealPos = new RealMode.Position();
|
|
||||||
RealMode.Barometer RealBar = new RealMode.Barometer();
|
|
||||||
RealMode.Range RealRange = new RealMode.Range();
|
|
||||||
|
|
||||||
public static byte[] getBytes(object data)
|
public static byte[] getBytes(object data)
|
||||||
{
|
{
|
||||||
@ -83,6 +72,33 @@ namespace DroneSimulator
|
|||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*public struct DataOut
|
||||||
|
{
|
||||||
|
public float AccX, AccY, AccZ;
|
||||||
|
public float GyrX, GyrY, GyrZ;
|
||||||
|
public float PosX, PosY;
|
||||||
|
public float LaserRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataOut GetDataOut()
|
||||||
|
{
|
||||||
|
DataOut data = new DataOut();
|
||||||
|
|
||||||
|
data.AccX = Acc.X; data.AccY = Acc.Y; data.AccZ = Acc.Z;
|
||||||
|
data.GyrX = Gyr.X; data.GyrY = Gyr.Y; data.GyrZ = Gyr.Z;
|
||||||
|
|
||||||
|
data.PosX = PosXYZ.X; data.PosY = PosXYZ.Y;
|
||||||
|
|
||||||
|
data.LaserRange = LaserRange;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct DataIn
|
||||||
|
{
|
||||||
|
public float MotorUL, MotorUR, MotorDL, MotorDR;
|
||||||
|
}*/
|
||||||
|
|
||||||
public struct DataVisual
|
public struct DataVisual
|
||||||
{
|
{
|
||||||
public int ID; // Идентификатор
|
public int ID; // Идентификатор
|
||||||
@ -248,14 +264,6 @@ namespace DroneSimulator
|
|||||||
if (tilt < 90 && ori.W > 0) LaserRange = PosXYZ.Z / MathF.Cos(tilt);
|
if (tilt < 90 && ori.W > 0) LaserRange = PosXYZ.Z / MathF.Cos(tilt);
|
||||||
else LaserRange = float.MaxValue;
|
else LaserRange = float.MaxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
RealAcc.Update(Acc, (uint)tick);
|
|
||||||
RealGyr.Update(Gyr, (uint)tick);
|
|
||||||
RealRange.Update(LaserRange, (uint)tick);
|
|
||||||
RealBar.Update(PosXYZ.Z * 11, (uint)tick);
|
|
||||||
RealPos.Update(PosXYZ, (uint)tick);
|
|
||||||
|
|
||||||
DataTimer = (uint)tick;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private float Range(float pow)
|
private float Range(float pow)
|
||||||
@ -284,94 +292,33 @@ namespace DroneSimulator
|
|||||||
SetQadroPow(mot.UL, mot.UR, mot.DL, mot.DR);
|
SetQadroPow(mot.UL, mot.UR, mot.DL, mot.DR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] SendDataAcc()
|
private byte[] SendDataIMU()
|
||||||
{
|
{
|
||||||
DroneData.DataAcc acc = new DroneData.DataAcc();
|
DroneData.DataIMU imu = new DroneData.DataIMU();
|
||||||
|
|
||||||
acc.Head.Size = Marshal.SizeOf(typeof(DroneData.DataAcc));
|
imu.Head.Size = Marshal.SizeOf(typeof(DroneData.DataIMU));
|
||||||
acc.Head.Mode = DroneData.DataMode.Response;
|
imu.Head.Mode = DroneData.DataMode.Response;
|
||||||
acc.Head.Type = DroneData.DataType.DataAcc;
|
imu.Head.Type = DroneData.DataType.DataIMU;
|
||||||
acc.Head.Time = (uint)Environment.TickCount;
|
|
||||||
|
|
||||||
acc.Acc.X = RealAcc.result.X; acc.Acc.Y = RealAcc.result.Y; acc.Acc.Z = RealAcc.result.Z;
|
imu.Acc.X = Acc.X; imu.Acc.Y = Acc.Y; imu.Acc.Z = Acc.Z;
|
||||||
acc.Time = RealAcc.timer;
|
imu.Gyr.X = Gyr.X; imu.Gyr.Y = Gyr.Y; imu.Gyr.Z = Gyr.Z;
|
||||||
|
imu.Mag.X = 0; imu.Mag.Y = 0; imu.Mag.Z = 0;
|
||||||
|
|
||||||
return getBytes(acc);
|
return getBytes(imu);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] SendDataGyr()
|
private byte[] SendDataPos()
|
||||||
{
|
{
|
||||||
DroneData.DataGyr gyr = new DroneData.DataGyr();
|
DroneData.DataPos pos = new DroneData.DataPos();
|
||||||
|
|
||||||
gyr.Head.Size = Marshal.SizeOf(typeof(DroneData.DataGyr));
|
pos.Head.Size = Marshal.SizeOf(typeof(DroneData.DataPos));
|
||||||
gyr.Head.Mode = DroneData.DataMode.Response;
|
pos.Head.Mode = DroneData.DataMode.Response;
|
||||||
gyr.Head.Type = DroneData.DataType.DataGyr;
|
pos.Head.Type = DroneData.DataType.DataPos;
|
||||||
gyr.Head.Time = (uint)Environment.TickCount;
|
|
||||||
|
|
||||||
gyr.Gyr.X = RealGyr.result.X; gyr.Gyr.Y = RealGyr.result.Y; gyr.Gyr.Z = RealGyr.result.Z;
|
pos.Local.X = PosXYZ.X; pos.Local.Y = PosXYZ.Y; pos.Local.Z = PosXYZ.Z;
|
||||||
gyr.Time = RealGyr.timer;
|
pos.LiDAR = LaserRange;
|
||||||
|
|
||||||
return getBytes(gyr);
|
return getBytes(pos);
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] SendDataMag()
|
|
||||||
{
|
|
||||||
DroneData.DataMag mag = new DroneData.DataMag();
|
|
||||||
|
|
||||||
mag.Head.Size = Marshal.SizeOf(typeof(DroneData.DataMag));
|
|
||||||
mag.Head.Mode = DroneData.DataMode.Response;
|
|
||||||
mag.Head.Type = DroneData.DataType.DataMag;
|
|
||||||
mag.Head.Time = (uint)Environment.TickCount;
|
|
||||||
|
|
||||||
mag.Mag.X = 0; mag.Mag.Y = 0; mag.Mag.Z = 0;
|
|
||||||
mag.Time = DataTimer;
|
|
||||||
|
|
||||||
return getBytes(mag);
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] SendDataRange()
|
|
||||||
{
|
|
||||||
DroneData.DataRange range = new DroneData.DataRange();
|
|
||||||
|
|
||||||
range.Head.Size = Marshal.SizeOf(typeof(DroneData.DataRange));
|
|
||||||
range.Head.Mode = DroneData.DataMode.Response;
|
|
||||||
range.Head.Type = DroneData.DataType.DataRange;
|
|
||||||
range.Head.Time = (uint)Environment.TickCount;
|
|
||||||
|
|
||||||
range.LiDAR = RealRange.result;
|
|
||||||
range.Time = RealRange.timer;
|
|
||||||
|
|
||||||
return getBytes(range);
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] SendDataLocal()
|
|
||||||
{
|
|
||||||
DroneData.DataLocal local = new DroneData.DataLocal();
|
|
||||||
|
|
||||||
local.Head.Size = Marshal.SizeOf(typeof(DroneData.DataLocal));
|
|
||||||
local.Head.Mode = DroneData.DataMode.Response;
|
|
||||||
local.Head.Type = DroneData.DataType.DataLocal;
|
|
||||||
local.Head.Time = (uint)Environment.TickCount;
|
|
||||||
|
|
||||||
local.Local.X = RealPos.result.X; local.Local.Y = RealPos.result.Y; local.Local.Z = RealPos.result.Z;
|
|
||||||
local.Time = RealPos.timer;
|
|
||||||
|
|
||||||
return getBytes(local);
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] SendDataBarometer()
|
|
||||||
{
|
|
||||||
DroneData.DataBar bar = new DroneData.DataBar();
|
|
||||||
|
|
||||||
bar.Head.Size = Marshal.SizeOf(typeof(DroneData.DataBar));
|
|
||||||
bar.Head.Mode = DroneData.DataMode.Response;
|
|
||||||
bar.Head.Type = DroneData.DataType.DataBar;
|
|
||||||
bar.Head.Time = (uint)Environment.TickCount;
|
|
||||||
|
|
||||||
bar.Pressure = RealBar.result;
|
|
||||||
bar.Time = RealBar.timer;
|
|
||||||
|
|
||||||
return getBytes(bar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[]? ServerRequestResponse(DroneData.DataHead head, byte[] body)
|
private byte[]? ServerRequestResponse(DroneData.DataHead head, byte[] body)
|
||||||
@ -380,12 +327,12 @@ namespace DroneSimulator
|
|||||||
|
|
||||||
switch (head.Type)
|
switch (head.Type)
|
||||||
{
|
{
|
||||||
case DroneData.DataType.DataAcc:
|
case DroneData.DataType.DataIMU:
|
||||||
{
|
{
|
||||||
if (head.Mode == DroneData.DataMode.Request)
|
if (head.Mode == DroneData.DataMode.Request)
|
||||||
{
|
{
|
||||||
// Запрос данных
|
// Запрос данных
|
||||||
return SendDataAcc();
|
return SendDataIMU();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -396,17 +343,38 @@ namespace DroneSimulator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case DroneData.DataType.DataGyr: if (head.Mode == DroneData.DataMode.Request) return SendDataGyr(); else return zero;
|
case DroneData.DataType.DataPos:
|
||||||
|
{
|
||||||
|
if (head.Mode == DroneData.DataMode.Request)
|
||||||
|
{
|
||||||
|
// Запрос данных
|
||||||
|
return SendDataPos();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Пришли данные
|
||||||
|
// ... //
|
||||||
|
//
|
||||||
|
return zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case DroneData.DataType.DataMag: if (head.Mode == DroneData.DataMode.Request) return SendDataMag(); else return zero;
|
case DroneData.DataType.DataMotor4:
|
||||||
|
{
|
||||||
case DroneData.DataType.DataRange: if (head.Mode == DroneData.DataMode.Request) return SendDataRange(); else return zero;
|
if (head.Mode == DroneData.DataMode.Request)
|
||||||
|
{
|
||||||
case DroneData.DataType.DataLocal: if (head.Mode == DroneData.DataMode.Request) return SendDataLocal(); else return zero;
|
// Запрос данных
|
||||||
|
// ... //
|
||||||
case DroneData.DataType.DataBar: if (head.Mode == DroneData.DataMode.Request) return SendDataBarometer(); else return zero;
|
//
|
||||||
|
return zero;
|
||||||
case DroneData.DataType.DataMotor4: if (head.Mode == DroneData.DataMode.Response) RecvDataMotor4(body); return zero;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Пришли данные
|
||||||
|
RecvDataMotor4(body);
|
||||||
|
return zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return zero;
|
return zero;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace DroneData
|
namespace DroneData
|
||||||
{
|
{
|
||||||
@ -12,7 +12,7 @@ namespace DroneData
|
|||||||
None = 0, Head = 1,
|
None = 0, Head = 1,
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
DataAcc = 1001, DataGyr = 1002, DataMag = 1003, DataRange = 1004, DataLocal = 1005, DataBar = 1006,
|
DataIMU = 1001, DataPos = 1002,
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
DataMotor4 = 2001, DataMotor6 = 2002
|
DataMotor4 = 2001, DataMotor6 = 2002
|
||||||
@ -25,76 +25,32 @@ namespace DroneData
|
|||||||
public DataMode Mode;
|
public DataMode Mode;
|
||||||
public DataType Type;
|
public DataType Type;
|
||||||
|
|
||||||
public uint Time; // Общее время
|
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataHead));
|
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataHead));
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct XYZ { public float X, Y, Z; }
|
public struct XYZ { public float X, Y, Z; }
|
||||||
|
|
||||||
public struct DataAcc
|
public struct DataIMU
|
||||||
{
|
{
|
||||||
public DataHead Head;
|
public DataHead Head;
|
||||||
public XYZ Acc;
|
public XYZ Acc, Gyr, Mag;
|
||||||
|
|
||||||
public uint Time; // Последнее время изменения данных
|
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataIMU));
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataAcc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct DataGyr
|
public struct DataPos
|
||||||
{
|
{
|
||||||
public DataHead Head;
|
public DataHead Head;
|
||||||
public XYZ Gyr;
|
public XYZ Local; // Ëîêàëüíûå êîîðäèíàòû
|
||||||
|
public float LiDAR; // Äàò÷èê ïîñàäêè
|
||||||
|
|
||||||
public uint Time; // Последнее время изменения данных
|
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataPos));
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataGyr));
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct DataMag
|
|
||||||
{
|
|
||||||
public DataHead Head;
|
|
||||||
public XYZ Mag;
|
|
||||||
|
|
||||||
public uint Time; // Последнее время изменения данных
|
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataMag));
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct DataRange
|
|
||||||
{
|
|
||||||
public DataHead Head;
|
|
||||||
public float LiDAR; // Датчик посадки
|
|
||||||
|
|
||||||
public uint Time; // Последнее время изменения данных
|
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataRange));
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct DataLocal
|
|
||||||
{
|
|
||||||
public DataHead Head;
|
|
||||||
public XYZ Local; // Локальные координаты
|
|
||||||
|
|
||||||
public uint Time; // Последнее время изменения данных
|
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataLocal));
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct DataBar
|
|
||||||
{
|
|
||||||
public DataHead Head;
|
|
||||||
public float Pressure; // Давление
|
|
||||||
|
|
||||||
public uint Time; // Последнее время изменения данных
|
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataBar));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct DataMotor4
|
public struct DataMotor4
|
||||||
{
|
{
|
||||||
public DataHead Head;
|
public DataHead Head;
|
||||||
|
public ulong Count;
|
||||||
public float UL, UR, DL, DR;
|
public float UL, UR, DL, DR;
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataMotor4));
|
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataMotor4));
|
||||||
@ -103,8 +59,9 @@ namespace DroneData
|
|||||||
public struct DataMotor6
|
public struct DataMotor6
|
||||||
{
|
{
|
||||||
public DataHead Head;
|
public DataHead Head;
|
||||||
|
public ulong Count;
|
||||||
public float UL, UR, LL, RR, DL, DR;
|
public float UL, UR, LL, RR, DL, DR;
|
||||||
|
|
||||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataMotor6));
|
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataMotor6));
|
||||||
}
|
}
|
||||||
}
|
}
|
1390
DroneSimulator/FormMain.Designer.cs
generated
1390
DroneSimulator/FormMain.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using static System.Net.Mime.MediaTypeNames;
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
@ -22,13 +22,6 @@ namespace DroneSimulator
|
|||||||
public Form_Main()
|
public Form_Main()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
RealMode.RealSimulation = checkBox_Mode_Real.Checked;
|
|
||||||
numericUpDown_Acc_Update(null, null);
|
|
||||||
numericUpDown_Gyr_Update(null, null);
|
|
||||||
numericUpDown_Pos_Update(null, null);
|
|
||||||
numericUpDown_Bar_Update(null, null);
|
|
||||||
numericUpDown_Range_Update(null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClientConnectionCallback(object o)
|
private void ClientConnectionCallback(object o)
|
||||||
@ -82,7 +75,7 @@ namespace DroneSimulator
|
|||||||
List<byte[]?>? send = drone.DataStream(data.Buffer, data.Size);
|
List<byte[]?>? send = drone.DataStream(data.Buffer, data.Size);
|
||||||
|
|
||||||
if (send == null) return;
|
if (send == null) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (byte[]? b in send)
|
foreach (byte[]? b in send)
|
||||||
{
|
{
|
||||||
@ -211,65 +204,5 @@ namespace DroneSimulator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void numericUpDown_Bar_Update(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try { RealMode.Barometer.Pressure = uint.Parse(textBox_Bar_Pressure.Text); }
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
RealMode.Barometer.Pressure = 102258;
|
|
||||||
MessageBox.Show("Pressure invalid format", "Barometer error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RealMode.Barometer.Freq = (uint)numericUpDown_Bar_Freq.Value;
|
|
||||||
RealMode.Barometer.Noise = (float)numericUpDown_Bar_Noise.Value;
|
|
||||||
RealMode.Barometer.Lateness = (float)numericUpDown_Bar_Laten.Value;
|
|
||||||
RealMode.Barometer.Enable = checkBox_Bar_Enable.Checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkBox_Mode_Real_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
RealMode.RealSimulation = checkBox_Mode_Real.Checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void numericUpDown_Acc_Update(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
RealMode.Accelerometer.Freq = (uint)numericUpDown_Acc_Freq.Value;
|
|
||||||
RealMode.Accelerometer.Noise = (float)numericUpDown_Acc_Noise.Value;
|
|
||||||
RealMode.Accelerometer.Lateness = (float)numericUpDown_Acc_Laten.Value;
|
|
||||||
|
|
||||||
RealMode.Accelerometer.ScaleLeft = (float)numericUpDown_Acc_Scale_Left.Value;
|
|
||||||
RealMode.Accelerometer.ScaleRight = (float)numericUpDown_Acc_Scale_Rigth.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void numericUpDown_Gyr_Update(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
RealMode.Gyroscope.Freq = (uint)numericUpDown_Gyr_Freq.Value;
|
|
||||||
RealMode.Gyroscope.Noise = (float)numericUpDown_Gyr_Noise.Value;
|
|
||||||
RealMode.Gyroscope.Lateness = (float)numericUpDown_Gyr_Laten.Value;
|
|
||||||
|
|
||||||
RealMode.Gyroscope.Shift.X = (float)numericUpDown_Gyr_Shift_X.Value;
|
|
||||||
RealMode.Gyroscope.Shift.Y = (float)numericUpDown_Gyr_Shift_Y.Value;
|
|
||||||
RealMode.Gyroscope.Shift.Z = (float)numericUpDown_Gyr_Shift_Z.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void numericUpDown_Pos_Update(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
RealMode.Position.Freq = (uint)numericUpDown_Pos_Freq.Value;
|
|
||||||
RealMode.Position.Noise = (float)numericUpDown_Pos_Noise.Value;
|
|
||||||
RealMode.Position.Lateness = (float)numericUpDown_Pos_Laten.Value;
|
|
||||||
RealMode.Position.Enable = checkBox_Pos_Enable.Checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void numericUpDown_Range_Update(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
RealMode.Range.Freq = (uint)numericUpDown_Range_Freq.Value;
|
|
||||||
RealMode.Range.Noise = (float)numericUpDown_Range_Noise.Value;
|
|
||||||
RealMode.Range.Lateness = (float)numericUpDown_Range_Laten.Value;
|
|
||||||
RealMode.Range.Enable = checkBox_Range_Enable.Checked;
|
|
||||||
|
|
||||||
RealMode.Range.MaxHeight = (float)numericUpDown_Range_Max.Value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,333 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Numerics;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace DroneSimulator
|
|
||||||
{
|
|
||||||
internal class RealMode
|
|
||||||
{
|
|
||||||
public static bool RealSimulation;
|
|
||||||
|
|
||||||
internal class Accelerometer
|
|
||||||
{
|
|
||||||
public static uint Freq;
|
|
||||||
public static float Noise;
|
|
||||||
public static float ScaleLeft;
|
|
||||||
public static float ScaleRight;
|
|
||||||
public static float Lateness;
|
|
||||||
|
|
||||||
private uint last = 0;
|
|
||||||
|
|
||||||
private Random rand = new Random();
|
|
||||||
|
|
||||||
private const int count = 1000;
|
|
||||||
private Vector3[] laten = new Vector3[count];
|
|
||||||
private uint index = 0;
|
|
||||||
|
|
||||||
public uint timer = 0;
|
|
||||||
public Vector3 result;
|
|
||||||
|
|
||||||
public void Update(Vector3 value, uint time)
|
|
||||||
{
|
|
||||||
if (!RealSimulation)
|
|
||||||
{
|
|
||||||
result = value;
|
|
||||||
timer = time;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
float scale = (ScaleRight - ScaleLeft) / 2;
|
|
||||||
float shift = scale + ScaleLeft;
|
|
||||||
|
|
||||||
value.X = (value.X * scale) + shift;
|
|
||||||
value.Y = (value.Y * scale) + shift;
|
|
||||||
value.Z = (value.Z * scale) + shift;
|
|
||||||
|
|
||||||
int noise = (int)(Noise * 1000);
|
|
||||||
value.X += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
value.Y += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
value.Z += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
|
|
||||||
uint clock = (uint)(Lateness * 1000);
|
|
||||||
|
|
||||||
uint tick = time - last;
|
|
||||||
last = time;
|
|
||||||
while (tick != 0)
|
|
||||||
{
|
|
||||||
tick--;
|
|
||||||
laten[index++] = value;
|
|
||||||
if (index >= clock) index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = laten[index];
|
|
||||||
|
|
||||||
uint freq = 1000 / Freq;
|
|
||||||
|
|
||||||
if (timer + freq < time)
|
|
||||||
{
|
|
||||||
result = value;
|
|
||||||
timer = time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class Gyroscope
|
|
||||||
{
|
|
||||||
public static uint Freq;
|
|
||||||
public static float Noise;
|
|
||||||
public static Vector3 Shift;
|
|
||||||
public static float Lateness;
|
|
||||||
|
|
||||||
private uint last = 0;
|
|
||||||
|
|
||||||
private Random rand = new Random();
|
|
||||||
|
|
||||||
private const int count = 1000;
|
|
||||||
private Vector3[] laten = new Vector3[count];
|
|
||||||
private uint index = 0;
|
|
||||||
|
|
||||||
public uint timer = 0;
|
|
||||||
public Vector3 result;
|
|
||||||
|
|
||||||
public void Update(Vector3 value, uint time)
|
|
||||||
{
|
|
||||||
if (!RealSimulation)
|
|
||||||
{
|
|
||||||
result = value;
|
|
||||||
timer = time;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
value.X += Shift.X;
|
|
||||||
value.Y += Shift.Y;
|
|
||||||
value.Z += Shift.Z;
|
|
||||||
|
|
||||||
int noise = (int)(Noise * 1000);
|
|
||||||
value.X += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
value.Y += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
value.Z += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
|
|
||||||
uint clock = (uint)(Lateness * 1000);
|
|
||||||
|
|
||||||
uint tick = time - last;
|
|
||||||
last = time;
|
|
||||||
while (tick != 0)
|
|
||||||
{
|
|
||||||
tick--;
|
|
||||||
laten[index++] = value;
|
|
||||||
if (index >= clock) index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = laten[index];
|
|
||||||
|
|
||||||
uint freq = 1000 / Freq;
|
|
||||||
|
|
||||||
if (timer + freq < time)
|
|
||||||
{
|
|
||||||
result = value;
|
|
||||||
timer = time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class Magnetometer
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class Position
|
|
||||||
{
|
|
||||||
public static bool Enable;
|
|
||||||
public static uint Freq;
|
|
||||||
public static float Noise;
|
|
||||||
public static float Lateness;
|
|
||||||
|
|
||||||
private uint last = 0;
|
|
||||||
|
|
||||||
private Random rand = new Random();
|
|
||||||
|
|
||||||
private const int count = 1000;
|
|
||||||
private Vector3[] laten = new Vector3[count];
|
|
||||||
private uint index = 0;
|
|
||||||
|
|
||||||
public uint timer = 0;
|
|
||||||
public Vector3 result;
|
|
||||||
|
|
||||||
public void Update(Vector3 value, uint time)
|
|
||||||
{
|
|
||||||
if (!RealSimulation)
|
|
||||||
{
|
|
||||||
result = value;
|
|
||||||
timer = time;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Enable)
|
|
||||||
{
|
|
||||||
result = Vector3.NaN;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int noise = (int)(Noise * 1000);
|
|
||||||
value.X += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
value.Y += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
value.Z += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
|
|
||||||
uint clock = (uint)(Lateness * 1000);
|
|
||||||
|
|
||||||
uint tick = time - last;
|
|
||||||
last = time;
|
|
||||||
while (tick != 0)
|
|
||||||
{
|
|
||||||
tick--;
|
|
||||||
laten[index++] = value;
|
|
||||||
if (index >= clock) index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = laten[index];
|
|
||||||
|
|
||||||
uint freq = 1000 / Freq;
|
|
||||||
|
|
||||||
if (timer + freq < time)
|
|
||||||
{
|
|
||||||
result = value;
|
|
||||||
timer = time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class Barometer
|
|
||||||
{
|
|
||||||
public static bool Enable;
|
|
||||||
public static float Pressure;
|
|
||||||
public static uint Freq;
|
|
||||||
public static float Noise;
|
|
||||||
public static float Lateness;
|
|
||||||
|
|
||||||
private uint last = 0;
|
|
||||||
|
|
||||||
private Random rand = new Random();
|
|
||||||
|
|
||||||
private const int count = 1000;
|
|
||||||
private float[] laten = new float[count];
|
|
||||||
private uint index = 0;
|
|
||||||
|
|
||||||
public uint timer = 0;
|
|
||||||
public float result;
|
|
||||||
|
|
||||||
public void Update(float value, uint time)
|
|
||||||
{
|
|
||||||
value = Pressure - value;
|
|
||||||
|
|
||||||
if (!RealSimulation)
|
|
||||||
{
|
|
||||||
result = value;
|
|
||||||
timer = time;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Enable)
|
|
||||||
{
|
|
||||||
result = float.NaN;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int noise = (int)(Noise * 1000);
|
|
||||||
value += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
|
|
||||||
uint clock = (uint)(Lateness * 1000);
|
|
||||||
|
|
||||||
uint tick = time - last;
|
|
||||||
last = time;
|
|
||||||
while (tick != 0)
|
|
||||||
{
|
|
||||||
tick--;
|
|
||||||
laten[index++] = value;
|
|
||||||
if (index >= clock) index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = laten[index];
|
|
||||||
|
|
||||||
uint freq = 1000 / Freq;
|
|
||||||
|
|
||||||
if (timer + freq < time)
|
|
||||||
{
|
|
||||||
result = value;
|
|
||||||
timer = time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class OpticalFlow
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class Range
|
|
||||||
{
|
|
||||||
public static bool Enable;
|
|
||||||
public static float MaxHeight;
|
|
||||||
public static uint Freq;
|
|
||||||
public static float Noise;
|
|
||||||
public static float Lateness;
|
|
||||||
|
|
||||||
private uint last = 0;
|
|
||||||
|
|
||||||
private Random rand = new Random();
|
|
||||||
|
|
||||||
private const int count = 1000;
|
|
||||||
private float[] laten = new float[count];
|
|
||||||
private uint index = 0;
|
|
||||||
|
|
||||||
public uint timer = 0;
|
|
||||||
public float result;
|
|
||||||
|
|
||||||
public void Update(float value, uint time)
|
|
||||||
{
|
|
||||||
if (!RealSimulation)
|
|
||||||
{
|
|
||||||
result = value;
|
|
||||||
timer = time;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Enable)
|
|
||||||
{
|
|
||||||
result = float.NaN;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value > MaxHeight) value = -1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int noise = (int)(Noise * 1000);
|
|
||||||
value += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint clock = (uint)(Lateness * 1000);
|
|
||||||
|
|
||||||
uint tick = time - last;
|
|
||||||
last = time;
|
|
||||||
while (tick != 0)
|
|
||||||
{
|
|
||||||
tick--;
|
|
||||||
laten[index++] = value;
|
|
||||||
if (index >= clock) index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = laten[index];
|
|
||||||
|
|
||||||
uint freq = 1000 / Freq;
|
|
||||||
|
|
||||||
if (timer + freq < time)
|
|
||||||
{
|
|
||||||
result = value;
|
|
||||||
timer = time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user