The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

aux/math: use int64_t for timestamps in m_relation_history

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2298>

authored by

Simon Zeni and committed by
Rylie Pavlik
ae7dca31 e2982445

+21 -23
+7 -7
src/xrt/auxiliary/math/m_relation_history.cpp
··· 37 37 struct relation_history_entry 38 38 { 39 39 struct xrt_space_relation relation; 40 - uint64_t timestamp; 40 + int64_t timestamp; 41 41 }; 42 42 43 43 static constexpr size_t BufLen = 4096; ··· 57 57 } 58 58 59 59 bool 60 - m_relation_history_push(struct m_relation_history *rh, struct xrt_space_relation const *in_relation, uint64_t timestamp) 60 + m_relation_history_push(struct m_relation_history *rh, struct xrt_space_relation const *in_relation, int64_t timestamp) 61 61 { 62 62 XRT_TRACE_MARKER(); 63 63 struct relation_history_entry rhe; ··· 82 82 83 83 enum m_relation_history_result 84 84 m_relation_history_get(const struct m_relation_history *rh, 85 - uint64_t at_timestamp_ns, 85 + int64_t at_timestamp_ns, 86 86 struct xrt_space_relation *out_relation) 87 87 { 88 88 XRT_TRACE_MARKER(); ··· 99 99 // Find the first element *not less than* our value. the lambda we pass is the comparison 100 100 // function, to compare against timestamps. 101 101 const auto it = 102 - std::lower_bound(b, e, at_timestamp_ns, [](const relation_history_entry &rhe, uint64_t timestamp) { 102 + std::lower_bound(b, e, at_timestamp_ns, [](const relation_history_entry &rhe, int64_t timestamp) { 103 103 return rhe.timestamp < timestamp; 104 104 }); 105 105 ··· 183 183 bool 184 184 m_relation_history_estimate_motion(struct m_relation_history *rh, 185 185 const struct xrt_space_relation *in_relation, 186 - uint64_t timestamp, 186 + int64_t timestamp, 187 187 struct xrt_space_relation *out_relation) 188 188 { 189 189 190 - uint64_t last_time_ns; 190 + int64_t last_time_ns; 191 191 struct xrt_space_relation last_relation; 192 192 if (!m_relation_history_get_latest(rh, &last_time_ns, &last_relation)) { 193 193 return false; ··· 229 229 230 230 bool 231 231 m_relation_history_get_latest(const struct m_relation_history *rh, 232 - uint64_t *out_time_ns, 232 + int64_t *out_time_ns, 233 233 struct xrt_space_relation *out_relation) 234 234 { 235 235 std::unique_lock<os::Mutex> lock(rh->mutex);
+7 -9
src/xrt/auxiliary/math/m_relation_history.h
··· 60 60 * @public @memberof m_relation_history 61 61 */ 62 62 bool 63 - m_relation_history_push(struct m_relation_history *rh, 64 - struct xrt_space_relation const *in_relation, 65 - uint64_t timestamp); 63 + m_relation_history_push(struct m_relation_history *rh, struct xrt_space_relation const *in_relation, int64_t timestamp); 66 64 67 65 /*! 68 66 * Interpolates or extrapolates to the desired timestamp. ··· 74 72 */ 75 73 enum m_relation_history_result 76 74 m_relation_history_get(const struct m_relation_history *rh, 77 - uint64_t at_timestamp_ns, 75 + int64_t at_timestamp_ns, 78 76 struct xrt_space_relation *out_relation); 79 77 80 78 /*! ··· 90 88 bool 91 89 m_relation_history_estimate_motion(struct m_relation_history *rh, 92 90 const struct xrt_space_relation *in_relation, 93 - uint64_t timestamp, 91 + int64_t timestamp, 94 92 struct xrt_space_relation *out_relation); 95 93 96 94 /*! ··· 106 104 */ 107 105 bool 108 106 m_relation_history_get_latest(const struct m_relation_history *rh, 109 - uint64_t *out_time_ns, 107 + int64_t *out_time_ns, 110 108 struct xrt_space_relation *out_relation); 111 109 112 110 /*! ··· 178 176 * @copydoc m_relation_history_push 179 177 */ 180 178 bool 181 - push(xrt_space_relation const &relation, uint64_t ts) noexcept 179 + push(xrt_space_relation const &relation, int64_t ts) noexcept 182 180 { 183 181 return m_relation_history_push(mPtr, &relation, ts); 184 182 } ··· 187 185 * @copydoc m_relation_history_get 188 186 */ 189 187 Result 190 - get(uint64_t at_time_ns, xrt_space_relation *out_relation) const noexcept 188 + get(int64_t at_time_ns, xrt_space_relation *out_relation) const noexcept 191 189 { 192 190 return m_relation_history_get(mPtr, at_time_ns, out_relation); 193 191 } ··· 196 194 * @copydoc m_relation_history_get_latest 197 195 */ 198 196 bool 199 - get_latest(uint64_t *out_time_ns, xrt_space_relation *out_relation) const noexcept 197 + get_latest(int64_t *out_time_ns, xrt_space_relation *out_relation) const noexcept 200 198 { 201 199 return m_relation_history_get_latest(mPtr, out_time_ns, out_relation); 202 200 }
+2 -2
src/xrt/auxiliary/tracking/t_tracker_slam.cpp
··· 762 762 763 763 // Last relation 764 764 xrt_space_relation lr = XRT_SPACE_RELATION_ZERO; 765 - uint64_t lts; 765 + int64_t lts; 766 766 t.slam_rels.get_latest(&lts, &lr); 767 767 xrt_vec3 lpos = lr.pose.position; 768 768 xrt_quat lrot = lr.pose.orientation; ··· 907 907 908 908 // Get last relation computed purely from SLAM data 909 909 xrt_space_relation rel{}; 910 - uint64_t rel_ts; 910 + int64_t rel_ts; 911 911 bool empty = !t.slam_rels.get_latest(&rel_ts, &rel); 912 912 913 913 // Stop if there is no previous relation to use for prediction
+3 -3
src/xrt/drivers/steamvr_lh/device.cpp
··· 146 146 }, 147 147 }; 148 148 149 - uint64_t 149 + int64_t 150 150 chrono_timestamp_ns() 151 151 { 152 152 auto now = std::chrono::steady_clock::now().time_since_epoch(); 153 - uint64_t ts = std::chrono::duration_cast<std::chrono::nanoseconds>(now).count(); 153 + int64_t ts = std::chrono::duration_cast<std::chrono::nanoseconds>(now).count(); 154 154 return ts; 155 155 } 156 156 ··· 317 317 auto curl_values = u_hand_tracking_curl_values{pinky, ring, middle, index, thumb}; 318 318 319 319 struct xrt_space_relation hand_relation = {}; 320 - uint64_t ts = chrono_timestamp_ns(); 320 + int64_t ts = chrono_timestamp_ns(); 321 321 m_relation_history_get_latest(relation_hist, &ts, &hand_relation); 322 322 323 323 u_hand_sim_simulate_for_valve_index_knuckles(&curl_values, get_xrt_hand(), &hand_relation, out);
+2 -2
tests/tests_history_buf.cpp
··· 57 57 constexpr auto T2 = T1 + (uint64_t)U_TIME_1S_IN_NS; 58 58 59 59 xrt_space_relation out_relation = XRT_SPACE_RELATION_ZERO; 60 - uint64_t out_time = 0; 60 + int64_t out_time = 0; 61 61 62 62 CHECK(m_relation_history_get_size(rh) == 0); 63 63 CHECK_FALSE(m_relation_history_get_latest(rh, &out_time, &out_relation)); ··· 152 152 constexpr auto T2 = T1 + (uint64_t)U_TIME_1S_IN_NS; 153 153 154 154 xrt_space_relation out_relation = XRT_SPACE_RELATION_ZERO; 155 - uint64_t out_time = 0; 155 + int64_t out_time = 0; 156 156 157 157 CHECK(rh.size() == 0); 158 158 CHECK_FALSE(rh.get_latest(&out_time, &out_relation));