Skip to content

Commit

Permalink
Merge pull request #799 from JuliaRobotics/master
Browse files Browse the repository at this point in the history
v0.15.2-rc1
  • Loading branch information
dehann authored Aug 23, 2021
2 parents ab922f1 + b5b84ff commit c0b6dd5
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 38 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DistributedFactorGraphs"
uuid = "b5cc3c7e-6572-11e9-2517-99fb8daf2f04"
version = "0.15.1"
version = "0.15.2"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down Expand Up @@ -46,7 +46,8 @@ GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "GraphPlot", "LinearAlgebra", "Manifolds", "Pkg"]
test = ["Test", "GraphPlot", "LinearAlgebra", "Manifolds", "Pkg", "Statistics"]
1 change: 1 addition & 0 deletions src/FileDFG/services/FileDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function loadDFG!(dfgLoadInto::AbstractDFG, dst::AbstractString)
map(f->addFactor!(dfgLoadInto, f), factors)

# Finally, rebuild the CCW's for the factors to completely reinflate them
# NOTE CREATES A NEW DFGFactor IF CCW TYPE CHANGES
@info "Rebuilding CCW's for the factors..."
for factor in factors
rebuildFactorMetadata!(dfgLoadInto, factor)
Expand Down
4 changes: 2 additions & 2 deletions src/LightDFG/services/LightDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ end
# end


function addFactor!(dfg::LightDFG{<:AbstractParams, <:AbstractDFGVariable, F}, factor::F)::F where F <: AbstractDFGFactor
function addFactor!(dfg::LightDFG{<:AbstractParams, <:AbstractDFGVariable, F}, factor::F) where F <: AbstractDFGFactor
if haskey(dfg.g.factors, factor.label)
error("Factor '$(factor.label)' already exists in the factor graph")
end
# TODO
# @assert FactorGraphs.addFactor!(dfg.g, getVariableOrder(factor), factor)
@assert FactorGraphs.addFactor!(dfg.g, factor._variableOrderSymbols, factor)
@assert FactorGraphs.addFactor!(dfg.g, Symbol[factor._variableOrderSymbols...], factor)
return factor
end

Expand Down
4 changes: 2 additions & 2 deletions src/entities/DFGFactor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Designing (WIP)
- in DFG.AbstractRelativeMinimize <: FunctorInferenceType
- in Main.SomeFactor <: AbstractRelativeMinimize
"""
mutable struct GenericFunctionNodeData{T<:Union{PackedInferenceType, FunctorInferenceType, FactorOperationalMemory}}
mutable struct GenericFunctionNodeData{T<:Union{<:PackedInferenceType, <:AbstractFactor, <:FactorOperationalMemory}}
eliminated::Bool
potentialused::Bool
edgeIDs::Vector{Int}
Expand Down Expand Up @@ -80,7 +80,7 @@ end
const PackedFunctionNodeData{T} = GenericFunctionNodeData{T} where T <: AbstractPackedFactor
PackedFunctionNodeData(args...) = PackedFunctionNodeData{typeof(args[4])}(args...)

const FunctionNodeData{T} = GenericFunctionNodeData{T} where T <: Union{AbstractFactor, FactorOperationalMemory}
const FunctionNodeData{T} = GenericFunctionNodeData{T} where T <: Union{<:AbstractFactor, <:FactorOperationalMemory}
FunctionNodeData(args...) = FunctionNodeData{typeof(args[4])}(args...)


Expand Down
3 changes: 2 additions & 1 deletion src/entities/DFGVariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ abstract type AbstractPointParametricEst end
Data container to store Parameteric Point Estimate (PPE) for mean and max.
"""
struct MeanMaxPPE <: AbstractPointParametricEst
solveKey::Symbol #repeated because of Sam's request
# repeat key value internally (from a design request by Sam)
solveKey::Symbol
suggested::Vector{Float64}
max::Vector{Float64}
mean::Vector{Float64}
Expand Down
2 changes: 1 addition & 1 deletion src/services/AbstractDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ getFactorOperationalMemoryType(dfg::AbstractDFG) = getFactorOperationalMemoryTyp
Method must be overloaded by the user for Serialization to work.
"""
rebuildFactorMetadata!(dfg::AbstractDFG{<:AbstractParams}, factor::AbstractDFGFactor) = error("rebuildFactorMetadata! is not implemented for $(typeof(dfg))")
rebuildFactorMetadata!(dfg::AbstractDFG{<:AbstractParams}, factor::AbstractDFGFactor, neighbors=[]) = error("rebuildFactorMetadata! is not implemented for $(typeof(dfg))")

##------------------------------------------------------------------------------
## Setters
Expand Down
53 changes: 31 additions & 22 deletions src/services/CompareUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,29 @@ end
"""
$(SIGNATURES)
Compare the all fields of T that are not in `skip` for objects `Al` and `Bl`.
Compare the all fields of T that are not in `skip` for objects `Al` and `Bl` and returns `::Bool`.
TODO > add to func_ref.md
"""
function compareFields(Al::T,
Bl::T;
show::Bool=true,
skip::Vector{Symbol}=Symbol[] )::Bool where {T}
for field in fieldnames(T)
function compareFields( Al::T1,
Bl::T2;
show::Bool=true,
skip::Vector{Symbol}=Symbol[] ) where {T1,T2}
#
T1 == T2 ? nothing : @warn("different types in compareFields", T1, T2)
for field in fieldnames(T1)
(field in skip) && continue
tp = compareField(Al, Bl, field)
show && @debug(" $tp : $field")==nothing
show && @debug(" $tp : $field") === nothing
!tp && return false
end
return true
end

function compareFields(Al::T,
Bl::T;
show::Bool=true,
skip::Vector{Symbol}=Symbol[] )::Bool where {T <: Union{Number, AbstractString}}
function compareFields( Al::T,
Bl::T;
show::Bool=true,
skip::Vector{Symbol}=Symbol[] )::Bool where {T <: Union{Number, AbstractString}}
#
return Al == Bl
end
Expand Down Expand Up @@ -130,12 +132,15 @@ function compareAll(Al::T,
return true
end

function compareAll(Al::T, Bl::T; show::Bool=true, skip::Vector{Symbol}=Symbol[]) where T
@debug "Comparing types $T:"
function compareAll(Al::T1, Bl::T2; show::Bool=true, skip::Vector{Symbol}=Symbol[]) where {T1,T2}
@debug "Comparing types $T1, $T2"
if T1 != T2
@warn "Types are different" T1 T2
end
# @debug " Al = $Al"
# @debug " Bl = $Bl"
!compareFields(Al, Bl, show=show, skip=skip) && return false
for field in fieldnames(T)
for field in fieldnames(T1)
field in skip && continue
@debug(" Checking field: $field")
(!isdefined(Al, field) && !isdefined(Al, field)) && return true
Expand Down Expand Up @@ -202,10 +207,11 @@ function compareAllSpecial(A::T1,
skip=Symbol[],
show::Bool=true) where {T1 <: GenericFunctionNodeData, T2 <: GenericFunctionNodeData}
if T1 != T2
return false
else
return compareAll(A, B, skip=skip, show=show)
@warn "compareAllSpecial is comparing different types" T1 T2
# return false
# else
end
return compareAll(A, B, skip=skip, show=show)
end


Expand Down Expand Up @@ -236,17 +242,20 @@ function compareFactor(A::DFGFactor,
skipsamples::Bool=true,
skipcompute::Bool=true )
#
skip_ =
TP = compareAll(A, B, skip=union([:attributes;:solverData;:_variableOrderSymbols;:_gradients],skip), show=show)
# TP = TP & compareAll(A.attributes, B.attributes, skip=[:data;], show=show)
skip_ = union([:attributes;:solverData;:_variableOrderSymbols;:_gradients],skip)
TP = compareAll(A, B, skip=skip_, show=show)
@debug "compareFactor 1/5" TP
TP = TP & compareAllSpecial(getSolverData(A), getSolverData(B), skip=union([:fnc;:_gradients], skip), show=show)
if :fnc in skip
@debug "compareFactor 2/5" TP
if !TP || :fnc in skip
return TP
end
TP = TP & compareAllSpecial(getSolverData(A).fnc, getSolverData(B).fnc, skip=union([:cpt;:measurement;:params;:varidx;:threadmodel;:_gradients], skip), show=show)
@debug "compareFactor 3/5" TP
if !(:measurement in skip)
TP = TP & (skipsamples || compareAll(getSolverData(A).fnc.measurement, getSolverData(B).fnc.measurement, show=show, skip=skip))
TP = TP & (skipsamples || compareAll(getSolverData(A).fnc.measurement, getSolverData(B).fnc.measurement, show=show, skip=skip))
end
@debug "compareFactor 4/5" TP
if !(:params in skip)
TP = TP & (skipcompute || compareAll(getSolverData(A).fnc.params, getSolverData(B).fnc.params, show=show, skip=skip))
end
Expand Down
16 changes: 8 additions & 8 deletions src/services/Serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,14 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any})::DFGFactor where G

# Rebuild DFGFactor
#TODO use constuctor to create factor
factor = DFGFactor(Symbol(label),
timestamp,
nstime,
Set(tags),
fullFactorData,
solvable,
Tuple(_variableOrderSymbols))

factor = DFGFactor( Symbol(label),
timestamp,
nstime,
Set(tags),
fullFactorData,
solvable,
Tuple(_variableOrderSymbols))
#

# Note, once inserted, you still need to call rebuildFactorMetadata!
return factor
Expand Down

0 comments on commit c0b6dd5

Please sign in to comment.