The open source OpenXR runtime

m/space: Restore upgrading of 3dof relations with valid positions

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2239>

authored by

Christoph Haag and committed by
Marge Bot
6d71c083 9da09d4d

+53 -23
+30 -9
src/xrt/auxiliary/math/m_space.cpp
··· 133 133 flags af = get_flags(a); 134 134 flags bf = get_flags(b); 135 135 136 - // If either of the relations does not have a valid or tracked flag, the entire chain loses that flag. 137 - flags nf = {}; 138 - nf.has_orientation = af.has_orientation && bf.has_orientation; 139 - nf.has_position = af.has_position && bf.has_position; 140 - nf.has_tracked_orientation = af.has_tracked_orientation && bf.has_tracked_orientation; 141 - nf.has_tracked_position = af.has_tracked_position && bf.has_tracked_position; 142 - nf.has_linear_velocity = af.has_linear_velocity && bf.has_linear_velocity; 143 - nf.has_angular_velocity = af.has_angular_velocity && bf.has_angular_velocity; 144 - 145 136 struct xrt_pose pose = XRT_POSE_IDENTITY; 146 137 struct xrt_vec3 linear_velocity = XRT_VEC3_ZERO; 147 138 struct xrt_vec3 angular_velocity = XRT_VEC3_ZERO; ··· 158 149 // work. The flags of the result are determined in nf and not taken from the result of the transform. 159 150 make_valid_pose(af, &a->pose, &body_pose); 160 151 make_valid_pose(bf, &b->pose, &base_pose); 152 + 153 + 154 + // This is a band aid to make 3dof devices work until we have a real solution. 155 + // A 3dof device may return a relation with only orientation valid/tracked and no position. 156 + // 157 + // Monado wants to apply a predefined offset to 3dof devices, giving them a position. 158 + // 159 + // But per the comment below "If either of the relations does not have a valid or tracked flag, the entire chain 160 + // loses that flag". 161 + // 162 + // For now we upgrade every relation that only has an orientation, to also have a position. Note that 163 + // make_valid_pose zeroed the position if has_position was not set originally, ensuring there are no garbage 164 + // values propagated. 165 + if (af.has_orientation && !af.has_position) { 166 + af.has_position = true; 167 + } 168 + if (bf.has_orientation && !bf.has_position) { 169 + bf.has_position = true; 170 + } 171 + 172 + 173 + // If either of the relations does not have a valid or tracked flag, the entire chain loses that flag. 174 + flags nf = {}; 175 + nf.has_orientation = af.has_orientation && bf.has_orientation; 176 + nf.has_position = af.has_position && bf.has_position; 177 + nf.has_tracked_orientation = af.has_tracked_orientation && bf.has_tracked_orientation; 178 + nf.has_tracked_position = af.has_tracked_position && bf.has_tracked_position; 179 + nf.has_linear_velocity = af.has_linear_velocity && bf.has_linear_velocity; 180 + nf.has_angular_velocity = af.has_angular_velocity && bf.has_angular_velocity; 181 + 161 182 162 183 // Not already valid poses needed to be made valid because the transoformed pose would be undefined otherwise 163 184 // and we still want e.g. valid positions.
+23 -14
tests/tests_relation_chain.cpp
··· 87 87 88 88 enum Functions 89 89 { 90 - NV, // (Non-Identity) (Space Relation) Not Valid Not Tracked 91 - VT, // (Non-Identity) (Space Relation) Valid Tracked 92 - VNT, // (Non-Identity) (Space Relation) Valid Not Tracked 90 + NV, // (Non-Identity) (Space Relation) Neither Position/Orientation Valid, Not Tracked 91 + VT, // (Non-Identity) (Space Relation) Position/Orientation Valid, Tracked 92 + VNT, // (Non-Identity) (Space Relation) Position/Orientation Valid, Not Tracked 93 93 P, // (Non-Identity) Pose 94 94 IP, // Identity Pose 95 - ONLY_ORIENTATION, // (Non-Identity) (Space Relation) Only orientation 96 - ONLY_POSITION, // (Non-Identity) (Space Relation) Only position 95 + ONLY_ORIENTATION, // (Non-Identity) (Space Relation) Only orientation Valid, Not Tracked 96 + ONLY_POSITION, // (Non-Identity) (Space Relation) Only position Valid, Not Tracked 97 97 }; 98 98 99 99 static void ··· 179 179 TEST_FLAGS(kFlagsValid, VT, VT, VNT, VT); 180 180 TEST_FLAGS(kFlagsValid, IP, VT, P, VNT, P, VT); 181 181 182 - TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, VT, ONLY_ORIENTATION); 182 + // ONLY_ORIENTATION relation is upgraded to position valid 183 + TEST_FLAGS(kFlagsValid, VT, ONLY_ORIENTATION); 183 184 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, VT, ONLY_POSITION); 184 - TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, ONLY_ORIENTATION, VT); 185 + // ONLY_ORIENTATION relation is upgraded to position valid 186 + TEST_FLAGS(kFlagsValid, ONLY_ORIENTATION, VT); 185 187 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, ONLY_POSITION, VT); 186 188 187 - TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, P, VT, ONLY_ORIENTATION, P); 189 + // ONLY_ORIENTATION relation is upgraded to position valid 190 + TEST_FLAGS(kFlagsValid, P, VT, ONLY_ORIENTATION, P); 188 191 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, P, VT, ONLY_POSITION, P); 189 - TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, P, ONLY_ORIENTATION, VT, P); 192 + // ONLY_ORIENTATION relation is upgraded to position valid 193 + TEST_FLAGS(kFlagsValid, P, ONLY_ORIENTATION, VT, P); 190 194 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, P, ONLY_POSITION, VT, P); 191 195 } 192 196 ··· 214 218 TEST_FLAGS(kFlagsValid, P, VNT, IP, P); 215 219 TEST_FLAGS(kFlagsValid, P, IP, VNT, P); 216 220 217 - TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, P, ONLY_ORIENTATION, IP, P); 221 + // ONLY_ORIENTATION relation is upgraded to position valid 222 + TEST_FLAGS(kFlagsValid, P, ONLY_ORIENTATION, IP, P); 218 223 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, P, ONLY_POSITION, IP, P); 219 224 220 - TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, ONLY_ORIENTATION, VNT); 225 + // ONLY_ORIENTATION relation is upgraded to position valid 226 + TEST_FLAGS(kFlagsValid, ONLY_ORIENTATION, VNT); 221 227 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, ONLY_POSITION, VNT); 222 - TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, VNT, ONLY_ORIENTATION); 228 + // ONLY_ORIENTATION relation is upgraded to position valid 229 + TEST_FLAGS(kFlagsValid, VNT, ONLY_ORIENTATION); 223 230 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, VNT, ONLY_POSITION); 224 231 225 - TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, ONLY_ORIENTATION, P, VNT); 232 + // ONLY_ORIENTATION relation is upgraded to position valid 233 + TEST_FLAGS(kFlagsValid, ONLY_ORIENTATION, P, VNT); 226 234 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, ONLY_POSITION, P, VNT); 227 - TEST_FLAGS(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT, VNT, ONLY_ORIENTATION, P); 235 + // ONLY_ORIENTATION relation is upgraded to position valid 236 + TEST_FLAGS(kFlagsValid, VNT, ONLY_ORIENTATION, P); 228 237 TEST_FLAGS(XRT_SPACE_RELATION_POSITION_VALID_BIT, VNT, ONLY_POSITION, P); 229 238 } 230 239 }