Monado OpenXR Runtime
Loading...
Searching...
No Matches
xrt::auxiliary::math::RelationHistoryBase< T > Struct Template Reference

The base type for a relation history. More...

#include <math/m_relation_history.hpp>

Collaboration diagram for xrt::auxiliary::math::RelationHistoryBase< T >:

Public Member Functions

bool pushOrUpdateLocked (const T &rhe, bool allow_update)
 Pushes a new entry (if newest) or updates an old one if allowed.
 
std::optional< T > getLatestLocked () const
 Gets the latest entry, or nullopt if none exists.
 
m_relation_history_result getLocked (timepoint_ns timestamp_ns, T &out_entry) const
 Gets the device's relation at the specified timestamp.
 
std::optional< T > getExactLocked (timepoint_ns timestamp_ns) const
 Gets an exact entry, if it exists.
 
std::optional< T > getNearestLocked (timepoint_ns timestamp_ns, time_duration_ns max_slop_ns) const
 Gets the stored entry nearest to the given timestamp, if one exists within max_slop_ns of it.
 
bool pushOrUpdate (const T &entry, bool allow_update)
 Pushes a new entry (if newest) or updates an old one if allowed.
 
std::optional< T > getLatest () const
 Gets the latest entry, or nullopt if none exists.
 
bool pushWithMotionEstimation (const T &new_entry, bool allow_update)
 Pushes a new entry, doing motion estimation if required.
 
uint32_t size () const
 Gets the amount of entries contained within the history.
 
void clear ()
 Clears the relation history.
 
m_relation_history_result get (timepoint_ns timestamp_ns, T &out_entry) const
 Gets the device's relation at the specified timestamp.
 
std::optional< T > getExact (timepoint_ns timestamp_ns) const
 Gets an exact entry, if it exists.
 
std::optional< T > getNearest (timepoint_ns timestamp_ns, time_duration_ns max_slop_ns) const
 Gets the stored entry nearest to the given timestamp, if one exists within max_slop_ns of it.
 

Data Fields

util::HistoryBuffer< T, kBufLen > impl
 
os::Mutex mutex
 

Static Public Attributes

static constexpr size_t kBufLen = 4096
 

Detailed Description

template<typename T>
struct xrt::auxiliary::math::RelationHistoryBase< T >

The base type for a relation history.

T must be a type compatible with RelationHistoryEntry (fields & functions).

Member Function Documentation

◆ clear()

template<typename T >
void xrt::auxiliary::math::RelationHistoryBase< T >::clear ( )
inline

Clears the relation history.

Thread safe, holds mutex.

◆ get()

template<typename T >
m_relation_history_result xrt::auxiliary::math::RelationHistoryBase< T >::get ( timepoint_ns  timestamp_ns,
T &  out_entry 
) const
inline

Gets the device's relation at the specified timestamp.

May predict or interpolate to get the closest value.

Call with mutex held.

Thread safe, holds mutex.

References xrt::auxiliary::math::RelationHistoryBase< T >::getLocked().

Referenced by xrt::auxiliary::tracking::slam::predict_pose().

◆ getExact()

template<typename T >
std::optional< T > xrt::auxiliary::math::RelationHistoryBase< T >::getExact ( timepoint_ns  timestamp_ns) const
inline

Gets an exact entry, if it exists.

Call with mutex held.

Thread safe, holds mutex.

References xrt::auxiliary::math::RelationHistoryBase< T >::getExactLocked().

◆ getExactLocked()

template<typename T >
std::optional< T > xrt::auxiliary::math::RelationHistoryBase< T >::getExactLocked ( timepoint_ns  timestamp_ns) const
inline

◆ getLatest()

template<typename T >
std::optional< T > xrt::auxiliary::math::RelationHistoryBase< T >::getLatest ( ) const
inline

Gets the latest entry, or nullopt if none exists.

Call with mutex locked.

Thread safe, holds mutex.

References xrt::auxiliary::math::RelationHistoryBase< T >::getLatestLocked().

Referenced by xrt::auxiliary::tracking::slam::flush_poses(), and xrt::auxiliary::tracking::slam::predict_pose().

◆ getLatestLocked()

template<typename T >
std::optional< T > xrt::auxiliary::math::RelationHistoryBase< T >::getLatestLocked ( ) const
inline

◆ getLocked()

◆ getNearest()

template<typename T >
std::optional< T > xrt::auxiliary::math::RelationHistoryBase< T >::getNearest ( timepoint_ns  timestamp_ns,
time_duration_ns  max_slop_ns 
) const
inline

Gets the stored entry nearest to the given timestamp, if one exists within max_slop_ns of it.

Never interpolates or extrapolates, the returned entry is exactly as stored (check its timestamp to see how far off it is). If two entries are equally close, the older one is returned.

Call with mutex held.

Thread safe, holds mutex.

References xrt::auxiliary::math::RelationHistoryBase< T >::getNearestLocked().

◆ getNearestLocked()

template<typename T >
std::optional< T > xrt::auxiliary::math::RelationHistoryBase< T >::getNearestLocked ( timepoint_ns  timestamp_ns,
time_duration_ns  max_slop_ns 
) const
inline

Gets the stored entry nearest to the given timestamp, if one exists within max_slop_ns of it.

Never interpolates or extrapolates, the returned entry is exactly as stored (check its timestamp to see how far off it is). If two entries are equally close, the older one is returned.

Call with mutex held.

References xrt::auxiliary::util::HistoryBuffer< T, MaxSize >::begin(), xrt::auxiliary::util::HistoryBuffer< T, MaxSize >::empty(), and xrt::auxiliary::util::HistoryBuffer< T, MaxSize >::end().

Referenced by xrt::auxiliary::math::RelationHistoryBase< T >::getNearest().

◆ pushOrUpdate()

template<typename T >
bool xrt::auxiliary::math::RelationHistoryBase< T >::pushOrUpdate ( const T &  entry,
bool  allow_update 
)
inline

Pushes a new entry (if newest) or updates an old one if allowed.

Call with mutex locked.

Thread safe, holds mutex.

References xrt::auxiliary::math::RelationHistoryBase< T >::pushOrUpdateLocked().

Referenced by xrt::auxiliary::tracking::slam::flush_poses().

◆ pushOrUpdateLocked()

◆ pushWithMotionEstimation()

template<typename T >
bool xrt::auxiliary::math::RelationHistoryBase< T >::pushWithMotionEstimation ( const T &  new_entry,
bool  allow_update 
)
inline

Pushes a new entry, doing motion estimation if required.

Thread safe, holds mutex.

References xrt::auxiliary::math::RelationHistoryBase< T >::getLatestLocked(), and xrt::auxiliary::math::RelationHistoryBase< T >::pushOrUpdateLocked().

◆ size()

template<typename T >
uint32_t xrt::auxiliary::math::RelationHistoryBase< T >::size ( ) const
inline

Gets the amount of entries contained within the history.

Thread safe, holds mutex.

References xrt::auxiliary::util::HistoryBuffer< T, MaxSize >::size().


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