OSVR-Core
|
Public Types | |
using | LedAndMeasurement = std::pair< Led &, LedMeasurement const & > |
using | LedMeasDistance = std::tuple< std::size_t, std::size_t, float > |
using | HeapValueType = LedMeasDistance |
using | HeapType = std::vector< HeapValueType > |
using | size_type = HeapType::size_type |
Public Member Functions | |
AssignMeasurementsToLeds (LedGroup &leds, LedMeasurementVec const &measurements, const std::size_t numBeacons, float blobMoveThresh, bool verbose=false) | |
void | populateStructures () |
Must call first, and only once. More... | |
size_type | discardInvalidEntries (bool verbose=false) |
Discards invalid entries (those where either the LED or the measurement, or both, have already been assigned) from the heap, and returns the count of entries so discarded. More... | |
bool | resumbitMeasurement (LedMeasurement const &meas) |
In case a measurement update goes bad, we can try to "un-mark" a measurement as consumed. More... | |
bool | hasMoreMatches (bool verbose=false) |
Searches the heap, discarding now-invalid entries, until it finds an entry where both the LED and the measurement are unclaimed, or it runs out of entries. More... | |
LedAndMeasurement | getMatch (bool verbose=false) |
Requires that hasMoreMatches() has been run and returns true. More... | |
bool | haveMadeMaxMatches () const |
Have we made as many matches as we possibly can? (that is, the minimum of the number of LED objects and the number of measurements) More... | |
size_type | maxMatches () const |
The maximum number of matches theoretically achievable with this input: the minimum of the number of LED objects and the number of measurements. | |
bool | empty () const |
Is our heap of possibilities empty? More... | |
size_type | size () const |
Entries in the heap of possibilities. More... | |
size_type | theoreticalMaxSize () const |
This is the size it could have potentially been, had all LEDs been within the distance threshold. More... | |
double | heapSizeFraction () const |
The fraction of the theoretical max that the size is. More... | |
size_type | numUnclaimedLedObjects () const |
void | eraseUnclaimedLedObjects (bool verbose=false) |
size_type | numUnclaimedMeasurements () const |
template<typename F > | |
void | forEachUnclaimedMeasurement (F &&op) |
size_type | numCompletedMatches () const |
|
inline |
Discards invalid entries (those where either the LED or the measurement, or both, have already been assigned) from the heap, and returns the count of entries so discarded.
Great, we found one!
|
inline |
Is our heap of possibilities empty?
Not terribly harmful here, just illogical, so assert instead of unconditional check and throw.
|
inline |
already used
|
inline |
already used
Apply the operation.
|
inline |
Requires that hasMoreMatches() has been run and returns true.
Mark that we've used this LED and measurement.
Postcondition check - shouldn't be valid anymore, we just consumed it.
Now, remove this entry from the heap.
Count it
and return the reward.
|
inline |
Searches the heap, discarding now-invalid entries, until it finds an entry where both the LED and the measurement are unclaimed, or it runs out of entries.
Early out: We've already matched up all of one type or another.
|
inline |
Have we made as many matches as we possibly can? (that is, the minimum of the number of LED objects and the number of measurements)
Not terribly harmful here, just illogical, so assert instead of unconditional check and throw.
|
inline |
The fraction of the theoretical max that the size is.
Not terribly harmful here, just illogical, so assert instead of unconditional check and throw.
|
inline |
Must call first, and only once.
Clean up LEDs and populate their ref vector.
Populate the measurement ref vector.
Do the O(n * m) distance computation to populate the vector that will become our min-heap.
WARNING: watch the order of arguments to this function, since the type of the indices is identical...
Turn that vector into our min-heap.
More efficient to do this one-time 3N=O(n) operation, than repeatedly push_heap (2log(N)=O(log n)) as we go, because:
|
inline |
In case a measurement update goes bad, we can try to "un-mark" a measurement as consumed.
Un-count the match.
Restore the entry in the refs table.
|
inline |
Entries in the heap of possibilities.
Not terribly harmful here, just illogical, so assert instead of nconditional check and throw.
|
inline |
This is the size it could have potentially been, had all LEDs been within the distance threshold.
(O(n m))