@@ -22,10 +22,20 @@ setDescription(dfg::GraphsDFG, description::String) = dfg.description = descript
22
22
getInnerGraph (dfg:: GraphsDFG ) = dfg. g
23
23
getAddHistory (dfg:: GraphsDFG ) = dfg. addHistory
24
24
getSolverParams (dfg:: GraphsDFG ) = dfg. solverParams
25
+ function setSolverParams (dfg:: GraphsDFG , solverParams:: T ) where T <: AbstractParams
26
+ dfg. solverParams = solverParams
27
+ end
25
28
26
- # setSolverParams(dfg::GraphsDFG, solverParams) = dfg.solverParams = solverParams
27
- function setSolverParams (dfg:: GraphsDFG , solverParams:: P ) where P <: AbstractParams
28
- dfg. solverParams = solverParams
29
+ """
30
+ $(SIGNATURES)
31
+ Gets an empty and unique CloudGraphsDFG derived from an existing DFG.
32
+ """
33
+ function _getDuplicatedEmptyDFG (dfg:: GraphsDFG ):: GraphsDFG
34
+ newDfg = GraphsDFG {typeof(dfg.solverParams)} (;
35
+ userId= dfg. userId, robotId= dfg. robotId, sessionId= dfg. sessionId,
36
+ params= deepcopy (dfg. solverParams))
37
+ newDfg. description = " (Copy of) $(dfg. description) "
38
+ return newDfg
29
39
end
30
40
31
41
"""
@@ -190,13 +200,6 @@ function deleteVariable!(dfg::GraphsDFG, label::Symbol)::DFGVariable
190
200
return variable
191
201
end
192
202
193
- # Alias
194
- """
195
- $(SIGNATURES)
196
- Delete a referenced DFGVariable from the DFG.
197
- """
198
- deleteVariable! (dfg:: GraphsDFG , variable:: DFGVariable ):: DFGVariable = deleteVariable! (dfg, variable. label)
199
-
200
203
"""
201
204
$(SIGNATURES)
202
205
Delete a DFGFactor from the DFG using its label.
@@ -211,13 +214,6 @@ function deleteFactor!(dfg::GraphsDFG, label::Symbol)::DFGFactor
211
214
return factor
212
215
end
213
216
214
- # Alias
215
- """
216
- $(SIGNATURES)
217
- Delete the referened DFGFactor from the DFG.
218
- """
219
- deleteFactor! (dfg:: GraphsDFG , factor:: DFGFactor ):: DFGFactor = deleteFactor! (dfg, factor. label)
220
-
221
217
"""
222
218
$(SIGNATURES)
223
219
List the DFGVariables in the DFG.
@@ -235,34 +231,6 @@ function getVariables(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing
235
231
return variables
236
232
end
237
233
238
- """
239
- $(SIGNATURES)
240
- Get a list of IDs of the DFGVariables in the DFG.
241
- Optionally specify a label regular expression to retrieves a subset of the variables.
242
-
243
- Example
244
- ```julia
245
- getVariableIds(dfg, r"l", tags=[:APRILTAG;])
246
- ```
247
-
248
- Related
249
-
250
- ls
251
- """
252
- function getVariableIds (dfg:: GraphsDFG , regexFilter:: Union{Nothing, Regex} = nothing ; tags:: Vector{Symbol} = Symbol[]):: Vector{Symbol}
253
- vars = getVariables (dfg, regexFilter, tags= tags)
254
- # mask = map(v -> length(intersect(v.tags, tags)) > 0, vars )
255
- map (v -> v. label, vars)
256
- end
257
-
258
- # Alias
259
- """
260
- $(SIGNATURES)
261
- List the DFGVariables in the DFG.
262
- Optionally specify a label regular expression to retrieves a subset of the variables.
263
- """
264
- ls (dfg:: GraphsDFG , regexFilter:: Union{Nothing, Regex} = nothing ; tags:: Vector{Symbol} = Symbol[]):: Vector{Symbol} = getVariableIds (dfg, regexFilter, tags= tags)
265
-
266
234
"""
267
235
$(SIGNATURES)
268
236
List the DFGFactors in the DFG.
@@ -276,29 +244,6 @@ function getFactors(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing):
276
244
return factors
277
245
end
278
246
279
- """
280
- $(SIGNATURES)
281
- Get a list of the IDs of the DFGFactors in the DFG.
282
- Optionally specify a label regular expression to retrieves a subset of the factors.
283
- """
284
- getFactorIds (dfg:: GraphsDFG , regexFilter:: Union{Nothing, Regex} = nothing ):: Vector{Symbol} = map (f -> f. label, getFactors (dfg, regexFilter))
285
-
286
- """
287
- $(SIGNATURES)
288
- List the DFGFactors in the DFG.
289
- Optionally specify a label regular expression to retrieves a subset of the factors.
290
- """
291
- # Alias
292
- lsf (dfg:: GraphsDFG , regexFilter:: Union{Nothing, Regex} = nothing ):: Vector{Symbol} = getFactorIds (dfg, regexFilter)
293
-
294
- """
295
- $(SIGNATURES)
296
- Alias for getNeighbors - returns neighbors around a given node label.
297
- """
298
- function lsf (dfg:: GraphsDFG , label:: Symbol ):: Vector{Symbol}
299
- return getNeighbors (dfg, label)
300
- end
301
-
302
247
"""
303
248
$(SIGNATURES)
304
249
Checks if the graph is fully connected, returns true if so.
@@ -307,14 +252,6 @@ function isFullyConnected(dfg::GraphsDFG)::Bool
307
252
return length (Graphs. connected_components (dfg. g)) == 1
308
253
end
309
254
310
- # Alias
311
- """
312
- $(SIGNATURES)
313
- Checks if the graph is not fully connected, returns true if it is not contiguous.
314
- """
315
- hasOrphans (dfg:: GraphsDFG ):: Bool = ! isFullyConnected (dfg)
316
-
317
-
318
255
"""
319
256
$(SIGNATURES)
320
257
Retrieve a list of labels of the immediate neighbors around a given variable or factor.
@@ -359,56 +296,40 @@ function getNeighbors(dfg::GraphsDFG, label::Symbol; ready::Union{Nothing, Int}=
359
296
return map (n -> n. dfgNode. label, neighbors)
360
297
end
361
298
362
- # Aliases
363
- """
364
- $(SIGNATURES)
365
- Retrieve a list of labels of the immediate neighbors around a given variable or factor.
366
- """
367
- function ls (dfg:: GraphsDFG , node:: T ):: Vector{Symbol} where T <: DFGNode
368
- return getNeighbors (dfg, node)
369
- end
370
- """
371
- $(SIGNATURES)
372
- Retrieve a list of labels of the immediate neighbors around a given variable or factor specified by its label.
373
- """
374
- function ls (dfg:: GraphsDFG , label:: Symbol ):: Vector{Symbol} where T <: DFGNode
375
- return getNeighbors (dfg, label)
376
- end
377
-
378
- function _copyIntoGraph! (sourceDFG:: GraphsDFG , destDFG:: GraphsDFG , variableFactorLabels:: Vector{Symbol} , includeOrphanFactors:: Bool = false ):: Nothing
379
- # Split into variables and factors
380
- verts = map (id -> sourceDFG. g. vertices[sourceDFG. labelDict[id]], variableFactorLabels)
381
- sourceVariables = filter (n -> n. dfgNode isa DFGVariable, verts)
382
- sourceFactors = filter (n -> n. dfgNode isa DFGFactor, verts)
383
-
384
- # Now we have to add all variables first,
385
- for variable in sourceVariables
386
- if ! haskey (destDFG. labelDict, variable. dfgNode. label)
387
- addVariable! (destDFG, deepcopy (variable. dfgNode))
388
- end
389
- end
390
- # And then all factors to the destDFG.
391
- for factor in sourceFactors
392
- if ! haskey (destDFG. labelDict, factor. dfgNode. label)
393
- # Get the original factor variables (we need them to create it)
394
- neighVarIds = getNeighbors (sourceDFG, factor. dfgNode. label) # OLD: in_neighbors(factor, sourceDFG.g)
395
- # Find the labels and associated neighVarIds in our new subgraph
396
- factVariables = DFGVariable[]
397
- for neighVarId in neighVarIds
398
- if haskey (destDFG. labelDict, neighVarId)
399
- push! (factVariables, getVariable (destDFG, neighVarId))
400
- # otherwise ignore
401
- end
402
- end
403
-
404
- # Only if we have all of them should we add it (otherwise strange things may happen on evaluation)
405
- if includeOrphanFactors || length (factVariables) == length (neighVarIds)
406
- addFactor! (destDFG, factVariables, deepcopy (factor. dfgNode))
407
- end
408
- end
409
- end
410
- return nothing
411
- end
299
+ # function _copyIntoGraph!(sourceDFG::GraphsDFG, destDFG::GraphsDFG, variableFactorLabels::Vector{Symbol}, includeOrphanFactors::Bool=false)::Nothing
300
+ # # Split into variables and factors
301
+ # verts = map(id -> sourceDFG.g.vertices[sourceDFG.labelDict[id]], variableFactorLabels)
302
+ # sourceVariables = filter(n -> n.dfgNode isa DFGVariable, verts)
303
+ # sourceFactors = filter(n -> n.dfgNode isa DFGFactor, verts)
304
+ #
305
+ # # Now we have to add all variables first,
306
+ # for variable in sourceVariables
307
+ # if !haskey(destDFG.labelDict, variable.dfgNode.label)
308
+ # addVariable!(destDFG, deepcopy(variable.dfgNode))
309
+ # end
310
+ # end
311
+ # # And then all factors to the destDFG.
312
+ # for factor in sourceFactors
313
+ # if !haskey(destDFG.labelDict, factor.dfgNode.label)
314
+ # # Get the original factor variables (we need them to create it)
315
+ # neighVarIds = getNeighbors(sourceDFG, factor.dfgNode.label) #OLD: in_neighbors(factor, sourceDFG.g)
316
+ # # Find the labels and associated neighVarIds in our new subgraph
317
+ # factVariables = DFGVariable[]
318
+ # for neighVarId in neighVarIds
319
+ # if haskey(destDFG.labelDict, neighVarId)
320
+ # push!(factVariables, getVariable(destDFG, neighVarId))
321
+ # #otherwise ignore
322
+ # end
323
+ # end
324
+ #
325
+ # # Only if we have all of them should we add it (otherwise strange things may happen on evaluation)
326
+ # if includeOrphanFactors || length(factVariables) == length(neighVarIds)
327
+ # addFactor!(destDFG, factVariables, deepcopy(factor.dfgNode))
328
+ # end
329
+ # end
330
+ # end
331
+ # return nothing
332
+ # end
412
333
413
334
"""
414
335
$(SIGNATURES)
@@ -445,23 +366,6 @@ function getSubgraphAroundNode(dfg::GraphsDFG{P}, node::T, distance::Int64=1, in
445
366
return addToDFG
446
367
end
447
368
448
- """
449
- $(SIGNATURES)
450
- Get a deep subgraph copy from the DFG given a list of variables and factors.
451
- Optionally provide an existing subgraph addToDFG, the extracted nodes will be copied into this graph. By default a new subgraph will be created.
452
- Note: By default orphaned factors (where the subgraph does not contain all the related variables) are not returned. Set includeOrphanFactors to return the orphans irrespective of whether the subgraph contains all the variables.
453
- """
454
- function getSubgraph (dfg:: GraphsDFG , variableFactorLabels:: Vector{Symbol} , includeOrphanFactors:: Bool = false , addToDFG:: GraphsDFG = GraphsDFG {AbstractParams} ()):: GraphsDFG
455
- for label in variableFactorLabels
456
- if ! haskey (dfg. labelDict, label)
457
- error (" Variable/factor with label '$(label) ' does not exist in the factor graph" )
458
- end
459
- end
460
-
461
- _copyIntoGraph! (dfg, addToDFG, variableFactorLabels, includeOrphanFactors)
462
- return addToDFG
463
- end
464
-
465
369
"""
466
370
$(SIGNATURES)
467
371
Get an adjacency matrix for the DFG, returned as a Matrix{Union{Nothing, Symbol}}.
0 commit comments