Skip to content

Commit c015649

Browse files
committed
Merge branch '23Q1/enh/dfg19update' of github.com:JuliaRobotics/IncrementalInference.jl into 23Q1/api/dfg19solve
2 parents 018f4d0 + 5a89599 commit c015649

File tree

3 files changed

+73
-55
lines changed

3 files changed

+73
-55
lines changed

src/ParametricUtils.jl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -790,20 +790,10 @@ Update the parametric solver data value and covariance.
790790
"""
791791
function updateSolverDataParametric! end
792792

793-
function updateSolverDataParametric!(
794-
v::DFGVariable,
795-
val::AbstractArray{<:Real},
796-
cov::Matrix;
797-
solveKey::Symbol = :parametric,
798-
)
799-
vnd = getSolverData(v, solveKey)
800-
return updateSolverDataParametric!(vnd, val, cov)
801-
end
802-
803793
function updateSolverDataParametric!(
804794
vnd::VariableNodeData,
805-
val::AbstractArray{<:Real},
806-
cov::Matrix,
795+
val::AbstractArray,
796+
cov::AbstractMatrix,
807797
)
808798
# fill in the variable node data value
809799
vnd.val[1] = val
@@ -812,6 +802,17 @@ function updateSolverDataParametric!(
812802
return vnd
813803
end
814804

805+
function updateSolverDataParametric!(
806+
v::DFGVariable,
807+
val::AbstractArray,
808+
cov::AbstractMatrix;
809+
solveKey::Symbol = :parametric,
810+
)
811+
vnd = getSolverData(v, solveKey)
812+
return updateSolverDataParametric!(vnd, val, cov)
813+
end
814+
815+
815816
"""
816817
$SIGNATURES
817818
Add parametric solver to fg, batch solve using [`solveGraphParametric`](@ref) and update fg.

src/services/FGOSUtils.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,23 @@ function calcPPE(
252252
Pme_ = getCoordinates(varType, Pme)
253253
# Pma_ = getCoordinates(M,Pme)
254254

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

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

src/services/FactorGraph.jl

Lines changed: 45 additions & 42 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,
@@ -862,7 +864,7 @@ end
862864

863865
function DFG.addFactor!(
864866
dfg::AbstractDFG,
865-
xisyms::AbstractVector{Symbol},
867+
vlbs::AbstractVector{Symbol},
866868
usrfnc::AbstractFactor;
867869
suppressChecks::Bool = false,
868870
kw...,
@@ -871,11 +873,12 @@ function DFG.addFactor!(
871873

872874
# basic sanity check for unary vs n-ary
873875
if !suppressChecks
874-
_checkFactorAdd(usrfnc, xisyms)
876+
_checkFactorAdd(usrfnc, vlbs)
877+
@assert length(vlbs) == length(unique(vlbs)) "List of variables should be unique and ordered."
875878
end
876879

877-
# variables = getVariable.(dfg, xisyms)
878-
variables = map(vid -> getVariable(dfg, vid), xisyms)
880+
# variables = getVariable.(dfg, vlbs)
881+
variables = map(vid -> getVariable(dfg, vid), vlbs)
879882
return addFactor!(dfg, variables, usrfnc; suppressChecks = suppressChecks, kw...)
880883
end
881884

0 commit comments

Comments
 (0)