Skip to content

Commit

Permalink
Merge pull request #1750 from JuliaRobotics/23Q3/fix/priorispart
Browse files Browse the repository at this point in the history
fix ispartial case on AbstractPrior
  • Loading branch information
dehann authored Jul 14, 2023
2 parents ab63b31 + b3c625e commit 4473045
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/services/EvalFactor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,16 @@ function evalPotentialSpecific(
ret
end

# TODO consider improving isPartial(ccwl<:AbstractPrior) to also check dimensions since we know pretty well what varDim is.
# TODO workaround until partial manifold approach is standardized, see #1492
Msrc = getManifold(fnc)
asPartial = isPartial(ccwl) || manifold_dimension(Msrc) < manifold_dimension(mani)

# view on elements marked for nullhypo
addEntrNH = view(addEntr, nhmask)
spreadDist = spreadNH * calcStdBasicSpread(getVariableType(variables[sfidx]), addEntr)
# partials are treated differently
ipc = if !isPartial(ccwl) #ccwl.partial
ipc = if !asPartial # isPartial(ccwl) #ccwl.partial
# TODO for now require measurements to be coordinates too
# @show typeof(ccwl.measurement[1])
for m in (1:length(addEntr))[ahmask]
Expand All @@ -473,7 +478,12 @@ function evalPotentialSpecific(
ones(getDimension(variables[sfidx]))
else
# FIXME but how to add partial factor info only on affected dimensions fro general manifold points?
pvec = [fnc.partial...]
# pvec
partialCoords = if hasfield(typeof(fnc), :partial)
ccwl.partialDims # [fnc.partial...]
else
collect(1:manifold_dimension(Msrc))
end

if !hasmethod(getManifold, (typeof(fnc),))
@debug "No method getManifold for $(typeof(fnc)), using getManifoldPartial"
Expand All @@ -484,13 +494,13 @@ function evalPotentialSpecific(
# addEntr is no longer in coordinates, these are now general manifold points!!
# for (i,dimnum) in enumerate(fnc.partial)
# FIXME, need ability to replace partial points
partialCoords = ccwl.partialDims
# partialCoords = ccwl.partialDims

#FIXME check if getManifold is defined otherwise fall back to getManifoldPartial, JT: I would like to standardize to getManifold
if hasmethod(getManifold, (typeof(fnc),))
Msrc = getManifold(fnc)
# TODO workaround until partial manifold approach is standardized, see #1492
asPartial = isPartial(fnc) || manifold_dimension(Msrc) < manifold_dimension(mani)
# Msrc = getManifold(fnc)
# # TODO workaround until partial manifold approach is standardized, see #1492
# asPartial = isPartial(fnc) || manifold_dimension(Msrc) < manifold_dimension(mani)

setPointPartial!(
mani,
Expand Down Expand Up @@ -520,10 +530,10 @@ function evalPotentialSpecific(
# null hypo mask that needs to be perturbed by "noise"
addEntrNHp = view(addEntr, nhmask)
# ongoing part of RoME.jl #244
addEntropyOnManifold!(mani, addEntrNHp, 1:getDimension(mani), spreadDist, pvec)
addEntropyOnManifold!(mani, addEntrNHp, 1:getDimension(mani), spreadDist, partialCoords) # pvec
# do info per coords
ipc_ = zeros(getDimension(variables[sfidx]))
ipc_[pvec] .= 1.0
ipc_[partialCoords] .= 1.0 # pvec
ipc_
end

Expand Down

0 comments on commit 4473045

Please sign in to comment.