@@ -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
92- function (cf:: CalcFactor{<:ManifoldFactor} )(Xc, p, q)
66+ function (cf:: CalcFactor{<:ManifoldFactor{<:AbstractGroupManifold} } )(Xc, p, q)
9367# function (cf::ManifoldFactor)(X, p, q)
9468 M = cf. factor. M
9569 # M = cf.M
10377export ManifoldPrior
10478# `p` is a point on manifold `M`
10579# `Z` is a measurement at the tangent space of `p` on manifold `M`
106- struct ManifoldPrior{M <: AbstractManifold , T <: SamplableBelief , P} <: AbstractPrior
80+ struct ManifoldPrior{M <: AbstractManifold , T <: SamplableBelief , P, B <: AbstractBasis } <: AbstractPrior
10781 M:: M
10882 p:: P # NOTE This is a fixed point from where the measurement `Z` is made in coordinates on tangent TpM
10983 Z:: T
84+ basis:: B
85+ retract_method:: AbstractRetractionMethod
11086end
11187
88+ ManifoldPrior (M:: AbstractGroupManifold , p, Z) = ManifoldPrior (M, p, Z, ManifoldsBase. VeeOrthogonalBasis (), ExponentialRetraction ())
89+
11290DFG. getManifold (f:: ManifoldPrior ) = f. M
11391
11492# TODO
@@ -120,32 +98,24 @@ DFG.getManifold(f::ManifoldPrior) = f.M
12098
12199# ManifoldPrior{M}(Z::SamplableBelief, p) where M = ManifoldPrior{M, typeof(Z), typeof(p)}(Z, p)
122100
123- # function getSample(cf::ManifoldPrior, N::Int=1)
124101function getSample (cf:: CalcFactor{<:ManifoldPrior} , N:: Int = 1 )
125102 Z = cf. factor. Z
126103 p = cf. factor. p
127104 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)
105+ basis = cf. factor. basis
106+ retract_method = cf. factor. retract_method
137107
108+ points = [samplePoint (M, Z, p, basis, retract_method) for _= 1 : N]
109+
138110 return (points, )
139111end
140112
141113# TODO investigate SVector if small dims, this is slower
142114# dim = manifold_dimension(M)
143115# Xc = [SVector{dim}(rand(Z)) for _ in 1:N]
144116
145- # function (cf::ManifoldPrior)(m, p)
146117function (cf:: CalcFactor{<:ManifoldPrior} )(m, p)
147118 M = cf. factor. M
148- # M = cf.M
149119 # return log(M, p, m)
150120 return vee (M,p,log (M, p, m))
151121 # return distancePrior(M, m, p)
@@ -163,35 +133,3 @@ function mahalanobus_distance2(M, X, inv_Σ)
163133 Xc = vee (M, p, X)
164134 return Xc' * inv_Σ * Xc
165135end
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