@@ -20,9 +20,12 @@ using TensorCast
20
20
21
21
# #
22
22
23
- function firstOrder! (dstate, state, force, t)
23
+ # a user specified ODE in standard form
24
+ # inplace `xdot = f(x, u, t)`
25
+ # if linear, `xdot = F*x(t) + G*u(t)`
26
+ function firstOrder! (dstate, state, u, t)
24
27
β = - 0.2
25
- dstate[1 ] = β* state[1 ] + force (t)
28
+ dstate[1 ] = β* state[1 ] + u (t)
26
29
nothing
27
30
end
28
31
@@ -34,7 +37,8 @@ tstForce(t) = 0
34
37
35
38
fg = initfg ()
36
39
# the starting points and "0 seconds"
37
- addVariable! (fg, :x0 , ContinuousScalar, timestamp= DateTime (2000 ,1 ,1 ,0 ,0 ,0 ))
40
+ # `accurate_time = trunc(getDatetime(var), Second) + (1e-9*getNstime(var) % 1)`
41
+ addVariable! (fg, :x0 , Position{1 }, timestamp= DateTime (2000 ,1 ,1 ,0 ,0 ,0 ))
38
42
# pin with a simple prior
39
43
addFactor! (fg, [:x0 ], Prior (Normal (1 ,0.01 )))
40
44
@@ -47,15 +51,16 @@ for i in 1:3
47
51
nextSym = Symbol (" x$i " )
48
52
49
53
# another point in the trajectory 5 seconds later
50
- addVariable! (fg, nextSym, ContinuousScalar, timestamp= DateTime (2000 ,1 ,1 ,0 ,0 ,5 * i))
51
- oder = IIF. DERelative (fg, [prev; nextSym],
52
- ContinuousEuclid{1 },
54
+ addVariable! (fg, nextSym, Position{1 }, timestamp= DateTime (2000 ,1 ,1 ,0 ,0 ,5 * i))
55
+ # build factor against manifold Manifolds.TranslationGroup(1)
56
+ ode_fac = IIF. DERelative (fg, [prev; nextSym],
57
+ Position{1 },
53
58
firstOrder!,
54
59
tstForce,
55
60
dt= 0.05 ,
56
61
problemType= ODEProblem )
57
62
#
58
- addFactor! ( fg, [prev;nextSym], oder , graphinit= false )
63
+ addFactor! ( fg, [prev;nextSym], ode_fac , graphinit= false )
59
64
initVariable! (fg, nextSym, [zeros (1 ) for _ in 1 : 100 ])
60
65
61
66
prev = nextSym
@@ -94,7 +99,7 @@ ref_ = (getBelief(fg, :x0) |> getPoints)
94
99
# #
95
100
96
101
oder_ = DERelative ( fg, [:x0 ; :x3 ],
97
- ContinuousEuclid {1 },
102
+ Position {1 },
98
103
firstOrder!,
99
104
tstForce,
100
105
dt= 0.05 ,
@@ -185,7 +190,7 @@ tstForce(t) = 0
185
190
fg = initfg ()
186
191
187
192
# the starting points and "0 seconds"
188
- addVariable! (fg, :x0 , ContinuousEuclid {2 }, timestamp= DateTime (2000 ,1 ,1 ,0 ,0 ,0 ))
193
+ addVariable! (fg, :x0 , Position {2 }, timestamp= DateTime (2000 ,1 ,1 ,0 ,0 ,0 ))
189
194
# pin with a simple prior
190
195
addFactor! (fg, [:x0 ], Prior (MvNormal ([1 ;0 ],0.01 * diagm (ones (2 )))))
191
196
@@ -201,9 +206,9 @@ for i in 1:7
201
206
nextSym = Symbol (" x$i " )
202
207
203
208
# another point in the trajectory 5 seconds later
204
- addVariable! (fg, nextSym, ContinuousEuclid {2 }, timestamp= DateTime (2000 ,1 ,1 ,0 ,0 ,DT* i))
209
+ addVariable! (fg, nextSym, Position {2 }, timestamp= DateTime (2000 ,1 ,1 ,0 ,0 ,DT* i))
205
210
oder = DERelative ( fg, [prev; nextSym],
206
- ContinuousEuclid {2 },
211
+ Position {2 },
207
212
dampedOscillator!,
208
213
tstForce,
209
214
# (state, var)->(state[1] = var[1]),
@@ -258,7 +263,7 @@ pts = approxConv(fg, :x0f1, :x7, setPPE=true, tfg=tfg)
258
263
259
264
260
265
oder_ = DERelative ( fg, [:x0 ; :x7 ],
261
- ContinuousEuclid {2 },
266
+ Position {2 },
262
267
dampedOscillator!,
263
268
tstForce,
264
269
# (state, var)->(state[1] = var[1]),
@@ -347,7 +352,7 @@ tstForce(t) = 0
347
352
fg = initfg ()
348
353
349
354
# the starting points and "0 seconds"
350
- addVariable! (fg, :x0 , ContinuousEuclid {2 }, timestamp= DateTime (2000 ,1 ,1 ,0 ,0 ,0 ))
355
+ addVariable! (fg, :x0 , Position {2 }, timestamp= DateTime (2000 ,1 ,1 ,0 ,0 ,0 ))
351
356
# pin with a simple prior
352
357
addFactor! (fg, [:x0 ], Prior (MvNormal ([1 ;0 ],0.01 * diagm (ones (2 )))))
353
358
doautoinit! (fg, :x0 )
@@ -357,7 +362,7 @@ doautoinit!(fg, :x0)
357
362
β = - 0.3
358
363
359
364
# these are the stochastic parameters
360
- addVariable! (fg, :ωβ , ContinuousEuclid {2 }) # timestamp should not matter
365
+ addVariable! (fg, :ωβ , Position {2 }) # timestamp should not matter
361
366
# pin with a simple prior
362
367
addFactor! (fg, [:ωβ ], Prior (MvNormal ([ω;β],0.0001 * diagm (ones (2 )))))
363
368
doautoinit! (fg, :ωβ )
@@ -373,9 +378,9 @@ for i in 1:7
373
378
nextSym = Symbol (" x$i " )
374
379
375
380
# another point in the trajectory 5 seconds later
376
- addVariable! (fg, nextSym, ContinuousEuclid {2 }, timestamp= DateTime (2000 ,1 ,1 ,0 ,0 ,DT* i))
381
+ addVariable! (fg, nextSym, Position {2 }, timestamp= DateTime (2000 ,1 ,1 ,0 ,0 ,DT* i))
377
382
oder = DERelative ( fg, [prev; nextSym; :ωβ ],
378
- ContinuousEuclid {2 },
383
+ Position {2 },
379
384
dampedOscillatorParametrized!,
380
385
tstForce, # this is passed in as `force_ωβ[1]`
381
386
# (state, var)->(state[1] = var[1]),
@@ -458,7 +463,7 @@ pts = approxConv(fg, :x0f1, :x7, setPPE=true, tfg=tfg, path=forcepath)
458
463
459
464
460
465
oder_ = DERelative ( fg, [:x0 ; :x7 ; :ωβ ],
461
- ContinuousEuclid {2 },
466
+ Position {2 },
462
467
dampedOscillatorParametrized!,
463
468
tstForce,
464
469
# (state, var)->(state[1] = var[1]),
0 commit comments