-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
55 lines (46 loc) · 1.07 KB
/
init.lua
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
52
53
54
55
require 'torch'
require 'dok'
require 'image'
require 'xlua'
local help_desc = [[
Mongoose 9 Dof reader for firmware found on
http://myrhev.net/?page_id=263
]]
mongoose = {}
-- load C lib
require 'libmongoose'
function mongoose.new(tty)
local mgdata = torch.Tensor(20):zero()
local mg = libmongoose.initMongoose(tty)
if mg == nil then
error("Could not open tty "..tty.." . Please check that the path is right and that you have the correct permission (you might have to join the group dialout).")
end
return {mg, mgdata}
end
function mongoose.release(mg)
libmongoose.releaseMongoose(mg[1])
end
function mongoose.fetchData(mg)
mg[2].libmongoose.fetchMongooseData(mg[1], mg[2])
end
function mongoose.getRotmat(mg)
if mg[2][1] ~= 0 then
return mg[2][{{11,19}}]:resize(3,3)
else
return nil
end
end
function mongoose.getAccel(mg)
if mg[2][1] ~= 0 then
return mg[2][{{2,4}}]
else
return nil
end
end
function mongoose.getTime(mg)
if mg[2][1] ~= 0 then
return mg[2][1]
else
return nil
end
end