In [1]:
using JSON
using Winston

In [7]:
client = connect(ip"127.0.0.1",5510)
println("Connected")


Connected

In [3]:
function lla2flatearth!(msg)
    Tlat = 37.61633
    Tlon = -122.38334
    Re = 6378137
    y = Re*(msg["LAT"]*180.0/pi - Tlat)*pi/180.0
    x = Re*(msg["LON"]*180.0/pi - Tlon)*pi/180.0
    return x, y
end


Out[3]:
lla2flatearth! (generic function with 1 method)

In [13]:
channel = "REQUEST_DATA"
my_dict = ["CHANNEL"=> channel]
reqPosMsg = json(my_dict)
print(client,reqPosMsg)
msgdata = readline(client)
msg = JSON.parse(msgdata)
x, y = lla2flatearth!(msg)
println("X: ", x, " |  Y: " ,y)
println(msg["HEADING"]*180.0/pi)
msg


X: 1729.5466349822132 |  Y: -1814.1552645733886
155.96384531962946
Out[13]:
Dict{String,Any} with 14 entries:
  "THETA"     => 0.024502521380782127
  "CHANNEL"   => "GLIDER_STATE"
  "CUR_INDEX" => 0
  "V_EAST"    => 10.240508651733398
  "HEADING"   => 2.7220826148986816
  "LON"       => -2.1357210645906615
  "PHI"       => -1.9179429955329397e-7
  "ALT"       => 816.4435091577981
  "V_NORTH"   => -22.961617053222657
  "VCAS"      => 14.204144622802735
  "LAT"       => 0.6562443776054303
  "V_DOWN"    => 0.993510287475586
  "BETA"      => 0.0
  "ALPHA"     => 0.049537718296051025

In [15]:
t = linspace(0.0, 1000.,3)
x = zeros(2,3)
u = [0.0*pi/180.0, 0.0*pi/180.0, 0.0*pi/180.0]
x[1,:] = [0.0,0.0,00.0]
x[2,:] = [00.0,1000.0,10000.0]

tape = ["CHANNEL"=> "NEW_TAPE", "t"=> t, "u"=>u[:,1], "x"=>x[1,:], "y"=>x[2,:]]
tapeMsg = json(tape)
print(client,tapeMsg)

In [8]:
# generate 8 points on circle
inc = 50
rho = 180
v = 25.9
t = linspace(0.0, 2pi*rho/v,inc)
th = linspace(0,2pi,inc)

x = zeros(2,inc)
u = zeros(inc)
for n in 1:length(th)
    x[1,n] = rho*cos(th[n])
    x[2,n] = rho*sin(th[n])-50
    u[n] = -0.4
end
tape = ["CHANNEL"=> "NEW_TAPE", "t"=> t, "u"=>u[:,1], "x"=>x[1,:], "y"=>x[2,:]]
tapeMsg = json(tape)
print(client,tapeMsg)

In [5]:
plot(x[1,:],x[2,:])


`getindex` has no method matching getindex(::Float64, ::Int64, ::UnitRange{Int64})
while loading In[5], in expression starting on line 1

In [14]:
close(client)

In [ ]:
t = linspace(0,0.5,2)
x = zeros(2)
y = zeros(2)
u = zeros(2)
u[2] = -2.0*pi/180.0
tape = ["CHANNEL"=> "NEW_TAPE", "t"=> t, "u"=>u, "x"=>x, "y"=>y]
tapeMsg = json(tape)
print(client,tapeMsg)