OSVR-Core
Classes | Public Member Functions | List of all members
osvr::vbtracker::TrackedBody Class Reference

This is the class representing a tracked rigid body in the system. More...

#include <TrackedBody.h>

Classes

struct  Impl
 

Public Member Functions

 TrackedBody (TrackingSystem &system, BodyId id)
 Constructor. More...
 
 ~TrackedBody ()
 Destructor - explicit so we can use unique_ptr for our pimpls.
 
 TrackedBody (TrackedBody const &)=delete
 Noncopyable.
 
TrackedBodyoperator= (TrackedBody const &)=delete
 Non-copy-assignable.
 
BodyId getId () const
 Gets the body ID within the tracking system.
 
ConfigParams const & getParams () const
 
BodyState const & getState () const
 
bool hasIMU () const
 Does this tracked body have an IMU?
 
TrackedBodyIMUgetIMU ()
 Get the IMU - only valid if hasIMU is true.
 
TrackedBodyIMU const & getIMU () const
 Get the IMU - only valid if hasIMU is true.
 
std::size_t getNumTargets () const
 How many (if any) video-based tracking targets does this tracked body have?
 
TrackedBodyTargetgetTarget (TargetId id)
 
TrackedBodyTarget const * getTarget (TargetId id) const
 
template<typename F >
void forEachTarget (F &&f)
 
template<typename F >
void forEachTarget (F &&f) const
 
bool hasPoseEstimate () const
 Do we have a pose estimate for this body in general? More...
 
bool hasEverHadPoseEstimate () const
 
bool getStateAtOrBefore (osvr::util::time::TimeValue const &desiredTime, osvr::util::time::TimeValue &outTime, BodyState &outState)
 Requests a copy of (a possibly historical snapshot of) body state, as close to desiredTime without being later than it. More...
 
void replaceStateSnapshot (osvr::util::time::TimeValue const &origTime, osvr::util::time::TimeValue const &newTime, BodyState const &newState)
 This is the counterpart to getStateAtOrBefore() and should only be called subsequent to it. More...
 
void pruneHistory (OSVR_TimeValue const &videoTime)
 Clean histories of no-longer-needed historical state and measurements. More...
 
osvr::util::time::TimeValue getStateTime () const
 Get timestamp associated with current state.
 
BodyProcessModelgetProcessModel ()
 
BodyStategetState ()
 
void incorporateNewMeasurementFromIMU (util::time::TimeValue const &tv, CannedIMUMeasurement const &meas)
 Incorporates a brand-new measurement from the IMU into the state. More...
 
TrackingSystemgetSystem ()
 
TrackingSystem const & getSystem () const
 
Child factories

Creates a fully-integrated IMU data source (that is, one that reports a reliable quaternion, and potentially angular velocity) to add to this body.

Todo:

eventually fix: Right now assumes that there is only one IMU per body

assumes the IMU is at the origin of the body (most important for velocity)

You do not own the pointer you get back - the tracked body does.

Returns
nullptr if an error occurred (such as an IMU already being added to this body)
TrackedBodyIMUcreateIntegratedIMU (double orientationVariance, double angularVelocityVariance=1.0)
 
TrackedBodyTargetcreateTarget (Eigen::Vector3d const &targetToBody, TargetSetupData const &setupData)
 Creates a video-based tracking target (constellation of beacons) to add to this body. More...
 

Detailed Description

This is the class representing a tracked rigid body in the system.

It may be tracked by one (or eventually more) video-based "target" (constellation of beacons in a known pattern with other known traits), and optionally by an IMU/AHRS - an orientation/angular-velocity-only high speed sensor.

This class has overall state

Constructor & Destructor Documentation

§ TrackedBody()

osvr::vbtracker::TrackedBody::TrackedBody ( TrackingSystem system,
BodyId  id 
)

Constructor.

Set error covariance matrix diagonal to large values for safety.

Member Function Documentation

§ createTarget()

TrackedBodyTarget * osvr::vbtracker::TrackedBody::createTarget ( Eigen::Vector3d const &  targetToBody,
TargetSetupData const &  setupData 
)

Creates a video-based tracking target (constellation of beacons) to add to this body.

Todo:
eventually fix: Right now assumes that there is only one target per body

You do not own the pointer you get back - the tracked body does.

Returns
nullptr if an error occurred (such as a target already being added to this body)
Todo:
handle multiple targets!

The target will always be target 0...

§ getParams()

ConfigParams const & osvr::vbtracker::TrackedBody::getParams ( ) const
Todo:
refactor

§ getState()

BodyState& osvr::vbtracker::TrackedBody::getState ( )
inline
Todo:
Note that this is stored in camera space!

§ getStateAtOrBefore()

bool osvr::vbtracker::TrackedBody::getStateAtOrBefore ( osvr::util::time::TimeValue const &  desiredTime,
osvr::util::time::TimeValue outTime,
BodyState outState 
)

Requests a copy of (a possibly historical snapshot of) body state, as close to desiredTime without being later than it.

If no such state is available (primarily because no valid state has been set yet), false will be returned and the out parameters will be untouched.

The purpose is to provide state that is potentially in the past, to integrate delayed measurements (like from video tracking) then later incorporate that state and replay later low-latency measurements.

Todo:
should this block others from trying to submit updates for times between outTime and desiredTime?
Parameters
[in]desiredTimeThe time you'd like state to be at or before
  • typically your measurement time.
[out]outTimeThe timestamp for the state copy you receive - modified only if return value is true. You'll need to retain this to re-submit with your updated state.
[out]outStateThe copy of the state will be placed here - modified only if return value is true.
Returns
true if a state for the body has been recorded at or prior to desiredTime and has thus been returned in outTime and outState.

couldn't find such a state.

§ hasPoseEstimate()

bool osvr::vbtracker::TrackedBody::hasPoseEstimate ( ) const

Do we have a pose estimate for this body in general?

Todo:
handle IMU here.

§ incorporateNewMeasurementFromIMU()

void osvr::vbtracker::TrackedBody::incorporateNewMeasurementFromIMU ( util::time::TimeValue const &  tv,
CannedIMUMeasurement const &  meas 
)

Incorporates a brand-new measurement from the IMU into the state.

Called only from the TrackedBodyIMU itself, please!

If room calibration is incomplete, don't handle this locally. If it's an orientation, hand it to the tracking system to hand off to the room calibrator.

Todo:
handle this better

If we have ever had a pose estimate, we can apply this IMU measurement. If we haven't yet got a pose from video, toss this or we'll end up getting NaNs.

§ pruneHistory()

void osvr::vbtracker::TrackedBody::pruneHistory ( OSVR_TimeValue const &  videoTime)

Clean histories of no-longer-needed historical state and measurements.

§ replaceStateSnapshot()

void osvr::vbtracker::TrackedBody::replaceStateSnapshot ( osvr::util::time::TimeValue const &  origTime,
osvr::util::time::TimeValue const &  newTime,
BodyState const &  newState 
)

This is the counterpart to getStateAtOrBefore() and should only be called subsequent to it.

You provide the timestamp that you originally got with the state from getStateAtOrBefore(), then the updated timestamp and state you got from incorporating your measurement.

In the history of this body, the old state will effectively be replaced (or immediately followed, implementation detail) by this one: classes of newer measurements will be replayed on the state as required to update the current body state to properly incorporate the presumably-dated information you just provided.

Parameters
origTimethe timestamp originally received from getStateAtOrBefore() as outTime
newTimethe timestamp currently associated with the state
newStatethe updated state.

Clear off the state we're about to invalidate.

Todo:
number popped should be the same (or very nearly) as the number of IMU measurements we replay - except at startup.

Put on the new state estimate we just computed.

Replay the IMU measurements timestamped later than our estimate


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