Skip to content

Commit 68c9066

Browse files
committed
wip w partials, sampleTangent
1 parent 0b1ea37 commit 68c9066

File tree

5 files changed

+26
-9
lines changed

5 files changed

+26
-9
lines changed

src/Factors/GenericFunctions.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ DFG.getManifold(f::ManifoldFactor) = f.M
8080
function getSample(cf::CalcFactor{<:ManifoldFactor{M, Z}}) where {M, Z}
8181
#TODO @assert dim == cf.factor.Z's dimension
8282
#TODO investigate use of SVector if small dims
83-
if M isa ManifoldKernelDensity
84-
ret = sample(cf.factor.Z.belief)[1]
85-
else
86-
ret = rand(cf.factor.Z)
87-
end
88-
# ret = sampleTangent(M, cf.factor.Z)
83+
# if M isa ManifoldKernelDensity
84+
# ret = sample(cf.factor.Z.belief)[1]
85+
# else
86+
# ret = rand(cf.factor.Z)
87+
# end
88+
89+
# ASSUME this function is only used for RelativeFactors which must use measurements as tangents
90+
ret = sampleTangent(cf.factor.M, cf.factor.Z)
8991
#return coordinates as we do not know the point here #TODO separate Lie group
9092
return ret
9193
end

src/ManifoldSampling.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function sampleTangent(x::ManifoldKernelDensity, p = mean(x))
2323
end
2424

2525
# Sampling Distributions
26-
function sampleTangent(M::AbstractManifold, z::Distribution, p, basis::AbstractBasis)
26+
function sampleTangent(M::AbstractManifold, z::Distribution, p = getPointIdentity(M), basis::AbstractBasis = DefaultOrthogonalBasis())
2727
return get_vector(M, p, rand(z), basis)
2828
end
2929

src/Variables/DefaultVariables.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function DFG.getDimension(val::InstanceType{Position{N}}) where {N}
1616
return manifold_dimension(getManifold(val))
1717
end
1818
DFG.getPointType(::Type{Position{N}}) where {N} = Vector{Float64}
19-
DFG.getPointIdentity(M_::Type{Position{N}}) where {N} = zeros(N) # identity_element(getManifold(M_), zeros(N))
19+
DFG.getPointIdentity(M_::Type{Position{N}}) where {N} = @SVector(zeros(N)) # identity_element(getManifold(M_), zeros(N))
2020

2121
function Base.convert(
2222
::Type{<:ManifoldsBase.AbstractManifold},

src/services/FGOSUtils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ function manikde!(
122122
) where {P <: Union{<:AbstractArray, <:Number, <:Manifolds.ArrayPartition}}
123123
#
124124
M = getManifold(variableType)
125+
# @info "pts" P typeof(pts[1]) pts[1]
125126
infoPerCoord = ones(AMP.getNumberCoords(M, pts[1]))
126127
return AMP.manikde!(M, pts; infoPerCoord, kw...)
127128
end

test/testSpecialEuclidean2Mani.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,23 @@ doautoinit!(fg, :x0)
388388
@test length(getPoints(getBelief(fg, :x0))) == getSolverParams(fg).N # 120
389389
# @info "PassThrough transfers the full point count to the graph, unless a product is calculated during the propagateBelief step."
390390

391+
392+
393+
## check the partials magic
394+
395+
dens, ipc = propagateBelief(fg,:x0,:)
396+
testv = deepcopy(getVariable(fg, :x0))
397+
setBelief!(testv, dens, true, ipc)
398+
399+
391400
##
392401

393-
solveGraph!(fg);
402+
smtasks = Task[]
403+
solveGraph!(fg; smtasks);
404+
# hists = fetchCliqHistoryAll!(smtasks)
405+
# printCSMHistoryLogical(hists)
406+
# hists_ = deepcopy(hists)
407+
# repeatCSMStep!(hists, 1, 6)
394408

395409
@test 120 == length(getPoints(fg, :x0))
396410

0 commit comments

Comments
 (0)