This commit is contained in:
2025-06-05 00:13:53 +03:00
parent 2d56ea0ae1
commit a97e618695
3 changed files with 141 additions and 86 deletions

View File

@ -10,7 +10,7 @@ namespace DroneSimulator
{
internal class RealMode
{
public static bool RealSimulation;
internal class Accelerometer
{
@ -19,6 +19,7 @@ namespace DroneSimulator
public static float ScaleLeft;
public static float ScaleRight;
public static float Lateness;
public static bool RealSimulation;
private uint last = 0;
@ -81,6 +82,7 @@ namespace DroneSimulator
public static float Noise;
public static Vector3 Shift;
public static float Lateness;
public static bool RealSimulation;
private uint last = 0;
@ -145,6 +147,7 @@ namespace DroneSimulator
public static uint Freq;
public static float Noise;
public static float Lateness;
public static bool RealSimulation;
private uint last = 0;
@ -159,6 +162,12 @@ namespace DroneSimulator
public void Update(Vector3 value, uint time)
{
if (!Enable)
{
result = Vector3.NaN;
return;
}
if (!RealSimulation)
{
result = value;
@ -166,12 +175,6 @@ namespace DroneSimulator
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;
@ -207,6 +210,7 @@ namespace DroneSimulator
public static uint Freq;
public static float Noise;
public static float Lateness;
public static bool RealSimulation;
private uint last = 0;
@ -223,6 +227,12 @@ namespace DroneSimulator
{
value = Pressure - value;
if (!Enable)
{
result = float.NaN;
return;
}
if (!RealSimulation)
{
result = value;
@ -230,12 +240,6 @@ namespace DroneSimulator
return;
}
if (!Enable)
{
result = float.NaN;
return;
}
int noise = (int)(Noise * 1000);
value += ((float)rand.Next(-noise, noise)) / 1000;
@ -272,6 +276,7 @@ namespace DroneSimulator
public static float Error;
public static uint Wait;
public static float Lens;
public static bool RealSimulation;
private uint last = 0;
@ -287,6 +292,12 @@ namespace DroneSimulator
public Vector2 result;
public void Update(Vector2 value, float Range, uint time)
{
if (!Enable)
{
result = Vector2.NaN;
return;
}
if (!RealSimulation)
{
result = value;
@ -294,12 +305,6 @@ namespace DroneSimulator
return;
}
if (!Enable)
{
result = Vector2.NaN;
return;
}
value *= Lens;
if (rand.Next(0, 1000) < (Error * 10))
@ -350,6 +355,7 @@ namespace DroneSimulator
public static uint Freq;
public static float Noise;
public static float Lateness;
public static bool RealSimulation;
private uint last = 0;
@ -364,6 +370,12 @@ namespace DroneSimulator
public void Update(float value, uint time)
{
if (!Enable)
{
result = float.NaN;
return;
}
if (!RealSimulation)
{
result = value;
@ -371,13 +383,7 @@ namespace DroneSimulator
return;
}
if (!Enable)
{
result = float.NaN;
return;
}
if (value > MaxHeight) value = -1;
if (value > MaxHeight) value = MaxHeight;
else
{
int noise = (int)(Noise * 1000);