@@ -20,9 +20,12 @@ using TensorCast
2020
2121# #
2222
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)
2427 β = - 0.2
25- dstate[1 ] = β* state[1 ] + force (t)
28+ dstate[1 ] = β* state[1 ] + u (t)
2629 nothing
2730end
2831
@@ -34,7 +37,8 @@ tstForce(t) = 0
3437
3538fg = initfg ()
3639# 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 ))
3842# pin with a simple prior
3943addFactor! (fg, [:x0 ], Prior (Normal (1 ,0.01 )))
4044
@@ -47,15 +51,16 @@ for i in 1:3
4751 nextSym = Symbol (" x$i " )
4852
4953 # 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 },
5358 firstOrder!,
5459 tstForce,
5560 dt= 0.05 ,
5661 problemType= ODEProblem )
5762 #
58- addFactor! ( fg, [prev;nextSym], oder , graphinit= false )
63+ addFactor! ( fg, [prev;nextSym], ode_fac , graphinit= false )
5964 initVariable! (fg, nextSym, [zeros (1 ) for _ in 1 : 100 ])
6065
6166 prev = nextSym
@@ -94,7 +99,7 @@ ref_ = (getBelief(fg, :x0) |> getPoints)
9499# #
95100
96101oder_ = DERelative ( fg, [:x0 ; :x3 ],
97- ContinuousEuclid {1 },
102+ Position {1 },
98103 firstOrder!,
99104 tstForce,
100105 dt= 0.05 ,
@@ -185,7 +190,7 @@ tstForce(t) = 0
185190fg = initfg ()
186191
187192# 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 ))
189194# pin with a simple prior
190195addFactor! (fg, [:x0 ], Prior (MvNormal ([1 ;0 ],0.01 * diagm (ones (2 )))))
191196
@@ -201,9 +206,9 @@ for i in 1:7
201206 nextSym = Symbol (" x$i " )
202207
203208 # 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))
205210 oder = DERelative ( fg, [prev; nextSym],
206- ContinuousEuclid {2 },
211+ Position {2 },
207212 dampedOscillator!,
208213 tstForce,
209214 # (state, var)->(state[1] = var[1]),
@@ -258,7 +263,7 @@ pts = approxConv(fg, :x0f1, :x7, setPPE=true, tfg=tfg)
258263
259264
260265oder_ = DERelative ( fg, [:x0 ; :x7 ],
261- ContinuousEuclid {2 },
266+ Position {2 },
262267 dampedOscillator!,
263268 tstForce,
264269 # (state, var)->(state[1] = var[1]),
@@ -347,7 +352,7 @@ tstForce(t) = 0
347352fg = initfg ()
348353
349354# 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 ))
351356# pin with a simple prior
352357addFactor! (fg, [:x0 ], Prior (MvNormal ([1 ;0 ],0.01 * diagm (ones (2 )))))
353358doautoinit! (fg, :x0 )
@@ -357,7 +362,7 @@ doautoinit!(fg, :x0)
357362β = - 0.3
358363
359364# these are the stochastic parameters
360- addVariable! (fg, :ωβ , ContinuousEuclid {2 }) # timestamp should not matter
365+ addVariable! (fg, :ωβ , Position {2 }) # timestamp should not matter
361366# pin with a simple prior
362367addFactor! (fg, [:ωβ ], Prior (MvNormal ([ω;β],0.0001 * diagm (ones (2 )))))
363368doautoinit! (fg, :ωβ )
@@ -373,9 +378,9 @@ for i in 1:7
373378 nextSym = Symbol (" x$i " )
374379
375380 # 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))
377382 oder = DERelative ( fg, [prev; nextSym; :ωβ ],
378- ContinuousEuclid {2 },
383+ Position {2 },
379384 dampedOscillatorParametrized!,
380385 tstForce, # this is passed in as `force_ωβ[1]`
381386 # (state, var)->(state[1] = var[1]),
@@ -458,7 +463,7 @@ pts = approxConv(fg, :x0f1, :x7, setPPE=true, tfg=tfg, path=forcepath)
458463
459464
460465oder_ = DERelative ( fg, [:x0 ; :x7 ; :ωβ ],
461- ContinuousEuclid {2 },
466+ Position {2 },
462467 dampedOscillatorParametrized!,
463468 tstForce,
464469 # (state, var)->(state[1] = var[1]),
0 commit comments