Skip to content

Commit b03c180

Browse files
authored
Merge pull request #9 from JuliaRobotics/bug/7_addFactor
Bug/7 add factor
2 parents 763ddcc + a113a4d commit b03c180

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/services/GraphsDFG.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ end
8080
$(SIGNATURES)
8181
Add a DFGFactor to a DFG.
8282
"""
83-
function addFactor!(dfg::GraphsDFG, factor::DFGFactor, variables::Vector{DFGVariable})::Bool
83+
function addFactor!(dfg::GraphsDFG, variables::Vector{DFGVariable}, factor::DFGFactor)::Bool
8484
if haskey(dfg.labelDict, factor.label)
8585
error("Factor '$(factor.label)' already exists in the factor graph")
8686
end
@@ -346,7 +346,7 @@ function _copyIntoGraph!(sourceDFG::GraphsDFG, destDFG::GraphsDFG, variableFacto
346346

347347
# Only if we have all of them should we add it (otherwise strange things may happen on evaluation)
348348
if includeOrphanFactors || length(factVariables) == length(variables)
349-
addFactor!(destDFG, deepcopy(factor.dfgNode), factVariables)
349+
addFactor!(destDFG, factVariables, deepcopy(factor.dfgNode))
350350
end
351351
end
352352
end

test/interfaceTests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ f1 = DFGFactor(:f1)
77
addVariable!(dfg, v1)
88
@test_throws Exception addVariable!(dfg, v1)
99
addVariable!(dfg, v2)
10-
addFactor!(dfg, f1, [v1, v2])
10+
addFactor!(dfg, [v1, v2], f1)
1111
@test_throws Exception addFactor!(dfg, DFGFactor("f2"), [v1, DFGVariable("Nope")])
1212
end
1313

@@ -71,7 +71,7 @@ numNodes = 10
7171
dfg = testDFGAPI()
7272
verts = map(n -> DFGVariable(Symbol("x$n")), 1:numNodes)
7373
map(v -> addVariable!(dfg, v), verts)
74-
map(n -> addFactor!(dfg, DFGFactor(Symbol("x$(n)x$(n+1)f1")), [verts[n], verts[n+1]]), 1:(numNodes-1))
74+
map(n -> addFactor!(dfg, [verts[n], verts[n+1]], DFGFactor(Symbol("x$(n)x$(n+1)f1"))), 1:(numNodes-1))
7575
# map(n -> addFactor!(dfg, [verts[n], verts[n+2]], DFGFactor(Symbol("x$(n)x$(n+2)f2"))), 1:2:(numNodes-2))
7676

7777
@testset "Getting Neighbors" begin

0 commit comments

Comments
 (0)