-
Notifications
You must be signed in to change notification settings - Fork 13
/
Deprecated.jl
365 lines (302 loc) · 14.7 KB
/
Deprecated.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
##==============================================================================
## Legacy, remove once AMP #41 is resolved
##==============================================================================
Base.convert(
::Type{<:Tuple},
::IIF.InstanceType{typeof(getManifold(RotVelPos))}
) = (
:Circular,:Circular,:Circular,
:Euclid,:Euclid,:Euclid,
:Euclid,:Euclid,:Euclid
)
##==============================================================================
## Legacy, remove some time after RoME v0.22
##==============================================================================
# @deprecate homographyToCoordinates(w...;kw...) homography_to_coordinates(w...;kw...)
# export measureMeanDist
# function measureMeanDist(fg::AbstractDFG, a::AbstractString, b::AbstractString)
# @error "RoME.measureMeanDist is obsolete"
# #bearrang!(residual::Array{Float64,1}, Z::Array{Float64,1}, X::Array{Float64,1}, L::Array{Float64,1})
# res = zeros(2)
# A = getVal(fg,a)
# B = getVal(fg,b)
# Ax = Statistics.mean(vec(A[1,:]))
# Ay = Statistics.mean(vec(A[2,:]))
# Bx = Statistics.mean(vec(B[1,:]))
# By = Statistics.mean(vec(B[2,:]))
# dx = Bx - Ax
# dy = By - Ay
# b = atan(dy,dx)
# r = sqrt(dx^2 + dy^2)
# return r, b
# end
# # should be deprecated or indicated more clearly
# @deprecate lsrBR(a) [a[2,:];a[1,:]]'
# # import AMP: _makeVectorManifold
# # AMP._makeVectorManifold(::M, prr::ProductRepr) where {M <: typeof(BearingRange_Manifold)} = coords(M, prr)
##==============================================================================
## Remove as part of Manifolds.jl consolidation, #244
##==============================================================================
# export veePose3, veePose
# function veePose3(s::SE3)
# TransformUtils.veeEuler(s)
# end
# function veePose(s::SE3)
# TransformUtils.veeEuler(s)
# end
# legacy support, will be deprecated
Base.convert(::Type{<:Tuple}, ::IIF.InstanceType{typeof(AMP.SE2_Manifold)}) = (:Euclid, :Euclid, :Circular)
Base.convert(::Type{<:Tuple}, ::IIF.InstanceType{typeof(SE2E2_Manifold)}) = (:Euclid,:Euclid,:Circular,:Euclid,:Euclid)
Base.convert(::Type{<:Tuple}, ::IIF.InstanceType{typeof(BearingRange_Manifold)}) = (:Circular,:Euclid)
Base.convert(::Type{<:Tuple}, ::IIF.InstanceType{typeof(Manifolds.ProductGroup(ProductManifold(SpecialEuclidean(2), TranslationGroup(2))))}) = (:Euclid,:Euclid,:Circular,:Euclid,:Euclid)
# Base.convert(::Type{<:ManifoldsBase.AbstractManifold}, ::IIF.InstanceType{Point2Point2}) = AMP.Euclid2
# Base.convert(::Type{<:ManifoldsBase.AbstractManifold}, ::IIF.InstanceType{Pose2Point2}) = AMP.Euclid2
# Base.convert(::Type{<:ManifoldsBase.AbstractManifold}, ::IIF.InstanceType{Pose2Point2Bearing}) = AMP.Euclid
# Base.convert(::Type{<:ManifoldsBase.AbstractManifold}, ::IIF.InstanceType{Point2Point2Range}) = AMP.Euclid
# Base.convert(::Type{<:ManifoldsBase.AbstractManifold}, ::IIF.InstanceType{Pose2Point2Range}) = AMP.Euclid
# Base.convert(::Type{<:ManifoldsBase.AbstractManifold}, ::IIF.InstanceType{Pose2Point2BearingRange}) = AMP.Euclid2
# Base.convert(::Type{<:ManifoldsBase.AbstractManifold}, ::IIF.InstanceType{Pose2Pose2}) = AMP.SE2_Manifold
# Base.convert(::Type{<:ManifoldsBase.AbstractManifold}, ::IIF.InstanceType{Pose3Pose3}) = AMP.SE3_Manifold
Base.convert(::Type{<:ManifoldsBase.AbstractManifold}, ::IIF.InstanceType{DynPoint2DynPoint2}) = AMP.Euclid4
Base.convert(::Type{<:ManifoldsBase.AbstractManifold}, ::IIF.InstanceType{DynPose2DynPose2}) = SE2E2_Manifold
Base.convert(::Type{<:ManifoldsBase.AbstractManifold}, ::IIF.InstanceType{VelPose2VelPose2}) = SE2E2_Manifold
##==============================================================================
## OLD Victory Park Example code, don't delete until replacements are coded
##==============================================================================
# function projNewLandmPoints(vps::Graphs.ExVertex, br::Array{Float64,1}, cov::Array{Float64,2})
# # TODO -- convert to use Distributions and common projection function
# Xps = getVal(vps)
# lmPts = zeros(2,size(Xps,2))
# for i in 1:size(Xps,2)
# ent = [cov[1,1]*randn(); cov[2,2]*randn()]
# init = vec(Xps[1:2,i])+randn(2)
# lmPts[:,i] = solveLandm(br + ent, vec(Xps[:,i]), init)
# end
# return lmPts
# end
# function calcIntersectVols( fgl::G, predLm::BallTreeDensity;
# currage=0, maxdeltaage=Inf) where G <: AbstractDFG
# # TODO upgrade to using MMD test
# # all landmarks of interest
# ll = ls(fgl, r"l\d")
# # output result
# rr = Dict{String, RemoteRef}()
# fetchlist = String[]
# iv = Dict{String, Float64}()
# for l in ll
# pvlm = getVariable(fgl,l)
# # TODO -- can be improved via query in DB case
# if currage - pvlm.attributes["maxage"] < maxdeltaage
# p = getBelief(fgl, l)
# rr[l] = remotecall(uppA(), intersIntgAppxIS, p,predLm)
# push!(fetchlist, l)
# else
# println("calcIntersectVols -- ignoring $(l) because maxdeltaage exceeded")
# iv[l] = 0
# end
# end
# max = 0
# maxl = String("")
# for l in fetchlist #ll
# # p = getBelief(fgl, l)
# # tv = intersIntgAppxIS(p,predLm)
# # iv[l] = tv
# tv = fetch(rr[l])
# iv[l] = tv
# if max < tv max = tv; maxl = l; end
# end
# return iv, maxl
# end
# function maxIvWithoutID(ivs::Dict{String, Float64}, l::T) where {T <: AbstractString}
# max = 0
# maxl = String("")
# for i in ivs
# if max < i[2] && i[1] != l; max = i[2]; maxl = i[1]; end
# end
# return maxl
# end
# # binary tests to distinguish how to automatically add a landmark to the existing factor graph
# function doAutoEvalTests(fgl::G, ivs::Dict{T, Float64}, maxl::T, lmid::Int, lmindx::Int) where {G <: AbstractDFG, T <: AbstractString}
# maxAnyval = maxl != String("") ? ivs[maxl] : 0.0
# # maxid = fgl.IDs[maxl]
# lmidSugg = lmid != -1 # a landmark ID has been suggested
# maxAnyExists = maxAnyval > 0.03 # there is notable intersection with previous landm
# lmIDExists = haskey(fgl.v, lmid) # suggested lmid already in fgl
# newlmindx = lmindx
# if lmIDExists
# lmSuggLbl = String(getVert(fgl,lmid).label) # TODO -- wasteful
# else
# newlmindx = lmindx + 1
# lmSuggLbl = String(string('l',newlmindx))
# end
# maxl2 = lmIDExists ? maxIvWithoutID(ivs, lmSuggLbl) : String("")
# maxl2Exists = lmIDExists ? (maxl2 != "" ? ivs[maxl2] > 0.03 : false) : false # there is notable intersection with previous landm
# intgLmIDExists = lmIDExists ? ivs[lmSuggLbl] > 0.03 : false
# return lmidSugg, maxAnyExists, maxl2Exists, maxl2, lmIDExists, intgLmIDExists, lmSuggLbl, newlmindx
# end
# function evalAutoCases!(fgl::G, lmid::Int, ivs::Dict{T, Float64}, maxl::T,
# pose::T, lmPts::Array{Float64,2}, br::Array{Float64,1}, cov::Array{Float64,2}, lmindx::Int;
# N::Int=100, solvable::Int=1 ) where {G <: AbstractDFG, T <: AbstractString}
# lmidSugg, maxAnyExists, maxl2Exists, maxl2, lmIDExists, intgLmIDExists, lmSuggLbl, newlmindx = doAutoEvalTests(fgl,ivs,maxl,lmid, lmindx)
# println("evalAutoCases -- found=$(lmidSugg), $(maxAnyExists), $(maxl2Exists), $(lmIDExists), $(intgLmIDExists)")
# vlm = Union{}; fbr = Union{};
# if (!lmidSugg && !maxAnyExists)
# #new landmark and UniBR constraint
# v,L,lm = getLastLandm2D(fgl)
# vlm = newLandm!(fgl, lm, lmPts, cov, N=N,solvable=solvable)
# fbr = addBRFG!(fgl, pose, lm, br, cov, solvable=solvable)
# elseif !lmidSugg && maxAnyExists
# # add UniBR to best match maxl
# vlm = getVariable(fgl,maxl)
# fbr = addBRFG!(fgl, pose, maxl, br, cov, solvable=solvable)
# elseif lmidSugg && !maxl2Exists && !lmIDExists
# #add new landmark and add UniBR to suggested lmid
# vlm = newLandm!(fgl, lmSuggLbl, lmPts, cov, N=N, solvable=solvable)
# fbr = addBRFG!(fgl, pose, lmSuggLbl, br, cov, solvable=solvable)
# elseif lmidSugg && !maxl2Exists && lmIDExists && intgLmIDExists
# # doesn't self intesect with existing lmid, add UniBR to lmid
# vlm = getVariable(fgl, lmid)
# fbr = addBRFG!(fgl, pose, lmSuggLbl, br, cov, solvable=solvable)
# elseif lmidSugg && maxl2Exists && !lmIDExists
# # add new landmark and add MMBR to both maxl and lmid
# vlm = newLandm!(fgl, lmSuggLbl, lmPts, cov, N=N, solvable=solvable)
# addMMBRFG!(fgl, pose, [maxl2;lmSuggLbl], br, cov, solvable=solvable)
# elseif lmidSugg && maxl2Exists && lmIDExists && intgLmIDExists
# # obvious case, add MMBR to both maxl and lmid. Double intersect might be the same thing
# println("evalAutoCases! -- obvious case is happening")
# addMMBRFG!(fgl, pose, [maxl2;lmSuggLbl], br, cov, solvable=solvable)
# vlm = getVariable(fgl,lmSuggLbl)
# elseif lmidSugg && maxl2Exists && lmIDExists && !intgLmIDExists
# # odd case, does not intersect with suggestion, but does with some previous landm
# # add MMBR
# @warn "evalAutoCases! -- no self intersect with suggested $(lmSuggLbl) detected"
# addMMBRFG!(fgl, pose, [maxl;lmSuggLbl], br, cov, solvable=solvable)
# vlm = getVariable(fgl,lmSuggLbl)
# elseif lmidSugg && !maxl2Exists && lmIDExists && !intgLmIDExists
# # # landm exists but no intersection with existing or suggested lmid
# # # may suggest some error
# @warn "evalAutoCases! -- no intersect with suggested $(lmSuggLbl) or map detected, adding new landmark MM constraint incase"
# v,L,lm = getLastLandm2D(fgl)
# vlm = newLandm!(fgl, lm, lmPts, cov, N=N, solvable=solvable)
# addMMBRFG!(fgl, pose, [lm; lmSuggLbl], br, cov, solvable=solvable)
# else
# error("evalAutoCases! -- unknown case encountered, can reduce to this error to a warning and ignore user request")
# end
# return vlm, fbr, newlmindx
# end
# function addAutoLandmBR!(fgl::G,
# pose::T,
# lmid::Int,
# br::Array{Float64,1},
# cov::Array{Float64,2},
# lmindx::Int;
# N::Int=100,
# solvable::Int=1 ) where {G <: AbstractDFG, T <: AbstractString}
# #
# vps = getVariable(fgl, pose)
# lmPts = projNewLandmPoints(vps, br, cov)
# lmkde = kde!(lmPts)
# currage = parse(Int, pose[2:end])
# ivs, maxl = calcIntersectVols(fgl, lmkde, currage=currage,maxdeltaage=10)
# # There are 8 cases of interest
# vlm, fbr, newlmindx = evalAutoCases!(fgl, lmid, ivs, maxl,pose,lmPts, br,cov,lmindx,N=N,solvable=solvable)
# return vlm, fbr, newlmindx
# end
# function newLandm!(fg::AbstractDFG, lm::T, wPos::Array{Float64,2}, sig::Array{Float64,2};
# N::Int=100, solvable::Int=1, labels::Vector{T}=String[]) where {T <: AbstractString}
# vert=addVariable!(fg, Symbol(lm), Point2, N=N, solvable=solvable, tags=union(["LANDMARK";], labels))
# # TODO -- need to confirm this function is updating the correct memory location. v should be pointing into graph
# # vert=addVariable!(fg, Symbol(lm), wPos, sig, N=N, solvable=solvable, tags=labels)
# vert.attributes["age"] = 0
# vert.attributes["maxage"] = 0
# vert.attributes["numposes"] = 0
# updateFullVert!(fg, vert)
# println("newLandm! -- added $(lm)")
# return vert
# end
# function addBRFG!(fg::G,
# pose::T,
# lm::T,
# br::Array{Float64,1},
# cov::Array{Float64,2};
# solvable::Int=1 ) where {G <: AbstractDFG, T <: AbstractString}
# #
# vps = getVert(fg,pose)
# vlm = getVert(fg,lm)
# testlbl = vps.label*vlm.label
# for nei in getOutNeighbors(fg, vlm)
# if nei.label == testlbl
# # TODO -- makes function call brittle
# @warn "We already have $(testlbl), skipping this constraint"
# return nothing
# end
# end
# @show keys(vlm.attributes)
# np = vlm.attributes["numposes"]
# la = vlm.attributes["age"]
# nage = parse(Int,pose[2:end])
# vlm.attributes["numposes"] = np+1
# vlm.attributes["age"] = ((la*np)+nage)/(np+1)
# vlm.attributes["maxage"] = nage
# updateFullVert!(fg, vlm)
# pbr = Pose2Point2BearingRange(Normal(br[1], cov[1,1]), Normal(br[2], cov[2,2])) #{Normal, Normal}
# @show vps, vlm
# f = addFactor!(fg, [vps;vlm], pbr, solvable=solvable, graphinit=true ) #[vps;vlm],
# # only used for max likelihood unimodal tests.
# u, P = pol2cart(br[[2;1]], diag(cov))
# infor = inv(P^2)
# # addLandmMeasRemote(vps.index,vlm.index,u,infor) # for iSAM1 remote solution as reference
# return f
# end
# function addMMBRFG!(fg::G,
# syms::Array{Symbol,1}, br::Array{Float64,1},
# cov::Array{Float64,2}; w::Vector{Float64}=Float64[0.5;0.5],
# solvable::Int=1) where G <: AbstractDFG
# #
# # vps = getVert(fg,pose)
# # vlm1 = getVert(fg,lm[1])
# # vlm2 = getVert(fg,lm[2])
# pbr = Pose2Point2BearingRange(Normal(br[1],cov[1,1]), Normal(br[2],cov[2,2]))
# syms = Symbol.([pose;lm...])
# f = addFactor!(fg, syms, pbr, multihypo=[1.0; w...], solvable=solvable, graphinit=true )
# return f
# end
# function projNewLandm!(fg::G,
# pose::T,
# lm::T,
# br::Array{Float64,1},
# cov::Array{Float64,2};
# addfactor=true,
# N::Int=100,
# solvable::Int=1,
# labels::Vector{T}=String[] ) where {G <: AbstractDFG, T <: AbstractString}
# #
# vps = getVariable(fg, pose)
# lmPts = projNewLandmPoints(vps, br, cov)
# vlm = newLandm!(fg, lm, lmPts, cov, N=N, solvable=solvable, tags=labels) # cov should not be required here
# if addfactor
# fbr = addBRFG!(fg, pose, lm, br, cov, solvable=solvable)
# return vlm, fbr
# end
# return vlm
# end
##==============================================================================
## OLD Victory Park Example code, don't delete until replacements are coded
##==============================================================================
# # optional tools
# using Requires
# function __init__()
# # combining neural networks natively into the non-Gaussian factor graph object
# # @require Flux="587475ba-b771-5e3f-ad9e-33799f191a9c" begin
# # # include("factors/flux/models/Pose2OdoNN_01.jl") # until a better way is found to deserialize
# # # include("factors/flux/MixtureFluxPose2Pose2.jl")
# # end
# # Scalar field specifics
# # @require ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534" begin
# # @require ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19" include("services/RequiresImages.jl")
# # end
# # Images="916415d5-f1e6-5110-898d-aaa5f9f070e0"
# # @require Interpolations="a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" begin
# # include("services/ScalarFieldsInterpolations.jl")
# # end
# end