OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
osvr::vbtracker::AssignMeasurementsToLeds Class Reference

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)
 
bool resumbitMeasurement (LedMeasurement const &meas)
 
bool hasMoreMatches (bool verbose=false)
 
LedAndMeasurement getMatch (bool verbose=false)
 Requires that hasMoreMatches() has been run and returns true. More...
 
bool haveMadeMaxMatches () const
 
size_type maxMatches () const
 
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
 
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
 

Detailed Description

Definition at line 75 of file AssignMeasurementsToLeds.h.

Member Function Documentation

void osvr::vbtracker::AssignMeasurementsToLeds::populateStructures ( )
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:

  • we don't need the heap property until we've completed processing all the input (so push_heap gives us no benefit there)
  • the max number of comparisons, by the requirements of the standard, are lower (and linear) and stay lower for the make_heap approach for a heap size of > 5.

Definition at line 96 of file AssignMeasurementsToLeds.h.

size_type osvr::vbtracker::AssignMeasurementsToLeds::discardInvalidEntries ( bool  verbose = false)
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!

Definition at line 145 of file AssignMeasurementsToLeds.h.

bool osvr::vbtracker::AssignMeasurementsToLeds::resumbitMeasurement ( LedMeasurement const &  meas)
inline

In case a measurement update goes bad, we can try to "un-mark" a measurement as consumed.

Todo:
do we throw a logic error here?

Un-count the match.

Restore the entry in the refs table.

Definition at line 178 of file AssignMeasurementsToLeds.h.

bool osvr::vbtracker::AssignMeasurementsToLeds::hasMoreMatches ( bool  verbose = false)
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.

Definition at line 208 of file AssignMeasurementsToLeds.h.

LedAndMeasurement osvr::vbtracker::AssignMeasurementsToLeds::getMatch ( bool  verbose = false)
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.

Definition at line 232 of file AssignMeasurementsToLeds.h.

bool osvr::vbtracker::AssignMeasurementsToLeds::haveMadeMaxMatches ( ) const
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.

Definition at line 273 of file AssignMeasurementsToLeds.h.

size_type osvr::vbtracker::AssignMeasurementsToLeds::maxMatches ( ) const
inline

The maximum number of matches theoretically achievable with this input: the minimum of the number of LED objects and the number of measurements

Definition at line 285 of file AssignMeasurementsToLeds.h.

bool osvr::vbtracker::AssignMeasurementsToLeds::empty ( ) const
inline

Is our heap of possibilities empty?

Not terribly harmful here, just illogical, so assert instead of unconditional check and throw.

Definition at line 288 of file AssignMeasurementsToLeds.h.

size_type osvr::vbtracker::AssignMeasurementsToLeds::size ( ) const
inline

Entries in the heap of possibilities.

Not terribly harmful here, just illogical, so assert instead of nconditional check and throw.

Definition at line 298 of file AssignMeasurementsToLeds.h.

size_type osvr::vbtracker::AssignMeasurementsToLeds::theoreticalMaxSize ( ) const
inline

This is the size it could have potentially been, had all LEDs been within the distance threshold. (O(n m))

Definition at line 309 of file AssignMeasurementsToLeds.h.

double osvr::vbtracker::AssignMeasurementsToLeds::heapSizeFraction ( ) const
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.

Definition at line 314 of file AssignMeasurementsToLeds.h.

void osvr::vbtracker::AssignMeasurementsToLeds::eraseUnclaimedLedObjects ( bool  verbose = false)
inline

already used

Definition at line 330 of file AssignMeasurementsToLeds.h.

template<typename F >
void osvr::vbtracker::AssignMeasurementsToLeds::forEachUnclaimedMeasurement ( F &&  op)
inline

already used

Apply the operation.

Definition at line 357 of file AssignMeasurementsToLeds.h.


The documentation for this class was generated from the following file: