• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  #ifndef ANDROID_DVR_PUBLIC_POSE_H_
2  #define ANDROID_DVR_PUBLIC_POSE_H_
3  
4  #include <stdint.h>
5  #include <sys/cdefs.h>
6  
7  __BEGIN_DECLS
8  
9  #ifdef __ARM_NEON
10  #include <arm_neon.h>
11  #else
12  #ifndef __FLOAT32X4T_86
13  #define __FLOAT32X4T_86
14  typedef float float32x4_t __attribute__((__vector_size__(16)));
15  #endif
16  #endif
17  
18  typedef struct DvrPoseClient DvrPoseClient;
19  typedef struct DvrReadBufferQueue DvrReadBufferQueue;
20  
21  // Represents an estimated pose, accessed asynchronously through a shared ring
22  // buffer. No assumptions should be made about the data in padding space.
23  // The size of this struct is 128 bytes.
24  typedef struct __attribute__((packed, aligned(16))) DvrPoseAsync {
25    // Left eye head-from-start orientation quaternion x,y,z,w.
26    float32x4_t orientation;
27    // Left eye head-from-start position x,y,z,pad in meters.
28    float32x4_t position;
29    // Right eye head-from-start orientation quaternion x,y,z,w.
30    float32x4_t right_orientation;
31    // Right eye head-from-start position x,y,z,pad in meters.
32    float32x4_t right_position;
33    // Start-space angular velocity x,y,z,pad in radians per second.
34    float32x4_t angular_velocity;
35    // Start-space positional velocity x,y,z,pad in meters per second.
36    float32x4_t velocity;
37    // Timestamp of when this pose is predicted for, typically halfway through
38    // scanout.
39    int64_t timestamp_ns;
40    // Bitmask of DVR_POSE_FLAG_* constants that apply to this pose.
41    //
42    // If DVR_POSE_FLAG_INVALID is set, the pose is indeterminate.
43    uint64_t flags;
44    // Reserved padding to 128 bytes.
45    uint8_t pad[16];
46  } DvrPoseAsync;
47  
48  enum {
49    DVR_POSE_FLAG_INVALID = (1ULL << 0),       // This pose is invalid.
50    DVR_POSE_FLAG_INITIALIZING = (1ULL << 1),  // The pose delivered during
51                                               // initialization and it may not be
52                                               // correct.
53    DVR_POSE_FLAG_3DOF =
54        (1ULL << 2),  // This pose is derived from 3Dof sensors. If
55                      // this is not set, pose is derived using
56                      // 3Dof and 6Dof sensors.
57    DVR_POSE_FLAG_FLOOR_HEIGHT_INVALID =
58        (1ULL << 3),  // If set the floor height is invalid.
59  
60    // Bits that indicate the tracking system state.
61    DVR_POSE_FLAG_SERVICE_EXCEPTION = (1ULL << 32),
62    DVR_POSE_FLAG_FISHEYE_OVER_EXPOSED = (1ULL << 33),
63    DVR_POSE_FLAG_FISHEYE_UNDER_EXPOSED = (1ULL << 34),
64    DVR_POSE_FLAG_COLOR_OVER_EXPOSED = (1ULL << 35),
65    DVR_POSE_FLAG_COLOR_UNDER_EXPOSED = (1ULL << 36),
66    DVR_POSE_FLAG_TOO_FEW_FEATURES_TRACKED = (1ULL << 37)
67  };
68  
69  // Represents a sensor pose sample.
70  typedef struct __attribute__((packed, aligned(16))) DvrPose {
71    // Head-from-start orientation quaternion x,y,z,w.
72    float32x4_t orientation;
73  
74    // The angular velocity where the x,y,z is the rotation axis and the
75    // magnitude is the radians / second in the same coordinate frame as
76    // orientation.
77    float32x4_t angular_velocity;
78  
79    // Head-from-start position x,y,z,pad in meters.
80    float32x4_t position;
81  
82    // In meters / second in the same coordinate frame as position.
83    float32x4_t velocity;
84  
85    // In meters / second ^ 2 in the same coordinate frame as position.
86    float32x4_t acceleration;
87  
88    // Timestamp for the measurement in nanoseconds.
89    int64_t timestamp_ns;
90  
91    // The combination of flags above.
92    uint64_t flags;
93  
94    // The current floor height. May be updated at a lower cadence than pose.
95    float floor_height;
96  
97    // Padding to 112 bytes so the size is a multiple of 16.
98    uint8_t padding[12];
99  } DvrPose;
100  
101  // Represents a data type that can be streamed from pose service.
102  enum {
103    DVR_POSE_RAW_DATA_STEREO_IMAGE = (1ULL << 0),
104    DVR_POSE_RAW_DATA_POINT_CLOUD = (1ULL << 1),
105    DVR_POSE_RAW_DATA_FEATURES = (1ULL << 2),
106  
107    // Always last.
108    DVR_POSE_RAW_DATA_COUNT = (1ULL << 3),
109  };
110  
111  // A request to retrieve data from the pose service. Expects that a buffer
112  // queue has been initialized through dvrPoseClientGetDataReader().
113  typedef struct DvrPoseDataCaptureRequest {
114    // The type of data to capture. Refer to enum DVR_POSE_RAW_DATA_* for types.
115    uint64_t data_type;
116    // The sample interval. This can be used to skip samples. For example, a
117    // value of 5 will capture every fifth frame and discard the 4 frames in
118    // between. Set to 1 to capture all frames.
119    uint32_t sample_interval;
120    // The length of time to capture samples in milliseconds. Set to 0 to capture
121    // indefinitely.
122    uint32_t capture_time_ms;
123    // Reserved fields.
124    uint32_t reserved0;
125    uint32_t reserved1;
126    uint32_t reserved2;
127    uint32_t reserved3;
128    uint32_t reserved4;
129  } DvrPoseDataCaptureRequest;
130  
131  // Gets a read buffer queue for the data type |data_type|. Each call returns a
132  // different read buffer queue connected to the same write buffer queue. A
133  // separate write buffer queue exists for each |data_type|.
134  //
135  // PoseService supports a single consumer per write buffer queue. The consumer
136  // is expected to hold a single DvrReadBufferQueue at a time. Callers should
137  // cache these instead of requesting new ones when possible. If the consumer
138  // disconnects from the queue, it can regain a read buffer queue for the same
139  // producer by calling this function.
140  //
141  // For data_type DVR_POSE_RAW_DATA_STEREO_IMAGE, each buffer consists of two
142  // images formatted as a AHARDWAREBUFFER_FORMAT_BLOB, where height is 1 and
143  // width is the total size of both images. The size of an individual image can
144  // be found in the metadata struct DvrNativeBufferMetadata, where width is
145  // |crop_right| and height is |crop_bottom|/2. Each image is contiguous in
146  // memory with stride equal to width.
147  int dvrPoseClientGetDataReader(DvrPoseClient* client, uint64_t data_type,
148                                 DvrReadBufferQueue** queue_out);
149  
150  // TODO(b/65067592): Move pose api's from pose_client.h to here.
151  
152  __END_DECLS
153  
154  #endif  // ANDROID_DVR_PUBLIC_POSE_H_
155