Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ function filterDFG!(nodes, predicate::Function, by::Function = identity)
return filter!(predicate ∘ by, nodes)
end

# specialized for label::Symbol filtering
function filterDFG!(nodes, predicate::Function, by::typeof(getLabel))
# TODO this is not as clean as it should be, revisit if any issues arise
# Standard predicates that needs to be converted to string to work with Symbols
# OR look for the type if predicate isa Base.Fix2 && (predicate.x isa AbstractString || predicate.x isa Regex)
if predicate isa Base.Fix2 &&
typeof(predicate.f) in [typeof(contains), typeof(startswith), typeof(endswith)]
return filter!(predicate ∘ string ∘ by, nodes)
else
return filter!(predicate ∘ by, nodes)
end
end

##==============================================================================
## Validation of session, robot, and user labels.
##==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/DataBlobs/services/BlobEntry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ function getBlobentries(
blobIdFilter::Union{Nothing, Function} = nothing,
)
entries = getBlobentries(v)
filterDFG!(entries, labelFilter, x -> string(x.label))
filterDFG!(entries, labelFilter, getLabel)
filterDFG!(entries, blobIdFilter, x -> string(x.blobId))
return entries
end
Expand Down
15 changes: 10 additions & 5 deletions src/GraphsDFG/services/GraphsDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ function mergeVariable!(dfg::GraphsDFG, variable::AbstractGraphVariable)
return 1
end

function mergeVariables!(dfg::GraphsDFG, variables)
cnts = map(mergeVariable!, variables)
return sum(cnts)
end

function mergeFactor!(dfg::GraphsDFG, factor::AbstractGraphFactor)
if !haskey(dfg.g.factors, factor.label)
addFactor!(dfg, factor)
Expand Down Expand Up @@ -174,7 +179,7 @@ function getVariables(
filterDFG!(variables, >=(solvable), getSolvable)
end

filterDFG!(variables, labelFilter, (String ∘ getLabel))
filterDFG!(variables, labelFilter, getLabel)
filterDFG!(variables, solvableFilter, getSolvable)
filterDFG!(variables, tagsFilter, getTags)
filterDFG!(variables, typeFilter, getVariableType)
Expand Down Expand Up @@ -236,7 +241,7 @@ function getFactors(
"The regex filter argument is deprecated, use kwarg `labelFilter=contains(regex)` instead", #v0.28
:getFactors,
)
filterDFG!(factors, contains(regex), (String ∘ getLabel))
filterDFG!(factors, contains(regex), getLabel)
end
if !isempty(tags)
# NOTE that !isdisjoint is not supported by NvaDFG.
Expand All @@ -255,7 +260,7 @@ function getFactors(
filterDFG!(factors, >=(solvable), getSolvable)
end

filterDFG!(factors, labelFilter, (String ∘ getLabel))
filterDFG!(factors, labelFilter, getLabel)
filterDFG!(factors, solvableFilter, getSolvable)
filterDFG!(factors, tagsFilter, getTags)
filterDFG!(factors, typeFilter, typeof ∘ getFactorType)
Expand Down Expand Up @@ -557,7 +562,7 @@ end

function getGraphBlobentries(fg::GraphsDFG; labelFilter::Union{Nothing, Function} = nothing)
entries = collect(values(fg.graph.blobEntries))
filterDFG!(entries, labelFilter, (String ∘ getLabel))
filterDFG!(entries, labelFilter, getLabel)
return entries
end

Expand All @@ -566,7 +571,7 @@ function listGraphBlobentries(
labelFilter::Union{Nothing, Function} = nothing,
)
labels = collect(keys(fg.graph.blobEntries))
filterDFG!(labels, labelFilter, String)
filterDFG!(labels, labelFilter, string)
return labels
end

Expand Down
2 changes: 1 addition & 1 deletion src/entities/AbstractDFG.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# TODO consider enforcing the full structure.
# This is not explicitly inforced, but surves as extra information of how the structure is put together.
# AbstractDFGNode are all nodes that make up a DFG, including Agent, Graph, Variable, Factor, Blobstore, etc.
# AbstractDFGNode are all nodes that make up a DFG, including Agent, Graph, Variable, Factor, Blobstore, Blobentry etc.
# abstract type AbstractDFGNode end
# any DFGNode shall have a label.
# abstract type AbstractGraphNode end <: AbstractDFGNode
Expand Down
3 changes: 3 additions & 0 deletions src/entities/DFGFactor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ Base.@kwdef struct FactorCompute{FT <: AbstractObservation, N} <: AbstractGraphF
solvercache::Base.RefValue{<:FactorCache} #TODO easy of use vs. performance as container is abstract in any case.
end

#FIXME rename smallData to metadata
refMetadata(node::FactorCompute) = node.smallData

##------------------------------------------------------------------------------
## Constructors

Expand Down
9 changes: 6 additions & 3 deletions src/entities/DFGVariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Base.@kwdef mutable struct State{T <: StateType, P, N}
Flag used by junction (Bayes) tree construction algorithm to know whether this variable has yet been included in the tree construction.
"""
eliminated::Bool = false
BayesNetVertID::Symbol = :NOTHING # Union{Nothing, }
BayesNetVertID::Symbol = :NOTHING # Union{Nothing, } #TODO deprecate
separator::Vector{Symbol} = Symbol[]
"""
False if initial numerical values are not yet available or stored values are not ready for further processing yet.
Expand Down Expand Up @@ -118,7 +118,7 @@ Base.@kwdef mutable struct PackedState
dimIDs::Vector{Int}
dims::Int
eliminated::Bool
BayesNetVertID::Symbol # Int
BayesNetVertID::Symbol # Int #TODO deprecate
separator::Vector{Symbol} # Int
variableType::String
initialized::Bool
Expand Down Expand Up @@ -163,7 +163,6 @@ Data container to store Parameteric Point Estimate (PPE) for mean and max.
"""
Base.@kwdef struct MeanMaxPPE <: AbstractPointParametricEst
id::Union{UUID, Nothing} = nothing # If it's blank it doesn't exist in the DB.
# repeat key value internally (from a design request by Sam)
solveKey::Symbol
suggested::Vector{Float64}
max::Vector{Float64}
Expand Down Expand Up @@ -326,6 +325,10 @@ Base.@kwdef struct VariableCompute{T <: StateType, P, N} <: AbstractGraphVariabl
solvable::Base.RefValue{Int} = Ref(1)
end

refStates(v::VariableCompute) = v.solverDataDict
refMetadata(v::VariableCompute) = v.smallData
refBlobentries(v::VariableCompute) = v.dataDict

##------------------------------------------------------------------------------
## Constructors

Expand Down
1 change: 1 addition & 0 deletions src/services/AbstractDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,7 @@ Related
"""
function findShortestPathDijkstra end

#TODO deprecate
"""
$SIGNATURES

Expand Down
5 changes: 5 additions & 0 deletions src/services/CommonAccessors.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
##==============================================================================
## Common Accessors
##==============================================================================

refTags(node) = node.tags
refMetadata(node) = node.metadata
refBlobentries(node) = node.blobEntries # FIXME rename blobEntries to blobentries to match noun

# Common get and set methods

# NOTE this could be reduced with macros and function generation to even less code.
Expand Down
28 changes: 14 additions & 14 deletions src/services/CompareUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,37 +196,37 @@ end

#Compare State
function compare(a::State, b::State)
a.val != b.val && @debug("val is not equal") == nothing && return false
a.bw != b.bw && @debug("bw is not equal") == nothing && return false
a.val != b.val && @debug("val is not equal") === nothing && return false
a.bw != b.bw && @debug("bw is not equal") === nothing && return false
a.BayesNetOutVertIDs != b.BayesNetOutVertIDs &&
@debug("BayesNetOutVertIDs is not equal") == nothing &&
@debug("BayesNetOutVertIDs is not equal") === nothing &&
return false
a.dimIDs != b.dimIDs && @debug("dimIDs is not equal") == nothing && return false
a.dims != b.dims && @debug("dims is not equal") == nothing && return false
a.dimIDs != b.dimIDs && @debug("dimIDs is not equal") === nothing && return false
a.dims != b.dims && @debug("dims is not equal") === nothing && return false
a.eliminated != b.eliminated &&
@debug("eliminated is not equal") == nothing &&
@debug("eliminated is not equal") === nothing &&
return false
a.BayesNetVertID != b.BayesNetVertID &&
@debug("BayesNetVertID is not equal") == nothing &&
@debug("BayesNetVertID is not equal") === nothing &&
return false
a.separator != b.separator &&
@debug("separator is not equal") == nothing &&
@debug("separator is not equal") === nothing &&
return false
a.initialized != b.initialized &&
@debug("initialized is not equal") == nothing &&
@debug("initialized is not equal") === nothing &&
return false
!isapprox(a.infoPerCoord, b.infoPerCoord; atol = 1e-13) &&
@debug("infoPerCoord is not equal") == nothing &&
@debug("infoPerCoord is not equal") === nothing &&
return false
a.ismargin != b.ismargin && @debug("ismargin is not equal") == nothing && return false
a.ismargin != b.ismargin && @debug("ismargin is not equal") === nothing && return false
a.dontmargin != b.dontmargin &&
@debug("dontmargin is not equal") == nothing &&
@debug("dontmargin is not equal") === nothing &&
return false
a.solveInProgress != b.solveInProgress &&
@debug("solveInProgress is not equal") == nothing &&
@debug("solveInProgress is not equal") === nothing &&
return false
getVariableType(a) != getVariableType(b) &&
@debug("variableType is not equal") == nothing &&
@debug("variableType is not equal") === nothing &&
return false
return true
end
Expand Down
3 changes: 2 additions & 1 deletion src/services/DFGFactor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ See documentation in [Manifolds.jl on making your own](https://juliamanifolds.gi

Example:
```
DFG.@defObservationType Pose2Pose2 RelativeObservation SpecialEuclidean(2)
DFG.@defObservationType Pose2Pose2 RelativeObservation SpecialEuclideanGroup(2)
```
"""
macro defObservationType(structname, factortype, manifold)
Expand Down Expand Up @@ -167,6 +167,7 @@ macro defObservationType(structname, factortype, manifold)
end

getManifold(obs::AbstractObservation) = getManifold(typeof(obs))
getManifold(f::AbstractGraphFactor) = getManifold(getObservation(f))

##==============================================================================
## Factors
Expand Down
4 changes: 2 additions & 2 deletions src/services/DFGVariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ See the [Manifolds.jl documentation on creating your own manifolds](https://juli

Example:
```
DFG.@defVariable Pose2 SpecialEuclidean(2) ArrayPartition([0;0.0],[1 0; 0 1.0])
DFG.@defVariable Pose2 SpecialEuclideanGroup(2) ArrayPartition([0;0.0],[1 0; 0 1.0])
```
"""
macro defStateType(structname, manifold, point_identity)
Expand Down Expand Up @@ -135,7 +135,7 @@ See the [Manifolds.jl documentation on creating your own manifolds](https://juli

Example:
```
DFG.@defStateTypeN Pose{N} SpecialEuclidean(N) ArrayPartition(zeros(SVector{N, Float64}), SMatrix{N, N, Float64}(I))
DFG.@defStateTypeN Pose{N} SpecialEuclideanGroup(N) ArrayPartition(zeros(SVector{N, Float64}), SMatrix{N, N, Float64}(I))
```
"""
macro defStateTypeN(structname, manifold, point_identity)
Expand Down
Loading