Skip to content

Commit bb53470

Browse files
authored
Merge pull request #1677 from JuliaRobotics/23Q1/enh/dfg19update
update for DFG v0.19
2 parents 5c818c3 + f171a84 commit bb53470

File tree

4 files changed

+70
-52
lines changed

4 files changed

+70
-52
lines changed

src/services/FGOSUtils.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ function calcPPE(
235235
varType::InferenceVariable = getVariableType(var);
236236
ppeType::Type{<:MeanMaxPPE} = MeanMaxPPE,
237237
solveKey::Symbol = :default,
238-
ppeKey::Symbol = solveKey,
239-
timestamp = now(),
238+
ppeKey::Symbol = solveKey
240239
)
241240
#
242241
P = getBelief(var, solveKey)
@@ -253,9 +252,22 @@ function calcPPE(
253252
Pme_ = getCoordinates(varType, Pme)
254253
# Pma_ = getCoordinates(M,Pme)
255254

255+
ppes = getPPEDict(var)
256+
id = if haskey(ppes, ppeKey)
257+
ppes[ppeKey].id
258+
else
259+
nothing
260+
end
261+
256262
# suggested, max, mean, current time
257263
# TODO, poor constructor argument assumptions on `ppeType`
258-
return ppeType(ppeKey, Pme_, Pma, Pme_, timestamp)
264+
return ppeType(;
265+
id,
266+
solveKey=ppeKey,
267+
suggested=Pme_,
268+
max=Pma,
269+
mean=Pme_,
270+
)
259271
end
260272

261273
# calcPPE(var::DFGVariable; method::Type{<:AbstractPointParametricEst}=MeanMaxPPE, solveKey::Symbol=:default) = calcPPE(var, getVariableType(var), method=method, solveKey=solveKey)

src/services/FactorGraph.jl

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -386,25 +386,26 @@ function DefaultNodeDataParametric(
386386
# gbw2, Symbol[], sp,
387387
# dims, false, :_null, Symbol[], variableType, true, 0.0, false, dontmargin)
388388
else
389-
sp = round.(Int, range(dodims; stop = dodims + dims - 1, length = dims))
389+
# dimIDs = round.(Int, range(dodims; stop = dodims + dims - 1, length = dims))
390390
ϵ = getPointIdentity(variableType)
391-
return VariableNodeData(
392-
[ϵ],
393-
zeros(dims, dims),
394-
Symbol[],
395-
sp,
391+
return VariableNodeData(;
392+
id=nothing,
393+
val=[ϵ],
394+
bw=zeros(dims, dims),
395+
# Symbol[],
396+
# dimIDs,
396397
dims,
397-
false,
398-
:_null,
399-
Symbol[],
398+
# false,
399+
# :_null,
400+
# Symbol[],
400401
variableType,
401-
false,
402-
zeros(dims),
403-
false,
402+
initialized=false,
403+
infoPerCoord=zeros(dims),
404+
ismargin=false,
404405
dontmargin,
405-
0,
406-
0,
407-
:parametric,
406+
# 0,
407+
# 0,
408+
solveKey,
408409
)
409410
end
410411
end
@@ -440,7 +441,7 @@ function setDefaultNodeData!(
440441
v::DFGVariable,
441442
dodims::Int,
442443
N::Int,
443-
dims::Int;
444+
dims::Int=getDimension(v);
444445
solveKey::Symbol = :default,
445446
gt = Dict(),
446447
initialized::Bool = true,
@@ -453,42 +454,43 @@ function setDefaultNodeData!(
453454
data = nothing
454455
isinit = false
455456
sp = Int[0;]
456-
(valpts, bws) = if initialized
457+
(val, bw) = if initialized
457458
pN = resample(getBelief(v))
458-
bws = getBW(pN)[:, 1:1]
459+
bw = getBW(pN)[:, 1:1]
459460
pNpts = getPoints(pN)
460461
isinit = true
461-
(pNpts, bws)
462+
(pNpts, bw)
462463
else
463464
sp = round.(Int, range(dodims; stop = dodims + dims - 1, length = dims))
464465
@assert getPointType(varType) != DataType "cannot add manifold point type $(getPointType(varType)), make sure the identity element argument in @defVariable $varType arguments is correct"
465-
valpts = Vector{getPointType(varType)}(undef, N)
466-
for i = 1:length(valpts)
467-
valpts[i] = getPointIdentity(varType)
466+
val = Vector{getPointType(varType)}(undef, N)
467+
for i = 1:length(val)
468+
val[i] = getPointIdentity(varType)
468469
end
469-
bws = zeros(dims, 1)
470+
bw = zeros(dims, 1)
470471
#
471-
(valpts, bws)
472+
(val, bw)
472473
end
473474
# make and set the new solverData
474475
setSolverData!(
475476
v,
476-
VariableNodeData(
477-
valpts,
478-
bws,
479-
Symbol[],
480-
sp,
477+
VariableNodeData(;
478+
id=nothing,
479+
val,
480+
bw,
481+
# Symbol[],
482+
# sp,
481483
dims,
482-
false,
483-
:_null,
484-
Symbol[],
485-
varType,
486-
isinit,
487-
zeros(getDimension(v)),
488-
false,
484+
# false,
485+
# :_null,
486+
# Symbol[],
487+
variableType=varType,
488+
initialized=isinit,
489+
infoPerCoord=zeros(getDimension(v)),
490+
ismargin=false,
489491
dontmargin,
490-
0,
491-
0,
492+
# 0,
493+
# 0,
492494
solveKey,
493495
),
494496
solveKey,
@@ -587,14 +589,17 @@ function addVariable!(
587589
#
588590
varType = _variableType(varTypeU)
589591

592+
_zonedtime(s::DateTime) = ZonedDateTime(s, localzone())
593+
_zonedtime(s::ZonedDateTime) = s
594+
590595
union!(tags, [:VARIABLE])
591596
v = DFGVariable(
592597
label,
593598
varType;
594599
tags = Set(tags),
595600
smallData = smalldata,
596601
solvable = solvable,
597-
timestamp = timestamp,
602+
timestamp = _zonedtime(timestamp),
598603
nstime = Nanosecond(nanosecondtime),
599604
)
600605

@@ -611,9 +616,7 @@ function addVariable!(
611616
(:parametric in initsolvekeys) &&
612617
setDefaultNodeDataParametric!(v, varType; initialized = false, dontmargin = dontmargin)
613618

614-
DFG.addVariable!(dfg, v)
615-
616-
return v
619+
return DFG.addVariable!(dfg, v)
617620
end
618621

619622
function parseusermultihypo(multihypo::Nothing, nullhypo::Float64)
@@ -825,6 +828,9 @@ function DFG.addFactor!(
825828

826829
@assert (suppressChecks || length(multihypo) === 0 || length(multihypo) == length(Xi)) "When using multihypo=[...], the number of variables and multihypo probabilies must match. See documentation on how to include fractional data-association uncertainty."
827830

831+
_zonedtime(s::ZonedDateTime) = s
832+
_zonedtime(s::DateTime) = ZonedDateTime(s, localzone())
833+
828834
varOrderLabels = Symbol[v.label for v in Xi]
829835
solverData = getDefaultFactorData(
830836
dfg,
@@ -843,16 +849,16 @@ function DFG.addFactor!(
843849
solverData;
844850
tags = Set(union(tags, [:FACTOR])),
845851
solvable,
846-
timestamp,
852+
timestamp = _zonedtime(timestamp),
847853
)
848854
#
849855

850-
success = addFactor!(dfg, newFactor)
856+
factor = addFactor!(dfg, newFactor)
851857

852858
# TODO: change this operation to update a conditioning variable
853859
graphinit && doautoinit!(dfg, Xi; singles = false)
854860

855-
return newFactor
861+
return factor
856862
end
857863

858864
function _checkFactorAdd(usrfnc, xisyms)
@@ -879,7 +885,7 @@ function DFG.addFactor!(
879885

880886
# variables = getVariable.(dfg, vlbs)
881887
variables = map(vid -> getVariable(dfg, vid), vlbs)
882-
return addFactor!(dfg, variables, usrfnc; suppressChecks = suppressChecks, kw...)
888+
return addFactor!(dfg, variables, usrfnc; suppressChecks, kw...)
883889
end
884890

885891
#

src/services/JunctionTreeUtils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ function prepBatchTreeOLD!(
847847
end
848848
end
849849

850-
tree = buildTreeFromOrdering!(dfg, p; drawbayesnet = false) # drawbayesnet
850+
tree = buildTreeFromOrdering!(dfg, Symbol.(p); drawbayesnet = false) # drawbayesnet
851851

852852
@info "Bayes Tree Complete"
853853
if drawpdf

test/testgraphpackingconverters.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ dat = getSolverData(getVariable(fg,:x1))
6868

6969
# dat.BayesNetVertID
7070

71-
pd = packVariableNodeData(fg, dat)
72-
unpckd = unpackVariableNodeData(fg, pd)
71+
pd = packVariableNodeData(dat)
72+
unpckd = unpackVariableNodeData(pd)
7373

7474
@test compareFields(dat, unpckd, skip=[:variableType])
7575
@test compareFields(getVariableType(dat), getVariableType(unpckd))

0 commit comments

Comments
 (0)