15
15
# Getters
16
16
"""
17
17
$(SIGNATURES)
18
+ Convenience function to get all the matadata of a DFG
18
19
"""
19
20
getDFGInfo (dfg:: AbstractDFG ) = (dfg. description, dfg. userId, dfg. robotId, dfg. sessionId, dfg. userData, dfg. robotData, dfg. sessionData, dfg. solverParams)
20
21
@@ -268,12 +269,14 @@ end
268
269
Get a DFGVariable with a specific solver key.
269
270
In memory types still return a reference, other types returns a variable with only solveKey.
270
271
"""
271
- function getVariable (dfg:: G , label:: Symbol , solveKey:: Symbol ):: AbstractDFGVariable where G <: AbstractDFG
272
+ function getVariable (dfg:: AbstractDFG , label:: Symbol , solveKey:: Symbol ):: AbstractDFGVariable
272
273
273
274
var = getVariable (dfg, label)
274
275
275
- if ! haskey (var. solverDataDict, solveKey)
276
+ if isa (var, DFGVariable) && ! haskey (var. solverDataDict, solveKey)
276
277
error (" Solvekey '$solveKey ' does not exists in the variable" )
278
+ elseif ! isa (var, DFGVariable)
279
+ @warn " getVariable(dfg, label, solveKey) only supported for type DFGVariable."
277
280
end
278
281
279
282
return var
394
397
List the DFGFactors in the DFG.
395
398
Optionally specify a label regular expression to retrieves a subset of the factors.
396
399
"""
397
- function getFactors (dfg:: G , regexFilter:: Union{Nothing, Regex} = nothing ; solvable:: Int = 0 ):: Vector{AbstractDFGFactor} where G <: AbstractDFG
400
+ function getFactors (dfg:: G , regexFilter:: Union{Nothing, Regex} = nothing ; tags :: Vector{Symbol} = Symbol[], solvable:: Int = 0 ):: Vector{AbstractDFGFactor} where G <: AbstractDFG
398
401
error (" getFactors not implemented for $(typeof (dfg)) " )
399
402
end
400
403
712
715
713
716
"""
714
717
$(SIGNATURES)
715
- Get variable PPE for a given solve key.
718
+ Get the parametric point estimate (PPE) for a variable in the factor graph for a given solve key.
719
+
720
+ Notes
721
+ - Defaults on keywords `solveKey` and `method`
722
+
723
+ Related
724
+ getMeanPPE, getMaxPPE, getKDEMean, getKDEFit, getPPEs, getVariablePPEs
716
725
"""
717
726
function getPPE (dfg:: AbstractDFG , variablekey:: Symbol , ppekey:: Symbol = :default ):: AbstractPointParametricEst
718
727
v = getVariable (dfg, variablekey)
@@ -721,7 +730,7 @@ function getPPE(dfg::AbstractDFG, variablekey::Symbol, ppekey::Symbol=:default):
721
730
end
722
731
723
732
# Not the most efficient call but it at least reuses above (in memory it's probably ok)
724
- getPPE (dfg:: AbstractDFG , sourceVariable:: DFGVariable , ppekey:: Symbol = default):: AbstractPointParametricEst = getPPE (dfg, sourceVariable. label, ppekey)
733
+ getPPE (dfg:: AbstractDFG , sourceVariable:: VariableDataLevel1 , ppekey:: Symbol = default):: AbstractPointParametricEst = getPPE (dfg, sourceVariable. label, ppekey)
725
734
726
735
"""
727
736
$(SIGNATURES)
@@ -765,14 +774,14 @@ end
765
774
Update PPE data if it exists, otherwise add it.
766
775
NOTE: Copies the PPE data.
767
776
"""
768
- updatePPE! (dfg:: AbstractDFG , sourceVariable:: DFGVariable , ppekey:: Symbol = :default ) =
777
+ updatePPE! (dfg:: AbstractDFG , sourceVariable:: VariableDataLevel1 , ppekey:: Symbol = :default ) =
769
778
updatePPE! (dfg, sourceVariable. label, deepcopy (getPPE (sourceVariable, ppekey)), ppekey)
770
779
771
780
"""
772
781
$(SIGNATURES)
773
782
Update PPE data if it exists, otherwise add it.
774
783
"""
775
- function updatePPE! (dfg:: AbstractDFG , sourceVariables:: Vector{<:DFGVariable } , ppekey:: Symbol = :default )
784
+ function updatePPE! (dfg:: AbstractDFG , sourceVariables:: Vector{<:VariableDataLevel1 } , ppekey:: Symbol = :default )
776
785
# I think cloud would do this in bulk for speed
777
786
for var in sourceVariables
778
787
updatePPE! (dfg, var. label, getPPE (dfg, var, ppekey), ppekey)
@@ -802,34 +811,69 @@ deletePPE!(dfg::AbstractDFG, sourceVariable::DFGVariable, ppekey::Symbol=:defaul
802
811
803
812
# ###
804
813
814
+
815
+ export mergeVariableSolverData!, mergePPEs!, mergeVariableData!, mergeGraphVariableData!
816
+ # update is implied, see API wiki
817
+ @deprecate mergeUpdateVariableSolverData! (dfg, sourceVariable) mergeVariableData! (dfg, sourceVariable)
818
+ @deprecate mergeUpdateGraphSolverData! (sourceDFG, destDFG, varSyms) mergeGraphVariableData! (destDFG, sourceDFG, varSyms)
819
+
805
820
"""
806
821
$(SIGNATURES)
807
822
Merges and updates solver and estimate data for a variable (variable can be from another graph).
808
- Note: Makes a copy of the estimates and solver data so that there is no coupling
809
- between graphs.
823
+ If the same key is present in another collection, the value for that key will be the value it has in the last collection listed (updated).
824
+ Note: Makes a copy of the estimates and solver data so that there is no coupling between graphs.
810
825
"""
811
- function mergeUpdateVariableSolverData! (dfg:: AbstractDFG , sourceVariable:: AbstractDFGVariable ):: AbstractDFGVariable
812
- if ! exists (dfg, sourceVariable)
813
- error (" Source variable '$(sourceVariable. label) ' doesn't exist in the graph." )
814
- end
815
- var = getVariable (dfg, sourceVariable. label)
826
+ # TODO API
827
+ function mergeVariableSolverData! (destVariable:: DFGVariable , sourceVariable:: DFGVariable ):: DFGVariable
828
+ # We don't know which graph this came from, must be copied!
829
+ merge! (destVariable. solverDataDict, deepcopy (sourceVariable. solverDataDict))
830
+ return destVariable
831
+ end
832
+
833
+ """
834
+ $(SIGNATURES)
835
+ Merges and updates solver and estimate data for a variable (variable can be from another graph).
836
+ Note: Makes a copy of the estimates and solver data so that there is no coupling between graphs.
837
+ """
838
+ # TODO API and only correct level
839
+ function mergePPEs! (destVariable:: AbstractDFGVariable , sourceVariable:: AbstractDFGVariable ):: AbstractDFGVariable
816
840
# We don't know which graph this came from, must be copied!
817
- merge! (var. ppeDict, deepcopy (sourceVariable. ppeDict))
841
+ merge! (destVariable. ppeDict, deepcopy (sourceVariable. ppeDict))
842
+ return destVariable
843
+ end
844
+
845
+ """
846
+ $(SIGNATURES)
847
+ Merges and updates solver and estimate data for a variable (variable can be from another graph).
848
+ Note: Makes a copy of the estimates and solver data so that there is no coupling between graphs.
849
+ """
850
+ # TODO API
851
+ function mergeVariableData! (dfg:: AbstractDFG , sourceVariable:: AbstractDFGVariable ):: AbstractDFGVariable
852
+
853
+ var = getVariable (dfg, sourceVariable. label)
854
+
855
+ mergePPEs! (var, sourceVariable)
818
856
# If this variable has solverDataDict (summaries do not)
819
- :solverDataDict in fieldnames (typeof (var)) && merge! (var. solverDataDict, deepcopy (sourceVariable. solverDataDict))
820
- return sourceVariable
857
+ :solverDataDict in fieldnames (typeof (var)) && mergeVariableSolverData! (var, sourceVariable)
858
+
859
+ # update if its not a InMemoryDFGTypes, otherwise it was a reference
860
+ # if satelite nodes are used it can be updated seprarately
861
+ # !(isa(dfg, InMemoryDFGTypes)) && updateVariable!(dfg, var)
862
+
863
+ return var
821
864
end
822
865
823
866
"""
824
867
$(SIGNATURES)
825
868
Common function to update all solver data and estimates from one graph to another.
826
869
This should be used to push local solve data back into a cloud graph, for example.
827
870
"""
828
- function mergeUpdateGraphSolverData! (sourceDFG:: G , destDFG:: H , varSyms:: Vector{Symbol} ):: Nothing where {G <: AbstractDFG , H <: AbstractDFG }
871
+ # TODO API
872
+ function mergeGraphVariableData! (destDFG:: H , sourceDFG:: G , varSyms:: Vector{Symbol} ):: Nothing where {G <: AbstractDFG , H <: AbstractDFG }
829
873
# Update all variables in the destination
830
874
# (For now... we may change this soon)
831
875
for variableId in varSyms
832
- mergeUpdateVariableSolverData ! (destDFG, getVariable (sourceDFG, variableId))
876
+ mergeVariableData ! (destDFG, getVariable (sourceDFG, variableId))
833
877
end
834
878
end
835
879
@@ -924,13 +968,15 @@ Related
924
968
925
969
isSolvable
926
970
"""
927
- function getSolveInProgress (var:: Union{DFGVariable, DFGFactor} ; solveKey:: Symbol = :default ):: Int
971
+ function getSolveInProgress (var:: Union{DFGVariable, DFGFactor} , solveKey:: Symbol = :default ):: Int
928
972
# Variable
929
973
var isa DFGVariable && return haskey (getSolverDataDict (var), solveKey) ? getSolverDataDict (var)[solveKey]. solveInProgress : 0
930
974
# Factor
931
975
return getSolverData (var). solveInProgress
932
976
end
933
977
978
+ isSolveInProgress (node:: Union{DFGVariable, DFGFactor} , solvekey:: Symbol = :default ) = getSolveInProgress (node, solvekey) > 0
979
+
934
980
"""
935
981
$SIGNATURES
936
982
0 commit comments