-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #492 from JuliaRobotics/master
fast forward feature branch
- Loading branch information
Showing
10 changed files
with
206 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# IIF #485 -- | ||
|
||
# using Revise | ||
|
||
using Test | ||
using Logging | ||
using Statistics | ||
using DistributedFactorGraphs | ||
using IncrementalInference | ||
|
||
|
||
@testset "test basic three variable graph with prior" begin | ||
|
||
VAR1 = :a | ||
VAR2 = :b | ||
VAR3 = :c | ||
|
||
logger = SimpleLogger(stdout, Logging.Debug) | ||
global_logger(logger) | ||
dfg = initfg() #LightDFG{SolverParams}(solverParams=SolverParams()) | ||
# Add some nodes. | ||
v1 = addVariable!(dfg, VAR1, ContinuousScalar, labels = [:POSE]) | ||
v2 = addVariable!(dfg, VAR2, ContinuousScalar, labels = [:POSE]) | ||
v3 = addVariable!(dfg, VAR3, ContinuousScalar, labels = [:LANDMARK]) | ||
f1 = addFactor!(dfg, [VAR1; VAR2], LinearConditional(Normal(50.0,2.0)) ) | ||
f2 = addFactor!(dfg, [VAR2; VAR3], LinearConditional(Normal(50.0,2.0)) ) | ||
|
||
addFactor!(dfg, [VAR1], Prior(Normal())) | ||
|
||
# drawGraph(dfg, show=true) | ||
|
||
|
||
# tree = wipeBuildNewTree!(dfg) | ||
# # drawTree(tree, show=true) | ||
# | ||
# getCliqFactors(tree, VAR3) | ||
# getCliqFactors(tree, VAR1) | ||
|
||
ensureAllInitialized!(dfg) | ||
|
||
|
||
# cliq= getCliq(tree, VAR3) | ||
# getData(cliq) | ||
# | ||
# cliq= getCliq(tree, VAR1) | ||
# getData(cliq) | ||
|
||
|
||
|
||
getSolverParams(dfg).limititers = 50 | ||
# getSolverParams(dfg).drawtree = true | ||
# getSolverParams(dfg).showtree = true | ||
# getSolverParams(dfg).dbg = true | ||
## getSolverParams(dfg).async = true | ||
|
||
|
||
tree, smtasks, hist = solveTree!(dfg) #, recordcliqs=ls(dfg)) | ||
|
||
|
||
@test 70 < Statistics.mean(getKDE(dfg, :c) |> getPoints) < 130 | ||
|
||
# # | ||
# using Gadfly, Cairo, Fontconfig | ||
# drawTree(tree, show=true, imgs=true) | ||
|
||
end | ||
|
||
|
||
|
||
|
||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# test basic forward convolve, see IIF issue #477 | ||
|
||
# using Revise | ||
|
||
using Test | ||
using IncrementalInference | ||
using Statistics | ||
|
||
|
||
@testset "Test basic convolution result..." begin | ||
|
||
|
||
function forwardConvolve(X0::Array{Float64,2}, model) | ||
|
||
fg = initfg() | ||
|
||
addVariable!(fg, :x0, ContinuousScalar) | ||
manualinit!(fg, :x0, X0) | ||
addVariable!(fg, :x1, ContinuousScalar) | ||
|
||
addFactor!(fg, [:x0;:x1], model) | ||
|
||
## TODO -- dont use name here, add API to just use z2 here | ||
return approxConv(fg, :x0x1f1, :x1) | ||
end | ||
|
||
|
||
## Start | ||
|
||
# first numerical values -- samples from the marginal of X0 | ||
z1 = Normal(0,0.1) | ||
X0 = rand(z1, 1,100) | ||
|
||
|
||
## predict -- project / conv | ||
# 0 -> 1 seconds | ||
# make approx function | ||
z2 = Normal(11,1.0) # odo | ||
statemodel = LinearConditional( z2 ) | ||
X1_ = forwardConvolve(X0, statemodel) | ||
|
||
|
||
## measure -- product of beliefs, using `ApproxManifoldProducts.jl` | ||
|
||
predX1 = manikde!(X1_, ContinuousScalar) | ||
z3 = Normal(9.5,0.75) | ||
measX1 = manikde!(reshape(rand(z3,100),1,:), ContinuousScalar) | ||
|
||
# do actual product | ||
posterioriX1 = predX1 * measX1 | ||
X1 = getPoints(posterioriX1) | ||
|
||
|
||
## predict, 1->2 seconds | ||
z4 = Normal(8,2.0) # odo | ||
statemodel = LinearConditional( z4 ) | ||
X2_ = forwardConvolve(X1, statemodel) | ||
|
||
@test size(X2_) == (1,100) | ||
@test 15 < Statistics.mean(X2_) < 25 | ||
|
||
end |