## Function Reference

**WORK IN PROGRESS** Not all functions have been added to this directory yet.

### Caesar

`Caesar.appendvertbigdata!`

— Function.```
appendvertbigdata!(cloudGraph, cv, description, data)
```

Append big data element into current blob store and update associated global vertex information.

```
appendvertbigdata!(fgl, vert, description, data)
```

Append big data element into current blob store and update associated global vertex information.

`appendvertbigdata!(fg, sym, descr, data)`

Append big data element into current blob store using parent appendvertbigdata!, but here specified by symbol of variable node in the FactorGraph. Note the default data layer api definition. User must define dlapi to refetching the vertex from the data layer. localapi avoids repeated network database fetches.

`Caesar.consoleaskuserfordb`

— Function.```
consoleaskuserfordb(; nparticles, drawdepth, clearslamindb, multisession, drawedges)
```

Obtain database addresses and login credientials from STDIN, as well as a few case dependent options.

`Caesar.db2jld`

— Function.`db2jld(cgl::CloudGraph, session::AbstractString, filename::AbstractString)`

Fetch and save a FactorGraph session to a jld, using CloudGraph object and session definition.

`db2jld(filename::AbstractString; addrdict::NothingUnion{Dict{AbstractString, AbstractString}}=nothing )`

Fetch and save a FactorGraph session to a jld, using or asking STDIN for credentials in the addrdict field.

`Caesar.executeQuery`

— Function.```
executeQuery(connection, query)
```

Run Neo4j Cypher queries on the cloudGraph database, and return Tuple with the unparsed (results, loadresponse). Throws an error if the query fails.

`Caesar.fetchrobotdatafirstpose`

— Function.`fetchrobotdatafirstpose(cg::CloudGraph, session::AbstractString, robot::AbstractString, user::AbstractString)`

Return dict of JSON parsed "robot_description" field as was inserted by counterpart `insertrobotdatafirstpose!`

function. Used for storing general robot specific data in easily accessible manner.

`Caesar.fetchsubgraph!`

— Function.```
fetchsubgraph!(fgl, cvs; numneighbors)
```

Fetch and insert list of CloudVertices into FactorGraph object, up to neighbor depth.

```
fetchsubgraph!(fgl, neoids; numneighbors)
```

Fetch and insert list of Neo4j IDs into FactorGraph object, up to neighbor depth.

`Caesar.findExistingMSConstraints`

— Function.Return Dict{Symbol, Int} of vertex symbol to Neo4j node ID of MULTISESSION constraints in this `fgl.sessionname`

.

`Caesar.getAllLandmarkNeoIDs`

— Function.```
getAllLandmarkNeoIDs(lm2others, slm)
```

Return Vector{Int} of Neo4j vertex IDs relating to symbol, as listed in lm2others.

`Caesar.getBigDataElement`

— Function.```
getBigDataElement(vertex, description)
```

Walk through vertex bigDataElements and return the last matching description.

`Caesar.getExVertexNeoIDs`

— Function.```
getExVertexNeoIDs(conn; label, ready, backendset, session, robot, user, reqbackendset)
```

Return array of tuples with ExVertex IDs and Neo4j IDs for vertices with label in session.

`Caesar.getLandmOtherSessNeoIDs`

— Function.`getLandmOtherSessNeoIDs{T <: AbstractString}(::CloudGraph, session::T="", robot::T="", user::T="", multisessions=Vector{T}())`

Return dict of dict of Neo4j vertex IDs by session and landmark symbols.

`Caesar.getLocalSubGraphMultisession`

— Function.```
getLocalSubGraphMultisession(cg, lm2others; session, robot, user, numneighbors)
```

Return subgraph copy of type FactorGraph contaning values from session in lm2others, and Vector{Symbol} of primary key symbols used for graph exstraction.

`Caesar.getPoseExVertexNeoIDs`

— Function.```
getPoseExVertexNeoIDs(conn; ready, backendset, session, reqbackendset)
```

Return array of tuples with ExVertex IDs and Neo4j IDs for all poses.

`Caesar.getVertNeoIDs!`

— Function.`getVertNeoIDs!(::CloudGraph, res::Dict{Symbol, Int}; session::AbstractString="NA", robot::AbstractString="NA", user::AbstractString="NA")`

Insert into and return dict `res`

with Neo4j IDs of ExVertex labels as stored per session in Neo4j database.

`Caesar.getfirstpose`

— Function.`getfirstpose(cg::CloudGraph, session::AbstractString, robot::AbstractString, user::AbstractString)`

Return Tuple{Symbol, Int} of first pose symbol and Neo4j node ID.

`Caesar.getnewvertdict`

— Function.`getnewvertdict(conn, session::AbstractString, robot::AbstractString, user::AbstractString)`

Return a dictionary with frtend and mongo_keys json string information for :NEWDATA elements in Neo4j database.

`Caesar.getprpt2kde`

— Function.`getprp2kde(::CloudGraph, neoids::Vector{Int}; N::Int=100)`

Return PriorPoint2DensityNH with N points based on beliefs of neoids, and equal share null hypothesis between length(neoids)+1 beliefs.

`Caesar.hasBigDataElement`

— Function.```
hasBigDataElement(vertex, description)
```

Return true if vertex has bigDataElements with matching description.

`Caesar.insertrobotdatafirstpose!`

— Function.`insertrobotdatafirstpose!(cg::CloudGraph, session::AbstractString, robot::AbstractString, user::AbstractString, robotdict::Dict)`

Saves robotdict via JSON to first pose in a SESSION in the database. Used for storing general robot specific data in easily accessible manner. Can fetch later retrieve same dict with counterpart `fetchrobotdatafirstpose`

function.

`Caesar.removeNeo4jID`

— Function.`removeNeo4jID(cg::CloudGraph, neoid=-1)`

Remove node from Neo4j according to Neo4j Node ID. Big data elements that may be associated with this node are not removed.

`Caesar.resetentireremotesession`

— Function.```
resetentireremotesession(conn, session, robot, user; segment)
```

match (n:session) remove n.backendset, n.ready, n.data, n.bigData, n.label, n.packedType, n.exVertexId, n.shape, n.width set n :NEWDATA return n

`Caesar.rmInstMultisessionPriors!`

— Function.`rmInstMultisessionPriors!(::CloudGraph; session<:AbstractString=, multisessions::Vector{<:AbstractString}= )`

`Caesar.standardcloudgraphsetup`

— Function.```
standardcloudgraphsetup(; addrdict, nparticles, drawdepth, drawedges, clearslamindb, multisession)
```

Connect to databases via network according to addrdict, or ask user for credentials and return active cloudGraph object, as well as addrdict.

`Caesar.updatenewverts!`

— Function.Convert vertices of session in Neo4j DB with Caesar.jl's required data elements in preparation for MM-iSAMCloudSolve process.

`Caesar.whosNear2D`

— Function.```
whosNear2D(cg, session, robot, user; x, y, yaw, dist, angle)
```

Find vertices near the point specified and return dictionary of symbol to Neo4j ID pairs.

`Caesar.whosNear3D`

— Function.```
whosNear3D(cg, session, robot, user; x, y, z, roll, pitch, yaw, dist, angle)
```

Find vertices near the point specified and return dictionary of symbol to Neo4j ID pairs.

### RoME

`RoME.getRangeKDEMax2D`

— Function.```
getRangeKDEMax2D(fgl, vsym1, vsym2)
```

Calculate the cartesian distance between two vertices in the graph using their symbol name, and by maximum belief point.

`getRangeKDEMax2D(cgl::CloudGraph, session::AbstractString, vsym1::Symbol, vsym2::Symbol)`

Calculate the cartesian distange between two vertices in the graph, by session and symbol names, and by maximum belief point.

`RoME.initFactorGraph!`

— Function.```
initFactorGraph!(fg; P0, init, N, lbl, ready, firstPoseType, labels)
```

Initialize a factor graph object as Pose2, Pose3, or neither and returns variable and factor symbols as array.

`RoME.addOdoFG!`

— Function.```
addOdoFG!(fg, n, DX, cov; N, ready, labels)
```

Create a new variable node and insert odometry constraint factor between which will automatically increment latest pose symbol x<k+1> for new node new node and constraint factor are returned as a tuple.

```
addOdoFG!(fgl, odo; N, ready, labels)
```

Create a new variable node and insert odometry constraint factor between which will automatically increment latest pose symbol x<k+1> for new node new node and constraint factor are returned as a tuple.

### IncrementalInference

`DistributedFactorGraphs.addVariable!`

— Function.```
addVariable!(dfg, lbl, softtype; N, autoinit, ready, dontmargin, labels, smalldata, checkduplicates)
```

Add a variable node `lbl::Symbol`

to `fg::FactorGraph`

, as `softtype<:InferenceVariable`

.

**Example**

```
fg = initfg()
addVariable!(fg, :x0, Pose2)
```

`DistributedFactorGraphs.addFactor!`

— Function.```
addFactor!(dfg, Xi, usrfnc; multihypo, ready, labels, autoinit, threadmodel, maxparallel)
```

Add factor with user defined type <: FunctorInferenceType to the factor graph object. Define whether the automatic initialization of variables should be performed. Use order sensitive `multihypo`

keyword argument to define if any variables are related to data association uncertainty.

`IncrementalInference.approxCliqMarginalUp!`

— Function.```
approxCliqMarginalUp!(fgl, treel, csym)
approxCliqMarginalUp!(fgl, treel, csym, onduplicate; N, dbg, iters, drawpdf, multiproc, logger)
```

Approximate Chapman-Kolmogorov transit integral and return separator marginals as messages to pass up the Bayes (Junction) tree, along with additional clique operation values for debugging.

Notes

`onduplicate=true`

by default internally uses deepcopy of factor graph and Bayes tree, and does**not**update the given objects. Set false to update`fgl`

and`treel`

during compute.

Future

- TODO: internal function chain is too long and needs to be refactored for maintainability.

`IncrementalInference.approxConv`

— Function.Draw samples from the approximate convolution of `towards`

symbol using factor `fct`

relative to the other variables. In addition the `api`

can be adjusted to recover the data from elsewhere (likely to be replaced/removed in the future).

`IncrementalInference.areCliqChildrenNeedDownMsg`

— Function.```
areCliqChildrenNeedDownMsg(children)
```

Return `true`

if any of the children cliques have status `:needdownmsg`

.

```
areCliqVariablesAllMarginalized(subfg, cliq)
```

Return true if all variables in clique are considered marginalized (and initialized).

`IncrementalInference.assignTreeHistory!`

— Function.```
assignTreeHistory!(treel, cliqHistories)
```

After solving, clique histories can be inserted back into the tree for later reference. This function helps do the required assigment task.

`IncrementalInference.asyncTreeInferUp!`

— Function.Perform tree based initialization of all variables not yet initialized in factor graph as non-blocking method.

Notes:

- To simplify debugging, this method does not include the usual
`@ sync`

around all the state machine async processes. - Extract the error stack with a
`fetch`

on the failed process return by this function.

Related

initInferTreeUp!

`IncrementalInference.attemptTreeSimilarClique`

— Function.```
attemptTreeSimilarClique(othertree, seeksSimilar)
```

Special internal function to try return the clique data if succesfully identified in `othertree::BayesTree`

, based on contents of `seeksSimilar::BayesTreeNodeData`

.

Notes

- Used to identify and skip similar cliques (i.e. recycle computations)

`IncrementalInference.batchSolve!`

— Function.Perform multimodal incremental smoothing and mapping (mm-iSAM) computations over given factor graph `fgl::FactorGraph`

on the local computer. A pdf of the Bayes (Junction) tree will be generated in the working folder with `drawpdf=true`

```
blockCliqUntilChildrenHaveUpStatus(tree, prnt)
blockCliqUntilChildrenHaveUpStatus(tree, prnt, logger)
```

Block the thread until child cliques of `prnt::Graphs.ExVertex`

have finished attempting upward initialization – i.e. have status result. Return `::Dict{Symbol}`

indicating whether next action that should be taken for each child clique.

Notes:

- See status options at
`getCliqStatusUp(..)`

. - Can be called multiple times

`IncrementalInference.buildSubgraphFromLabels`

— Function.```
buildSubgraphFromLabels(dfg, syms)
buildSubgraphFromLabels(dfg, syms, destType)
```

Construct a new factor graph object as a subgraph of `fgl::FactorGraph`

based on the variable labels `syms::Vector{Symbols}`

.

Notes

- Slighly messy internals, but gets the job done – some room for performance improvement.

Related

getVariableIds

`IncrementalInference.buildTreeFromOrdering!`

— Function.```
buildTreeFromOrdering!(dfg, p; drawbayesnet, maxparallel)
```

Build Bayes/Junction/Elimination tree from a given variable ordering.

`IncrementalInference.buildCliqSubgraphDown`

— Function.```
buildCliqSubgraphDown(fgl, treel, cliqsym)
buildCliqSubgraphDown(fgl, treel, cliqsym, varsym)
```

Build a new subgraph from `fgl::FactorGraph`

containing all variables and factors associated with `cliq`

. Additionally add the upward message prior factors as needed for belief propagation (inference).

Notes

`cliqsym::Symbol`

defines the cliq where variable appears as a frontal variable.`varsym::Symbol`

defaults to the cliq frontal variable definition but can in case a separator variable is required instead.

`IncrementalInference.buildCliqSubgraphUp`

— Function.```
buildCliqSubgraphUp(fgl, treel, cliqsym)
buildCliqSubgraphUp(fgl, treel, cliqsym, varsym)
```

Build a new subgraph from `fgl::FactorGraph`

containing all variables and factors associated with `cliq`

. Additionally add the upward message prior factors as needed for belief propagation (inference).

Notes

`cliqsym::Symbol`

defines the cliq where variable appears as a frontal variable.`varsym::Symbol`

defaults to the cliq frontal variable definition but can in case a separator variable is required instead.

`IncrementalInference.childCliqs`

— Function.```
childCliqs(treel, cliq)
```

Return a vector of child cliques to `cliq`

.

`IncrementalInference.cliqGibbs`

— Function.```
cliqGibbs(fg, cliq, vsym, inmsgs, N, dbg, manis)
cliqGibbs(fg, cliq, vsym, inmsgs, N, dbg, manis, logger)
```

Perform one step of the minibatch clique Gibbs operation for solving the Chapman-Kolmogov trasit integral – here involving separate approximate functional convolution and product operations.

`IncrementalInference.cliqHistFilterTransitions`

— Function.```
cliqHistFilterTransitions(hist, nextfnc)
```

Return state machine transition steps from history such that the `nextfnc::Function`

.

Related:

getCliqSolveHistory, printCliqHistorySummary, filterHistAllToArray, sandboxCliqResolveStep

```
cliqInitSolveUpByStateMachine!(dfg, tree, cliq; N, oldcliqdata, drawtree, show, incremental, limititers, upsolve, downsolve, recordhistory, delay, logger)
```

EXPERIMENTAL: perform upward inference using a state machine solution approach.

Notes:

- will call on values from children or parent cliques
- can be called multiple times
- Assumes all cliques in tree are being solved simultaneously and in similar manner.
- State machine rev.1 – copied from first TreeBasedInitialization.jl.
- Doesn't do partial initialized state properly yet.

`IncrementalInference.compareAllVariables`

— Function.```
compareAllVariables(fgA, fgB; skip, show, skipsamples)
```

Compare all variables in both `::FactorGraph`

s A and B.

Notes

- A and B should all the same variables and factors.

Related:

`compareFactorGraphs`

, `compareSimilarVariables`

, `compareVariable`

, `ls`

`IncrementalInference.compareFactorGraphs`

— Function.Compare and return if two factor graph objects are the same, by comparing similar variables and factors.

Notes:

- Default items to skip with
`skipsamples`

,`skipcompute`

. - User defined fields to skip can be specified with
`skip::Vector{Symbol}`

.

Related:

`compareSimilarVariables`

, `compareSimilarFactors`

, `compareAllVariables`

, `ls`

.

`IncrementalInference.compareSimilarFactors`

— Function.Compare similar factors between `::FactorGraph`

s A and B.

Related:

`compareFactorGraphs`

, `compareSimilarVariables`

, `compareAllVariables`

, `ls`

.

`IncrementalInference.compareSimilarVariables`

— Function.Compare similar labels between `::FactorGraph`

s A and B.

Notes

- At least one variable label should exist in both A and B.

Related:

`compareFactorGraphs`

, `compareAllVariables`

, `compareSimilarFactors`

, `compareVariable`

, `ls`

.

`IncrementalInference.compareSubsetFactorGraph`

— Function.```
compareSubsetFactorGraph(fgS, fgA)
```

Determine if and compare `fgS::FactorGraph`

is a subset with similar content to `fgA`

.

Notes

`fgS`

⊆`fgA`

.

Related:

`compareFactorGraphs`

, `compareSimilarVariables`

, `compareSimilarFactors`

, `ls`

.

`IncrementalInference.compareVariable`

— Function.```
compareVariable(A, B; skip, show, skipsamples)
```

Compare that all fields are the same in a `::FactorGraph`

variable.

`IncrementalInference.convert2packedfunctionnode`

— Function.Encode complicated function node type to related 'Packed<type>' format assuming a user supplied convert function .

`IncrementalInference.csmAnimate`

— Function.```
csmAnimate(fg, tree, cliqsyms; frames, rmfirst)
```

Animate multiple clique state machines on the same graphviz visualization. Renders according to linear time for all provided histories.

Example:

```
using Caesar
# build a factor graph
fg = initfg()
# addVariable!(...)
# addFactor!(...)
# ...
fsy = getTreeAllFrontalSyms(fg, tree) # for later use
# perform inference to find the factor graph marginal posterior estimates
tree, smt, hist = solveTree!(fg, recordcliqs=fsy)
# generate frames in standard location /tmp/caesar/csmCompound/
# requires: sudo apt-get install graphviz
csmAnimate(fg, tree, fsy, frames=500)
# to render and show from default location (might require)
# sudo apt-get install ffmpeg vlc
# .ogv [Totem Ubuntu default]
Base.rm("/tmp/caesar/csmCompound/out.ogv")
run(`ffmpeg -r 10 -i /tmp/caesar/csmCompound/csm_%d.png -c:v libtheora -vf fps=25 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -q 10 /tmp/caesar/csmCompound/out.ogv`)
run(`totem /tmp/caesar/csmCompound/out.ogv`)
# h.264 [VLC not default]
Base.rm("/tmp/caesar/csmCompound/out.mp4")
run(`ffmpeg -r 10 -i /tmp/caesar/csmCompound/csm_%d.png -c:v libx264 -vf fps=25 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" /tmp/caesar/csmCompound/out.mp4`)
run(`vlc /tmp/caesar/csmCompound/out.mp4`)
```

`IncrementalInference.cycleInitByVarOrder!`

— Function.Cycle through var order and initialize variables as possible in `subfg::FactorGraph`

. Return true if something was updated.

Notes:

- assumed
`subfg`

is a subgraph containing only the factors that can be used.- including the required up or down messages

- intended for both up and down initialization operations.

Dev Notes

- Should monitor updates based on the number of inferred & solvable dimensions

`IncrementalInference.decodefg`

— Function.```
decodefg(fgs)
```

Unpack PackedFunctionNodeData formats back to regular FunctonNodeData.

Missing docstring for `deleteFactor!`

. Check Documenter's build log for details.

Missing docstring for `deleteVariable!`

. Check Documenter's build log for details.

`IncrementalInference.doautoinit!`

— Function.```
doautoinit!(dfg, xi; singles, N, logger)
```

EXPERIMENTAL: initialize target variable `xi`

based on connected factors in the factor graph `fgl`

. Possibly called from `addFactor!`

, or `doCliqAutoInitUp!`

.

Development Notes:

Target factor is first (singletons) or second (dim 2 pairwise) variable vertex in

`xi`

.

- TODO use DFG properly with local operations and DB update at end.
- TODO get faster version of
`isInitialized`

for database version. - TODO: Persist this back if we want to here.

`IncrementalInference.doCliqUpSolve!`

— Function.Update `subfg<:AbstractDFG`

according to internal computations for a full upsolve.

`IncrementalInference.downGibbsCliqueDensity`

— Function.```
downGibbsCliqueDensity(fg, cliq, dwnMsgs)
downGibbsCliqueDensity(fg, cliq, dwnMsgs, N)
downGibbsCliqueDensity(fg, cliq, dwnMsgs, N, MCMCIter)
downGibbsCliqueDensity(fg, cliq, dwnMsgs, N, MCMCIter, dbg)
downGibbsCliqueDensity(fg, cliq, dwnMsgs, N, MCMCIter, dbg, usemsgpriors)
downGibbsCliqueDensity(fg, cliq, dwnMsgs, N, MCMCIter, dbg, usemsgpriors, logger)
```

Perform Chapman-Kolmogorov transit integral approximation for `cliq`

in downward pass direction.

Notes

- Only update frontal variables of the clique.

`IncrementalInference.downMsgPassingRecursive`

— Function.Pass NBPMessages back down the tree – pre order tree traversal.

`IncrementalInference.drawCliqSubgraphUpMocking`

— Function.```
drawCliqSubgraphUpMocking(fgl, treel, frontalSym; show, filepath, engine, viewerapp)
```

Construct (new) subgraph and draw the subgraph associated with clique `frontalSym::Symbol`

.

Notes

- See
`drawGraphCliq`

/`writeGraphPdf`

for details on keyword options.

Related

drawGraphCliq, spyCliqMat, drawTree, buildCliqSubgraphUp, buildSubgraphFromLabels

`IncrementalInference.dwnMsg`

— Function.```
dwnMsg(cliq)
```

Return the last down message stored in `cliq`

of Bayes (Junction) tree.

`IncrementalInference.encodefg`

— Function.Make a full memory copy of the graph and encode all composite function node types – assuming that convert methods for 'Packed<type>' formats exist. The same converters are used for database persistence with CloudGraphs.jl.

`IncrementalInference.fifoFreeze!`

— Function.Freeze nodes that are older than the quasi fixed-lag length defined by `fg.qfl`

, according to `fg.fifo`

ordering.

Future:

- Allow different freezing strategies beyond fifo.

`IncrementalInference.filterHistAllToArray`

— Function.```
filterHistAllToArray(tree, frontals, nextfnc)
```

Return state machine transition steps from all cliq histories with transition `nextfnc::Function`

.

Related:

getCliqSolveHistory, printCliqHistorySummary, cliqHistFilterTransitions, sandboxCliqResolveStep

`IncrementalInference.findRelatedFromPotential`

— Function.```
findRelatedFromPotential(dfg, fct, varid, N)
findRelatedFromPotential(dfg, fct, varid, N, dbg)
```

Compute proposal belief on `vertid`

through `fct`

representing some constraint in factor graph. Always full dimension variable node – partial constraints will only influence subset of variable dimensions. The remaining dimensions will keep pre-existing variable values.

Notes

- fulldim is true when "rank-deficient" – TODO swap to false (or even float)

`IncrementalInference.fmcmc!`

— Function.```
fmcmc!(fgl, cliq, fmsgs, lbls, N, MCMCIter)
fmcmc!(fgl, cliq, fmsgs, lbls, N, MCMCIter, dbg)
fmcmc!(fgl, cliq, fmsgs, lbls, N, MCMCIter, dbg, logger)
fmcmc!(fgl, cliq, fmsgs, lbls, N, MCMCIter, dbg, logger, multithreaded)
```

Iterate successive approximations of clique marginal beliefs by means of the stipulated proposal convolutions and products of the functional objects for tree clique `cliq`

.

`IncrementalInference.getCliq`

— Function.```
getCliq(bt, frt)
```

Return the Graphs.ExVertex node object that represents a clique in the Bayes (Junction) tree, as defined by one of the frontal variables `frt<:AbstractString`

.

Notes

- Frontal variables only occur once in a clique per tree, therefore is a unique identifier.

Related:

getCliq, getTreeAllFrontalSyms

`IncrementalInference.getCliqAllVarIds`

— Function.```
getCliqAllVarIds(cliq)
```

Get all `cliq`

variable ids`::Symbol`

.

Related

getCliqVarIdsAll, getCliqAllFactIds, getCliqVarsWithFrontalNeighbors

`IncrementalInference.getCliqAllVarSyms`

— Function.Get all `cliq`

variable labels as `::Symbol`

.

`IncrementalInference.getCliqAssocMat`

— Function.```
getCliqAssocMat(cliq)
```

Return boolean matrix of factor by variable (row by column) associations within clique, corresponds to order presented by `getCliqFactorIds`

and `getCliqAllVarIds`

.

`IncrementalInference.getCliqChildMsgsUp`

— Function.```
getCliqChildMsgsUp(fg_, treel, cliq, ?)
```

Get and return upward belief messages as stored in child cliques from `treel::BayesTree`

.

Notes

- Use last parameter to select the return format.

`IncrementalInference.getCliqDepth`

— Function.```
getCliqDepth(tree, cliq)
```

Return depth in tree as `::Int`

, with root as depth=0.

Related

getCliq

Return dictionary of down messages consisting of all frontal and separator beliefs of this clique.

Notes:

- Fetches numerical results from
`subdfg`

as dictated in`cliq`

.

`IncrementalInference.getCliqFrontalVarIds`

— Function.```
getCliqFrontalVarIds(cliqdata)
```

Get the frontal variable IDs `::Int`

for a given clique in a Bayes (Junction) tree.

`IncrementalInference.getCliqVarInitOrderUp`

— Function.```
getCliqVarInitOrderUp(cliq)
```

Return the most likely ordering for initializing factor (assuming up solve sequence).

Notes:

- sorts id for increasing number of connected factors.

`IncrementalInference.getCliqMat`

— Function.```
getCliqMat(cliq; showmsg)
```

Return boolean matrix of factor variable associations for a clique, optionally including (`showmsg::Bool=true`

) the upward message singletons. Variable order corresponds to `getCliqAllVarIds`

.

`IncrementalInference.getCliqMsgsDown`

— Function.```
getCliqMsgsDown(cliql)
```

Return the last down message stored in `cliq`

of Bayes (Junction) tree.

`IncrementalInference.getCliqMsgsUp`

— Function.```
getCliqMsgsUp(cliql)
```

Return the last up message stored in `cliq`

of Bayes (Junction) tree.

`IncrementalInference.getCliqOrderUpSolve`

— Function.```
getCliqOrderUpSolve(treel)
getCliqOrderUpSolve(treel, startcliq)
```

Return clique pointers for the given order in which they will be solved (sequentially).

`IncrementalInference.getCliqParentMsgDown`

— Function.```
getCliqParentMsgDown(treel, cliq)
```

Get the latest down message from the parent node (without calculating anything).

Notes

- Different from down initialization messages that do calculate new values – see
`prepCliqInitMsgsDown!`

. - Basically converts function
`getDwnMsgs`

from`Dict{Symbol,BallTreeDensity}`

to`Dict{Symbol,Vector{BallTreeDensity}}`

.

`IncrementalInference.getCliqSeparatorVarIds`

— Function.```
getCliqSeparatorVarIds(cliqdata)
```

Get `cliq`

separator (a.k.a. conditional) variable ids`::Symbol`

.

`IncrementalInference.getCliqSiblings`

— Function.```
getCliqSiblings(treel, cliq)
getCliqSiblings(treel, cliq, inclusive)
```

Return a vector of all siblings to a clique, which defaults to not `inclusive`

the calling `cliq`

.

`IncrementalInference.getCliqSolveHistory`

— Function.```
getCliqSolveHistory(cliq)
```

Return clique state machine history from `tree`

if it was solved with `recordcliqs`

.

Notes

- Cliques are identified by front variable
`::Symbol`

which are always unique across the cliques.

`IncrementalInference.getCliqVarIdsPriors`

— Function.```
getCliqVarIdsPriors(cliq)
getCliqVarIdsPriors(cliq, allids)
getCliqVarIdsPriors(cliq, allids, partials)
```

Get variable ids`::Int`

with prior factors associated with this `cliq`

.

Notes:

- does not include any singleton messages from upward or downward message passing.

`IncrementalInference.getCliqVars`

— Function.```
getCliqVars(subfg, cliq)
```

Return array of all variable vertices in a clique.

`IncrementalInference.getCliqVarSingletons`

— Function.```
getCliqVarSingletons(cliq)
getCliqVarSingletons(cliq, allids)
getCliqVarSingletons(cliq, allids, partials)
```

Get `cliq`

variable IDs with singleton factors – i.e. both in clique priors and up messages.

`IncrementalInference.getCurrentWorkspaceFactors`

— Function.```
getCurrentWorkspaceFactors()
```

Return all factors currently registered in the workspace.

```
getCurrentWorkspaceVariables()
```

Return all variables currently registered in the workspace.

`IncrementalInference.getKDE`

— Function.```
getKDE(v)
```

Get KernelDensityEstimate kde estimate stored in variable node.

`IncrementalInference.getManifolds`

— Function.```
getManifolds(vd)
```

Return the manifolds on which variable `sym::Symbol`

is defined.

`IncrementalInference.getParent`

— Function.```
getParent(treel, afrontal)
```

Return `cliq`

's parent clique.

`IncrementalInference.getTreeAllFrontalSyms`

— Function.Return one symbol (a frontal variable) from each clique in the `::BayesTree`

.

Notes

- Frontal variables only occur once in a clique per tree, therefore is a unique identifier.

Related:

whichCliq, printCliqHistorySummary

`IncrementalInference.getTreeCliqSolveOrderUp`

— Function.```
getTreeCliqSolveOrderUp(treel)
getTreeCliqSolveOrderUp(treel, startcliq)
```

Return clique pointers for the given order in which they will be solved (sequentially).

`IncrementalInference.getTreeCliqsSolverHistories`

— Function.Return dict of all histories in a Bayes Tree.

`IncrementalInference.getVal`

— Function.```
getVal(v; solveKey)
```

Convenience function to get point values sampled i.i.d from marginal of `lbl`

variable in the current factor graph.

```
getVal(vA)
getVal(vA, solveKey)
```

Fetch the variable marginal sample points without the KDE bandwidth parameter. Use getVertKDE to retrieve the full KDE object.

`IncrementalInference.getVariableDim`

— Function.```
getVariableDim(vard)
```

Return the number of dimensions this variable vertex `var`

contains.

Related

getVariableInferredDim, getVariableInferredDimFraction

`IncrementalInference.getVariableInferredDim`

— Function.```
getVariableInferredDim(vard)
getVariableInferredDim(vard, saturate)
```

Return the number of projected dimensions into a variable during inference.

Notes

`saturate`

clamps return value to no greater than variable dimension

Related

getVariableDim, getVariableInferredDimFraction, getVariableInferredDim, getVariableDim

`IncrementalInference.getVertKDE`

— Function.```
getVertKDE(v)
```

Get KernelDensityEstimate kde estimate stored in variable node.

`IncrementalInference.getUpMsgs`

— Function.```
getUpMsgs(cliql)
```

Return the last up message stored in `cliq`

of Bayes (Junction) tree.

`IncrementalInference.getDwnMsgs`

— Function.```
getDwnMsgs(cliql)
```

Return the last down message stored in `cliq`

of Bayes (Junction) tree.

`IncrementalInference.hasCliq`

— Function.```
hasCliq(bt, frt)
```

Return boolean on whether the frontal variable `frt::Symbol`

exists somewhere in the `::BayesTree`

.

`IncrementalInference.inferOverTree!`

— Function.Perform up and down message passing (multi-process) algorithm for full sum-product solution of all continuous marginal beliefs.

Notes

- For legacy versions of tree traversal, see
`inferOverTreeIterative!`

instead.

`IncrementalInference.inferOverTreeR!`

— Function.Perform up and down message passing (single process, recursive) algorithm for full sum-product solution of all continuous marginal beliefs.

`IncrementalInference.initfg`

— Function.```
initfg()
initfg(dfg; sessionname, robotname, username, cloudgraph)
```

Initialize an empty in-memory DistributedFactorGraph `::DistributedFactorGraph`

object.

`IncrementalInference.initInferTreeUp!`

— Function.```
initInferTreeUp!(dfg, treel; oldtree, drawtree, N, limititers, downsolve, incremental, skipcliqids, recordcliqs, delaycliqs)
```

Perform tree based initialization of all variables not yet initialized in factor graph.

Related

asyncTreeInferUp!

`IncrementalInference.isCliqMarginalizedFromVars`

— Function.```
isCliqMarginalizedFromVars(subfg, cliq)
```

Return `::Bool`

on whether all variables in this `cliq`

are marginalzed.

`IncrementalInference.isCliqReadyInferenceUp`

— Function.```
isCliqReadyInferenceUp(fgl, tree, cliq)
```

Determine if this `cliq`

has been fully initialized and child cliques have completed their full upward inference.

`DistributedFactorGraphs.isInitialized`

— Function.```
isInitialized(vert)
```

Returns state of vertex data `.initialized`

flag.

Notes:

- used by Bayes tree clique logic.
- similar method in DFG

`IncrementalInference.isMarginalized`

— Function.```
isMarginalized(vert)
```

Return `::Bool`

on whether this variable has been marginalized.

`IncrementalInference.isTreeSolved`

— Function.```
isTreeSolved(treel; skipinitialized)
```

Return true or false depending on whether the tree has been fully initialized/solved/marginalized.

`IncrementalInference.isPartial`

— Function.```
isPartial(fcf)
```

Return `::Bool`

on whether factor is a partial constraint.

`IncrementalInference.landmarks`

— Function.```
landmarks(fgl, vsym)
```

Return `Vector{Symbol}`

of landmarks attached to vertex vsym in `fgl::FactorGraph`

.

`IncrementalInference.loadjld`

— Function.```
loadjld(; file)
```

Opposite of savejld(fg, gt=gt, file="tempfg.jl") to load data from file. This function uses the unpacking converters for converting all PackedInferenceType to FunctorInferenceType.

`IncrementalInference.localProduct`

— Function.Using factor graph object `dfg`

, project belief through connected factors (convolution with conditional) to variable `sym`

followed by a approximate functional product.

Return: product belief, full proposals, partial dimension proposals, labels

`DistributedFactorGraphs.ls`

— Function.```
ls(cgl, session, robot, user; sym, neoid, exvid)
```

List neighbors to node in cgl::CloudGraph by returning Dict{Sym}=(exvid, neoid, Symbol[labels]), and can take any of the three as input node identifier. Not specifying an identifier will result in all Variable nodes being returned.

`IncrementalInference.lsRear`

— Function.```
lsRear(fgl)
lsRear(fgl, n)
```

Return array of all variable nodes connected to the last `n`

many poses (`:x*`

).

Example:

```
# Shallow copy the tail end of poses from a factor graph `fg1`
vars = lsRear(fg1, 5)
fg1_r5 = subgraphFromVerts(fg1, vars)
```

`IncrementalInference.makeCsmMovie`

— Function.```
makeCsmMovie(fg, tree)
makeCsmMovie(fg, tree, cliqs; assignhist, show, filename, frames)
```

Convenience function to assign and make video of CSM state machine for `cliqs`

.

Notes

- Probably several teething issues still (lower priority).
- Use
`assignhist`

if solver params async was true, or errored.

Related

csmAnimate, printCliqHistorySummary

`IncrementalInference.manualinit!`

— Function.```
manualinit!(dfg, vert, pX)
```

Workaround function when first-version (factor graph based) auto initialization fails. Usually occurs when using factors that have high connectivity to multiple variables.

`IncrementalInference.parentCliq`

— Function.```
parentCliq(treel, cliq)
```

Return `cliq`

's parent clique.

`IncrementalInference.packFromLocalPotentials!`

— Function.```
packFromLocalPotentials!(dfg, dens, wfac, cliq, vsym, N)
packFromLocalPotentials!(dfg, dens, wfac, cliq, vsym, N, dbg)
```

Add all potentials associated with this clique and vertid to dens.

`IncrementalInference.prepBatchTree!`

— Function.```
prepBatchTree!(dfg; ordering, drawpdf, show, filepath, viewerapp, imgs, drawbayesnet, maxparallel)
```

Build Bayes/Junction/Elimination tree.

Notes

- Default to free qr factorization for variable elimination order.

`IncrementalInference.prepCliqInitMsgsDown!`

— Function.```
prepCliqInitMsgsDown!(fgl, tree, prnt, cliq; logger, dbgnew)
```

Initialization downward message passing is different from regular inference since it is possible that none of the child cliq variables have been initialized.

Notes

- init msgs from child upward passes are individually stored in this
`cliq`

. - fresh product of overlapping beliefs are calculated on each function call.
- Assumed that
`prnt`

of siblings

Dev Notes

- This should be the initialization cycle of parent, build up bit by bit...

`IncrementalInference.printCliqHistorySummary`

— Function.```
printCliqHistorySummary(fid, hist)
```

Print a short summary of state machine history for a clique solve.

Related:

getTreeAllFrontalSyms, getCliqSolveHistory, animateCliqStateMachines

`IncrementalInference.printgraphmax`

— Function.```
printgraphmax(fgl)
```

Print the maximum point values form all variables approximate marginals in the factor graph. The full marginal can be recovered for example `X0 = getVertKDE(fg, :x0)`

.

`IncrementalInference.productpartials!`

— Function.```
productpartials!(pGM, dummy, partials, manis)
```

Multiply different dimensions from partial constraints individually.

`IncrementalInference.prodmultiplefullpartials`

— Function.Multiply various full and partial dimension constraints.

`IncrementalInference.prodmultipleonefullpartials`

— Function.```
prodmultipleonefullpartials(dens, partials, Ndims, N, manis)
```

Multiply a single full and several partial dimension constraints.

`IncrementalInference.resetBuildTreeFromOrder!`

— Function.```
resetBuildTreeFromOrder!(fgl, p)
```

Reset factor graph and build a new tree from the provided variable ordering `p`

.

`IncrementalInference.resetCliqSolve!`

— Function.Reset the state of all variables in a clique to not initialized.

Notes

- resets numberical values to zeros.

Dev Notes

- TODO not all kde manifolds will initialize to zero.

`IncrementalInference.resetData!`

— Function.```
resetData!(vdata)
```

Partial reset of basic data fields in `::VariableNodeData`

of `::FunctionNode`

structures.

`IncrementalInference.resetTreeCliquesForUpSolve!`

— Function.```
resetTreeCliquesForUpSolve!(treel)
```

Reset the Bayes (Junction) tree so that a new upsolve can be performed.

Notes

- Will change previous clique status from
`:downsolved`

to`:initialized`

only. - Sets the color of tree clique to
`lightgreen`

.

`IncrementalInference.resetVariable!`

— Function.```
resetVariable!(varid; solveKey)
```

Reset the solve state of a variable to uninitialized/unsolved state.

`IncrementalInference.sandboxCliqResolveStep`

— Function.```
sandboxCliqResolveStep(tree, frontal, step)
```

Repeat a solver state machine step without changing history or primary values.

printCliqSummary, printCliqHistorySummary, getCliqSolveHistory, cliqHistFilterTransitions

`IncrementalInference.savejld`

— Function.Save mostly complete Factor Graph type by converting complicated FunctionNodeData types to 'Packed' types using user supplied converters. Ground truth can also be saved and recovered by the associated loadjld(file="tempfg.jld2") method.

Notes:

- Must use
`.jld2`

since Julia 1.0 (previous version was deprecated).

`IncrementalInference.setCliqAsMarginalized!`

— Function.```
setCliqAsMarginalized!(cliq, status)
```

Set the marginalized status of a clique.

`IncrementalInference.setCliqStatus!`

— Function.```
setCliqStatus!(cliq, status)
```

Set up initialization or solve status of this `cliq`

.

`IncrementalInference.setDwnMsg!`

— Function.```
setDwnMsg!(cliql, msgs)
```

Set the downward passing message for Bayes (Junction) tree clique `cliql`

.

`IncrementalInference.setfreeze!`

— Function.```
setfreeze!(dfg, sym)
```

Set variable(s) `sym`

of factor graph to be marginalized – i.e. not be updated by inference computation.

`IncrementalInference.setTreeCliquesMarginalized!`

— Function.Set all Bayes (Junction) tree cliques that have all marginalized and initialized variables.

`IncrementalInference.setUpMsg!`

— Function.```
setUpMsg!(cliql, msgs)
```

Set the upward passing message for Bayes (Junction) tree clique `cliql`

.

Dev Notes

- TODO setUpMsg! should also set inferred dimension

`IncrementalInference.setValKDE!`

— Function.```
setValKDE!(vd, pts, bws)
setValKDE!(vd, pts, bws, setinit)
setValKDE!(vd, pts, bws, setinit, inferdim)
```

Set the point centers and bandwidth parameters of a variable node, also set `isInitialized=true`

if `setinit::Bool=true`

(as per default).

Notes

`initialized`

is used for initial solve of factor graph where variables are not yet initialized.`inferdim`

is used to identify if the initialized was only partial.

`IncrementalInference.setVariableInitialized!`

— Function.```
setVariableInitialized!(varid, status)
```

Set variable initialized status.

`IncrementalInference.setVariableInferDim!`

— Function.```
setVariableInferDim!(varid, val)
```

Set method for the inferred dimension value in a variable.

`IncrementalInference.showVariable`

— Function.Display the content of `VariableNodeData`

to console for a given factor graph and variable tag`::Symbol`

.

Dev Notes

- TODO split as two show macros between AMP and DFG

`IncrementalInference.solveCliq!`

— Function.Perform inference over one clique in the Bayes tree according to `opt::SolverParams`

.

Example

```
tree = wipeBuildNewTree!(fg)
smt, hist = solveCliq!(fg, tree, :x1 [,cliqHistories=hist] )
```

Related

solveTree!, wipeBuildNewTree!

`IncrementalInference.solveCliqWithStateMachine!`

— Function.Standalone state machine solution for a single clique.

Related:

initInferTreeUp!

`IncrementalInference.solveTree!`

— Function.Perform inference over the Bayes tree according to `opt::SolverParams`

.

Notes

- Variety of options, including fixed-lag solving – see
`getSolverParams(fg)`

for details.

Example

```
# without [or with] compute recycling
tree, smt, hist = solveTree!(fg [,tree])
```

Related

solveCliq!, wipeBuildNewTree!

`IncrementalInference.transferUpdateSubGraph!`

— Function.```
transferUpdateSubGraph!(dest, src)
transferUpdateSubGraph!(dest, src, syms)
transferUpdateSubGraph!(dest, src, syms, logger)
```

Transfer contents of `src::FactorGraph`

variables `syms::Vector{Symbol}`

to `dest::FactorGraph`

.

Notes

- Reads,
`dest`

:=`src`

, for all`syms`

`IncrementalInference.treeProductDwn`

— Function.```
treeProductDwn(fg, tree, cliq, sym; N, dbg)
```

Calculate a fresh–-single step–-approximation to the variable `sym`

in clique `cliq`

as though during the downward message passing. The full inference algorithm may repeatedly calculate successive apprimxations to the variable based on the structure of variables, factors, and incoming messages to this clique. Which clique to be used is defined by frontal variable symbols (`cliq`

in this case) – see `whichCliq(...)`

for more details. The `sym`

symbol indicates which symbol of this clique to be calculated. **Note** that the `sym`

variable must appear in the clique where `cliq`

is a frontal variable.

`IncrementalInference.treeProductUp`

— Function.```
treeProductUp(fg, tree, cliq, sym; N, dbg)
```

Calculate a fresh (single step) approximation to the variable `sym`

in clique `cliq`

as though during the upward message passing. The full inference algorithm may repeatedly calculate successive apprimxations to the variables based on the structure of the clique, factors, and incoming messages. Which clique to be used is defined by frontal variable symbols (`cliq`

in this case) – see `whichCliq(...)`

for more details. The `sym`

symbol indicates which symbol of this clique to be calculated. **Note** that the `sym`

variable must appear in the clique where `cliq`

is a frontal variable.

`IncrementalInference.unfreezeVariablesAll!`

— Function.Free all variables from marginalization.

Related

dontMarginalizeVariablesAll!

Free all variables from marginalization.

`IncrementalInference.updateFGBT!`

— Function.```
updateFGBT!(fg, bt, cliqID, drt; dbg, fillcolor, logger)
```

Update cliq `cliqID`

in Bayes (Juction) tree `bt`

according to contents of `ddt`

– intended use is to update main clique after a downward belief propagation computation has been completed per clique.

```
updateFGBT!(fg, cliq, urt; dbg, fillcolor, logger)
```

Update cliq `cliqID`

in Bayes (Juction) tree `bt`

according to contents of `urt`

– intended use is to update main clique after a upward belief propagation computation has been completed per clique.

```
updateTreeCliquesAsMarginalizedFromVars!(fgl, tree)
```

Run through entire tree and set cliques as marginalized if all clique variables are marginalized.

Notes:

- TODO can be made fully parallel, consider converting for use with
`@threads`

`for`

.

`IncrementalInference.upGibbsCliqueDensity`

— Function.```
upGibbsCliqueDensity(inp)
upGibbsCliqueDensity(inp, N)
upGibbsCliqueDensity(inp, N, dbg)
upGibbsCliqueDensity(inp, N, dbg, iters)
upGibbsCliqueDensity(inp, N, dbg, iters, logger)
```

Perform computations required for the upward message passing during belief propation on the Bayes (Junction) tree. This function is usually called as via remote_call for multiprocess dispatch.

Example

```
inp = ExploreTreeType(fg,tree,cliq,parent,childmsgs)
urt = upGibbsCliqueDensity(inp)
```

`fg`

factor graph,`tree`

Bayes tree,`cliq`

which cliq to perform the computation on,`parent`

the parent clique to where the upward message will be sent,`childmsgs`

is for any incoming messages from child cliques.

`IncrementalInference.upMsg`

— Function.```
upMsg(cliq)
```

Return the last up message stored in `cliq`

of Bayes (Junction) tree.

`IncrementalInference.wipeBuildNewTree!`

— Function.Build a completely new Bayes (Junction) tree, after first wiping clean all temporary state in fg from a possibly pre-existing tree.

Related:

buildTreeFromOrdering!

`IncrementalInference.writeGraphPdf`

— Function.Draw and show the factor graph `<:AbstractDFG`

via system graphviz and pdf app.

Notes

- Should not be calling outside programs.
- Need long term solution
- DFG's
`toDotFile`

a better solution – view with`xdot`

application. - also try
`engine={"sfdp","fdp","dot","twopi","circo","neato"}`

Future:

- Might be kept with different call strategy since this function so VERY useful!
- Major issue that this function calls an external program such as "evince", which should be under user control only.
- Maybe solution is
`toDot(fg,file=...); @async run(`xdot file.dot`)`

, or`toDot(fg,file=...); exportPdf(...); @async run(`evince ...pdf`)`

.

```
resetVariableAllInitializations!(fgl)
```

Reset initialization flag on all variables in `::FactorGraphs`

.

Notes

- Numerical values remain, but inference will overwrite since init flags are now
`false`

.

<!– lsfPriors –>