···8080 os_mutex_unlock(&rh->mutex);
8181}
82828383-void
8383+enum m_relation_history_result
8484m_relation_history_get(struct m_relation_history *rh, struct xrt_space_relation *out_relation, uint64_t at_timestamp_ns)
8585{
8686 XRT_TRACE_MARKER();
8787 os_mutex_lock(&rh->mutex);
8888+ m_relation_history_result ret = M_RELATION_HISTORY_RESULT_INVALID;
8989+8890 if (rh->has_first_sample == 0) {
8991 // Do nothing. You push nothing to the buffer you get nothing from the buffer.
9092 goto end;
···104106 U_LOG_T("Extrapolating %f s after the head of the buffer!", delta_s);
105107106108 m_predict_relation(&rh->impl[0]->relation, delta_s, out_relation);
109109+ ret = M_RELATION_HISTORY_RESULT_PREDICTED;
107110 goto end;
108111109112 } else if (at_timestamp_ns < oldest_in_buffer) {
···114117 double delta_s = time_ns_to_s(diff_prediction_ns);
115118 U_LOG_T("Extrapolating %f s before the tail of the buffer!", delta_s);
116119 m_predict_relation(&rh->impl[rh->impl.length() - 1]->relation, delta_s, out_relation);
120120+ ret = M_RELATION_HISTORY_RESULT_REVERSE_PREDICTED;
121121+117122 goto end;
118123 }
119124 U_LOG_T("Interpolating within buffer!");
···196201 m_vec3_lerp(before.angular_velocity, after.angular_velocity, amount_to_lerp);
197202 out_relation->linear_velocity =
198203 m_vec3_lerp(before.linear_velocity, after.linear_velocity, amount_to_lerp);
204204+ ret = M_RELATION_HISTORY_RESULT_INTERPOLATED;
199205 }
200206end:
201207 os_mutex_unlock(&rh->mutex);
208208+ return ret;
202209}
203210204211void
+35-11
src/xrt/auxiliary/math/m_relation_history.h
···77 * @author Moses Turner <moses@collabora.com>
88 * @ingroup drv_ht
99 */
1010+#pragma once
10111112#include "xrt/xrt_defines.h"
1212-struct m_relation_history;
13131414#ifdef __cplusplus
1515extern "C" {
1616#endif
17171818-/*!
1919- * Creates an opaque relation_history object.
1818+/**
1919+ * @brief Opaque type for storing the history of a space relation in a ring buffer
2020 *
2121 * @ingroup aux_util
2222 */
2323+struct m_relation_history;
2424+2525+/**
2626+ * @brief Describes how the resulting space relation for the desired time stamp was generated.
2727+ *
2828+ * @relates m_relation_history
2929+ */
3030+enum m_relation_history_result
3131+{
3232+ M_RELATION_HISTORY_RESULT_INVALID = 0, //!< The supplied timestamp was invalid (0) or buffer was empty
3333+ M_RELATION_HISTORY_RESULT_EXACT, //!< The exact desired timestamp was found
3434+ M_RELATION_HISTORY_RESULT_INTERPOLATED, //!< The desired timestamp was between two entries
3535+ M_RELATION_HISTORY_RESULT_PREDICTED, //!< The desired timestamp was newer than the most recent entry
3636+ M_RELATION_HISTORY_RESULT_REVERSE_PREDICTED, //!< The desired timestamp was older than the oldest entry
3737+};
3838+3939+/*!
4040+ * @brief Creates an opaque relation_history object.
4141+ *
4242+ * @public @memberof m_relation_history
4343+ */
2344void
2445m_relation_history_create(struct m_relation_history **rh);
25462647/*!
2727- * Pushes a new pose to the history - if the history is full, it will also pop a pose out of the other side of the
2828- * buffer.
4848+ * Pushes a new pose to the history.
2949 *
3030- * @ingroup aux_util
5050+ * If the history is full, it will also pop a pose out of the other side of the buffer.
5151+ *
5252+ * @public @memberof m_relation_history
3153 */
3254void
3355m_relation_history_push(struct m_relation_history *rh, struct xrt_space_relation *in_relation, uint64_t ts);
34563557/*!
3636- * Interpolates or extrapolates to the desired timestamp. Read-only operation - doesn't remove anything from the buffer
3737- * or anything like that - you can call this as often as you want.
5858+ * @brief Interpolates or extrapolates to the desired timestamp.
3859 *
3939- * @ingroup aux_util
6060+ * Read-only operation - doesn't remove anything from the buffer or anything like that - you can call this as often as
6161+ * you want.
6262+ *
6363+ * @public @memberof m_relation_history
4064 */
4141-void
6565+enum m_relation_history_result
4266m_relation_history_get(struct m_relation_history *rh, struct xrt_space_relation *out_relation, uint64_t at_time_ns);
43674468/*!
4569 * Destroys an opaque relation_history object.
4670 *
4747- * @ingroup aux_util
7171+ * @public @memberof m_relation_history
4872 */
4973void
5074m_relation_history_destroy(struct m_relation_history **rh);