enpose_api/
marker_pose.rs

1//! The [`MarkerPose`] wire type, shared between the Enpose API and the
2//! on-device daemon.
3//!
4//! [`MarkerPose`] is serialized with MessagePack on the wire (see
5//! [`crate::posestream`]). It carries no networking logic itself, so this
6//! module compiles on any target — including ones without a sockets stack —
7//! and is available regardless of the `net` feature.
8
9use serde::{Deserialize, Serialize};
10
11/// Position and orientation of one tracked marker in world coordinates.
12///
13/// One [`MarkerPose`] is produced per localized marker per tracking
14/// update. A [`crate::PoseStream`] delivers these as they arrive from the
15/// device.
16///
17/// # Units
18///
19/// All positions ([`x`](Self::x), [`y`](Self::y), [`z`](Self::z) and
20/// [`position_rmse`](Self::position_rmse)) are in **meters**; rotation error
21/// ([`rotation_rmse`](Self::rotation_rmse)) is in **radians**.
22///
23/// The layout is `#[repr(C)]` so the C API can use a struct with the same
24/// fields directly. This does not affect the MessagePack wire format, which
25/// is derived from the field definitions, not the memory layout.
26#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
27#[repr(C)]
28pub struct MarkerPose {
29    /// Microseconds since the tracking device started. All markers from the
30    /// same tracking update share one timestamp. Subtract two poses'
31    /// timestamps to get the elapsed time between them; the absolute value
32    /// is not a wall-clock time and is only meaningful relative to other
33    /// poses from the same device session.
34    pub timestamp: u64,
35    /// Identifier of the marker this pose belongs to.
36    pub marker_id: u16,
37    /// World-space position in meters (of the first model emitter).
38    pub x: f64,
39    pub y: f64,
40    pub z: f64,
41    /// Rotation matrix (row-major 3x3), model frame to world frame.
42    pub rotation: [f64; 9],
43    /// Estimated RMS error of the position, in meters (the same units as
44    /// x/y/z).
45    pub position_rmse: f64,
46    /// Estimated RMS error of the rotation, expressed as the magnitude of an
47    /// axis-angle perturbation 3-vector (radians).
48    pub rotation_rmse: f64,
49    /// Number of sensors that contributed to this measurement.
50    pub sensors: u8,
51}