Skip to content

Commit cdc9f1b

Browse files
committed
switch defVariable to Manifolds.jl
1 parent 28eec11 commit cdc9f1b

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

Project.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DistributedFactorGraphs"
22
uuid = "b5cc3c7e-6572-11e9-2517-99fb8daf2f04"
3-
version = "0.12.0"
3+
version = "0.13.0"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
@@ -12,6 +12,7 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
1212
JSON2 = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3"
1313
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
1414
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
15+
ManifoldsBase = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb"
1516
Neo4j = "d2adbeaf-5838-5367-8a2f-e46d570981db"
1617
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1718
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
@@ -29,6 +30,7 @@ DocStringExtensions = "0.8, 0.9, 0.10, 1"
2930
JSON = "0.21"
3031
JSON2 = "0.3.1"
3132
LightGraphs = "1.2, 1.3"
33+
ManifoldsBase = "0.10"
3234
Neo4j = "2"
3335
Pkg = "1.4, 1.5"
3436
Reexport = "0.2, 0.3, 0.4, 0.5, 1"
@@ -39,8 +41,9 @@ julia = "1.4"
3941

4042
[extras]
4143
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
44+
Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e"
4245
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
4346
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4447

4548
[targets]
46-
test = ["Test", "GraphPlot", "Pkg"]
49+
test = ["Test", "GraphPlot", "Manifolds", "Pkg"]

src/DistributedFactorGraphs.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ using SparseArrays
2929
using UUIDs
3030
using Pkg
3131

32+
# used for @defVariable
33+
import ManifoldsBase
34+
import ManifoldsBase: Manifold, manifold_dimension
35+
export Manifold, manifold_dimension
36+
3237
import Base: getindex
3338

3439

src/services/DFGVariable.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,21 @@ Example:
7777
DFG.@defVariable Pose2 3 (:Euclid, :Euclid, :Circular)
7878
```
7979
"""
80-
macro defVariable(structname, dimension::Int, manifolds)#::Vararg{Symbol})#NTuple{dimension, Symbol})
80+
macro defVariable(structname, manifold) #::Vararg{Symbol})#NTuple{dimension, Symbol})
8181
# :(struct $structname <: InferenceVariable end)
8282
return esc(quote
8383
Base.@__doc__ struct $structname <: InferenceVariable end
84-
DistributedFactorGraphs.getDimension(::$structname) = $dimension
85-
DistributedFactorGraphs.getManifolds(::$structname) = $manifolds
84+
getManifold(::Type{M}) where {M <: $structname} = $manifold
85+
getManifold(::M) where {M <: $structname} = getManifold(M)
86+
87+
getDimension(::Type{M}) where {M <: $structname} = manifold_dimension(getManifold(M))
88+
getDimension(::M) where {M <: $structname} = manifold_dimension(getManifold(M))
89+
# FIXME legacy API to be deprecated
90+
getManifolds(::Type{M}) where {M <: $structname} = convert(Tuple, $manifold)
91+
getManifolds(::M) where {M <: $structname} = convert(Tuple, $manifold)
8692
end)
8793
end
94+
8895
##------------------------------------------------------------------------------
8996
## solvedCount
9097
##------------------------------------------------------------------------------

test/testBlocks.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using DistributedFactorGraphs
22
using Test
33
using Dates
4+
using Manifolds
45

56
import Base: convert
67

@@ -11,13 +12,18 @@ import Base: convert
1112
# TestVariableType1() = new(1,(:Euclid,))
1213
# end
1314

14-
DFG.@defVariable TestVariableType1 1 (:Euclid,)
1515

16-
struct TestVariableType2 <: InferenceVariable
17-
dims::Int
18-
manifolds::Tuple{Symbol, Symbol}
19-
TestVariableType2() = new(2,(:Euclid,:Circular,))
20-
end
16+
Base.convert(::Type{<:Tuple}, ::typeof(Euclidean(1))) = (:Euclid,)
17+
Base.convert(::Type{<:Tuple}, ::typeof(Euclidean(2))) = (:Euclid, :Euclid)
18+
19+
DFG.@defVariable TestVariableType1 Euclidean(1) # 1 (:Euclid,)
20+
DFG.@defVariable TestVariableType2 Euclidean(2) # 1 (:Euclid,)
21+
22+
# struct TestVariableType2 <: InferenceVariable
23+
# dims::Int
24+
# manifolds::Tuple{Symbol, Symbol}
25+
# TestVariableType2() = new(2,(:Euclid,:Circular,))
26+
# end
2127

2228

2329
struct TestFunctorInferenceType1 <: AbstractRelative end

0 commit comments

Comments
 (0)