Skip to content

Commit 45b661f

Browse files
authored
Merge pull request #1791 from JuliaRobotics/master
fast forward
2 parents 008ab5b + 4bcc7b4 commit 45b661f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1651
-1076
lines changed

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ The list below highlights breaking changes according to normal semver workflow -
1717
- Deprecate `AbstractRelativeRoots`.
1818
- Standardization improvements surrounding weakdeps code extensions.
1919
- Code quality improvements along wiht refactoring and reorganizing of file names and locations.
20-
- Restoring `DERelative` factors, although further fixes necessary beyond anticipated patch release v0.34.1.
20+
- Restoring `DERelative` factors, through v0.34.1 and v0.34.2.
21+
- Switching to weakdep AMD.jl for `ccolmod` dependency, part of Julia 1.10 upgrade. Dropping `SuiteSparse_long` dependency. Further fixes necessary to restore full user constrained tree variable order functionality.
2122

2223
# Changes in v0.33
2324

Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ version = "0.34.1"
88
ApproxManifoldProducts = "9bbbb610-88a1-53cd-9763-118ce10c1f89"
99
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
1010
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
11-
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
1211
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
1312
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
1413
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
@@ -67,7 +66,6 @@ IncrInfrInterpolationsExt = "Interpolations"
6766
[compat]
6867
ApproxManifoldProducts = "0.7, 0.8"
6968
BSON = "0.2, 0.3"
70-
BlockArrays = "0.16"
7169
Combinatorics = "1.0"
7270
DataStructures = "0.16, 0.17, 0.18"
7371
DelimitedFiles = "1"

benchmark/runbenchmarks.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fg.solverParams.graphinit=false;
3535
addVariable!(fg, :x0, Pose2);
3636
addFactor!(fg, [:x0], PriorPose2(MvNormal([0.0,0,0], diagm([0.1,0.1,0.01].^2))));
3737

38-
r = @timed IIF.solveGraphParametric!(fg; init=false);
38+
r = @timed IIF.solveGraphParametric!(fg; init=false, is_sparse=false);
3939

4040
timed = [r];
4141

@@ -44,7 +44,7 @@ for i = 1:14
4444
to = Symbol("x",i)
4545
addVariable!(fg, to, Pose2)
4646
addFactor!(fg, [fr,to], Pose2Pose2(MvNormal([10.0,0,pi/3], diagm([0.5,0.5,0.05].^2))))
47-
r = @timed IIF.solveGraphParametric!(fg; init=false);
47+
r = @timed IIF.solveGraphParametric!(fg; init=false, is_sparse=false);
4848
push!(timed, r)
4949
end
5050

@@ -53,7 +53,7 @@ addVariable!(fg, :l1, RoME.Point2, tags=[:LANDMARK;]);
5353
addFactor!(fg, [:x0; :l1], Pose2Point2BearingRange(Normal(0.0,0.1), Normal(20.0, 1.0)));
5454
addFactor!(fg, [:x6; :l1], Pose2Point2BearingRange(Normal(0.0,0.1), Normal(20.0, 1.0)));
5555

56-
r = @timed IIF.solveGraphParametric!(fg; init=false);
56+
r = @timed IIF.solveGraphParametric!(fg; init=false, is_sparse=false);
5757
push!(timed, r);
5858

5959
getproperty.(timed, :time)

ext/IncrInfrDiffEqFactorExt.jl

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import DifferentialEquations: solve
88
using Dates
99

1010
using IncrementalInference
11-
import IncrementalInference: getSample, getManifold, DERelative
12-
import IncrementalInference: sampleFactor
11+
import IncrementalInference: DERelative, _solveFactorODE!
12+
import IncrementalInference: getSample, sampleFactor, getManifold
1313

1414
using DocStringExtensions
1515

@@ -174,12 +174,12 @@ function (cf::CalcFactor{<:DERelative})(measurement, X...)
174174
# need to recalculate new ODE (forward) for change in parameters (solving for 3rd or higher variable)
175175
solveforIdx = 2
176176
# use forward solve for all solvefor not in [1;2]
177-
u0pts = getBelief(cf.fullvariables[1]) |> getPoints
177+
# u0pts = getBelief(cf.fullvariables[1]) |> getPoints
178178
# update parameters for additional variables
179179
_solveFactorODE!(
180180
meas1,
181181
oderel.forwardProblem,
182-
u0pts[cf._sampleIdx],
182+
X[1], # u0pts[cf._sampleIdx],
183183
_maketuplebeyond2args(X...)...,
184184
)
185185
end
@@ -192,13 +192,52 @@ function (cf::CalcFactor{<:DERelative})(measurement, X...)
192192
#FIXME
193193
res = zeros(size(X[2], 1))
194194
for i = 1:size(X[2], 1)
195-
# diffop( test, reference ) <===> ΔX = test \ reference
195+
# diffop( reference?, test? ) <===> ΔX = test \ reference
196196
res[i] = diffOp[i](X[solveforIdx][i], meas1[i])
197197
end
198198
return res
199199
end
200200

201201

202+
# # FIXME see #1025, `multihypo=` will not work properly yet
203+
# function getSample(cf::CalcFactor{<:DERelative})
204+
205+
# oder = cf.factor
206+
207+
# # how many trajectories to propagate?
208+
# # @show getLabel(cf.fullvariables[2]), getDimension(cf.fullvariables[2])
209+
# meas = zeros(getDimension(cf.fullvariables[2]))
210+
211+
# # pick forward or backward direction
212+
# # set boundary condition
213+
# u0pts = if cf.solvefor == 1
214+
# # backward direction
215+
# prob = oder.backwardProblem
216+
# addOp, diffOp, _, _ = AMP.buildHybridManifoldCallbacks(
217+
# convert(Tuple, getManifold(getVariableType(cf.fullvariables[1]))),
218+
# )
219+
# cf._legacyParams[2]
220+
# else
221+
# # forward backward
222+
# prob = oder.forwardProblem
223+
# # buffer manifold operations for use during factor evaluation
224+
# addOp, diffOp, _, _ = AMP.buildHybridManifoldCallbacks(
225+
# convert(Tuple, getManifold(getVariableType(cf.fullvariables[2]))),
226+
# )
227+
# cf._legacyParams[1]
228+
# end
229+
230+
# i = cf._sampleIdx
231+
# # solve likely elements
232+
# # TODO, does this respect hyporecipe ???
233+
# idxArr = (k -> cf._legacyParams[k][i]).(1:length(cf._legacyParams))
234+
# _solveFactorODE!(meas, prob, u0pts[i], _maketuplebeyond2args(idxArr...)...)
235+
# # _solveFactorODE!(meas, prob, u0pts, i, _maketuplebeyond2args(cf._legacyParams...)...)
236+
237+
# return meas, diffOp
238+
# end
239+
240+
202241

203242

204243
## =========================================================================
@@ -221,15 +260,17 @@ function IncrementalInference.sampleFactor(cf::CalcFactor{<:DERelative}, N::Int
221260
addOp, diffOp, _, _ = AMP.buildHybridManifoldCallbacks(
222261
convert(Tuple, getManifold(getVariableType(cf.fullvariables[1]))),
223262
)
224-
getBelief(cf.fullvariables[2]) |> getPoints
263+
# getBelief(cf.fullvariables[2]) |> getPoints
264+
cf._legacyParams[2]
225265
else
226266
# forward backward
227267
prob = oder.forwardProblem
228268
# buffer manifold operations for use during factor evaluation
229269
addOp, diffOp, _, _ = AMP.buildHybridManifoldCallbacks(
230270
convert(Tuple, getManifold(getVariableType(cf.fullvariables[2]))),
231271
)
232-
getBelief(cf.fullvariables[1]) |> getPoints
272+
# getBelief(cf.fullvariables[1]) |> getPoints
273+
cf._legacyParams[1]
233274
end
234275

235276
# solve likely elements

ext/WeakDepsPrototypes.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
function _ccolamd! end
44
function _ccolamd end
55

6+
# DiffEq
7+
function _solveFactorODE! end
8+
69
# Flux.jl
710
function MixtureFluxModels end
811

src/Factors/Circular.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ DFG.getManifold(::CircularCircular) = RealCircleGroup()
2323

2424
function (cf::CalcFactor{<:CircularCircular})(X, p, q)
2525
#
26-
M = cf.manifold # getManifold(cf.factor)
26+
M = getManifold(cf)
2727
return distanceTangent2Point(M, X, p, q)
2828
end
2929

@@ -68,7 +68,7 @@ function getSample(cf::CalcFactor{<:PriorCircular})
6868
end
6969

7070
function (cf::CalcFactor{<:PriorCircular})(m, p)
71-
M = cf.manifold # getManifold(cf.factor)
71+
M = getManifold(cf)
7272
Xc = vee(M, p, log(M, p, m))
7373
return Xc
7474
end

src/Factors/GenericFunctions.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ end
3737

3838
#::MeasurementOnTangent
3939
function distanceTangent2Point(M::SemidirectProductGroup, X, p, q)
40-
= Manifolds.compose(M, p, exp(M, identity_element(M, p), X)) #for groups
40+
= Manifolds.compose(M, p, exp(M, getPointIdentity(M), X)) #for groups
4141
# return log(M, q, q̂)
4242
return vee(M, q, log(M, q, q̂))
4343
# return distance(M, q, q̂)
@@ -96,7 +96,7 @@ end
9696

9797
# function (cf::CalcFactor{<:ManifoldFactor{<:AbstractDecoratorManifold}})(Xc, p, q)
9898
function (cf::CalcFactor{<:ManifoldFactor})(X, p, q)
99-
return distanceTangent2Point(cf.manifold, X, p, q)
99+
return distanceTangent2Point(cf.factor.M, X, p, q)
100100
end
101101

102102
## ======================================================================================
@@ -141,12 +141,20 @@ function getSample(cf::CalcFactor{<:ManifoldPrior})
141141
return point
142142
end
143143

144+
function getFactorMeasurementParametric(fac::ManifoldPrior)
145+
M = getManifold(fac)
146+
dims = manifold_dimension(M)
147+
meas = fac.p
148+
= convert(SMatrix{dims, dims}, invcov(fac.Z))
149+
meas, iΣ
150+
end
151+
144152
#TODO investigate SVector if small dims, this is slower
145153
# dim = manifold_dimension(M)
146154
# Xc = [SVector{dim}(rand(Z)) for _ in 1:N]
147155

148156
function (cf::CalcFactor{<:ManifoldPrior})(m, p)
149-
M = cf.manifold # .factor.M
157+
M = cf.factor.M
150158
# return log(M, p, m)
151159
return vee(M, p, log(M, p, m))
152160
# return distancePrior(M, m, p)
@@ -235,7 +243,7 @@ DFG.getManifold(f::ManifoldPriorPartial) = f.M
235243

236244
function getSample(cf::CalcFactor{<:ManifoldPriorPartial})
237245
Z = cf.factor.Z
238-
M = cf.manifold # getManifold(cf.factor)
246+
M = getManifold(cf)
239247
partial = collect(cf.factor.partial)
240248

241249
return (samplePointPartial(M, Z, partial),)

src/Factors/Mixture.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,25 +118,36 @@ function sampleFactor(cf::CalcFactor{<:Mixture}, N::Int = 1)
118118
## example case is old FluxModelsPose2Pose2 requiring velocity
119119
# FIXME better consolidation of when to pass down .mechanics, also see #1099 and #1094 and #1069
120120

121-
cf_ = CalcFactor(
121+
cf_ = CalcFactorNormSq(
122122
cf.factor.mechanics,
123123
0,
124124
cf._legacyParams,
125125
cf._allowThreads,
126126
cf.cache,
127127
cf.fullvariables,
128128
cf.solvefor,
129-
cf.manifold
129+
cf.manifold,
130+
cf.measurement,
131+
nothing,
130132
)
131133
smpls = [getSample(cf_) for _ = 1:N]
132134
# smpls = Array{Float64,2}(undef,s.dims,N)
133135
#out memory should be right size first
134136
length(cf.factor.labels) != N ? resize!(cf.factor.labels, N) : nothing
135137
cf.factor.labels .= rand(cf.factor.diversity, N)
138+
M = cf.manifold
139+
140+
# mixture needs to be refactored so let's make it worse :-)
141+
if cf.factor.mechanics isa AbstractPrior
142+
samplef = samplePoint
143+
elseif cf.factor.mechanics isa AbstractRelative
144+
samplef = sampleTangent
145+
end
146+
136147
for i = 1:N
137148
mixComponent = cf.factor.components[cf.factor.labels[i]]
138149
# measurements relate to the factor's manifold (either tangent vector or manifold point)
139-
setPointsMani!(smpls[i], rand(mixComponent, 1))
150+
setPointsMani!(smpls, samplef(M, mixComponent), i)
140151
end
141152

142153
# TODO only does first element of meas::Tuple at this stage, see #1099

src/Factors/MsgPrior.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ end
3232
getManifold(mp::MsgPrior{<:ManifoldKernelDensity}) = mp.Z.manifold
3333
getManifold(mp::MsgPrior) = mp.M
3434

35+
#FIXME this will not work on manifolds
3536
(cfo::CalcFactor{<:MsgPrior})(z, x1) = z .- x1
3637

3738
Base.@kwdef struct PackedMsgPrior <: AbstractPackedFactor

src/IncrementalInference.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ include("parametric/services/ConsolidateParametricRelatives.jl")
221221
include("parametric/services/ParametricCSMFunctions.jl")
222222
include("parametric/services/ParametricUtils.jl")
223223
include("parametric/services/ParametricOptim.jl")
224-
include("parametric/services/ParametricManoptDev.jl")
224+
include("parametric/services/ParametricManopt.jl")
225225
include("services/MaxMixture.jl")
226226

227227
#X-stroke

0 commit comments

Comments
 (0)