diff --git a/IncrementalInference/Project.toml b/IncrementalInference/Project.toml index 66d9c91f..0515d176 100644 --- a/IncrementalInference/Project.toml +++ b/IncrementalInference/Project.toml @@ -48,6 +48,7 @@ StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4" SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" TensorCast = "02d47bb6-7ce6-556a-be16-bb1710789e2b" TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53" +TimesDates = "bdfc003b-8df8-5c39-adcd-3a9087f5df4a" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" [weakdeps] @@ -108,6 +109,7 @@ StatsBase = "0.32, 0.33, 0.34" StructTypes = "1" TensorCast = "0.3.3, 0.4" TimeZones = "1.3.1" +TimesDates = "0.3.3" julia = "1.10" [extras] diff --git a/IncrementalInference/src/ExportAPI.jl b/IncrementalInference/src/ExportAPI.jl index 95f7b351..f2ae7e9a 100644 --- a/IncrementalInference/src/ExportAPI.jl +++ b/IncrementalInference/src/ExportAPI.jl @@ -24,12 +24,12 @@ export AbstractDFG, diagm, listBlobEntries, FolderStore, - addBlobStore!, + addBlobstore!, addData!, addBlob!, getData, VariableCompute, - DFGVariableSummary, + VariableSummary, FactorCompute, DFGFactorSummary, deleteVariableSolverData! diff --git a/IncrementalInference/src/Factors/LinearRelative.jl b/IncrementalInference/src/Factors/LinearRelative.jl index 12e4734a..6a4d32ad 100644 --- a/IncrementalInference/src/Factors/LinearRelative.jl +++ b/IncrementalInference/src/Factors/LinearRelative.jl @@ -11,7 +11,7 @@ X_2 = X_1 + η_Z ``` """ DFG.@tags struct LinearRelative{N, T <: SamplableBelief} <: RelativeObservation - Z::T & (lower = DFG.Packed, choosetype = DFG.resolvePackedType) + Z::T & DFG.@packed end # need several helper constructors since the dimension over which LinearRelative will be used is unknown at this point diff --git a/IncrementalInference/src/Factors/Mixture.jl b/IncrementalInference/src/Factors/Mixture.jl index 6623520d..7d1a8a59 100644 --- a/IncrementalInference/src/Factors/Mixture.jl +++ b/IncrementalInference/src/Factors/Mixture.jl @@ -56,7 +56,7 @@ end DFG.@tags struct PackedMixture components::NamedTuple & (choosetype = obj->NamedTuple{Tuple(Symbol.(keys(obj))), Tuple{DFG.resolveType.(values(obj))...}}, ) - prior & (lower = DFG.Packed, choosetype = DFG.resolvePackedType) + prior & DFG.@packed end function DFG.pack(m::Mixture) diff --git a/IncrementalInference/src/Factors/PartialPriorPassThrough.jl b/IncrementalInference/src/Factors/PartialPriorPassThrough.jl index 8fd38fb6..69d86058 100644 --- a/IncrementalInference/src/Factors/PartialPriorPassThrough.jl +++ b/IncrementalInference/src/Factors/PartialPriorPassThrough.jl @@ -6,7 +6,7 @@ DFG.@tags struct PartialPriorPassThrough{ B <: Union{<:HeatmapGridDensity, <:LevelSetGridNormal}, T <: Tuple, } <: AbstractPriorObservation - Z::B & (lower = DFG.Packed, choosetype = DFG.resolvePackedType) + Z::B & DFG.@packed partial::T & (choosetype = x->NTuple{length(x), Int},) end diff --git a/IncrementalInference/src/IncrementalInference.jl b/IncrementalInference/src/IncrementalInference.jl index 3df65fe2..73393175 100644 --- a/IncrementalInference/src/IncrementalInference.jl +++ b/IncrementalInference/src/IncrementalInference.jl @@ -79,6 +79,9 @@ using Dates, UUIDs, TensorCast +using TimesDates: TimeDateZone +using TimeZones: ZonedDateTime + using StructTypes using StaticArrays diff --git a/IncrementalInference/src/services/FactorGraph.jl b/IncrementalInference/src/services/FactorGraph.jl index 92b7d8f0..ce34391b 100644 --- a/IncrementalInference/src/services/FactorGraph.jl +++ b/IncrementalInference/src/services/FactorGraph.jl @@ -566,41 +566,47 @@ fg = initfg() addVariable!(fg, :x0, Pose2) ``` """ -function addVariable!( +function DFG.addVariable!( dfg::AbstractDFG, label::Symbol, - varTypeU::Union{T, Type{T}}; - N::Int = getSolverParams(dfg).N, + statetype::Union{T, Type{T}}; + tags::Union{Set{Symbol}, Vector{Symbol}} = Set{Symbol}(), + timestamp::Union{TimeDateZone, ZonedDateTime} = DFG.now_tdz(), solvable::Int = 1, - timestamp::Union{DateTime, ZonedDateTime} = now(localzone()), - nanosecondtime = nothing, - # dontmargin::Bool = false, - tags::Vector{Symbol} = Symbol[], - smalldata = Dict{Symbol, DFG.MetadataTypes}(), + # IIF extras + N::Int = getSolverParams(dfg).N, checkduplicates::Bool = true, + # dontmargin::Bool = false, initsolvekeys::Vector{Symbol} = getSolverParams(dfg).algorithms, + + #deprecated v0.37 + smalldata = nothing, + nanosecondtime = nothing, + + # default DFG + bloblets = DFG.Bloblets(), + blobentries = DFG.Blobentries(), + kwargs..., ) where {T <: StateType} if !isnothing(nanosecondtime) - Base.depwarn( - "nanosecondtime kwarg is deprecated, use `timestamp` instead", - :addVariable!, - ) + error("nanosecondtime kwarg is deprecated, use `timestamp` instead") end - varType = _variableType(varTypeU) - - _zonedtime(s::DateTime) = ZonedDateTime(s, localzone()) - _zonedtime(s::ZonedDateTime) = s + if !isnothing(smalldata) + error("smalldata kwarg is deprecated, use `bloblets` instead") + end - union!(tags, [:VARIABLE]) - v = VariableCompute( + tags = union(Set(tags), [:VARIABLE]) + v = VariableDFG( label, - varType; - tags = Set(tags), - bloblets = smalldata, - solvable = solvable, - timestamp = _zonedtime(timestamp), + statetype; + tags, + bloblets, + blobentries, + solvable, + timestamp, + kwargs..., ) (:default in initsolvekeys) && setDefaultNodeData!( @@ -608,19 +614,19 @@ function addVariable!( 0, N; initialized = false, - varType = varType, + varType = T(), # dontmargin = dontmargin, ) # dodims (:parametric in initsolvekeys) && setDefaultNodeDataParametric!( v, - varType; + T(); initialized = false, # dontmargin = dontmargin ) - return DFG.addVariable!(dfg, v) + return addVariable!(dfg, v) end function parseusermultihypo(multihypo::Nothing, nullhypo::Float64) diff --git a/IncrementalInference/src/services/SolverUtilities.jl b/IncrementalInference/src/services/SolverUtilities.jl index 3f46f254..db89d32d 100644 --- a/IncrementalInference/src/services/SolverUtilities.jl +++ b/IncrementalInference/src/services/SolverUtilities.jl @@ -198,7 +198,7 @@ end Check if a variable might already be located at the test location, by means of a (default) `refKey=:simulated` PPE stored in the existing variables. Notes -- Checks, using provided `factor` from `srcLabel` in `fg` to an assumed `dest` variable whcih may or may not yet exist. +- Checks, using provided `factor` from `srcLabel` in `fg` to an assumed `dest` variable which may or may not yet exist. - This function was written to aid in building simulation code, - it's use in real world usage may have unexpected behaviour -- hence not exported. - Return `::Tuple{Bool, Vector{Float64}, Symbol}`, eg. already exists `(true, [refVal], :l17)`, or if a refernce variable does not yet `(false, [refVal], :l28)`. diff --git a/IncrementalInferenceTypes/src/factors/LinearRelative.jl b/IncrementalInferenceTypes/src/factors/LinearRelative.jl index 51e74b56..e9da7c98 100644 --- a/IncrementalInferenceTypes/src/factors/LinearRelative.jl +++ b/IncrementalInferenceTypes/src/factors/LinearRelative.jl @@ -9,7 +9,7 @@ X_2 = X_1 + η_Z ``` """ # @tags struct LinearRelative{T} <: RelativeObservation -# Z::T & (lower = DFG.Packed, choosetype = DFG.resolvePackedType) +# Z::T & DFG.@packed # end #TODO