···133133 flags af = get_flags(a);
134134 flags bf = get_flags(b);
135135136136- // If either of the relations does not have a valid or tracked flag, the entire chain loses that flag.
137137- flags nf = {};
138138- nf.has_orientation = af.has_orientation && bf.has_orientation;
139139- nf.has_position = af.has_position && bf.has_position;
140140- nf.has_tracked_orientation = af.has_tracked_orientation && bf.has_tracked_orientation;
141141- nf.has_tracked_position = af.has_tracked_position && bf.has_tracked_position;
142142- nf.has_linear_velocity = af.has_linear_velocity && bf.has_linear_velocity;
143143- nf.has_angular_velocity = af.has_angular_velocity && bf.has_angular_velocity;
144144-145136 struct xrt_pose pose = XRT_POSE_IDENTITY;
146137 struct xrt_vec3 linear_velocity = XRT_VEC3_ZERO;
147138 struct xrt_vec3 angular_velocity = XRT_VEC3_ZERO;
···158149 // work. The flags of the result are determined in nf and not taken from the result of the transform.
159150 make_valid_pose(af, &a->pose, &body_pose);
160151 make_valid_pose(bf, &b->pose, &base_pose);
152152+153153+154154+ // This is a band aid to make 3dof devices work until we have a real solution.
155155+ // A 3dof device may return a relation with only orientation valid/tracked and no position.
156156+ //
157157+ // Monado wants to apply a predefined offset to 3dof devices, giving them a position.
158158+ //
159159+ // But per the comment below "If either of the relations does not have a valid or tracked flag, the entire chain
160160+ // loses that flag".
161161+ //
162162+ // For now we upgrade every relation that only has an orientation, to also have a position. Note that
163163+ // make_valid_pose zeroed the position if has_position was not set originally, ensuring there are no garbage
164164+ // values propagated.
165165+ if (af.has_orientation && !af.has_position) {
166166+ af.has_position = true;
167167+ }
168168+ if (bf.has_orientation && !bf.has_position) {
169169+ bf.has_position = true;
170170+ }
171171+172172+173173+ // If either of the relations does not have a valid or tracked flag, the entire chain loses that flag.
174174+ flags nf = {};
175175+ nf.has_orientation = af.has_orientation && bf.has_orientation;
176176+ nf.has_position = af.has_position && bf.has_position;
177177+ nf.has_tracked_orientation = af.has_tracked_orientation && bf.has_tracked_orientation;
178178+ nf.has_tracked_position = af.has_tracked_position && bf.has_tracked_position;
179179+ nf.has_linear_velocity = af.has_linear_velocity && bf.has_linear_velocity;
180180+ nf.has_angular_velocity = af.has_angular_velocity && bf.has_angular_velocity;
181181+161182162183 // Not already valid poses needed to be made valid because the transoformed pose would be undefined otherwise
163184 // and we still want e.g. valid positions.
+23-14
tests/tests_relation_chain.cpp
···87878888enum Functions
8989{
9090- NV, // (Non-Identity) (Space Relation) Not Valid Not Tracked
9191- VT, // (Non-Identity) (Space Relation) Valid Tracked
9292- VNT, // (Non-Identity) (Space Relation) Valid Not Tracked
9090+ NV, // (Non-Identity) (Space Relation) Neither Position/Orientation Valid, Not Tracked
9191+ VT, // (Non-Identity) (Space Relation) Position/Orientation Valid, Tracked
9292+ VNT, // (Non-Identity) (Space Relation) Position/Orientation Valid, Not Tracked
9393 P, // (Non-Identity) Pose
9494 IP, // Identity Pose
9595- ONLY_ORIENTATION, // (Non-Identity) (Space Relation) Only orientation
9696- ONLY_POSITION, // (Non-Identity) (Space Relation) Only position
9595+ ONLY_ORIENTATION, // (Non-Identity) (Space Relation) Only orientation Valid, Not Tracked
9696+ ONLY_POSITION, // (Non-Identity) (Space Relation) Only position Valid, Not Tracked
9797};
98989999static void
···179179 TEST_FLAGS(kFlagsValid, VT, VT, VNT, VT);
180180 TEST_FLAGS(kFlagsValid, IP, VT, P, VNT, P, VT);
181181182182- TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, VT, ONLY_ORIENTATION);
182182+ // ONLY_ORIENTATION relation is upgraded to position valid
183183+ TEST_FLAGS(kFlagsValid, VT, ONLY_ORIENTATION);
183184 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, VT, ONLY_POSITION);
184184- TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, ONLY_ORIENTATION, VT);
185185+ // ONLY_ORIENTATION relation is upgraded to position valid
186186+ TEST_FLAGS(kFlagsValid, ONLY_ORIENTATION, VT);
185187 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, ONLY_POSITION, VT);
186188187187- TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, P, VT, ONLY_ORIENTATION, P);
189189+ // ONLY_ORIENTATION relation is upgraded to position valid
190190+ TEST_FLAGS(kFlagsValid, P, VT, ONLY_ORIENTATION, P);
188191 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, P, VT, ONLY_POSITION, P);
189189- TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, P, ONLY_ORIENTATION, VT, P);
192192+ // ONLY_ORIENTATION relation is upgraded to position valid
193193+ TEST_FLAGS(kFlagsValid, P, ONLY_ORIENTATION, VT, P);
190194 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, P, ONLY_POSITION, VT, P);
191195 }
192196···214218 TEST_FLAGS(kFlagsValid, P, VNT, IP, P);
215219 TEST_FLAGS(kFlagsValid, P, IP, VNT, P);
216220217217- TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, P, ONLY_ORIENTATION, IP, P);
221221+ // ONLY_ORIENTATION relation is upgraded to position valid
222222+ TEST_FLAGS(kFlagsValid, P, ONLY_ORIENTATION, IP, P);
218223 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, P, ONLY_POSITION, IP, P);
219224220220- TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, ONLY_ORIENTATION, VNT);
225225+ // ONLY_ORIENTATION relation is upgraded to position valid
226226+ TEST_FLAGS(kFlagsValid, ONLY_ORIENTATION, VNT);
221227 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, ONLY_POSITION, VNT);
222222- TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, VNT, ONLY_ORIENTATION);
228228+ // ONLY_ORIENTATION relation is upgraded to position valid
229229+ TEST_FLAGS(kFlagsValid, VNT, ONLY_ORIENTATION);
223230 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, VNT, ONLY_POSITION);
224231225225- TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, ONLY_ORIENTATION, P, VNT);
232232+ // ONLY_ORIENTATION relation is upgraded to position valid
233233+ TEST_FLAGS(kFlagsValid, ONLY_ORIENTATION, P, VNT);
226234 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, ONLY_POSITION, P, VNT);
227227- TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, VNT, ONLY_ORIENTATION, P);
235235+ // ONLY_ORIENTATION relation is upgraded to position valid
236236+ TEST_FLAGS(kFlagsValid, VNT, ONLY_ORIENTATION, P);
228237 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, VNT, ONLY_POSITION, P);
229238 }
230239}