|
| 1 | +using GraphPlot |
| 2 | +using Neo4j |
| 3 | +using DistributedFactorGraphs |
| 4 | +using IncrementalInference |
| 5 | + |
| 6 | +@testset "test fourdoor early example" begin |
| 7 | + |
| 8 | +DistributedFactorGraphs.CloudGraphsDFG{SolverParams}() = CloudGraphsDFG{SolverParams}("localhost", 7474, "neo4j", "test", |
| 9 | + "testUser", "testRobot", "testSession", |
| 10 | + nothing, |
| 11 | + nothing, |
| 12 | + IncrementalInference.decodePackedType, |
| 13 | + IncrementalInference.rebuildFactorMetadata!, |
| 14 | + solverParams=SolverParams()) |
| 15 | + |
| 16 | +N=100 |
| 17 | +# fg = initfg(CloudGraphsDFG{SolverParams}()) |
| 18 | +fg = initfg(GraphsDFG{SolverParams}) |
| 19 | + |
| 20 | +doors = reshape(Float64[-100.0;0.0;100.0;300.0],1,4) |
| 21 | +pd = kde!(doors,[3.0]) |
| 22 | +pd = resample(pd,N); |
| 23 | +bws = getBW(pd)[:,1] |
| 24 | +doors2 = getPoints(pd); |
| 25 | + |
| 26 | + |
| 27 | +addVariable!(fg,:x0,ContinuousScalar,N=N) |
| 28 | +addFactor!(fg,[:x0], Prior( pd ) ) |
| 29 | + |
| 30 | +# tem = 2.0*randn(1,N)+getVal(v1)+50.0 |
| 31 | +addVariable!(fg,:x2, ContinuousScalar, N=N) |
| 32 | +addFactor!(fg, [:x0; :x2], LinearConditional(Normal(50.0,2.0)) ) |
| 33 | +# addFactor!(fg, [v1;v2], Odo(50.0*ones(1,1),[2.0]',[1.0])) |
| 34 | + |
| 35 | + |
| 36 | +# monocular sighting would look something like |
| 37 | +#addFactor!(fg, Mono, [:x3,:l1], [14.0], [1.0], [1.0]) |
| 38 | +#addFactor!(fg, Mono, [:x4,:l1], [11.0], [1.0], [1.0]) |
| 39 | + |
| 40 | +addVariable!(fg,:x3,ContinuousScalar, N=N) |
| 41 | +addFactor!(fg,[:x2;:x3], LinearConditional( Normal(50.0,4.0)) ) |
| 42 | +addFactor!(fg,[:x3], Prior( pd )) |
| 43 | + |
| 44 | +addVariable!(fg,:x4,ContinuousScalar, N=N) |
| 45 | +addFactor!(fg,[:x3;:x4], LinearConditional( Normal(50.0,2.0)) ) |
| 46 | + |
| 47 | + |
| 48 | +addVariable!(fg, :l1, ContinuousScalar, N=N) |
| 49 | +addFactor!(fg, [:x3,:l1], Ranged([64.0],[0.5],[1.0])) |
| 50 | +addFactor!(fg, [:x4,:l1], Ranged([16.0],[0.5],[1.0])) |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +addVariable!(fg,:x5,ContinuousScalar, N=N) |
| 55 | +addFactor!(fg,[:x4;:x5], LinearConditional( Normal(50.0,2.0)) ) |
| 56 | + |
| 57 | + |
| 58 | +addVariable!(fg,:x6,ContinuousScalar, N=N) |
| 59 | +addFactor!(fg,[:x5;:x6], LinearConditional( Normal(40.0,1.20)) ) |
| 60 | + |
| 61 | + |
| 62 | +addVariable!(fg,:x7,ContinuousScalar, N=N) |
| 63 | +addFactor!(fg,[:x6;:x7], LinearConditional( Normal(60.0,2.0)) ) |
| 64 | + |
| 65 | +# ensureAllInitialized!(fg) |
| 66 | + |
| 67 | +mlc = MixturePrior(Normal.(doors[1,:], bws[1]), 0.25*ones(4)) |
| 68 | + |
| 69 | +# getSample(mlc) |
| 70 | + |
| 71 | +addFactor!(fg,[:x7], mlc ) |
| 72 | + |
| 73 | + |
| 74 | +dfgplot(fg) |
| 75 | + |
| 76 | +tree, smt, hist = solveTree!(fg) |
| 77 | + |
| 78 | + |
| 79 | +end |
| 80 | + |
| 81 | +# |
0 commit comments