-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExport.lua
More file actions
51 lines (37 loc) · 1.17 KB
/
Export.lua
File metadata and controls
51 lines (37 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--Export.lua file for Tumbledryer_2D
function LuaExportStart()
package.path = package.path..";"..lfs.currentdir().."/LuaSocket/?.lua"
package.cpath = package.cpath..";"..lfs.currentdir().."/LuaSocket/?.dll"
socket = require("socket")
IPAddress = "127.0.0.1" -- localhost
Port = 31090
Nutkicker_socket = socket.try(socket.connect(IPAddress, Port))
Nutkicker_socket:setoption("tcp-nodelay",true)
NMC_Counter = 0
end
function LuaExportBeforeNextFrame()
end
function LuaExportAfterNextFrame()
--Euler angles:
local mySelf = LoGetSelfData()
local NMC_inertial_Pitch = mySelf.Pitch
local NMC_inertial_Bank = mySelf.Bank
--Angular rates:
local NMC_Omega = LoGetAngularVelocity()
--Accelerations:
local NMC_Accel = LoGetAccelerationUnits()
--Let's send the data to the software:
socket.try(Nutkicker_socket:send(string.format("%.4f, %.4f, %.4f \n",
NMC_inertial_Bank,
NMC_inertial_Pitch,
NMC_Accel.y
)))
end
function LuaExportStop()
if Nutkicker_socket then
socket.try(Nutkicker_socket:send("exit")) -- closing the socket
Nutkicker_socket:close()
end
end
function LuaExportActivityNextEvent(t)
end