mlat test now creates a cheesy moving simulated aircraft. mlat is broken though due to incorrect assumptions in the solver.

This commit is contained in:
Nick Foster
2012-12-06 13:04:11 -08:00
parent e771c21730
commit c7e216bca0
3 changed files with 144 additions and 75 deletions
+25 -9
View File
@@ -2,7 +2,8 @@
#test stuff for mlat server
import socket, pickle, time, random, sys
import socket, pickle, time, random, sys, math, numpy
import air_modes
class rx_data:
secs = 0
@@ -12,17 +13,13 @@ class rx_data:
class client_info:
def __init__(self):
self.name = ""
self.latitude = 0.0
self.longitude = 0.0
self.altitude = 0.0
self.position = []
self.offset_secs = 0
self.offset_frac_secs = 0.0
info = client_info()
info.name = sys.argv[1]
info.latitude = float(sys.argv[2])
info.longitude = float(sys.argv[3])
info.altitude = 123
info.position = [float(sys.argv[2]), float(sys.argv[3]), 100]
info.offset_secs = 0
info.offset_frac_secs = 0.0
@@ -30,15 +27,34 @@ data1 = rx_data()
data1.secs = 0
data1.data = int("0x8da81f875857f10eb65b10cb66f3", 16)
ac_starting_pos = [37.617175, -122.400843, 8000]
ac_hdg = 130.
ac_spd = 0.00008
def get_pos(time):
return [ac_starting_pos[0] + ac_spd * time * math.cos(ac_hdg*math.pi/180.), \
ac_starting_pos[1] + ac_spd * time * math.sin(ac_hdg*math.pi/180.), \
ac_starting_pos[2]]
def get_simulated_timestamp(time, position):
return time + numpy.linalg.norm(numpy.array(air_modes.mlat.llh2ecef(position))-numpy.array(air_modes.mlat.llh2geoid(info.position))) / air_modes.mlat.c
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setblocking(1)
sock.connect(("localhost", 31337))
sock.send(pickle.dumps(info))
print sock.recv(1024)
ts = 0.0
while 1:
time.sleep(0.05)
data1.frac_secs = random.random()
pos = get_pos(ts)
stamp = get_simulated_timestamp(ts, pos)
print "Timestamp: %.10f" % (stamp)
print "Position: ", pos
data1.secs = int(stamp)
data1.frac_secs = float(stamp)
data1.frac_secs -= int(data1.frac_secs)
sock.send(pickle.dumps([data1]))
ts+=1
time.sleep(1)
sock.close()
sock = None