-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGraphsDFGSummaryTypes.jl
179 lines (157 loc) · 4.8 KB
/
GraphsDFGSummaryTypes.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# VARTYPE = VariableSummary
# FACTYPE = FactorSummary
dfg = GraphsDFG{NoSolverParams, VARTYPE, FACTYPE}()
function DistributedFactorGraphs.VariableSummary(label::Symbol)
return VariableSummary(
nothing,
label,
DistributedFactorGraphs.now(localzone()),
Set{Symbol}(),
Dict{Symbol, MeanMaxPPE}(),
:Pose2,
Dict{Symbol, BlobEntry}(),
)
end
function DistributedFactorGraphs.VariableSummary(
label::Symbol,
::VariableNodeData{T},
) where {T}
return VariableSummary(
nothing,
label,
DistributedFactorGraphs.now(localzone()),
Set{Symbol}(),
Dict{Symbol, MeanMaxPPE}(),
Symbol(T),
Dict{Symbol, BlobEntry}(),
)
end
function DistributedFactorGraphs.VariableSkeleton(label::Symbol, args...)
return VariableSkeleton(label)
end
function DistributedFactorGraphs.VariableSkeleton(
label::Symbol,
::VariableNodeData{T},
) where {T}
return VariableSkeleton(nothing, label, Set{Symbol}())
end
dfg = GraphsDFG{NoSolverParams, VARTYPE, FACTYPE}()
v1 = VARTYPE(:a)
v2 = VARTYPE(:b)
v3 = VARTYPE(:c)
f0 = FACTYPE(:af1, [:a])
f1 = FACTYPE(:abf1, [:a, :b])
f2 = FACTYPE(:bcf1, [:b, :c])
union!(v1.tags, [:VARIABLE, :POSE])
union!(v2.tags, [:VARIABLE, :LANDMARK])
union!(f1.tags, [:FACTOR])
if false
#TODO add to tests
VARTYPE = VariableDFG
FACTYPE = FactorDFG
dfg = GraphsDFG{NoSolverParams, VariableDFG, FactorDFG}()
v1 = VariableDFG(; label = :a, variableType = "Pose2", tags = [:VARIABLE, :POSE])
v2 = VariableDFG(; label = :b, variableType = "Pose2", tags = [:VARIABLE, :LANDMARK])
v3 = VariableDFG(; label = :c, variableType = "Pose2")
orphan = VariableDFG(; label = :orphan, variableType = "Pose2")
f0 = FactorDFG(;
label = :af1,
tags = [:FACTOR],
_variableOrderSymbols = [:a],
timestamp = DFG.Dates.now(DFG.tz"Z"),
nstime = 0,
fnctype = "PriorPose2",
solvable = 1,
data = "",
metadata = "",
)
f1 = FactorDFG(;
label = :abf1,
tags = [:FACTOR],
_variableOrderSymbols = [:a, :b],
timestamp = DFG.Dates.now(DFG.tz"Z"),
nstime = 0,
fnctype = "Pose2Pose2",
solvable = 1,
data = "",
metadata = "",
)
f2 = FactorDFG(;
label = :bcf1,
tags = [:FACTOR],
_variableOrderSymbols = [:b, :c],
timestamp = DFG.Dates.now(DFG.tz"Z"),
nstime = 0,
fnctype = "Pose2Pose2",
solvable = 1,
data = "",
metadata = "",
)
end
@testset "Variables and Factors CRUD and SET" begin
VariablesandFactorsCRUD_SET!(dfg, v1, v2, v3, f0, f1, f2)
end
# Gets
@testset "Gets, Sets, and Accessors" begin
global dfg, v1, v2, f1
@test getLabel(v1) == v1.label
@test getTags(v1) == v1.tags
@test getLabel(f1) == f1.label
@test getTags(f1) == f1.tags
if VARTYPE == VariableSummary
@test getTimestamp(v1) == v1.timestamp
@test getVariablePPEDict(v1) == v1.ppeDict
@test_throws KeyError getVariablePPE(v1, :notfound)
@test getVariableTypeName(v1) == :Pose2
# FACTYPE == FactorSummary
testTimestamp = now(localzone())
v1ts = setTimestamp(v1, testTimestamp)
@test getTimestamp(v1ts) == testTimestamp
#follow with updateVariable!(fg, v1ts)
# setTimestamp!(v1, testTimestamp) not implemented, we can do an setTimestamp() updateVariable!() for a setTimestamp!(dfg, v1, testTimestamp)
@test_throws MethodError setTimestamp!(v1, testTimestamp)
f1ts = setTimestamp(f1, testTimestamp)
@test !(f1ts === f1)
@test getTimestamp(f1ts) == testTimestamp
@test_throws MethodError setTimestamp!(v1, testTimestamp)
end
end
@testset "Updating Nodes" begin
VARTYPE == VariableSummary && PPETestBlock!(dfg, v1)
end
@testset "Adjacency Matrices" begin
fg = GraphsDFG{NoSolverParams, VARTYPE, FACTYPE}()
addVariable!(fg, VARTYPE(:a))
addVariable!(fg, VARTYPE(:b))
addFactor!(fg, FACTYPE(:abf1, [:a, :b]))
addVariable!(fg, VARTYPE(:orphan))
AdjacencyMatricesTestBlock(fg)
end
@testset "Getting Neighbors" begin
GettingNeighbors(
GraphsDFG{NoSolverParams, VARTYPE, FACTYPE};
VARTYPE = VARTYPE,
FACTYPE = FACTYPE,
)
end
@testset "Building Subgraphs" begin
BuildingSubgraphs(
GraphsDFG{NoSolverParams, VARTYPE, FACTYPE};
VARTYPE = VARTYPE,
FACTYPE = FACTYPE,
)
end
@testset "Producing Dot Files" begin
ProducingDotFiles(
GraphsDFG{NoSolverParams, VARTYPE, FACTYPE};
VARTYPE = VARTYPE,
FACTYPE = FACTYPE,
)
end
@testset "Connectivity Test" begin
ConnectivityTest(
GraphsDFG{NoSolverParams, VARTYPE, FACTYPE};
VARTYPE = VARTYPE,
FACTYPE = FACTYPE,
)
end