@@ -22,6 +22,25 @@ import Manifolds: allocate, compose, hat, Identity, vee, log
22
22
23
23
getManifold (de:: DERelative{T} ) where {T} = getManifold (de. domain)
24
24
25
+
26
+ function Base. show (
27
+ io:: IO ,
28
+ :: Union{<:DERelative{T,O},Type{<:DERelative{T,O}}}
29
+ ) where {T,O}
30
+ println (io, " DERelative{" )
31
+ println (io, " " , T)
32
+ println (io, " " , O. name. name)
33
+ println (io, " }" )
34
+ nothing
35
+ end
36
+
37
+ Base. show (
38
+ io:: IO ,
39
+ :: MIME"text/plain" ,
40
+ der:: DERelative
41
+ ) = show (io, der)
42
+
43
+
25
44
"""
26
45
$SIGNATURES
27
46
@@ -31,7 +50,9 @@ DevNotes
31
50
- TODO does not yet incorporate Xi.nanosecond field.
32
51
- TODO does not handle timezone crossing properly yet.
33
52
"""
34
- function _calcTimespan (Xi:: AbstractVector{<:DFGVariable} )
53
+ function _calcTimespan (
54
+ Xi:: AbstractVector{<:DFGVariable}
55
+ )
35
56
#
36
57
tsmps = getTimestamp .(Xi[1 : 2 ]) .| > DateTime .| > datetime2unix
37
58
# toffs = (tsmps .- tsmps[1]) .|> x-> elemType(x.value*1e-3)
@@ -50,8 +71,8 @@ function DERelative(
50
71
f:: Function ,
51
72
data = () -> ();
52
73
dt:: Real = 1 ,
53
- state0:: AbstractVector{<:Real} = zeros (getDimension (domain)),
54
- state1:: AbstractVector{<:Real} = zeros (getDimension (domain)),
74
+ state0:: AbstractVector{<:Real} = allocate ( getPointIdentity (domain)), # zeros(getDimension(domain)),
75
+ state1:: AbstractVector{<:Real} = allocate ( getPointIdentity (domain)), # zeros(getDimension(domain)),
55
76
tspan:: Tuple{<:Real, <:Real} = _calcTimespan (Xi),
56
77
problemType = DiscreteProblem,
57
78
)
@@ -78,8 +99,8 @@ function DERelative(
78
99
data = () -> ();
79
100
Xi:: AbstractArray{<:DFGVariable} = getVariable .(dfg, labels),
80
101
dt:: Real = 1 ,
81
- state0 :: AbstractVector{<:Real} = zeros (getDimension (domain)),
82
- state1 :: AbstractVector{<:Real} = zeros (getDimension (domain)),
102
+ state1 :: AbstractVector{<:Real} = allocate ( getPointIdentity (domain)), # zeros(getDimension(domain)),
103
+ state0 :: AbstractVector{<:Real} = allocate ( getPointIdentity (domain)), # zeros(getDimension(domain)),
83
104
tspan:: Tuple{<:Real, <:Real} = _calcTimespan (Xi),
84
105
problemType = DiscreteProblem,
85
106
)
99
120
#
100
121
101
122
# n-ary factor: Xtra splat are variable points (X3::Matrix, X4::Matrix,...)
102
- function _solveFactorODE! (measArr, prob, u0pts, Xtra... )
123
+ function _solveFactorODE! (
124
+ measArr,
125
+ prob,
126
+ u0pts,
127
+ Xtra...
128
+ )
103
129
# happens when more variables (n-ary) must be included in DE solve
104
130
for (xid, xtra) in enumerate (Xtra)
105
131
# update the data register before ODE solver calls the function
@@ -159,22 +185,21 @@ end
159
185
160
186
161
187
# NOTE see #1025, CalcFactor should fix `multihypo=` in `cf.__` fields; OBSOLETE
162
- function (cf:: CalcFactor{<:DERelative} )(measurement, X... )
188
+ function (cf:: CalcFactor{<:DERelative} )(
189
+ measurement,
190
+ X...
191
+ )
163
192
#
193
+ # numerical measurement values
164
194
meas1 = measurement[1 ]
195
+ # work on-manifold via sampleFactor piggy back of particular manifold definition
165
196
M = measurement[2 ]
166
- # diffOp = measurement[2]
167
-
197
+ # lazy factor pointer
168
198
oderel = cf. factor
169
-
170
- # work on-manifold
171
- # diffOp = meas[2]
172
- # if backwardSolve else forward
173
-
174
199
# check direction
175
-
176
200
solveforIdx = cf. solvefor
177
-
201
+
202
+ # if backwardSolve else forward
178
203
if solveforIdx > 2
179
204
# need to recalculate new ODE (forward) for change in parameters (solving for 3rd or higher variable)
180
205
solveforIdx = 2
@@ -190,19 +215,10 @@ function (cf::CalcFactor{<:DERelative})(measurement, X...)
190
215
end
191
216
192
217
# find the difference between measured and predicted.
193
- # # assuming the ODE integrated from current X1 through to predicted X2 (ie `meas1[:,idx]`)
194
- # # FIXME , obviously this is not going to work for more compilcated groups/manifolds -- must fix this soon!
195
- # @show cf._sampleIdx, solveforIdx, meas1
196
-
218
+ # assuming the ODE integrated from current X1 through to predicted X2 (ie `meas1[:,idx]`)
197
219
res_ = compose (M, inv (M, X[solveforIdx]), meas1)
198
220
res = vee (M, Identity (M), log (M, Identity (M), res_))
199
221
200
- # #FIXME 0
201
- # res = zeros(size(X[2], 1))
202
- # for i = 1:size(X[2], 1)
203
- # # diffop( reference?, test? ) <===> ΔX = test \ reference
204
- # res[i] = diffOp[i](X[solveforIdx][i], meas1[i])
205
- # end
206
222
return res
207
223
end
208
224
300
316
301
317
302
318
303
- function Base. show (io:: IO , :: Union{<:DERelative{T,O},Type{<:DERelative{T,O}}} ) where {T,O}
304
- println (io, " DERelative{" )
305
- println (io, " " , T)
306
- println (io, " " , O. name. name)
307
- println (io, " }" )
308
- nothing
309
- end
310
-
311
- Base. show (io:: IO , :: MIME"text/plain" , der:: DERelative ) = show (io, der)
312
-
313
- # # the function
314
- # ode.problem.f.f
315
-
316
- #
317
-
318
319
end # module
0 commit comments