@@ -38,29 +38,6 @@ function distancePrior(M::AbstractManifold, meas, p)
3838 # return distance(M, p, meas)
3939end
4040
41- # # ======================================================================================
42- # # Default Identities #TODO only development, replace with better idea
43- # # ======================================================================================
44-
45- default_identity (M) = error (" No default identity element defined for $(typeof (M)) " )
46- default_identity (M:: GroupManifold{ℝ, <:ProductManifold} ) = error (" No default identity element defined for $(typeof (M)) " )
47- function default_identity (:: SpecialEuclidean{N} ) where N
48- T = Float64
49- t = zeros (SVector{N, T})
50- R = SMatrix {N,N,T} (one (T)I)
51- return ProductRepr (t, R)
52- end
53- function default_identity (M:: GroupManifold{ℝ, <:AbstractManifold} )
54- T = Float64
55- s = representation_size (M)
56- return identity_element (M, zeros (SArray{Tuple{s... },T}))
57- end
58-
59- # function default_identity(::SpecialOrthogonal{N}) where N
60- # T = Float64
61- # return SMatrix{N,N,T}(one(T)I)
62- # end
63-
6441# # ======================================================================================
6542# # ManifoldFactor
6643# # ======================================================================================
7855
7956DFG. getManifold (f:: ManifoldFactor ) = f. M
8057
81- # function getSample(cf::ManifoldFactor, N::Int=1)
8258function getSample (cf:: CalcFactor{<:ManifoldFactor} , N:: Int = 1 )
8359 # TODO @assert dim == cf.factor.Z's dimension
8460 # TODO investigate use of SVector if small dims
8561 ret = [rand (cf. factor. Z) for _ in 1 : N]
86-
87- # TODO tangent or not?
88- # tangent for now to fit with rest
62+ # return coordinates as we do not know the point here #TODO separate Lie group
8963 (ret, )
9064end
9165
66+ # function (cf::CalcFactor{<:ManifoldFactor{<:AbstractGroupManifold}})(Xc, p, q)
9267function (cf:: CalcFactor{<:ManifoldFactor} )(Xc, p, q)
9368# function (cf::ManifoldFactor)(X, p, q)
9469 M = cf. factor. M
10378export ManifoldPrior
10479# `p` is a point on manifold `M`
10580# `Z` is a measurement at the tangent space of `p` on manifold `M`
106- struct ManifoldPrior{M <: AbstractManifold , T <: SamplableBelief , P} <: AbstractPrior
81+ struct ManifoldPrior{M <: AbstractManifold , T <: SamplableBelief , P, B <: AbstractBasis } <: AbstractPrior
10782 M:: M
10883 p:: P # NOTE This is a fixed point from where the measurement `Z` is made in coordinates on tangent TpM
10984 Z:: T
85+ basis:: B
86+ retract_method:: AbstractRetractionMethod
11087end
11188
89+ ManifoldPrior (M:: AbstractGroupManifold , p, Z) = ManifoldPrior (M, p, Z, ManifoldsBase. VeeOrthogonalBasis (), ExponentialRetraction ())
90+
11291DFG. getManifold (f:: ManifoldPrior ) = f. M
11392
11493# TODO
@@ -120,32 +99,24 @@ DFG.getManifold(f::ManifoldPrior) = f.M
12099
121100# ManifoldPrior{M}(Z::SamplableBelief, p) where M = ManifoldPrior{M, typeof(Z), typeof(p)}(Z, p)
122101
123- # function getSample(cf::ManifoldPrior, N::Int=1)
124102function getSample (cf:: CalcFactor{<:ManifoldPrior} , N:: Int = 1 )
125103 Z = cf. factor. Z
126104 p = cf. factor. p
127105 M = cf. factor. M
128- # Z = cf.Z
129- # p = cf.p
130- # M = cf.M
131-
132- Xc = [rand (Z) for _ in 1 : N]
133-
134- # X = get_vector.(Ref(M), Ref(p), Xc, Ref(DefaultOrthogonalBasis()))
135- X = hat .(Ref (M), Ref (p), Xc)
136- points = exp .(Ref (M), Ref (p), X)
106+ basis = cf. factor. basis
107+ retract_method = cf. factor. retract_method
137108
109+ points = [samplePoint (M, Z, p, basis, retract_method) for _= 1 : N]
110+
138111 return (points, )
139112end
140113
141114# TODO investigate SVector if small dims, this is slower
142115# dim = manifold_dimension(M)
143116# Xc = [SVector{dim}(rand(Z)) for _ in 1:N]
144117
145- # function (cf::ManifoldPrior)(m, p)
146118function (cf:: CalcFactor{<:ManifoldPrior} )(m, p)
147119 M = cf. factor. M
148- # M = cf.M
149120 # return log(M, p, m)
150121 return vee (M,p,log (M, p, m))
151122 # return distancePrior(M, m, p)
@@ -163,35 +134,3 @@ function mahalanobus_distance2(M, X, inv_Σ)
163134 Xc = vee (M, p, X)
164135 return Xc' * inv_Σ * Xc
165136end
166-
167- if false
168- using IncrementalInference
169- using Manifolds
170- using LinearAlgebra
171- using StaticArrays
172-
173- f = ManifoldFactor (SpecialOrthogonal (3 ), MvNormal ([0.1 , 0.02 , 0.01 ]))
174- s = getSample (f,10 )[1 ]
175- s[1 ]
176-
177- f = ManifoldFactor (SpecialEuclidean (2 ), MvNormal ([0.1 , 0.2 , 0.01 ]))
178- s = getSample (f,10 )[1 ]
179- s[1 ]
180-
181-
182- f = ManifoldPrior (SpecialOrthogonal (2 ), SA[1.0 0 ; 0 1 ], MvNormal ([0.1 ]))
183- meas = getSample (f,10 )[1 ]
184- meas[1 ]
185- f .(meas, Ref (SA[1.0 0 ; 0 1 ]))
186-
187- f = ManifoldPrior (SpecialOrthogonal (3 ), SA[1.0 0 0 ; 0 1 0 ; 0 0 1 ], MvNormal ([0.1 , 0.02 , 0.01 ]))
188- s = getSample (f,10 )[1 ]
189- s[1 ]
190-
191- f = ManifoldPrior (SpecialEuclidean (2 ), ProductRepr (SA[0 ,0 ], SA[1.0 0 ; 0 1 ]), MvNormal ([0.1 , 0.2 , 0.01 ]))
192- s = getSample (f,10 )[1 ]
193- s[1 ]
194-
195-
196-
197- end
0 commit comments