diff --git a/Project.toml b/Project.toml index d2e8c101..92ebaf16 100644 --- a/Project.toml +++ b/Project.toml @@ -75,11 +75,13 @@ Test = "1.10" TimeZones = "1.3.1" UUIDs = "1.10" julia = "1.10" +LieGroups = "0.1" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" GraphMakie = "1ecd5474-83a3-4783-bb4f-06765db800d2" +LieGroups = "6774de46-80ba-43f8-ba42-e41071ccfc5f" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" @@ -87,4 +89,4 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Aqua", "Test", "DataStructures", "GraphMakie", "LinearAlgebra", "Manifolds", "Pkg", "Statistics"] +test = ["Aqua", "Test", "DataStructures", "GraphMakie", "LinearAlgebra", "Manifolds", "Pkg", "Statistics", "LieGroups"] diff --git a/src/DataBlobs/entities/BlobStores.jl b/src/DataBlobs/entities/BlobStores.jl index 5d20c358..b6769f55 100644 --- a/src/DataBlobs/entities/BlobStores.jl +++ b/src/DataBlobs/entities/BlobStores.jl @@ -29,3 +29,4 @@ Design goal: all `Blobstore`s with the same `label` can contain the same `blobId """ abstract type AbstractBlobstore{T} end +const Blobstore = AbstractBlobstore diff --git a/src/DataBlobs/services/BlobEntry.jl b/src/DataBlobs/services/BlobEntry.jl index 21e10c20..c6935c19 100644 --- a/src/DataBlobs/services/BlobEntry.jl +++ b/src/DataBlobs/services/BlobEntry.jl @@ -1,14 +1,3 @@ - -##============================================================================== -## Blobentry - compare -##============================================================================== - -import Base: == - -@generated function ==(x::T, y::T) where {T <: Blobentry} - return mapreduce(n -> :(x.$n == y.$n), (a, b) -> :($a && $b), fieldnames(x)) -end - ##============================================================================== ## Blobentry - common ##============================================================================== @@ -85,49 +74,26 @@ Finds and returns the first blob entry that matches the filter. Also see: [`getBlobentry`](@ref) """ -function getfirstBlobentry(var::AbstractGraphVariable, blobId::UUID) - for (k, v) in var.dataDict - if blobId == v.blobId - return v - end - end - throw(KeyError("No blobEntry with blobId $(blobId) found in variable $(getLabel(var))")) -end - -function getfirstBlobentry(dfg::AbstractDFG, label::Symbol, blobId::UUID) - return getfirstBlobentry(getVariable(dfg, label), blobId) -end - -function getfirstBlobentry(var::AbstractGraphVariable, key::Regex) - for (k, v) in var.dataDict - if occursin(key, string(v.label)) - return v - end - end - throw( - KeyError( - "No blobEntry with label matching regex $(key) found in variable $(getLabel(var))", - ), - ) -end - -function getfirstBlobentry(var::VariableDFG, key::Regex) - firstIdx = findfirst(x -> contains(string(x.label), key), var.blobEntries) - if isnothing(firstIdx) - throw(KeyError("$key")) +function getfirstBlobentry( + v::AbstractGraphVariable; + labelFilter::Union{Nothing, Function} = nothing, + blobIdFilter::Union{Nothing, Function} = nothing, +) + entries = getBlobentries(v; labelFilter, blobIdFilter) + if isempty(entries) + return nothing + else + return entries[1] end - return var.blobEntries[firstIdx] end -function getfirstBlobentry(dfg::AbstractDFG, label::Symbol, key::Regex) - els = listBlobentries(dfg, label) - firstIdx = findfirst(contains(key), string.(els)) - isnothing(firstIdx) && throw( - KeyError( - "No blobEntry with label matching regex $(key) found in variable $(label)", - ), - ) - return getBlobentry(dfg, label, els[firstIdx]) +function getfirstBlobentry( + dfg::AbstractDFG, + label::Symbol; + labelFilter::Union{Nothing, Function} = nothing, + blobIdFilter::Union{Nothing, Function} = nothing, +) + return getfirstBlobentry(getVariable(dfg, label); labelFilter, blobIdFilter) end # TODO Consider autogenerating all methods of the form: @@ -140,22 +106,18 @@ end # @eval DistributedFactorGraphs $met(dfg::AbstractDFG, label::Symbol, args...; kwargs...) = $met(getVariable(dfg, label), args...; kwargs...) # end -function getBlobentry(dfg::AbstractDFG, label::Symbol, key::Symbol) - return getBlobentry(getVariable(dfg, label), key) +function getBlobentry(dfg::AbstractDFG, varLabel::Symbol, label::Symbol) + return getBlobentry(getVariable(dfg, varLabel), label) end -# getBlobentry(dfg::AbstractDFG, label::Symbol, key::Symbol) = getBlobentry(getVariable(dfg, label), key) """ $(SIGNATURES) -Add Data Entry to a DFG variable +Add a `Blobentry` to a variable Should be extended if DFG variable is not returned by reference. -Also see: [`getBlobentry`](@ref), [`addBlob!`](@ref), [`mergeBlobentries!`](@ref) +Also see: [`getBlobentry`](@ref), [`addBlob!`](@ref), [`mergeBlobentry!`](@ref) """ -function addBlobentry!(var::AbstractGraphVariable, entry::Blobentry) - # see https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/985 - # blobId::Union{UUID,Nothing} = (isnothing(entry.blobId) ? entry.id : entry.blobId), - # blobSize::Int = (hasfield(Blobentry, :size) ? entry.size : -1) +function addBlobentry!(var::VariableCompute, entry::Blobentry) haskey(var.dataDict, entry.label) && throw(LabelExistsError("Blobentry", entry.label)) var.dataDict[entry.label] = entry return entry @@ -197,37 +159,28 @@ end """ $(SIGNATURES) -Delete a blob entry from the factor graph. -Note this doesn't remove it from any data stores. +Delete a `Blobentry` from the factor graph variable. Notes: -- users responsibility to delete data in db before deleting entry +- This doesn't remove the associated `Blob` from any Blobstores. """ -function deleteBlobentry!(var::AbstractGraphVariable, key::Symbol) - pop!(var.dataDict, key) +function deleteBlobentry!(var::VariableCompute, key::Symbol) + !hasBlobentry(var, key) && throw(LabelNotFoundError("Blobentry", key)) + delete!(var.dataDict, key) return 1 end function deleteBlobentry!(var::VariableDFG, key::Symbol) - if !hasBlobentry(var, key) - throw( - KeyError( - "No dataEntry label $(key) found in variable $(getLabel(var)). Available keys: $(keys(var.dataDict))", - ), - ) - end + !hasBlobentry(var, key) && throw(LabelNotFoundError("Blobentry", key)) deleteat!(var.blobEntries, findfirst(x -> x.label == key, var.blobEntries)) return 1 end function deleteBlobentry!(dfg::AbstractDFG, label::Symbol, key::Symbol) - #users responsibility to delete data in db before deleting entry - # !isVariable(dfg, label) && return nothing return deleteBlobentry!(getVariable(dfg, label), key) end function deleteBlobentry!(var::AbstractGraphVariable, entry::Blobentry) - #users responsibility to delete data in db before deleting entry return deleteBlobentry!(var, entry.label) end @@ -240,73 +193,66 @@ end Does a blob entry exist with `blobLabel`. """ -hasBlobentry(var::AbstractGraphVariable, blobLabel::Symbol) = - haskey(var.dataDict, blobLabel) +hasBlobentry(v::VariableCompute, blobLabel::Symbol) = haskey(v.dataDict, blobLabel) -function hasBlobentry(var::VariableDFG, label::Symbol) - return label in getproperty.(var.blobEntries, :label) +function hasBlobentry(v::VariableDFG, label::Symbol) + return label in getproperty.(v.blobEntries, :label) end """ $(SIGNATURES) -Get blob entries, Vector{Blobentry} +Get blob entries, returns a `Vector{Blobentry}`. """ -function getBlobentries(var::AbstractGraphVariable) - #or should we return the iterator, Base.ValueIterator{Dict{Symbol,Blobentry}}? - return collect(values(var.dataDict)) +function getBlobentries(v::VariableCompute) + return collect(values(v.dataDict)) end -function getBlobentries(var::VariableDFG) - return var.blobEntries +function getBlobentries(v::VariableDFG) + return copy(v.blobEntries) end -function getBlobentries(dfg::AbstractDFG, label::Symbol) - # !isVariable(dfg, label) && return nothing - #or should we return the iterator, Base.ValueIterator{Dict{Symbol,Blobentry}}? - return getBlobentries(getVariable(dfg, label)) -end - -function getBlobentries(dfg::AbstractDFG, label::Symbol, regex::Regex) - entries = getBlobentries(dfg, label) - return filter(entries) do e - return occursin(regex, string(e.label)) - end +function getBlobentries( + v::AbstractGraphVariable; + labelFilter::Union{Nothing, Function} = nothing, + blobIdFilter::Union{Nothing, Function} = nothing, +) + entries = getBlobentries(v) + filterDFG!(entries, labelFilter, x -> string(x.label)) + filterDFG!(entries, blobIdFilter, x -> string(x.blobId)) + return entries end function getBlobentries( dfg::AbstractDFG, - label::Symbol, - skey::Union{Symbol, <:AbstractString}, + variableLabel::Symbol; + labelFilter::Union{Nothing, Function} = nothing, + blobIdFilter::Union{Nothing, Function} = nothing, ) - return getBlobentries(dfg, label, Regex(string(skey))) + return getBlobentries(getVariable(dfg, variableLabel); labelFilter, blobIdFilter) end -""" - $(SIGNATURES) - -Get all blob entries matching a Regex pattern over variables - -Notes -- Use `dropEmpties=true` to not include empty lists in result. -- Use keyword `varList` for which variables to search through. -""" -function getBlobentriesVariables( - dfg::AbstractDFG, - bLblPattern::Regex; - varList::AbstractVector{Symbol} = sort(listVariables(dfg); lt = natural_lt), - dropEmpties::Bool = false, +function gatherBlobentries( + dfg::AbstractDFG; + labelFilter::Union{Nothing, Function} = nothing, + blobIdFilter::Union{Nothing, Function} = nothing, + solvableFilter::Union{Nothing, Function} = nothing, + tagsFilter::Union{Nothing, Function} = nothing, + typeFilter::Union{Nothing, Function} = nothing, + variableLabelFilter::Union{Nothing, Function} = nothing, ) - RETLIST = Vector{Vector{Blobentry}}() - @showprogress "Get entries matching $bLblPattern" for vl in varList - bes = filter(s -> occursin(bLblPattern, string(s.label)), listBlobentries(dfg, vl)) - # only push to list if there are entries on this variable - (!dropEmpties || 0 < length(bes)) ? nothing : continue - push!(RETLIST, bes) + vls = listVariables( + dfg; + solvableFilter, + tagsFilter, + typeFilter, + labelFilter = variableLabelFilter, + ) + return map(vls) do vl + return vl => getBlobentries(dfg, vl; labelFilter, blobIdFilter) end - - return RETLIST end +const collectBlobentries = gatherBlobentries """ $(SIGNATURES) @@ -321,7 +267,6 @@ function listBlobentries(var::VariableDFG) end function listBlobentries(dfg::AbstractDFG, label::Symbol) - # !isVariable(dfg, label) && return nothing return listBlobentries(getVariable(dfg, label)) end @@ -357,66 +302,6 @@ function listBlobentrySequence( return ents_[findall(entMsk)] |> _sort end -""" - $SIGNATURES - -Add a blob entry into the destination variable which already exists -in a source variable. - -See also: [`addBlobentry!`](@ref), [`getBlobentry`](@ref), [`listBlobentries`](@ref), [`getBlob`](@ref) -""" -function mergeBlobentries!( - dst::AbstractDFG, - dlbl::Symbol, - src::AbstractDFG, - slbl::Symbol, - bllb::Union{Symbol, UUID, <:AbstractString, Regex}, -) - # - _makevec(s) = [s;] - _makevec(s::AbstractVector) = s - des_ = getBlobentry(src, slbl, bllb) - des = _makevec(des_) - # don't add data entries that already exist - dde = listBlobentries(dst, dlbl) - # HACK, verb list should just return vector of Symbol. NCE36 - _getid(s) = s - _getid(s::Blobentry) = s.id - uids = _getid.(dde) # (s->s.id).(dde) - filter!(s -> !(_getid(s) in uids), des) - # add any data entries not already in the destination variable, by uuid - return addBlobentry!.(dst, dlbl, des) -end - -function mergeBlobentries!( - dst::AbstractDFG, - dlbl::Symbol, - src::AbstractDFG, - slbl::Symbol, - ::Colon = :, -) - des = listBlobentries(src, slbl) - # don't add data entries that already exist - uids = listBlobentries(dst, dlbl) - # verb list should just return vector of Symbol. NCE36 - filter!(s -> !(s in uids), des) - if 0 < length(des) - union(((s -> mergeBlobentries!(dst, dlbl, src, slbl, s)).(des))...) - end -end - -function mergeBlobentries!( - dest::AbstractDFG, - src::AbstractDFG, - w...; - varList::AbstractVector = listVariables(dest) |> sortDFG, -) - @showprogress 1 "merging data entries" for vl in varList - mergeBlobentries!(dest, vl, src, vl, w...) - end - return varList -end - """ $SIGNATURES diff --git a/src/DataBlobs/services/BlobStores.jl b/src/DataBlobs/services/BlobStores.jl index 078cda66..7122f5f5 100644 --- a/src/DataBlobs/services/BlobStores.jl +++ b/src/DataBlobs/services/BlobStores.jl @@ -275,10 +275,6 @@ function getBlob(store::LinkStore, blobId::UUID) return read(fname) end -function addBlob!(store::LinkStore, entry::Blobentry, linkfile::String) - return addBlob!(store, entry.blobId, linkfile) -end - function addBlob!(store::LinkStore, blobId::UUID, linkfile::String) if haskey(store.cache, blobId) throw(IdExistsError("Blob", blobId)) diff --git a/src/Deprecated.jl b/src/Deprecated.jl index 1f5e78bf..48d00c89 100644 --- a/src/Deprecated.jl +++ b/src/Deprecated.jl @@ -11,9 +11,9 @@ export AbstractRelativeMinimize, #TODO: maybe just remove these export NoSolverParams - const AbstractPrior = PriorObservation const AbstractRelative = RelativeObservation +export AbstractParams const AbstractParams = AbstractDFGParams abstract type AbstractRelativeMinimize <: RelativeObservation end @@ -209,6 +209,151 @@ function listSolveKeys( end const listSupersolves = listSolveKeys +#TODO mergeBlobentries! does not fit with merge definition, should probably be updated to copyto or sync. +# leaving here until it is done. + +# """ +# $SIGNATURES + +# Add a blob entry into the destination variable which already exists +# in a source variable. + +# See also: [`addBlobentry!`](@ref), [`getBlobentry`](@ref), [`listBlobentries`](@ref), [`getBlob`](@ref) +# """ +function mergeBlobentries!( + dst::AbstractDFG, + dlbl::Symbol, + src::AbstractDFG, + slbl::Symbol, + bllb::Union{Symbol, UUID, <:AbstractString, Regex}, +) + # + _makevec(s) = [s;] + _makevec(s::AbstractVector) = s + des_ = getBlobentry(src, slbl, bllb) + des = _makevec(des_) + # don't add data entries that already exist + dde = listBlobentries(dst, dlbl) + # HACK, verb list should just return vector of Symbol. NCE36 + _getid(s) = s + _getid(s::Blobentry) = s.id + uids = _getid.(dde) # (s->s.id).(dde) + filter!(s -> !(_getid(s) in uids), des) + # add any data entries not already in the destination variable, by uuid + return addBlobentry!.(dst, dlbl, des) +end + +function mergeBlobentries!( + dst::AbstractDFG, + dlbl::Symbol, + src::AbstractDFG, + slbl::Symbol, + ::Colon = :, +) + des = listBlobentries(src, slbl) + # don't add data entries that already exist + uids = listBlobentries(dst, dlbl) + # verb list should just return vector of Symbol. NCE36 + filter!(s -> !(s in uids), des) + if 0 < length(des) + union(((s -> mergeBlobentries!(dst, dlbl, src, slbl, s)).(des))...) + end +end + +function mergeBlobentries!( + dest::AbstractDFG, + src::AbstractDFG, + w...; + varList::AbstractVector = listVariables(dest) |> sortDFG, +) + @showprogress 1 "merging data entries" for vl in varList + mergeBlobentries!(dest, vl, src, vl, w...) + end + return varList +end + +# """ +# $(SIGNATURES) + +# Get all blob entries matching a Regex pattern over variables + +# Notes +# - Use `dropEmpties=true` to not include empty lists in result. +# - Use keyword `varList` for which variables to search through. +# """ +function getBlobentriesVariables( + dfg::AbstractDFG, + bLblPattern::Regex; + varList::AbstractVector{Symbol} = sort(listVariables(dfg); lt = natural_lt), + dropEmpties::Bool = false, +) + Base.depwarn( + "getBlobentriesVariables is deprecated, use gatherBlobentries instead.", + :getBlobentriesVariables, + ) + RETLIST = Vector{Vector{Blobentry}}() + @showprogress "Get entries matching $bLblPattern" for vl in varList + bes = filter(s -> occursin(bLblPattern, string(s.label)), listBlobentries(dfg, vl)) + # only push to list if there are entries on this variable + (!dropEmpties || 0 < length(bes)) ? nothing : continue + push!(RETLIST, bes) + end + + return RETLIST +end + +function getBlobentries(dfg::AbstractDFG, label::Symbol, regex::Regex) + Base.depwarn( + "getBlobentries(dfg, label, ::Regex) is deprecated, use getBlobentries(dfg, label; labelFilter=contains(regex)) instead.", + :getBlobentries, + ) + return entries = getBlobentries(dfg, label; labelFilter = contains(regex)) +end + +function getBlobentries( + dfg::AbstractDFG, + label::Symbol, + skey::Union{Symbol, <:AbstractString}, +) + Base.depwarn( + "getBlobentries(dfg, label, ::Union{Symbol, <:AbstractString}) is deprecated, use getBlobentries(dfg, label; labelFilter=contains(regex)) instead.", + :getBlobentries, + ) + return getBlobentries(dfg, label, Regex(string(skey))) +end + +function getfirstBlobentry(var::AbstractGraphVariable, blobId::UUID) + Base.depwarn( + "getfirstBlobentry(var, blobId) is deprecated, use getfirstBlobentry(var; blobIdFilter = ==(string(blobId))) instead.", + :getfirstBlobentry, + ) + return getfirstBlobentry(var; blobIdFilter = ==(string(blobId))) +end + +function getfirstBlobentry(dfg::AbstractDFG, label::Symbol, blobId::UUID) + Base.depwarn( + "getfirstBlobentry(dfg, label, blobId) is deprecated, use getfirstBlobentry(dfg, label; blobIdFilter = ==(string(blobId))) instead.", + :getfirstBlobentry, + ) + return getfirstBlobentry(dfg, label; blobIdFilter = ==(string(blobId))) +end + +function getfirstBlobentry(var::AbstractGraphVariable, key::Regex) + Base.depwarn( + "getfirstBlobentry(var, key::Regex) is deprecated, use getfirstBlobentry(var; labelFilter=contains(key)) instead.", + :getfirstBlobentry, + ) + return getfirstBlobentry(var; labelFilter = contains(key)) +end + +function getfirstBlobentry(dfg::AbstractDFG, label::Symbol, key::Regex) + Base.depwarn( + "getfirstBlobentry(dfg, label, key::Regex) is deprecated, use getfirstBlobentry(dfg, label; labelFilter=contains(key)) instead.", + :getfirstBlobentry, + ) + return getfirstBlobentry(dfg, label; labelFilter = contains(key)) +end + ## ================================================================================ ## Deprecated in v0.27 ##================================================================================= diff --git a/src/DistributedFactorGraphs.jl b/src/DistributedFactorGraphs.jl index b73e8699..f51e9c46 100644 --- a/src/DistributedFactorGraphs.jl +++ b/src/DistributedFactorGraphs.jl @@ -54,14 +54,46 @@ using InteractiveUtils: subtypes ##============================================================================== # Exports ##============================================================================== +## Abstract types and their aliases +export AbstractDFG +export AbstractDFGParams, DFGParams +export AbstractBlobstore, Blobstore +export AbstractGraphNode, GraphNode +export AbstractGraphVariable, GraphVariable +export AbstractGraphFactor, GraphFactor +export AbstractPackedObservation, PackedObservation +export AbstractObservation, Observation +export AbstractPriorObservation, PriorObservation +export AbstractRelativeObservation, RelativeObservation +export AbstractFactorCache, FactorCache +export AbstractStateType, StateType +export AbstractPackedBelief, PackedBelief + +## types +# Variables +export VariableCompute, VariableDFG, VariableSummary, VariableSkeleton +# Factors +export FactorCompute, FactorDFG, FactorSummary, FactorSkeleton # v1 name, signiture, return, and error checked -export getFactor, getBlobentry, getGraphBlobentry +export addVariable!, mergeVariable!, deleteVariable! +export addVariables!, getVariables +export addFactor!, getFactor, deleteFactor! +export addFactors!, getFactors -export addVariable!, addFactor!, addBlobentry! +export addState!, getState, mergeState!, deleteState! +export addStates!, mergeStates!, deleteStates! -export deleteVariable! +export addBlobentry!, getBlobentry, mergeBlobentry!, deleteBlobentry! +export addBlobentries! +## list +export listVariables, listFactors, listStates + +## +export getGraphBlobentry + +export getObservation # v1 name, signiture, and return # v1 name only @@ -87,7 +119,7 @@ export DFG export GraphsDFGs, GraphsDFG ## -export getState, getFactorState # FIXME these were questioned and being reviewed again for name, other than that they are checked. +export getFactorState # FIXME getFactorState were questioned and being reviewed again for name, other than that they are checked. ## CRUD Matrix # export addVariable!, getVariable, mergeVariable!, deleteVariable! @@ -95,11 +127,12 @@ export getState, getFactorState # FIXME these were questioned and being reviewed # export addFactor!, getFactor, mergeFactor!, deleteFactor! # export addFactors!, getFactors, mergeFactors!, deleteFactors! -# export addState!, getState, mergeState!, deleteState! -# export addStates!, getStates, mergeStates!, deleteStates! +# export addState!, getState, mergeState!, deleteState! +# export addStates!, getStates, mergeStates!, deleteStates! # export addBlobentry!, getBlobentry, mergeBlobentry!, deleteBlobentry! # historic for VariableBlobentry # export addBlobentries!, getBlobentries, mergeBlobentries!, deleteBlobentries! +# TODO first pass progress # export addGraphBlobentry!, getGraphBlobentry, mergeGraphBlobentry!, deleteGraphBlobentry! # export addGraphBlobentries!, getGraphBlobentries, mergeGraphBlobentries!, deleteGraphBlobentries! # export addAgentBlobentry!, getAgentBlobentry, mergeAgentBlobentry!, deleteAgentBlobentry! @@ -119,22 +152,10 @@ export getState, getFactorState # FIXME these were questioned and being reviewed ## list # export listVariables, listFactors, listStates, listBlobentries, listFactorBlobEntries, listGraphBlobentries, listAgentBlobentries +# not implemented yet (maybe not for DFG v1.0 yet): # export listVariableMetadata, listFactorMetadata, listAgentMetadata, listGraphMetadata # export listVariableBlobentryMetadata, listFactorBlobentryMetadata, listAgentBlobentryMetadata, listGraphBlobentryMetadata -##------------------------------------------------------------------------------ -## Abstract types -##------------------------------------------------------------------------------ - -export AbstractObservation, AbstractPackedObservation -export PriorObservation, RelativeObservation -export FactorCache - -#TODO -export PackedBelief - -# public AbstractGraphVariable, AbstractGraphFactor - ##============================================================================== ## Internal or not yet ready ##============================================================================== @@ -142,12 +163,6 @@ export PackedBelief ##------------------------------------------------------------------------------ ## DFG ##------------------------------------------------------------------------------ -export AbstractDFGParams, DFGParams - -# Abstract Nodes -export AbstractGraphNode -export AbstractDFG -export AbstractBlobstore # accessors & crud export getDescription, @@ -187,21 +202,7 @@ export getBlobstore, export InMemoryDFGTypes, LocalDFG # AbstractDFG Interface -export exists, - addVariables!, - addFactors!, - mergeVariable!, - mergeFactor!, - deleteVariable!, - deleteFactor!, - listVariables, - listFactors, - getVariables, - getFactors, - isVariable, - isFactor - -export getindex +export exists, mergeFactor!, isVariable, isFactor export isConnected @@ -209,12 +210,6 @@ export getBiadjacencyMatrix export getSummaryGraph -# Variables -export VariableCompute, VariableSummary, VariableSkeleton, VariableDFG - -# Factors -export FactorCompute, FactorSummary, FactorSkeleton, FactorDFG - # Common export getSolvable, setSolvable!, isSolvable export getVariableLabelNumber @@ -234,15 +229,10 @@ export removeTags! #TODO do we want this one ##------------------------------------------------------------------------------ # Variable ##------------------------------------------------------------------------------ -# Abstract Variable Data -export StateType - # accessors export getSolverDataDict export getVariableType, getVariableTypeName -export getObservation - export getVariableType # VariableType functions @@ -260,7 +250,7 @@ export getMetadata, emptyMetadata! # CRUD & SET -export getStates, addState!, mergeState!, deleteState!, listStates +export getStates # PPE ##------------------------------------------------------------------------------ @@ -294,13 +284,7 @@ export copyGraph!, deepcopyGraph, deepcopyGraph!, buildSubgraph, mergeGraph! ##------------------------------------------------------------------------------ export hasBlobentry, - getfirstBlobentry, - addBlobentry!, - addBlobentries!, - mergeBlobentry!, - deleteBlobentry!, - listBlobentrySequence, - mergeBlobentries! + getfirstBlobentry, addBlobentries!, listBlobentrySequence, mergeBlobentries! export incrDataLabelSuffix export getBlobentries diff --git a/src/GraphsDFG/services/GraphsDFG.jl b/src/GraphsDFG/services/GraphsDFG.jl index 6d01ab1b..fb1e20d5 100644 --- a/src/GraphsDFG/services/GraphsDFG.jl +++ b/src/GraphsDFG/services/GraphsDFG.jl @@ -91,7 +91,7 @@ function mergeVariable!(dfg::GraphsDFG, variable::AbstractGraphVariable) return 1 end -function mergeFactor!(dfg::GraphsDFG, factor::AbstractGraphFactor;) +function mergeFactor!(dfg::GraphsDFG, factor::AbstractGraphFactor) if !haskey(dfg.g.factors, factor.label) addFactor!(dfg, factor) elseif dfg.g.factors[factor.label]._variableOrderSymbols != factor._variableOrderSymbols @@ -120,7 +120,7 @@ function deleteVariable!(dfg::GraphsDFG, label::Symbol)#::Tuple{AbstractGraphVar return sum(del_facs) + 1 end -function deleteFactor!(dfg::GraphsDFG, label::Symbol; suppressGetFactor::Bool = false) +function deleteFactor!(dfg::GraphsDFG, label::Symbol) if !haskey(dfg.g.factors, label) throw(LabelNotFoundError("Factor", label)) end @@ -277,7 +277,7 @@ function listFactors( !isnothing(typeFilter) || !isnothing(regexFilter) || #TODO deprecated !isempty(tags) || #TODO deprecated - !isnothing(solvable) #TODO Maybe deprecated? + !isnothing(solvable) #TODO deprecated return map( getLabel, getFactors( @@ -555,22 +555,19 @@ function getGraphBlobentry(fg::GraphsDFG, label::Symbol) return fg.graph.blobEntries[label] end -function getGraphBlobentries( - fg::GraphsDFG, - filt::Union{Nothing, String, Base.Fix2} = nothing, -) - entries = collect(values(fg.graphBlobEntries)) - if !isnothing(filt) && isa(filt, String) - @warn "String filter is deprecated, use startswith(filt_string) instead" - filter!(e -> startswith(string(e.label), filt), entries) - elseif !isnothing(filt) - filter!(e -> filt(string(e.label)), entries) - end +function getGraphBlobentries(fg::GraphsDFG; labelFilter::Union{Nothing, Function} = nothing) + entries = collect(values(fg.graph.blobEntries)) + filterDFG!(entries, labelFilter, (String ∘ getLabel)) return entries end -function listGraphBlobentries(fg::GraphsDFG) - return collect(keys(fg.graphBlobEntries)) +function listGraphBlobentries( + fg::GraphsDFG; + labelFilter::Union{Nothing, Function} = nothing, +) + labels = collect(keys(fg.graph.blobEntries)) + filterDFG!(labels, labelFilter, String) + return labels end function listAgentBlobentries(fg::GraphsDFG) diff --git a/src/entities/AbstractDFG.jl b/src/entities/AbstractDFG.jl index 01256f36..0a5daa51 100644 --- a/src/entities/AbstractDFG.jl +++ b/src/entities/AbstractDFG.jl @@ -6,42 +6,42 @@ # any DFGNode shall have a label. # abstract type AbstractGraphNode end <: AbstractDFGNode # the rest of the nodes are also AbstractDFGNodes, eg. -# Agent <: AbstractGraphNode -# FactorgraphRoot <: AbstractGraphNode +# Agent <: AbstractDFGNode +# FactorgraphRoot <: AbstractDFGNode """ $(TYPEDEF) Abstract parent struct for DFG variables and factors. """ -abstract type AbstractGraphNode end #✅ +abstract type AbstractGraphNode end const GraphNode = AbstractGraphNode """ $(TYPEDEF) An abstract DFG variable. """ -abstract type AbstractGraphVariable <: AbstractGraphNode end #✅ +abstract type AbstractGraphVariable <: AbstractGraphNode end const GraphVariable = AbstractGraphVariable """ $(TYPEDEF) An abstract DFG factor. """ -abstract type AbstractGraphFactor <: AbstractGraphNode end #✅ +abstract type AbstractGraphFactor <: AbstractGraphNode end const GraphFactor = AbstractGraphFactor """ $(TYPEDEF) Abstract parent struct for a DFG graph. """ -abstract type AbstractDFG{V <: AbstractGraphVariable, F <: AbstractGraphFactor} end #✅ +abstract type AbstractDFG{V <: AbstractGraphVariable, F <: AbstractGraphFactor} end #const DFG clashes with module DFG. """ $(TYPEDEF) Abstract parent struct for solver parameters. """ -abstract type AbstractDFGParams end #✅ +abstract type AbstractDFGParams end const DFGParams = AbstractDFGParams """ diff --git a/src/entities/DFGFactor.jl b/src/entities/DFGFactor.jl index 857b6465..4bb25c3e 100644 --- a/src/entities/DFGFactor.jl +++ b/src/entities/DFGFactor.jl @@ -2,24 +2,24 @@ ## Abstract Types ##============================================================================== -abstract type AbstractPackedObservation end #✅ +abstract type AbstractPackedObservation end const PackedObservation = AbstractPackedObservation -abstract type AbstractObservation end #✅ +abstract type AbstractObservation end const Observation = AbstractObservation -abstract type AbstractPriorObservation <: AbstractObservation end #✅ +abstract type AbstractPriorObservation <: AbstractObservation end const PriorObservation = AbstractPriorObservation -abstract type AbstractRelativeObservation <: AbstractObservation end #✅ +abstract type AbstractRelativeObservation <: AbstractObservation end const RelativeObservation = AbstractRelativeObservation -abstract type AbstractPackedBelief end #✅ +abstract type AbstractPackedBelief end const PackedBelief = AbstractPackedBelief # TODO https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/pull/1127#discussion_r2154672975 # and #1138 -abstract type AbstractFactorCache end #✅ +abstract type AbstractFactorCache end const FactorCache = AbstractFactorCache # ##============================================================================== diff --git a/src/entities/DFGVariable.jl b/src/entities/DFGVariable.jl index ba316bfb..4c0f3dec 100644 --- a/src/entities/DFGVariable.jl +++ b/src/entities/DFGVariable.jl @@ -131,6 +131,10 @@ Base.@kwdef mutable struct PackedState covar::Vector{Float64} _version::VersionNumber = _getDFGVersion() end + +#FIXME remove once solveKey field is renamed to `label` +getLabel(packedstate::PackedState) = packedstate.solveKey + # maybe add # createdTimestamp::DateTime#! # lastUpdatedTimestamp::DateTime#! diff --git a/src/services/AbstractDFG.jl b/src/services/AbstractDFG.jl index 0715f0e1..7e6082a1 100644 --- a/src/services/AbstractDFG.jl +++ b/src/services/AbstractDFG.jl @@ -380,7 +380,7 @@ function mergeFactor! end """ $(SIGNATURES) -Delete a VariableCompute from the DFG using its label. +Delete a VariableCompute from the DFG. Implement `deleteVariable!(dfg::AbstractDFG, label::Symbol)` """ function deleteVariable! end @@ -504,27 +504,16 @@ function getVariable(dfg::AbstractDFG, label::Symbol, solveKey::Symbol) return var end -""" - $(SIGNATURES) -Delete a referenced VariableCompute from the DFG. - -Notes -- Returns `Tuple{AbstractGraphVariable, Vector{<:AbstractGraphFactor}}` -""" function deleteVariable!(dfg::AbstractDFG, variable::AbstractGraphVariable) return deleteVariable!(dfg, variable.label) end """ $(SIGNATURES) -Delete the referened FactorCompute from the DFG. -""" -function deleteFactor!( - dfg::G, - factor::F; - suppressGetFactor::Bool = false, -) where {G <: AbstractDFG, F <: AbstractGraphFactor} - return deleteFactor!(dfg, factor.label; suppressGetFactor = suppressGetFactor) +Delete the referenced Factor from the DFG. +""" +function deleteFactor!(dfg::AbstractDFG, factor::AbstractGraphFactor) + return deleteFactor!(dfg, factor.label) end # rather use isa in code, but ok, here it is @@ -711,7 +700,7 @@ Notes: - Returns `Vector{Symbol}` """ function lsfPriors(dfg::AbstractDFG) - return listFactors(dfg; typeFilter = x -> x <: AbstractPriorObservation) + return listFactors(dfg; typeFilter = isPrior) end ## Listing DataTypes in a DFG diff --git a/src/services/CompareUtils.jl b/src/services/CompareUtils.jl index 5e3c6bc5..e2ee8768 100644 --- a/src/services/CompareUtils.jl +++ b/src/services/CompareUtils.jl @@ -21,6 +21,7 @@ const GeneratedCompareUnion = Union{ MeanMaxPPE, State, PackedState, + Blobentry, VariableCompute, VariableDFG, VariableSummary, diff --git a/src/services/DFGFactor.jl b/src/services/DFGFactor.jl index f0c59bfc..81af2009 100644 --- a/src/services/DFGFactor.jl +++ b/src/services/DFGFactor.jl @@ -268,18 +268,16 @@ getVariableOrder(dfg::AbstractDFG, fct::Symbol) = getVariableOrder(getFactor(dfg Return `::Bool` on whether given factor `fc::Symbol` is a prior in factor graph `dfg`. """ -function isPrior(dfg::AbstractDFG, fc::Symbol) - fco = getFactor(dfg, fc) - return isPrior(getFactorType(fco)) +function isPrior(::Type{T}) where {T <: AbstractObservation} + return T <: AbstractPriorObservation end -function isPrior(::PriorObservation) - return true +function isPrior(::T) where {T <: AbstractObservation} + return isPrior(T) end -function isPrior(::RelativeObservation) - return false -end +isPrior(f::AbstractGraphFactor) = isPrior(getObservation(f)) +isPrior(dfg::AbstractDFG, fl::Symbol) = isPrior(getFactor(dfg, fl)) ##============================================================================== ## Layer 2 CRUD (none) and Sets diff --git a/src/services/DFGVariable.jl b/src/services/DFGVariable.jl index fe186c4f..384da1a9 100644 --- a/src/services/DFGVariable.jl +++ b/src/services/DFGVariable.jl @@ -78,7 +78,7 @@ getVariableType(dfg::AbstractDFG, lbl::Symbol) = getVariableType(getVariable(dfg # getManifolds(::T) where {T <: ManifoldsBase.AbstractManifold} = getManifolds(T) """ - @defVarstateType StructName manifold point_identity + @defStateType StructName manifold point_identity A macro to create a new variable type with name `StructName` associated with a given manifold and identity point. @@ -95,7 +95,7 @@ Example: DFG.@defVariable Pose2 SpecialEuclidean(2) ArrayPartition([0;0.0],[1 0; 0 1.0]) ``` """ -macro defVarstateType(structname, manifold, point_identity) +macro defStateType(structname, manifold, point_identity) return esc( quote Base.@__doc__ struct $structname <: StateType{Any} end @@ -117,11 +117,11 @@ macro defVarstateType(structname, manifold, point_identity) end macro defVariable(args...) - return esc(:(DFG.@defVarstateType $(args...))) + return esc(:(DFG.@defStateType $(args...))) end """ - @defVarstateTypeN StructName manifold point_identity + @defStateTypeN StructName manifold point_identity A macro to create a new variable type with name `StructName` that is parameterized by `N` and associated with a given manifold and identity point. @@ -135,10 +135,10 @@ See the [Manifolds.jl documentation on creating your own manifolds](https://juli Example: ``` -DFG.@defVarstateTypeN Pose{N} SpecialEuclidean(N) ArrayPartition(zeros(SVector{N, Float64}), SMatrix{N, N, Float64}(I)) +DFG.@defStateTypeN Pose{N} SpecialEuclidean(N) ArrayPartition(zeros(SVector{N, Float64}), SMatrix{N, N, Float64}(I)) ``` """ -macro defVarstateTypeN(structname, manifold, point_identity) +macro defStateTypeN(structname, manifold, point_identity) return esc( quote Base.@__doc__ struct $structname <: StateType{N} end @@ -532,21 +532,6 @@ Get solver data dictionary for a variable. Advised to use graph CRUD operations """ getSolverDataDict(v::VariableCompute) = v.solverDataDict -# TODO move to crud, don't know if this should exist, should rather always update with fg object to simplify inmem vs cloud -""" - $SIGNATURES - -Retrieve solver data structure stored in a variable. -""" -function getState(v::VariableCompute, label::Symbol) - vnd = if haskey(getSolverDataDict(v), label) - return getSolverDataDict(v)[label] - else - throw(LabelNotFoundError("State", label)) - end - return vnd -end - ##------------------------------------------------------------------------------ ## Variable Metadata ##------------------------------------------------------------------------------ @@ -667,14 +652,24 @@ end ## CRUD: get, add, update, delete ##------------------------------------------------------------------------------ +function getState(v::VariableCompute, label::Symbol) + !haskey(getSolverDataDict(v), label) && throw(LabelNotFoundError("State", label)) + return getSolverDataDict(v)[label] +end + +function getState(v::VariableDFG, label::Symbol) + stateidx = findfirst(==(label) ∘ getLabel, v.solverData) + isnothing(stateidx) && throw(LabelNotFoundError("State", label)) + return unpackState(v.solverData[stateidx]) +end + """ $(SIGNATURES) -Get variable solverdata for a given solve key. +Get the variable `State` for a given state label. """ function getState(dfg::AbstractDFG, variableLabel::Symbol, label::Symbol) v = getVariable(dfg, variableLabel) - !haskey(v.solverDataDict, label) && throw(LabelNotFoundError("State", label)) - return v.solverDataDict[label] + return getState(v, label) end function getStates(dfg::AbstractDFG, variableLabel::Symbol) @@ -686,16 +681,12 @@ end $(SIGNATURES) Add variable solver data, errors if it already exists. """ -function addState!(dfg::AbstractDFG, variablekey::Symbol, state::State) - var = getVariable(dfg, variablekey) - if haskey(var.solverDataDict, state.solveKey) - throw(LabelExistsError("State", state.solveKey)) - end - var.solverDataDict[state.solveKey] = state - return state +function addState!(dfg::GraphsDFG, variableLabel::Symbol, state::State) + var = getVariable(dfg, variableLabel) + return addState!(var, state) end -function addState!(v, state::State) +function addState!(v::VariableCompute, state::State) if haskey(v.solverDataDict, state.solveKey) throw(LabelExistsError("State", state.solveKey)) end @@ -703,6 +694,25 @@ function addState!(v, state::State) return state end +""" + $(SIGNATURES) +Add variable `State`s by calling `addState!`. +NOTE: If an error occurs while adding one of the states, previously added states will not be rolled back. +""" +function addStates!(dfg::AbstractDFG, variableLabel::Symbol, states::Vector{<:State}) + cnt = asyncmap(states) do state + return addState!(dfg, variableLabel, state) + end + return sum(cnt) +end + +function addStates!(dfg::AbstractDFG, varLabel_state_pairs::Vector{<:Pair{Symbol, <:State}}) + cnt = asyncmap(varLabel_state_pairs) do (varLabel, state) + return addState!(dfg, varLabel, state) + end + return sum(cnt) +end + """ $(SIGNATURES) Update the variable state if it exists, otherwise add it. @@ -711,16 +721,8 @@ Related mergeStates! """ -function mergeState!(dfg::AbstractDFG, variablekey::Symbol, vnd::State) - v = getVariable(dfg, variablekey) - - if !haskey(v.solverDataDict, vnd.solveKey) - addState!(dfg, variablekey, vnd) - else - v.solverDataDict[vnd.solveKey] = vnd - end - - return 1 +function mergeState!(dfg::GraphsDFG, variableLabel::Symbol, vnd::State) + return mergeState!(getVariable(dfg, variableLabel), vnd) end function mergeState!(v::VariableCompute, vnd::State) @@ -729,11 +731,13 @@ function mergeState!(v::VariableCompute, vnd::State) else v.solverDataDict[vnd.solveKey] = vnd end - return 1 end -function mergeStates!(dfg::AbstractDFG, varLabel_state_pairs::Vector{<:Pair{Symbol, <:State}}) +function mergeStates!( + dfg::AbstractDFG, + varLabel_state_pairs::Vector{<:Pair{Symbol, <:State}}, +) cnt = asyncmap(varLabel_state_pairs) do (varLabel, state) return mergeState!(dfg, varLabel, state) end @@ -765,24 +769,43 @@ end """ $(SIGNATURES) -Delete variable solver data, returns the number of deleted elements. +Delete the variable `State` by label, returns the number of deleted elements. """ -function deleteState!(dfg::AbstractDFG, variablekey::Symbol, solveKey::Symbol) - var = getVariable(dfg, variablekey) +function deleteState!(dfg::GraphsDFG, variableLabel::Symbol, label::Symbol) + return deleteState!(getVariable(dfg, variableLabel), label) +end - if !haskey(var.solverDataDict, solveKey) - throw(KeyError("State '$(solveKey)' does not exist")) +function deleteState!(v::VariableCompute, label::Symbol) + if !haskey(v.solverDataDict, label) + throw(LabelNotFoundError("State", label)) end - pop!(var.solverDataDict, solveKey) + delete!(v.solverDataDict, label) return 1 end +function deleteState!(dfg::AbstractDFG, sourceVariable::VariableCompute, label::Symbol) + return deleteState!(dfg, sourceVariable.label, label) +end + """ $(SIGNATURES) -Delete variable solver data, returns the number of deleted elements. +Delete the variable `State`s by label, returns the number of deleted elements. """ -function deleteState!(dfg::AbstractDFG, sourceVariable::VariableCompute, solveKey::Symbol) - return deleteState!(dfg, sourceVariable.label, solveKey) +function deleteStates!(dfg::AbstractDFG, variableLabel::Symbol, labels::Vector{Symbol}) + cnt = asyncmap(labels) do label + return deleteState!(dfg, variableLabel, label) + end + return sum(cnt) +end + +function deleteStates!( + dfg::AbstractDFG, + varLabel_stateLabel_pairs::Vector{Pair{Symbol, Symbol}}, +) + cnt = asyncmap(varLabel_stateLabel_pairs) do (varLabel, stateLabel) + return deleteState!(dfg, varLabel, stateLabel) + end + return sum(cnt) end ##------------------------------------------------------------------------------ @@ -828,6 +851,7 @@ function listStates( return labels end +#TODO deprecate PPEs ##============================================================================== ## Point Parametric Estimates ##============================================================================== @@ -850,8 +874,8 @@ function getPPE(v::VariableCompute, ppekey::Symbol = :default) !haskey(v.ppeDict, ppekey) && throw(LabelNotFoundError("PPE", ppekey)) return v.ppeDict[ppekey] end -function getPPE(dfg::AbstractDFG, variablekey::Symbol, ppekey::Symbol = :default) - return getPPE(getVariable(dfg, variablekey), ppekey) +function getPPE(dfg::AbstractDFG, variableLabel::Symbol, ppekey::Symbol = :default) + return getPPE(getVariable(dfg, variableLabel), ppekey) end # Not the most efficient call but it at least reuses above (in memory it's probably ok) function getPPE( @@ -868,10 +892,10 @@ Add variable PPE, errors if it already exists. """ function addPPE!( dfg::AbstractDFG, - variablekey::Symbol, + variableLabel::Symbol, ppe::P, ) where {P <: AbstractPointParametricEst} - var = getVariable(dfg, variablekey) + var = getVariable(dfg, variableLabel) if haskey(var.ppeDict, ppe.solveKey) throw(LabelExistsError("PPE", ppe.solveKey)) end @@ -909,11 +933,11 @@ Notes """ function updatePPE!( dfg::AbstractDFG, - variablekey::Symbol, + variableLabel::Symbol, ppe::AbstractPointParametricEst; warn_if_absent::Bool = true, ) - var = getVariable(dfg, variablekey) + var = getVariable(dfg, variableLabel) if warn_if_absent && !haskey(var.ppeDict, ppe.solveKey) @warn "PPE '$(ppe.solveKey)' does not exist, adding" end @@ -966,8 +990,8 @@ end $(SIGNATURES) Delete PPE data, returns the deleted element. """ -function deletePPE!(dfg::AbstractDFG, variablekey::Symbol, ppekey::Symbol = :default) - var = getVariable(dfg, variablekey) +function deletePPE!(dfg::AbstractDFG, variableLabel::Symbol, ppekey::Symbol = :default) + var = getVariable(dfg, variableLabel) if !haskey(var.ppeDict, ppekey) throw(LabelNotFoundError("PPE", ppekey)) @@ -996,8 +1020,8 @@ end $(SIGNATURES) List all the PPE data keys in the variable. """ -function listPPEs(dfg::AbstractDFG, variablekey::Symbol) - v = getVariable(dfg, variablekey) +function listPPEs(dfg::AbstractDFG, variableLabel::Symbol) + v = getVariable(dfg, variableLabel) return collect(keys(v.ppeDict))::Vector{Symbol} end diff --git a/test/testBlocks.jl b/test/testBlocks.jl index 615c31f7..b8d2258f 100644 --- a/test/testBlocks.jl +++ b/test/testBlocks.jl @@ -17,7 +17,7 @@ Base.convert(::Type{<:Tuple}, ::typeof(Euclidean(1))) = (:Euclid,) Base.convert(::Type{<:Tuple}, ::typeof(Euclidean(2))) = (:Euclid, :Euclid) @defVariable TestVariableType1 Euclidean(1) [0.0;] -DFG.@defVarstateTypeN TestVariableType{N} Euclidean(N) zeros(N) +DFG.@defStateTypeN TestVariableType{N} Euclidean(N) zeros(N) const TestVariableType2 = TestVariableType{2} struct TestFunctorInferenceType1 <: AbstractRelative end @@ -1047,6 +1047,15 @@ function blobsStoresTestBlock!(fg) @test issetequal(listBlobentries(fg, :a), [:label1, :label2]) @test listBlobentries(fg, :b) == Symbol[:label2] + # test collecting blobentries with filters + gathered = DFG.gatherBlobentries( + fg; + variableLabelFilter = contains("a"), + labelFilter = contains("1"), + ) + @test first(gathered[1]) == :a + @test last(gathered[1])[1] == getBlobentry(fg, :a, :label1) + #delete @test deleteBlobentry!(fg, var1.label, de1.label) == 1 @test listBlobentries(fg, var1.label) == Symbol[:label2] @@ -1102,7 +1111,7 @@ function blobsStoresTestBlock!(fg) @test data[1].hash == newData.hash #[1] data = getData(fg, :a, r"testing") # convenience wrapper over getBlob @test data[1].hash == newData.hash #[1] - be = getfirstBlobentry(fg, :a, r"testing") + be = getfirstBlobentry(fg, :a; labelFilter = contains(r"testing")) data = getData(fg, :a, be.blobId) # convenience wrapper over getBlob @test data[1].hash == newData.hash #[1] # @test data[2] == newData[2] diff --git a/test/test_defVariable.jl b/test/test_defVariable.jl index 668a5f67..450a9adc 100644 --- a/test/test_defVariable.jl +++ b/test/test_defVariable.jl @@ -1,3 +1,4 @@ +using LieGroups using Manifolds using Test using LinearAlgebra @@ -14,14 +15,14 @@ using LinearAlgebra @defVariable(TestVarType1, Euclidean(3), zeros(3)) @defVariable( TestVarType2, - SpecialEuclidean(3), + SpecialEuclideanGroup(3), ArrayPartition(zeros(3), diagm(ones(3))) ) ## @test getManifold(TestVarType1) == Euclidean(3) - @test getManifold(TestVarType2) == SpecialEuclidean(3) + @test getManifold(TestVarType2) == SpecialEuclideanGroup(3) @test getDimension(TestVarType1) === 3 @test getDimension(TestVarType2) === 6 @@ -39,7 +40,7 @@ using LinearAlgebra ## @test getManifold(TestVarType1()) == Euclidean(3) - @test getManifold(TestVarType2()) == SpecialEuclidean(3) + @test getManifold(TestVarType2()) == SpecialEuclideanGroup(3) @test getDimension(TestVarType1()) === 3 @test getDimension(TestVarType2()) === 6