Skip to content

Commit

Permalink
Merge pull request #1436 from JuliaRobotics/master
Browse files Browse the repository at this point in the history
v0.25.5-rc1
  • Loading branch information
dehann authored Oct 22, 2021
2 parents 959d766 + adbe12a commit 59e6dd7
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The list below highlights major breaking changes, and please note that significa
- Removing obsolete `approxConvCircular`, use `approxConvBelief` instead.
- `getSample` should return a single sample and no longer takes the N(number of samples) parameter.
- `solveTree!` / `solveGraph!` now returns just one value `tree<:AbstractBayesTree`. Previous version returned three values, `tree, smt, hist` (#1379).
- **Note for v0.25.5** Serialization of newly introduced type `PackedHeatmapGridDensity` changed from v0.25.4, unlikely have yet been used publically, therefore emphasizing fastest possible standardization in this case (even though this particular event does not strictly follow semver). General usage and operation is effectively unchanged,see #1435.

# Major changes in v0.24

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "IncrementalInference"
uuid = "904591bb-b899-562f-9e6f-b8df64c7d480"
keywords = ["MM-iSAMv2", "Bayes tree", "junction tree", "Bayes network", "variable elimination", "graphical models", "SLAM", "inference", "sum-product", "belief-propagation"]
desc = "Implements the Multimodal-iSAMv2 algorithm."
version = "0.25.4"
version = "0.25.5"

[deps]
ApproxManifoldProducts = "9bbbb610-88a1-53cd-9763-118ce10c1f89"
Expand Down
2 changes: 1 addition & 1 deletion src/DispatchPackedConversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ end

## unpack converters------------------------------------------------------------


# FIXME see #1424
function convert(
::Type{GenericFunctionNodeData{CommonConvWrapper{F}}},
packed::GenericFunctionNodeData{P} ) where {F <: AbstractFactor, P <: PackedInferenceType}
Expand Down
14 changes: 8 additions & 6 deletions src/SerializingDistributions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ mutable struct PackedHeatmapGridDensity <: PackedSamplableBelief
domain::Tuple{Vector{Float64}, Vector{Float64}}
hint_callback::String
bw_factor::Float64
densityFnc::String
N::Int
# densityFnc::String # TODO rather rebuild at unpack
end


Expand All @@ -171,28 +172,29 @@ function convert( ::Union{Type{<:SamplableBelief},Type{<:HeatmapGridDensity}},
data__ = map(x->collect(x), data_)
@cast data[i,j] := data__[j][i]
_data__ = collect(data)
densFnc = convert(SamplableBelief, obj.densityFnc)
# densFnc = convert(SamplableBelief, obj.densityFnc)
# build the final object, misses the hint...
HeatmapGridDensity( _data__,
obj.domain,
obj.hint_callback == "" ? nothing : nothing,
obj.bw_factor,
densFnc )
obj.bw_factor;
N=obj.N )
end

function convert( ::Union{Type{<:PackedSamplableBelief},Type{<:PackedHeatmapGridDensity}},
obj::HeatmapGridDensity )
#
data_ = obj.data
@cast data[j][i] := data_[i,j]
str = convert(SamplableBelief, obj.densityFnc)
# str = convert(SamplableBelief, obj.densityFnc)
N = Npts(obj.densityFnc)
# TODO misses the hint...
PackedHeatmapGridDensity( "IncrementalInference.PackedHeatmapGridDensity",
data,
obj.domain,
"",
obj.bw_factor,
str )
N )
end


Expand Down
3 changes: 3 additions & 0 deletions src/entities/OptionalDensities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ Notes
- Density approximation is constructed on Guassian measurement assumption of level set and sigma variation.
- Assume data is on a regular grid on TranslationGroup(2)
- Assume on early implementation `x_grid, y_grid = domain`
- Serialization currently does not store the hint callback.
- To save space, serialization does not store the internal density, but rather reconstructs at unpacking.
DevNotes:
- Generalize to scalar fields on any Manifold.
- Generalize to vector fields if interpolation is sensible.
- TODO standardize with AliasingScalarSampler see IIF #1341
- TODO store the hint function (at least any easy cases)
"""
struct HeatmapGridDensity{T <: Real, H <: Union{<:Function, Nothing}, B <: Union{ManifoldKernelDensity, BallTreeDensity}}
"""intensity data, on regular grid"""
Expand Down
12 changes: 9 additions & 3 deletions src/services/CalcFactor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ function calcFactorResidualTemporary( fct::AbstractRelative,
measurement,
pts::Tuple;
tfg::AbstractDFG = initfg(),
_blockRecursion::Bool=false )
_blockRecursion::Bool=false,
doTime::Bool=false )
#

# build a new temporary graph
Expand All @@ -135,9 +136,14 @@ function calcFactorResidualTemporary( fct::AbstractRelative,
cfo = CalcFactor(_getCCW(_dfgfct))
sampleFactor(cfo, 1)[1]
end

# assume a single sample point is being run
return calcFactorResidual(_dfgfct, _measurement, pts...)
return if doTime
@time res = calcFactorResidual(_dfgfct, _measurement, pts...)
res
else
calcFactorResidual(_dfgfct, _measurement, pts...)
end
end


Expand Down
8 changes: 4 additions & 4 deletions src/services/HeatmapSampler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ end
# Helper function to construct HGD
function HeatmapGridDensity(data::AbstractMatrix{<:Real},
domain::Tuple{<:AbstractVector{<:Real},<:AbstractVector{<:Real}},
hist_callback::Union{<:Function, Nothing}=nothing,
hint_callback::Union{<:Function, Nothing}=nothing,
bw_factor::Real=0.7; # kde spread between domain points
N::Int=10000 )
#
Expand Down Expand Up @@ -101,7 +101,7 @@ function HeatmapGridDensity(data::AbstractMatrix{<:Real},
density = ManifoldKernelDensity(TranslationGroup(Ndim(bel)), bel)

# return `<:SamplableBelief` object
HeatmapGridDensity(data, domain, hist_callback, bw_factor, density)
HeatmapGridDensity(data, domain, hint_callback, bw_factor, density)
end


Expand All @@ -111,7 +111,7 @@ function LevelSetGridNormal(data::AbstractMatrix{<:Real},
level::Real,
sigma::Real;
sigma_scale::Real=3,
hist_callback::Union{<:Function, Nothing}=nothing,
hint_callback::Union{<:Function, Nothing}=nothing,
bw_factor::Real=0.7, # kde spread between domain points
N::Int=10000 )
#
Expand All @@ -128,7 +128,7 @@ function LevelSetGridNormal(data::AbstractMatrix{<:Real},
# l = 1/2 (h-z/σ)^2
# masked_roi = 0 .< κ^2 - l

hgd = HeatmapGridDensity(data, domain, hist_callback, bw_factor; N=N)
hgd = HeatmapGridDensity(data, domain, hint_callback, bw_factor; N=N)

LevelSetGridNormal(level, sigma, float(sigma_scale), hgd)
end
Expand Down

0 comments on commit 59e6dd7

Please sign in to comment.