Skip to content

Commit 26b0fbd

Browse files
committed
Rename IIF abstract types
1 parent dd9f43a commit 26b0fbd

File tree

12 files changed

+139
-78
lines changed

12 files changed

+139
-78
lines changed

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Listing news on any major breaking changes in DFG. For regular changes, see integrated Github.com project milestones for DFG.
22
# v0.28
33
- Reading or deserialzing of factor graphs created prior to v0.25 are no longer suppoted with the complete removal of User/Robot/Session
4+
- Deprecated AbstractRelativeMinimize and AbstractManifoldsMinimize
5+
6+
#TODO pending:
7+
- AbstractPrior -> AbstractPriorObservation/PriorObservation
8+
- AbstractRelative -> RelativeObservation/RelativeObservation
9+
- InferenceType -> AbstractPackedFactorObservation
10+
- InferenceVariable -> [Abstract]VariableStateType/AbstractVarstateType
11+
- PackedSamplableBelief -> [Abstract]PackedBelief
412

513
# v0.27
614
- `delete` returns number of nodes deleted and no longer the object that was deleted.

src/Deprecated.jl

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
## ================================================================================
2+
## Deprecated in v0.28
3+
##=================================================================================
4+
export AbstractRelativeMinimize,
5+
AbstractManifoldMinimize,
6+
AbstractPrior,
7+
AbstractRelative,
8+
InferenceVariable,
9+
InferenceType,
10+
PackedSamplableBelief
11+
12+
const AbstractPrior = PriorObservation
13+
const AbstractRelative = RelativeObservation
14+
15+
abstract type AbstractRelativeMinimize <: RelativeObservation end
16+
abstract type AbstractManifoldMinimize <: RelativeObservation end
17+
18+
const InferenceVariable = VariableStateType{Any}
19+
const InferenceType = AbstractPackedFactorObservation
20+
21+
const PackedSamplableBelief = PackedBelief
22+
123
## ================================================================================
224
## Deprecated in v0.27
325
##=================================================================================
@@ -430,15 +452,15 @@ function getFactorOperationalMemoryType(dfg::AbstractDFG)
430452
return getFactorOperationalMemoryType(getSolverParams(dfg))
431453
end
432454

433-
function typeModuleName(variableType::InferenceVariable)
455+
function typeModuleName(variableType::VariableStateType)
434456
Base.depwarn("typeModuleName is obsolete", :typeModuleName)
435457
io = IOBuffer()
436458
ioc = IOContext(io, :module => DistributedFactorGraphs)
437459
show(ioc, typeof(variableType))
438460
return String(take!(io))
439461
end
440462

441-
typeModuleName(varT::Type{<:InferenceVariable}) = typeModuleName(varT())
463+
typeModuleName(varT::Type{<:VariableStateType}) = typeModuleName(varT())
442464

443465
## ================================================================================
444466
## Deprecated in v0.25

src/DistributedFactorGraphs.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export listTags, mergeTags!, removeTags!, emptyTags!
171171
# Variable
172172
##------------------------------------------------------------------------------
173173
# Abstract Variable Data
174-
export InferenceVariable
174+
export VariableStateType
175175

176176
# accessors
177177
export getSolverDataDict, setSolverData!
@@ -257,7 +257,7 @@ export @format_str # exported from FileIO
257257
##------------------------------------------------------------------------------
258258
# Factor Data
259259
export AbstractFactorObservation, AbstractPackedFactorObservation
260-
export AbstractPrior, AbstractRelative, AbstractRelativeMinimize, AbstractManifoldMinimize
260+
export PriorObservation, RelativeObservation
261261
export FactorSolverCache
262262

263263
# accessors

src/entities/DFGFactor.jl

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
abstract type AbstractPackedFactorObservation end
66
abstract type AbstractFactorObservation end
77

8-
abstract type AbstractPrior <: AbstractFactorObservation end
9-
abstract type AbstractRelative <: AbstractFactorObservation end
10-
abstract type AbstractRelativeMinimize <: AbstractRelative end
11-
abstract type AbstractManifoldMinimize <: AbstractRelative end
12-
8+
abstract type PriorObservation <: AbstractFactorObservation end
9+
abstract type RelativeObservation <: AbstractFactorObservation end
10+
abstract type PackedObservation <: AbstractFactorObservation end
1311
# NOTE DF, Convolution is IIF idea, but DFG should know about "FactorSolverCache"
1412
# DF, IIF.CommonConvWrapper <: FactorSolverCache #
1513
# NOTE was `<: Function` as unnecessary
@@ -129,16 +127,6 @@ end
129127

130128
FactorDFG(f::FactorDFG) = f
131129

132-
# TODO consolidate to just one type
133-
"""
134-
$(TYPEDEF)
135-
Abstract parent type for all InferenceTypes, which are the
136-
observation functions inside of factors.
137-
"""
138-
abstract type InferenceType <: AbstractPackedFactorObservation end
139-
140-
#TODO deprecate InferenceType in favor of AbstractPackedFactorObservation v0.26
141-
142130
# Packed Factor constructor
143131
function assembleFactorName(xisyms::Union{Vector{String}, Vector{Symbol}})
144132
return Symbol(xisyms..., "_f", randstring(4))

src/entities/DFGVariable.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## Abstract Types
33
##==============================================================================
44

5-
abstract type InferenceVariable end
5+
abstract type VariableStateType{N} end
66

77
##==============================================================================
88
## VariableState
@@ -19,7 +19,7 @@ N: Manifold dimension.
1919
Fields:
2020
$(TYPEDFIELDS)
2121
"""
22-
Base.@kwdef mutable struct VariableState{T <: InferenceVariable, P, N}
22+
Base.@kwdef mutable struct VariableState{T <: VariableStateType, P, N}
2323
"""
2424
Globally unique identifier.
2525
"""
@@ -82,10 +82,10 @@ end
8282

8383
##------------------------------------------------------------------------------
8484
## Constructors
85-
function VariableState{T}(; kwargs...) where {T <: InferenceVariable}
85+
function VariableState{T}(; kwargs...) where {T <: VariableStateType}
8686
return VariableState{T, getPointType(T), getDimension(T)}(; kwargs...)
8787
end
88-
function VariableState(variableType::InferenceVariable; kwargs...)
88+
function VariableState(variableType::VariableStateType; kwargs...)
8989
return VariableState{typeof(variableType)}(; kwargs...)
9090
end
9191

@@ -283,7 +283,7 @@ Complete variable structure for a DistributedFactorGraph variable.
283283
Fields:
284284
$(TYPEDFIELDS)
285285
"""
286-
Base.@kwdef struct VariableCompute{T <: InferenceVariable, P, N} <: AbstractDFGVariable
286+
Base.@kwdef struct VariableCompute{T <: VariableStateType, P, N} <: AbstractDFGVariable
287287
"""The ID for the variable"""
288288
id::Union{UUID, Nothing} = nothing
289289
"""Variable label, e.g. :x1.
@@ -325,7 +325,7 @@ The default VariableCompute constructor.
325325
"""
326326
function VariableCompute(
327327
label::Symbol,
328-
T::Type{<:InferenceVariable};
328+
T::Type{<:VariableStateType};
329329
timestamp::ZonedDateTime = now(localzone()),
330330
solvable::Union{Int, Base.RefValue{Int}} = Ref(1),
331331
kwargs...,
@@ -337,7 +337,7 @@ function VariableCompute(
337337
return VariableCompute{T, P, N}(; label, timestamp, solvable, kwargs...)
338338
end
339339

340-
function VariableCompute(label::Symbol, variableType::InferenceVariable; kwargs...)
340+
function VariableCompute(label::Symbol, variableType::VariableStateType; kwargs...)
341341
return VariableCompute(label, typeof(variableType); kwargs...)
342342
end
343343

src/services/AbstractDFG.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ end
601601
# to be consolidated, see #612
602602
function listVariables(
603603
dfg::AbstractDFG,
604-
typeFilter::Type{<:InferenceVariable};
604+
typeFilter::Type{<:VariableStateType};
605605
tags::Vector{Symbol} = Symbol[],
606606
solvable::Int = 0,
607607
)
@@ -667,7 +667,7 @@ end
667667

668668
function listSolveKeys(
669669
dfg::AbstractDFG,
670-
filterVariables::Union{Type{<:InferenceVariable}, Regex, Nothing} = nothing;
670+
filterVariables::Union{Type{<:VariableStateType}, Regex, Nothing} = nothing;
671671
filterSolveKeys::Union{Regex, Nothing} = nothing,
672672
tags::Vector{Symbol} = Symbol[],
673673
solvable::Int = 0,
@@ -747,7 +747,7 @@ end
747747
## list by types
748748
##--------------
749749

750-
function ls(dfg::G, ::Type{T}) where {G <: AbstractDFG, T <: InferenceVariable}
750+
function ls(dfg::G, ::Type{T}) where {G <: AbstractDFG, T <: VariableStateType}
751751
xx = getVariables(dfg)
752752
mask = getVariableType.(xx) .|> typeof .== T
753753
vxx = view(xx, mask)

src/services/CompareUtils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import Base.==
66
# Reference https://github.com/JuliaLang/julia/issues/4648
77

88
#=
9-
For now abstract `InferenceVariable`s are considered equal if they are the same type, dims, and manifolds (abels are deprecated)
9+
For now abstract `VariableStateType`s are considered equal if they are the same type, dims, and manifolds (abels are deprecated)
1010
If your implentation has aditional properties such as `DynPose2` with `ut::Int64` (microsecond time) or support different manifolds
1111
implement compare if needed.
1212
=#
13-
# ==(a::InferenceVariable,b::InferenceVariable) = typeof(a) == typeof(b) && a.dims == b.dims && a.manifolds == b.manifolds
13+
# ==(a::VariableStateType,b::VariableStateType) = typeof(a) == typeof(b) && a.dims == b.dims && a.manifolds == b.manifolds
1414

1515
==(a::FactorSolverCache, b::FactorSolverCache) = typeof(a) == typeof(b)
1616

src/services/DFGFactor.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,61 +102,61 @@ using RoME
102102
@assert RoME.PriorPose2 == DFG._getPriorType(Pose2)
103103
```
104104
"""
105-
function _getPriorType(_type::Type{<:InferenceVariable})
105+
function _getPriorType(_type::Type{<:VariableStateType})
106106
return getfield(_type.name.module, Symbol(:Prior, _type.name.name))
107107
end
108108

109109
##==============================================================================
110110
## Default Factors Function Macro
111111
##==============================================================================
112-
export PackedSamplableBelief
112+
export PackedBelief
113113

114114
function pack end
115115
function unpack end
116116
function packDistribution end
117117
function unpackDistribution end
118118

119-
abstract type PackedSamplableBelief end
120-
StructTypes.StructType(::Type{<:PackedSamplableBelief}) = StructTypes.UnorderedStruct()
119+
abstract type PackedBelief end
120+
StructTypes.StructType(::Type{<:PackedBelief}) = StructTypes.UnorderedStruct()
121121

122122
#TODO remove, rather use StructTypes.jl properly
123-
function Base.convert(::Type{<:PackedSamplableBelief}, nt::Union{NamedTuple, JSON3.Object})
123+
function Base.convert(::Type{<:PackedBelief}, nt::Union{NamedTuple, JSON3.Object})
124124
distrType = getTypeFromSerializationModule(nt._type)
125125
return distrType(; nt...)
126126
end
127127

128128
"""
129-
@defFactorType StructName factortype<:AbstractFactorObservation manifolds<:AbstractManifold
129+
@defObservationType StructName factortype<:AbstractFactorObservation manifolds<:AbstractManifold
130130
131131
A macro to create a new factor function with name `StructName` and manifold. Note that
132132
the `manifold` is an object and *must* be a subtype of `ManifoldsBase.AbstractManifold`.
133133
See documentation in [Manifolds.jl on making your own](https://juliamanifolds.github.io/Manifolds.jl/stable/examples/manifold.html).
134134
135135
Example:
136136
```
137-
DFG.@defFactorType Pose2Pose2 AbstractManifoldMinimize SpecialEuclidean(2)
137+
DFG.@defObservationType Pose2Pose2 RelativeObservation SpecialEuclidean(2)
138138
```
139139
"""
140-
macro defFactorType(structname, factortype, manifold)
140+
macro defObservationType(structname, factortype, manifold)
141141
packedstructname = Symbol("Packed", structname)
142142
return esc(
143143
quote
144144
# user manifold must be a <:Manifold
145-
@assert ($manifold isa AbstractManifold) "@defFactorType manifold (" *
145+
@assert ($manifold isa AbstractManifold) "@defObservationType manifold (" *
146146
string($manifold) *
147147
") is not an `AbstractManifold`"
148148

149-
@assert ($factortype <: AbstractFactorObservation) "@defFactorType factortype (" *
149+
@assert ($factortype <: AbstractFactorObservation) "@defObservationType factortype (" *
150150
string($factortype) *
151151
") is not an `AbstractFactorObservation`"
152152

153153
Base.@__doc__ struct $structname{T} <: $factortype
154154
Z::T
155155
end
156156

157-
#TODO should this be $packedstructname{T <: PackedSamplableBelief}
157+
#TODO should this be $packedstructname{T <: PackedBelief}
158158
Base.@__doc__ struct $packedstructname <: AbstractPackedFactorObservation
159-
Z::PackedSamplableBelief
159+
Z::PackedBelief
160160
end
161161

162162
# $structname(; Z) = $structname(Z)
@@ -275,11 +275,11 @@ function isPrior(dfg::AbstractDFG, fc::Symbol)
275275
return isPrior(getFactorType(fco))
276276
end
277277

278-
function isPrior(::AbstractPrior)
278+
function isPrior(::PriorObservation)
279279
return true
280280
end
281281

282-
function isPrior(::AbstractRelative)
282+
function isPrior(::RelativeObservation)
283283
return false
284284
end
285285

0 commit comments

Comments
 (0)