Skip to content

Commit 4918b57

Browse files
authored
Merge pull request #1748 from JuliaRobotics/23Q3/ext/derelative
wip DiffEqFactorExt
2 parents 71a5c22 + 1393d57 commit 4918b57

File tree

7 files changed

+54
-36
lines changed

7 files changed

+54
-36
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
5050
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
5151

5252
[weakdeps]
53+
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
5354
Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004"
5455
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
5556
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
5657

5758
[extensions]
59+
DiffEqFactorExt = "DifferentialEquations"
5860
GadflyExt = "Gadfly"
5961
InteractiveUtilsExt = "InteractiveUtils"
6062
InterpolationsExt = "Interpolations"
@@ -96,7 +98,6 @@ TimeZones = "1.3.1"
9698
julia = "1.8"
9799

98100
[extras]
99-
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
100101
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
101102
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
102103
LineSearches = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"

src/ODE/DERelative.jl renamed to ext/DiffEqFactorExt.jl

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,20 @@
1+
module DiffEqFactorExt
12

2-
@info "IncrementalInference.jl is loading tools related to DifferentialEquations.jl"
3+
@info "IncrementalInference.jl is loading extensions related to DifferentialEquations.jl"
34

4-
using .DifferentialEquations
5+
using DifferentialEquations
6+
import DifferentialEquations: solve
57

6-
import .DifferentialEquations: solve
8+
using Dates
79

8-
import IncrementalInference: getSample, getManifold
10+
using IncrementalInference
11+
import IncrementalInference: getSample, getManifold, DERelative
912

10-
export DERelative
13+
using DocStringExtensions
1114

12-
"""
13-
$TYPEDEF
15+
export DERelative
1416

15-
Build a full ODE solution into a relative factor to condense possible sensor data into a relative transformation,
16-
but keeping the parameter estimation process fluid. Assumes first and second variable in order
17-
are of same dimension and compatible manifolds, such that ODE runs from Xi to Xi+1 on all
18-
dimensions. Internal state vector can be decoupled onto different domain as needed.
1917

20-
Notes
21-
- Based on DifferentialEquations.jl
22-
- `getSample` step does the `solve(ODEProblem)` step.
23-
- `tspan` is taken from variables only once at object construction -- i.e. won't detect changed timestamps.
24-
- Regular factor evaluation is done as full dimension `AbstractRelativeRoots`, and is basic linear difference.
25-
26-
DevNotes
27-
- FIXME see 1025, `multihypo=` will not yet work.
28-
- FIXME Lots of consolidation and standardization to do, see RoME.jl #244 regarding Manifolds.jl.
29-
- TODO does not yet handle case where a factor spans across two timezones.
30-
"""
31-
struct DERelative{T <: InferenceVariable, P, D} <: AbstractRelativeRoots
32-
domain::Type{T}
33-
forwardProblem::P
34-
backwardProblem::P
35-
# second element of this data tuple is additional variables that will be passed down as a parameter
36-
data::D
37-
specialSampler::Function
38-
end
3918

4019
getManifold(de::DERelative{T}) where {T} = getManifold(de.domain)
4120

@@ -132,6 +111,8 @@ function _solveFactorODE!(measArr, prob, u0pts, Xtra...)
132111
return sol
133112
end
134113

114+
getSample(cf::CalcFactor{<:DERelative}) = error("getSample(::CalcFactor{<:DERelative}) not implemented yet")
115+
135116
# FIXME see #1025, `multihypo=` will not work properly yet
136117
function sampleFactor(cf::CalcFactor{<:DERelative}, N::Int = 1)
137118
#
@@ -220,3 +201,5 @@ end
220201
# ode.problem.f.f
221202

222203
#
204+
205+
end # module

ext/GadflyExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module GadflyExt
44

55
using Gadfly
66
using DocStringExtensions
7-
using IncrementalInference: AbstractBayesTree, TreeCliq, getCliqueData, getCliqAssocMat, getCliqMat, getLabel, getCliqMsgMat, getClique
7+
using IncrementalInference: AbstractBayesTree, TreeClique, getCliqueData, getCliqAssocMat, getCliqMat, getLabel, getCliqMsgMat, getClique
88
import IncrementalInference: exportimg, spyCliqMat
99

1010
export exportimg, spyCliqMat

ext/WeakDepsPrototypes.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
11

2+
"""
3+
$TYPEDEF
4+
5+
Build a full ODE solution into a relative factor to condense possible sensor data into a relative transformation,
6+
but keeping the parameter estimation process fluid. Assumes first and second variable in order
7+
are of same dimension and compatible manifolds, such that ODE runs from Xi to Xi+1 on all
8+
dimensions. Internal state vector can be decoupled onto different domain as needed.
9+
10+
Notes
11+
- Based on DifferentialEquations.jl
12+
- `getSample` step does the `solve(ODEProblem)` step.
13+
- `tspan` is taken from variables only once at object construction -- i.e. won't detect changed timestamps.
14+
- Regular factor evaluation is done as full dimension `AbstractRelativeRoots`, and is basic linear difference.
15+
16+
DevNotes
17+
- FIXME see 1025, `multihypo=` will not yet work.
18+
- FIXME Lots of consolidation and standardization to do, see RoME.jl #244 regarding Manifolds.jl.
19+
- TODO does not yet handle case where a factor spans across two timezones.
20+
"""
21+
struct DERelative{T <: InferenceVariable, P, D} <: AbstractRelativeMinimize
22+
domain::Type{T}
23+
forwardProblem::P
24+
backwardProblem::P
25+
# second element of this data tuple is additional variables that will be passed down as a parameter
26+
data::D
27+
specialSampler::Function
28+
end
29+
230
# InteractiveUtils.jl
331
function getCurrentWorkspaceFactors end
432
function getCurrentWorkspaceVariables end

src/ExportAPI.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ export makeSolverData!
358358

359359
export MetaPrior
360360

361+
export DERelative
362+
361363
# weakdeps on InteractiveUtils.jl
362364
export getCurrentWorkspaceFactors, getCurrentWorkspaceVariables
363365
export listTypeTree

src/IncrementalInference.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ function __init__()
246246
# @require Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004" include(
247247
# "services/EmbeddedPlottingUtils.jl",
248248
# )
249-
@require DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa" include(
250-
"ODE/DERelative.jl",
251-
)
249+
# @require DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa" include(
250+
# "ODE/DERelative.jl",
251+
# )
252252
# @require Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" include(
253253
# "services/HeatmapSampler.jl",
254254
# )

test/runtests.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ include("testCircular.jl")
9696
include("testMixtureLinearConditional.jl")
9797
include("testFluxModelsDistribution.jl")
9898
include("testAnalysisTools.jl")
99-
# include("testDERelative.jl")
99+
try
100+
include("testDERelative.jl")
101+
catch
102+
@error "[FAILED] Fix testDERelative.jl, likely just requires implementing DiffEqFactorExt.getSample(::CalcFactor{<:DERelative})."
103+
end
100104

101105
include("testBasicParametric.jl")
102106
include("testMixtureParametric.jl")

0 commit comments

Comments
 (0)