xrt: Remove out_timestamp argument to xrt_device::get_tracked_pose

This commit is contained in:
Jakob Bornecrantz 2020-09-04 14:37:50 +01:00
parent eaffa05a37
commit 8e24dda794
20 changed files with 14 additions and 72 deletions

View file

@ -0,0 +1,3 @@
Remove the `out_timestamp` argument to the `xrt_device::get_tracked_pose`
function, it's not needed anymore and the devices can do prediction better
as it knows more about it's tracking system the the state tracker.

View file

@ -399,11 +399,9 @@ static void
_get_view_projection(struct comp_renderer *r) _get_view_projection(struct comp_renderer *r)
{ {
struct xrt_space_relation relation; struct xrt_space_relation relation;
uint64_t out_timestamp;
xrt_device_get_tracked_pose(r->c->xdev, XRT_INPUT_GENERIC_HEAD_POSE, xrt_device_get_tracked_pose(r->c->xdev, XRT_INPUT_GENERIC_HEAD_POSE,
r->c->last_frame_time_ns, &out_timestamp, r->c->last_frame_time_ns, &relation);
&relation);
struct xrt_vec3 eye_relation = { struct xrt_vec3 eye_relation = {
0.063000f, /* TODO: get actual ipd_meters */ 0.063000f, /* TODO: get actual ipd_meters */

View file

@ -359,16 +359,12 @@ static void
arduino_device_get_tracked_pose(struct xrt_device *xdev, arduino_device_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
uint64_t *out_relation_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct arduino_device *ad = arduino_device(xdev); struct arduino_device *ad = arduino_device(xdev);
uint64_t now = os_monotonic_get_ns();
(void)at_timestamp_ns; (void)at_timestamp_ns;
arduino_get_fusion_pose(ad, name, out_relation); arduino_get_fusion_pose(ad, name, out_relation);
*out_relation_timestamp_ns = now;
} }

View file

@ -323,15 +323,12 @@ static void
daydream_device_get_tracked_pose(struct xrt_device *xdev, daydream_device_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
uint64_t *out_relation_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct daydream_device *daydream = daydream_device(xdev); struct daydream_device *daydream = daydream_device(xdev);
uint64_t now = os_monotonic_get_ns();
(void)at_timestamp_ns; (void)at_timestamp_ns;
daydream_get_fusion_pose(daydream, name, out_relation); daydream_get_fusion_pose(daydream, name, out_relation);
*out_relation_timestamp_ns = now;
} }

View file

@ -110,7 +110,6 @@ static void
dummy_hmd_get_tracked_pose(struct xrt_device *xdev, dummy_hmd_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
uint64_t *out_relation_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct dummy_hmd *dh = dummy_hmd(xdev); struct dummy_hmd *dh = dummy_hmd(xdev);
@ -120,9 +119,6 @@ dummy_hmd_get_tracked_pose(struct xrt_device *xdev,
return; return;
} }
uint64_t now = os_monotonic_get_ns();
*out_relation_timestamp_ns = now;
out_relation->pose = dh->pose; out_relation->pose = dh->pose;
out_relation->relation_flags = (enum xrt_space_relation_flags)( out_relation->relation_flags = (enum xrt_space_relation_flags)(
XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_VALID_BIT |

View file

@ -206,7 +206,6 @@ static void
hdk_device_get_tracked_pose(struct xrt_device *xdev, hdk_device_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t requested_timestamp_ns, uint64_t requested_timestamp_ns,
uint64_t *out_actual_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct hdk_device *hd = hdk_device(xdev); struct hdk_device *hd = hdk_device(xdev);
@ -220,7 +219,6 @@ hdk_device_get_tracked_pose(struct xrt_device *xdev,
// Adjusting for latency - 14ms, found empirically. // Adjusting for latency - 14ms, found empirically.
now -= 14000000; now -= 14000000;
*out_actual_timestamp_ns = now;
if (!hd->quat_valid) { if (!hd->quat_valid) {
out_relation->relation_flags = XRT_SPACE_RELATION_BITMASK_NONE; out_relation->relation_flags = XRT_SPACE_RELATION_BITMASK_NONE;

View file

@ -543,7 +543,6 @@ static void
hydra_device_get_tracked_pose(struct xrt_device *xdev, hydra_device_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
uint64_t *out_relation_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct hydra_device *hd = hydra_device(xdev); struct hydra_device *hd = hydra_device(xdev);
@ -551,7 +550,6 @@ hydra_device_get_tracked_pose(struct xrt_device *xdev,
hydra_system_update(hs); hydra_system_update(hs);
*out_relation_timestamp_ns = hs->report_time;
out_relation->pose = hd->state.pose; out_relation->pose = hd->state.pose;
//! @todo how do we report this is not (necessarily) the same base space //! @todo how do we report this is not (necessarily) the same base space

View file

@ -72,7 +72,6 @@ static void
ns_hmd_get_tracked_pose(struct xrt_device *xdev, ns_hmd_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
uint64_t *out_relation_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct ns_hmd *ns = ns_hmd(xdev); struct ns_hmd *ns = ns_hmd(xdev);
@ -81,7 +80,6 @@ ns_hmd_get_tracked_pose(struct xrt_device *xdev,
// If the tracking device is created use it. // If the tracking device is created use it.
if (ns->tracker != NULL) { if (ns->tracker != NULL) {
xrt_device_get_tracked_pose(ns->tracker, name, at_timestamp_ns, xrt_device_get_tracked_pose(ns->tracker, name, at_timestamp_ns,
out_relation_timestamp_ns,
out_relation); out_relation);
return; return;
} }
@ -91,9 +89,6 @@ ns_hmd_get_tracked_pose(struct xrt_device *xdev,
return; return;
} }
uint64_t now = os_monotonic_get_ns();
*out_relation_timestamp_ns = now;
out_relation->pose = ns->pose; out_relation->pose = ns->pose;
out_relation->relation_flags = (enum xrt_space_relation_flags)( out_relation->relation_flags = (enum xrt_space_relation_flags)(
XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_VALID_BIT |

View file

@ -64,7 +64,6 @@ static void
oh_device_get_tracked_pose(struct xrt_device *xdev, oh_device_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
uint64_t *out_relation_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct oh_device *ohd = oh_device(xdev); struct oh_device *ohd = oh_device(xdev);
@ -80,7 +79,6 @@ oh_device_get_tracked_pose(struct xrt_device *xdev,
uint64_t now = os_monotonic_get_ns(); uint64_t now = os_monotonic_get_ns();
//! @todo adjust for latency here //! @todo adjust for latency here
*out_relation_timestamp_ns = now;
ohmd_device_getf(ohd->dev, OHMD_ROTATION_QUAT, &quat.x); ohmd_device_getf(ohd->dev, OHMD_ROTATION_QUAT, &quat.x);
ohmd_device_getf(ohd->dev, OHMD_POSITION_VECTOR, &pos.x); ohmd_device_getf(ohd->dev, OHMD_POSITION_VECTOR, &pos.x);
out_relation->pose.orientation = quat; out_relation->pose.orientation = quat;
@ -119,7 +117,6 @@ oh_device_get_tracked_pose(struct xrt_device *xdev,
/*! @todo this is a hack - should really get a timestamp on the /*! @todo this is a hack - should really get a timestamp on the
* USB data and use that instead. * USB data and use that instead.
*/ */
*out_relation_timestamp_ns = ohd->last_update;
*out_relation = ohd->last_relation; *out_relation = ohd->last_relation;
OH_SPEW(ohd, "GET_TRACKED_POSE - no new data"); OH_SPEW(ohd, "GET_TRACKED_POSE - no new data");
return; return;
@ -131,8 +128,7 @@ oh_device_get_tracked_pose(struct xrt_device *xdev,
*/ */
if (ohd->enable_finite_difference && !have_ang_vel) { if (ohd->enable_finite_difference && !have_ang_vel) {
// No angular velocity // No angular velocity
float dt = float dt = time_ns_to_s(now - ohd->last_update);
time_ns_to_s(*out_relation_timestamp_ns - ohd->last_update);
if (ohd->last_update == 0) { if (ohd->last_update == 0) {
// This is the first report, so just print a warning // This is the first report, so just print a warning
// instead of estimating ang vel. // instead of estimating ang vel.
@ -165,7 +161,7 @@ oh_device_get_tracked_pose(struct xrt_device *xdev,
} }
// Update state within driver // Update state within driver
ohd->last_update = *out_relation_timestamp_ns; ohd->last_update = now;
ohd->last_relation = *out_relation; ohd->last_relation = *out_relation;
} }

View file

@ -933,7 +933,6 @@ static void
psmv_device_get_tracked_pose(struct xrt_device *xdev, psmv_device_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
uint64_t *out_relation_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct xrt_space_graph xgs = {0}; struct xrt_space_graph xgs = {0};
@ -941,8 +940,6 @@ psmv_device_get_tracked_pose(struct xrt_device *xdev,
psmv_device_get_space_graph(xdev, name, at_timestamp_ns, &xgs); psmv_device_get_space_graph(xdev, name, at_timestamp_ns, &xgs);
m_space_graph_resolve(&xgs, out_relation); m_space_graph_resolve(&xgs, out_relation);
*out_relation_timestamp_ns = at_timestamp_ns;
} }
static void static void

View file

@ -915,7 +915,6 @@ static void
psvr_device_get_tracked_pose(struct xrt_device *xdev, psvr_device_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
uint64_t *out_relation_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct psvr_device *psvr = psvr_device(xdev); struct psvr_device *psvr = psvr_device(xdev);
@ -939,14 +938,9 @@ psvr_device_get_tracked_pose(struct xrt_device *xdev,
out_relation->relation_flags = (enum xrt_space_relation_flags)( out_relation->relation_flags = (enum xrt_space_relation_flags)(
XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_VALID_BIT |
XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT); XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT);
*out_relation_timestamp_ns = os_monotonic_get_ns();
} else { } else {
xrt_tracked_psvr_get_tracked_pose( xrt_tracked_psvr_get_tracked_pose(
psvr->tracker, at_timestamp_ns, out_relation); psvr->tracker, at_timestamp_ns, out_relation);
*out_relation_timestamp_ns = at_timestamp_ns;
} }
//! @todo Move this to the tracker. //! @todo Move this to the tracker.

View file

@ -250,7 +250,6 @@ static void
rs_6dof_get_tracked_pose(struct xrt_device *xdev, rs_6dof_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
uint64_t *out_relation_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct rs_6dof *rs = rs_6dof(xdev); struct rs_6dof *rs = rs_6dof(xdev);
@ -260,9 +259,6 @@ rs_6dof_get_tracked_pose(struct xrt_device *xdev,
return; return;
} }
uint64_t now = os_monotonic_get_ns();
*out_relation_timestamp_ns = now;
os_thread_helper_lock(&rs->oth); os_thread_helper_lock(&rs->oth);
out_relation->pose = rs->pose; out_relation->pose = rs->pose;
os_thread_helper_unlock(&rs->oth); os_thread_helper_unlock(&rs->oth);

View file

@ -322,7 +322,6 @@ static void
vive_controller_device_get_tracked_pose(struct xrt_device *xdev, vive_controller_device_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
uint64_t *out_relation_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct vive_controller_device *d = vive_controller_device(xdev); struct vive_controller_device *d = vive_controller_device(xdev);
@ -339,9 +338,6 @@ vive_controller_device_get_tracked_pose(struct xrt_device *xdev,
// Clear out the relation. // Clear out the relation.
U_ZERO(out_relation); U_ZERO(out_relation);
uint64_t now = os_monotonic_get_ns();
*out_relation_timestamp_ns = now;
os_thread_helper_lock(&d->controller_thread); os_thread_helper_lock(&d->controller_thread);
// Don't do anything if we have stopped. // Don't do anything if we have stopped.

View file

@ -94,7 +94,6 @@ static void
vive_device_get_tracked_pose(struct xrt_device *xdev, vive_device_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
uint64_t *out_relation_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct vive_device *d = vive_device(xdev); struct vive_device *d = vive_device(xdev);
@ -109,8 +108,6 @@ vive_device_get_tracked_pose(struct xrt_device *xdev,
//! @todo Use this properly. //! @todo Use this properly.
(void)at_timestamp_ns; (void)at_timestamp_ns;
uint64_t when = os_monotonic_get_ns();
*out_relation_timestamp_ns = when;
os_thread_helper_lock(&d->sensors_thread); os_thread_helper_lock(&d->sensors_thread);

View file

@ -237,11 +237,9 @@ struct xrt_device
void (*update_inputs)(struct xrt_device *xdev); void (*update_inputs)(struct xrt_device *xdev);
/*! /*!
* Get relationship of a tracked device to the device "base space". * Get relationship of a tracked device to the tracking origin space as
* * the base space. It is the responsibility of the device driver to do
* Right now the base space is assumed to be local space. * any prediction, there are helper functions available for this.
*
* This is very very WIP and will need to be made a lot more advanced.
* *
* The timestamps are system monotonic timestamps, such as returned by * The timestamps are system monotonic timestamps, such as returned by
* os_monotonic_get_ns(). * os_monotonic_get_ns().
@ -253,8 +251,6 @@ struct xrt_device
* @param[in] at_timestamp_ns If the device can predict or has a history * @param[in] at_timestamp_ns If the device can predict or has a history
* of positions, this is when the caller * of positions, this is when the caller
* wants the pose to be from. * wants the pose to be from.
* @param[out] out_relation_timestamp_ns Timestamp when this relation
* was captured.
* @param[out] out_relation The relation read from the device. * @param[out] out_relation The relation read from the device.
* *
* @see xrt_input_name * @see xrt_input_name
@ -262,7 +258,6 @@ struct xrt_device
void (*get_tracked_pose)(struct xrt_device *xdev, void (*get_tracked_pose)(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
uint64_t *out_relation_timestamp_ns,
struct xrt_space_relation *out_relation); struct xrt_space_relation *out_relation);
/*! /*!
@ -327,11 +322,10 @@ static inline void
xrt_device_get_tracked_pose(struct xrt_device *xdev, xrt_device_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t requested_timestamp_ns, uint64_t requested_timestamp_ns,
uint64_t *out_actual_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
xdev->get_tracked_pose(xdev, name, requested_timestamp_ns, xdev->get_tracked_pose(xdev, name, requested_timestamp_ns,
out_actual_timestamp_ns, out_relation); out_relation);
} }
/*! /*!

View file

@ -93,14 +93,12 @@ static void
ipc_client_device_get_tracked_pose(struct xrt_device *xdev, ipc_client_device_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
uint64_t *out_relation_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct ipc_client_device *icd = ipc_client_device(xdev); struct ipc_client_device *icd = ipc_client_device(xdev);
xrt_result_t r = ipc_call_device_get_tracked_pose( xrt_result_t r = ipc_call_device_get_tracked_pose(
icd->ipc_c, icd->device_id, name, at_timestamp_ns, icd->ipc_c, icd->device_id, name, at_timestamp_ns, out_relation);
out_relation_timestamp_ns, out_relation);
if (r != XRT_SUCCESS) { if (r != XRT_SUCCESS) {
IPC_DEBUG(icd->ipc_c, "IPC: Error sending input update!"); IPC_DEBUG(icd->ipc_c, "IPC: Error sending input update!");
} }

View file

@ -93,14 +93,12 @@ static void
ipc_client_hmd_get_tracked_pose(struct xrt_device *xdev, ipc_client_hmd_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
uint64_t *out_relation_timestamp_ns,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct ipc_client_hmd *ich = ipc_client_hmd(xdev); struct ipc_client_hmd *ich = ipc_client_hmd(xdev);
xrt_result_t r = ipc_call_device_get_tracked_pose( xrt_result_t r = ipc_call_device_get_tracked_pose(
ich->ipc_c, ich->device_id, name, at_timestamp_ns, ich->ipc_c, ich->device_id, name, at_timestamp_ns, out_relation);
out_relation_timestamp_ns, out_relation);
if (r != XRT_SUCCESS) { if (r != XRT_SUCCESS) {
IPC_DEBUG(ich->ipc_c, "IPC: Error calling tracked pose!"); IPC_DEBUG(ich->ipc_c, "IPC: Error calling tracked pose!");
} }

View file

@ -558,7 +558,6 @@ ipc_handle_device_get_tracked_pose(volatile struct ipc_client_state *ics,
uint32_t id, uint32_t id,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp, uint64_t at_timestamp,
uint64_t *out_timestamp,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
@ -581,7 +580,6 @@ ipc_handle_device_get_tracked_pose(volatile struct ipc_client_state *ics,
// We have been disabled but the client hasn't called update. // We have been disabled but the client hasn't called update.
if (disabled && active_on_client) { if (disabled && active_on_client) {
U_ZERO(out_relation); U_ZERO(out_relation);
*out_timestamp = at_timestamp;
return XRT_SUCCESS; return XRT_SUCCESS;
} }
@ -590,8 +588,7 @@ ipc_handle_device_get_tracked_pose(volatile struct ipc_client_state *ics,
} }
// Get the pose. // Get the pose.
xrt_device_get_tracked_pose(xdev, name, at_timestamp, out_timestamp, xrt_device_get_tracked_pose(xdev, name, at_timestamp, out_relation);
out_relation);
return XRT_SUCCESS; return XRT_SUCCESS;
} }

View file

@ -176,7 +176,6 @@
{"name": "at_timestamp", "type": "uint64_t"} {"name": "at_timestamp", "type": "uint64_t"}
], ],
"out": [ "out": [
{"name": "timestamp", "type": "uint64_t"},
{"name": "relation", "type": "struct xrt_space_relation"} {"name": "relation", "type": "struct xrt_space_relation"}
] ]
}, },

View file

@ -93,10 +93,9 @@ oxr_xdev_get_space_graph(struct oxr_logger *log,
// Convert at_time to monotonic and give to device. // Convert at_time to monotonic and give to device.
uint64_t at_timestamp_ns = uint64_t at_timestamp_ns =
time_state_ts_to_monotonic_ns(inst->timekeeping, at_time); time_state_ts_to_monotonic_ns(inst->timekeeping, at_time);
uint64_t dummy = 0;
struct xrt_space_relation *rel = m_space_graph_reserve(xsg); struct xrt_space_relation *rel = m_space_graph_reserve(xsg);
xrt_device_get_tracked_pose(xdev, name, at_timestamp_ns, &dummy, rel); xrt_device_get_tracked_pose(xdev, name, at_timestamp_ns, rel);
// Add in the offset from the tracking system. // Add in the offset from the tracking system.
m_space_graph_add_pose(xsg, &xdev->tracking_origin->offset); m_space_graph_add_pose(xsg, &xdev->tracking_origin->offset);