WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 823b618

Browse files
authored
use DFG.@PACKED macro and update addVariable! (#1897)
1 parent 324de14 commit 823b618

File tree

9 files changed

+44
-33
lines changed

9 files changed

+44
-33
lines changed

IncrementalInference/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
4848
SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
4949
TensorCast = "02d47bb6-7ce6-556a-be16-bb1710789e2b"
5050
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
51+
TimesDates = "bdfc003b-8df8-5c39-adcd-3a9087f5df4a"
5152
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
5253

5354
[weakdeps]
@@ -108,6 +109,7 @@ StatsBase = "0.32, 0.33, 0.34"
108109
StructTypes = "1"
109110
TensorCast = "0.3.3, 0.4"
110111
TimeZones = "1.3.1"
112+
TimesDates = "0.3.3"
111113
julia = "1.10"
112114

113115
[extras]

IncrementalInference/src/ExportAPI.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ export AbstractDFG,
2424
diagm,
2525
listBlobEntries,
2626
FolderStore,
27-
addBlobStore!,
27+
addBlobstore!,
2828
addData!,
2929
addBlob!,
3030
getData,
3131
VariableCompute,
32-
DFGVariableSummary,
32+
VariableSummary,
3333
FactorCompute,
3434
DFGFactorSummary,
3535
deleteVariableSolverData!

IncrementalInference/src/Factors/LinearRelative.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ X_2 = X_1 + η_Z
1111
```
1212
"""
1313
DFG.@tags struct LinearRelative{N, T <: SamplableBelief} <: RelativeObservation
14-
Z::T & (lower = DFG.Packed, choosetype = DFG.resolvePackedType)
14+
Z::T & DFG.@packed
1515
end
1616

1717
# need several helper constructors since the dimension over which LinearRelative will be used is unknown at this point

IncrementalInference/src/Factors/Mixture.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ end
5656

5757
DFG.@tags struct PackedMixture
5858
components::NamedTuple & (choosetype = obj->NamedTuple{Tuple(Symbol.(keys(obj))), Tuple{DFG.resolveType.(values(obj))...}}, )
59-
prior & (lower = DFG.Packed, choosetype = DFG.resolvePackedType)
59+
prior & DFG.@packed
6060
end
6161

6262
function DFG.pack(m::Mixture)

IncrementalInference/src/Factors/PartialPriorPassThrough.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DFG.@tags struct PartialPriorPassThrough{
66
B <: Union{<:HeatmapGridDensity, <:LevelSetGridNormal},
77
T <: Tuple,
88
} <: AbstractPriorObservation
9-
Z::B & (lower = DFG.Packed, choosetype = DFG.resolvePackedType)
9+
Z::B & DFG.@packed
1010
partial::T & (choosetype = x->NTuple{length(x), Int},)
1111
end
1212

IncrementalInference/src/IncrementalInference.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ using Dates,
7979
UUIDs,
8080
TensorCast
8181

82+
using TimesDates: TimeDateZone
83+
using TimeZones: ZonedDateTime
84+
8285
using StructTypes
8386

8487
using StaticArrays

IncrementalInference/src/services/FactorGraph.jl

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -566,61 +566,67 @@ fg = initfg()
566566
addVariable!(fg, :x0, Pose2)
567567
```
568568
"""
569-
function addVariable!(
569+
function DFG.addVariable!(
570570
dfg::AbstractDFG,
571571
label::Symbol,
572-
varTypeU::Union{T, Type{T}};
573-
N::Int = getSolverParams(dfg).N,
572+
statetype::Union{T, Type{T}};
573+
tags::Union{Set{Symbol}, Vector{Symbol}} = Set{Symbol}(),
574+
timestamp::Union{TimeDateZone, ZonedDateTime} = DFG.now_tdz(),
574575
solvable::Int = 1,
575-
timestamp::Union{DateTime, ZonedDateTime} = now(localzone()),
576-
nanosecondtime = nothing,
577-
# dontmargin::Bool = false,
578-
tags::Vector{Symbol} = Symbol[],
579-
smalldata = Dict{Symbol, DFG.MetadataTypes}(),
576+
# IIF extras
577+
N::Int = getSolverParams(dfg).N,
580578
checkduplicates::Bool = true,
579+
# dontmargin::Bool = false,
581580
initsolvekeys::Vector{Symbol} = getSolverParams(dfg).algorithms,
581+
582+
#deprecated v0.37
583+
smalldata = nothing,
584+
nanosecondtime = nothing,
585+
586+
# default DFG
587+
bloblets = DFG.Bloblets(),
588+
blobentries = DFG.Blobentries(),
589+
kwargs...,
582590
) where {T <: StateType}
583591

584592
if !isnothing(nanosecondtime)
585-
Base.depwarn(
586-
"nanosecondtime kwarg is deprecated, use `timestamp` instead",
587-
:addVariable!,
588-
)
593+
error("nanosecondtime kwarg is deprecated, use `timestamp` instead")
589594
end
590595

591-
varType = _variableType(varTypeU)
592-
593-
_zonedtime(s::DateTime) = ZonedDateTime(s, localzone())
594-
_zonedtime(s::ZonedDateTime) = s
596+
if !isnothing(smalldata)
597+
error("smalldata kwarg is deprecated, use `bloblets` instead")
598+
end
595599

596-
union!(tags, [:VARIABLE])
597-
v = VariableCompute(
600+
tags = union(Set(tags), [:VARIABLE])
601+
v = VariableDFG(
598602
label,
599-
varType;
600-
tags = Set(tags),
601-
bloblets = smalldata,
602-
solvable = solvable,
603-
timestamp = _zonedtime(timestamp),
603+
statetype;
604+
tags,
605+
bloblets,
606+
blobentries,
607+
solvable,
608+
timestamp,
609+
kwargs...,
604610
)
605611

606612
(:default in initsolvekeys) && setDefaultNodeData!(
607613
v,
608614
0,
609615
N;
610616
initialized = false,
611-
varType = varType,
617+
varType = T(),
612618
# dontmargin = dontmargin,
613619
) # dodims
614620

615621
(:parametric in initsolvekeys) &&
616622
setDefaultNodeDataParametric!(
617623
v,
618-
varType;
624+
T();
619625
initialized = false,
620626
# dontmargin = dontmargin
621627
)
622628

623-
return DFG.addVariable!(dfg, v)
629+
return addVariable!(dfg, v)
624630
end
625631

626632
function parseusermultihypo(multihypo::Nothing, nullhypo::Float64)

IncrementalInference/src/services/SolverUtilities.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ end
198198
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.
199199
200200
Notes
201-
- Checks, using provided `factor` from `srcLabel` in `fg` to an assumed `dest` variable whcih may or may not yet exist.
201+
- Checks, using provided `factor` from `srcLabel` in `fg` to an assumed `dest` variable which may or may not yet exist.
202202
- This function was written to aid in building simulation code,
203203
- it's use in real world usage may have unexpected behaviour -- hence not exported.
204204
- Return `::Tuple{Bool, Vector{Float64}, Symbol}`, eg. already exists `(true, [refVal], :l17)`, or if a refernce variable does not yet `(false, [refVal], :l28)`.

IncrementalInferenceTypes/src/factors/LinearRelative.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ X_2 = X_1 + η_Z
99
```
1010
"""
1111
# @tags struct LinearRelative{T} <: RelativeObservation
12-
# Z::T & (lower = DFG.Packed, choosetype = DFG.resolvePackedType)
12+
# Z::T & DFG.@packed
1313
# end
1414

1515
#TODO

0 commit comments

Comments
 (0)