function
SLAM.LoopClosure.RGBDVisualVocabulary.Valid
Public declarations
Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.
| Role | Name | Type | Dimensions / attributes / default | Description |
|---|---|---|---|---|
| input | state | State | | |
| output | valid | Boolean | |
Modelica declarations and implementation
Show parameters, interfaces and source
Parameters, inputs, outputs, defaults and equations from the source file.
function Valid
input State state;
output Boolean valid;
protected
Real mean; Real energy;
algorithm
valid := state.generation >= 1 and state.generation <= identifierLimit
and state.sourceRevision >= 1 and state.sourceRevision <= identifierLimit
and state.version >= 1 and state.version <= identifierLimit
and state.count >= 0 and state.count <= vocabularyCapacity
and (not state.ready or state.count >= 1);
mean := 0.0; energy := 0.0;
for word in 1:vocabularyCapacity loop
valid := valid and state.enabled[word] == (if word <= state.count then 1.0 else 0.0);
// Disabled word storage is opaque, including restored padding.
if word <= state.count then
mean := 0.0; energy := 0.0;
for component in 1:descriptorSize loop
valid := valid and abs(state.words[word,component]) <= 1.0;
mean := mean+state.words[word,component]/descriptorSize;
energy := energy+state.words[word,component]*state.words[word,component];
end for;
valid := valid and abs(mean) <= 1e-6 and abs(energy-1.0) <= 1e-6;
end if;
end for;
end Valid;