mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
xrt: Remove out_timestamp argument to xrt_device::get_tracked_pose
This commit is contained in:
parent
eaffa05a37
commit
8e24dda794
3
doc/changes/xrt/mr.521.md
Normal file
3
doc/changes/xrt/mr.521.md
Normal 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.
|
|
@ -399,11 +399,9 @@ static void
|
|||
_get_view_projection(struct comp_renderer *r)
|
||||
{
|
||||
struct xrt_space_relation relation;
|
||||
uint64_t out_timestamp;
|
||||
|
||||
xrt_device_get_tracked_pose(r->c->xdev, XRT_INPUT_GENERIC_HEAD_POSE,
|
||||
r->c->last_frame_time_ns, &out_timestamp,
|
||||
&relation);
|
||||
r->c->last_frame_time_ns, &relation);
|
||||
|
||||
struct xrt_vec3 eye_relation = {
|
||||
0.063000f, /* TODO: get actual ipd_meters */
|
||||
|
|
|
@ -359,16 +359,12 @@ static void
|
|||
arduino_device_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp_ns,
|
||||
uint64_t *out_relation_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
struct arduino_device *ad = arduino_device(xdev);
|
||||
|
||||
uint64_t now = os_monotonic_get_ns();
|
||||
|
||||
(void)at_timestamp_ns;
|
||||
arduino_get_fusion_pose(ad, name, out_relation);
|
||||
*out_relation_timestamp_ns = now;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -323,15 +323,12 @@ static void
|
|||
daydream_device_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp_ns,
|
||||
uint64_t *out_relation_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
struct daydream_device *daydream = daydream_device(xdev);
|
||||
uint64_t now = os_monotonic_get_ns();
|
||||
|
||||
(void)at_timestamp_ns;
|
||||
daydream_get_fusion_pose(daydream, name, out_relation);
|
||||
*out_relation_timestamp_ns = now;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -110,7 +110,6 @@ static void
|
|||
dummy_hmd_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp_ns,
|
||||
uint64_t *out_relation_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
struct dummy_hmd *dh = dummy_hmd(xdev);
|
||||
|
@ -120,9 +119,6 @@ dummy_hmd_get_tracked_pose(struct xrt_device *xdev,
|
|||
return;
|
||||
}
|
||||
|
||||
uint64_t now = os_monotonic_get_ns();
|
||||
|
||||
*out_relation_timestamp_ns = now;
|
||||
out_relation->pose = dh->pose;
|
||||
out_relation->relation_flags = (enum xrt_space_relation_flags)(
|
||||
XRT_SPACE_RELATION_ORIENTATION_VALID_BIT |
|
||||
|
|
|
@ -206,7 +206,6 @@ static void
|
|||
hdk_device_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t requested_timestamp_ns,
|
||||
uint64_t *out_actual_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
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.
|
||||
now -= 14000000;
|
||||
*out_actual_timestamp_ns = now;
|
||||
|
||||
if (!hd->quat_valid) {
|
||||
out_relation->relation_flags = XRT_SPACE_RELATION_BITMASK_NONE;
|
||||
|
|
|
@ -543,7 +543,6 @@ static void
|
|||
hydra_device_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp_ns,
|
||||
uint64_t *out_relation_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
struct hydra_device *hd = hydra_device(xdev);
|
||||
|
@ -551,7 +550,6 @@ hydra_device_get_tracked_pose(struct xrt_device *xdev,
|
|||
|
||||
hydra_system_update(hs);
|
||||
|
||||
*out_relation_timestamp_ns = hs->report_time;
|
||||
out_relation->pose = hd->state.pose;
|
||||
|
||||
//! @todo how do we report this is not (necessarily) the same base space
|
||||
|
|
|
@ -72,7 +72,6 @@ static void
|
|||
ns_hmd_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp_ns,
|
||||
uint64_t *out_relation_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
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 (ns->tracker != NULL) {
|
||||
xrt_device_get_tracked_pose(ns->tracker, name, at_timestamp_ns,
|
||||
out_relation_timestamp_ns,
|
||||
out_relation);
|
||||
return;
|
||||
}
|
||||
|
@ -91,9 +89,6 @@ ns_hmd_get_tracked_pose(struct xrt_device *xdev,
|
|||
return;
|
||||
}
|
||||
|
||||
uint64_t now = os_monotonic_get_ns();
|
||||
|
||||
*out_relation_timestamp_ns = now;
|
||||
out_relation->pose = ns->pose;
|
||||
out_relation->relation_flags = (enum xrt_space_relation_flags)(
|
||||
XRT_SPACE_RELATION_ORIENTATION_VALID_BIT |
|
||||
|
|
|
@ -64,7 +64,6 @@ static void
|
|||
oh_device_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp_ns,
|
||||
uint64_t *out_relation_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
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();
|
||||
|
||||
//! @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_POSITION_VECTOR, &pos.x);
|
||||
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
|
||||
* USB data and use that instead.
|
||||
*/
|
||||
*out_relation_timestamp_ns = ohd->last_update;
|
||||
*out_relation = ohd->last_relation;
|
||||
OH_SPEW(ohd, "GET_TRACKED_POSE - no new data");
|
||||
return;
|
||||
|
@ -131,8 +128,7 @@ oh_device_get_tracked_pose(struct xrt_device *xdev,
|
|||
*/
|
||||
if (ohd->enable_finite_difference && !have_ang_vel) {
|
||||
// No angular velocity
|
||||
float dt =
|
||||
time_ns_to_s(*out_relation_timestamp_ns - ohd->last_update);
|
||||
float dt = time_ns_to_s(now - ohd->last_update);
|
||||
if (ohd->last_update == 0) {
|
||||
// This is the first report, so just print a warning
|
||||
// instead of estimating ang vel.
|
||||
|
@ -165,7 +161,7 @@ oh_device_get_tracked_pose(struct xrt_device *xdev,
|
|||
}
|
||||
|
||||
// Update state within driver
|
||||
ohd->last_update = *out_relation_timestamp_ns;
|
||||
ohd->last_update = now;
|
||||
ohd->last_relation = *out_relation;
|
||||
}
|
||||
|
||||
|
|
|
@ -933,7 +933,6 @@ static void
|
|||
psmv_device_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp_ns,
|
||||
uint64_t *out_relation_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
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);
|
||||
|
||||
m_space_graph_resolve(&xgs, out_relation);
|
||||
|
||||
*out_relation_timestamp_ns = at_timestamp_ns;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -915,7 +915,6 @@ static void
|
|||
psvr_device_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp_ns,
|
||||
uint64_t *out_relation_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
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)(
|
||||
XRT_SPACE_RELATION_ORIENTATION_VALID_BIT |
|
||||
XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT);
|
||||
|
||||
|
||||
*out_relation_timestamp_ns = os_monotonic_get_ns();
|
||||
} else {
|
||||
xrt_tracked_psvr_get_tracked_pose(
|
||||
psvr->tracker, at_timestamp_ns, out_relation);
|
||||
|
||||
*out_relation_timestamp_ns = at_timestamp_ns;
|
||||
}
|
||||
|
||||
//! @todo Move this to the tracker.
|
||||
|
|
|
@ -250,7 +250,6 @@ static void
|
|||
rs_6dof_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp_ns,
|
||||
uint64_t *out_relation_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
struct rs_6dof *rs = rs_6dof(xdev);
|
||||
|
@ -260,9 +259,6 @@ rs_6dof_get_tracked_pose(struct xrt_device *xdev,
|
|||
return;
|
||||
}
|
||||
|
||||
uint64_t now = os_monotonic_get_ns();
|
||||
*out_relation_timestamp_ns = now;
|
||||
|
||||
os_thread_helper_lock(&rs->oth);
|
||||
out_relation->pose = rs->pose;
|
||||
os_thread_helper_unlock(&rs->oth);
|
||||
|
|
|
@ -322,7 +322,6 @@ static void
|
|||
vive_controller_device_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp_ns,
|
||||
uint64_t *out_relation_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
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.
|
||||
U_ZERO(out_relation);
|
||||
|
||||
uint64_t now = os_monotonic_get_ns();
|
||||
*out_relation_timestamp_ns = now;
|
||||
|
||||
os_thread_helper_lock(&d->controller_thread);
|
||||
|
||||
// Don't do anything if we have stopped.
|
||||
|
|
|
@ -94,7 +94,6 @@ static void
|
|||
vive_device_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp_ns,
|
||||
uint64_t *out_relation_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
struct vive_device *d = vive_device(xdev);
|
||||
|
@ -109,8 +108,6 @@ vive_device_get_tracked_pose(struct xrt_device *xdev,
|
|||
|
||||
//! @todo Use this properly.
|
||||
(void)at_timestamp_ns;
|
||||
uint64_t when = os_monotonic_get_ns();
|
||||
*out_relation_timestamp_ns = when;
|
||||
|
||||
os_thread_helper_lock(&d->sensors_thread);
|
||||
|
||||
|
|
|
@ -237,11 +237,9 @@ struct xrt_device
|
|||
void (*update_inputs)(struct xrt_device *xdev);
|
||||
|
||||
/*!
|
||||
* Get relationship of a tracked device to the device "base space".
|
||||
*
|
||||
* Right now the base space is assumed to be local space.
|
||||
*
|
||||
* This is very very WIP and will need to be made a lot more advanced.
|
||||
* 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
|
||||
* any prediction, there are helper functions available for this.
|
||||
*
|
||||
* The timestamps are system monotonic timestamps, such as returned by
|
||||
* 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
|
||||
* of positions, this is when the caller
|
||||
* 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.
|
||||
*
|
||||
* @see xrt_input_name
|
||||
|
@ -262,7 +258,6 @@ struct xrt_device
|
|||
void (*get_tracked_pose)(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp_ns,
|
||||
uint64_t *out_relation_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation);
|
||||
|
||||
/*!
|
||||
|
@ -327,11 +322,10 @@ static inline void
|
|||
xrt_device_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t requested_timestamp_ns,
|
||||
uint64_t *out_actual_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
xdev->get_tracked_pose(xdev, name, requested_timestamp_ns,
|
||||
out_actual_timestamp_ns, out_relation);
|
||||
out_relation);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -93,14 +93,12 @@ static void
|
|||
ipc_client_device_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp_ns,
|
||||
uint64_t *out_relation_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
struct ipc_client_device *icd = ipc_client_device(xdev);
|
||||
|
||||
xrt_result_t r = ipc_call_device_get_tracked_pose(
|
||||
icd->ipc_c, icd->device_id, name, at_timestamp_ns,
|
||||
out_relation_timestamp_ns, out_relation);
|
||||
icd->ipc_c, icd->device_id, name, at_timestamp_ns, out_relation);
|
||||
if (r != XRT_SUCCESS) {
|
||||
IPC_DEBUG(icd->ipc_c, "IPC: Error sending input update!");
|
||||
}
|
||||
|
|
|
@ -93,14 +93,12 @@ static void
|
|||
ipc_client_hmd_get_tracked_pose(struct xrt_device *xdev,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp_ns,
|
||||
uint64_t *out_relation_timestamp_ns,
|
||||
struct xrt_space_relation *out_relation)
|
||||
{
|
||||
struct ipc_client_hmd *ich = ipc_client_hmd(xdev);
|
||||
|
||||
xrt_result_t r = ipc_call_device_get_tracked_pose(
|
||||
ich->ipc_c, ich->device_id, name, at_timestamp_ns,
|
||||
out_relation_timestamp_ns, out_relation);
|
||||
ich->ipc_c, ich->device_id, name, at_timestamp_ns, out_relation);
|
||||
if (r != XRT_SUCCESS) {
|
||||
IPC_DEBUG(ich->ipc_c, "IPC: Error calling tracked pose!");
|
||||
}
|
||||
|
|
|
@ -558,7 +558,6 @@ ipc_handle_device_get_tracked_pose(volatile struct ipc_client_state *ics,
|
|||
uint32_t id,
|
||||
enum xrt_input_name name,
|
||||
uint64_t at_timestamp,
|
||||
uint64_t *out_timestamp,
|
||||
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.
|
||||
if (disabled && active_on_client) {
|
||||
U_ZERO(out_relation);
|
||||
*out_timestamp = at_timestamp;
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -590,8 +588,7 @@ ipc_handle_device_get_tracked_pose(volatile struct ipc_client_state *ics,
|
|||
}
|
||||
|
||||
// Get the pose.
|
||||
xrt_device_get_tracked_pose(xdev, name, at_timestamp, out_timestamp,
|
||||
out_relation);
|
||||
xrt_device_get_tracked_pose(xdev, name, at_timestamp, out_relation);
|
||||
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -176,7 +176,6 @@
|
|||
{"name": "at_timestamp", "type": "uint64_t"}
|
||||
],
|
||||
"out": [
|
||||
{"name": "timestamp", "type": "uint64_t"},
|
||||
{"name": "relation", "type": "struct xrt_space_relation"}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -93,10 +93,9 @@ oxr_xdev_get_space_graph(struct oxr_logger *log,
|
|||
// Convert at_time to monotonic and give to device.
|
||||
uint64_t at_timestamp_ns =
|
||||
time_state_ts_to_monotonic_ns(inst->timekeeping, at_time);
|
||||
uint64_t dummy = 0;
|
||||
|
||||
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.
|
||||
m_space_graph_add_pose(xsg, &xdev->tracking_origin->offset);
|
||||
|
|
Loading…
Reference in a new issue