Skip to content

Commit 9ee9a29

Browse files
committed
add some extra logging
1 parent ae53826 commit 9ee9a29

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

code/mobile/android/PhoneVR/app/src/main/cpp/alvr_main.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ struct NativeContext {
4646
AlvrQuat lastOrientation = {0.f, 0.f, 0.f, 0.f};
4747
float lastPosition[3] = {0.f, 0.f, 0.f};
4848

49-
float currentMagnetometerValues[4] = {0.f, 0.f, 0.f, 0.f};
50-
5149
int screenWidth = 0;
5250
int screenHeight = 0;
5351
int screenRotation = 0;
@@ -159,6 +157,14 @@ AlvrPose getPose(uint64_t timestampNs) {
159157
ArCamera_getTrackingState(CTX.arSession, arCamera, &arTrackingState);
160158
if (arTrackingState != AR_TRACKING_STATE_TRACKING) {
161159
error("getPose: Camera is not tracking, using last position");
160+
if (arTrackingState == AR_TRACKING_STATE_PAUSED) {
161+
error("- AR tracking state is PAUSED");
162+
ArTrackingFailureReason failureReason;
163+
ArCamera_getTrackingFailureReason(CTX.arSession, arCamera, &failureReason);
164+
error("- Failure reason: %d", failureReason);
165+
} else if (arTrackingState == AR_TRACKING_STATE_STOPPED) {
166+
error("- AR tracking state is STOPPED");
167+
}
162168
returnLastPosition = true;
163169
ArCamera_release(arCamera);
164170
goto out;
@@ -171,19 +177,12 @@ AlvrPose getPose(uint64_t timestampNs) {
171177
float arRawPose[7] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
172178
ArPose_getPoseRaw(CTX.arSession, arPose, arRawPose);
173179

174-
175-
/* We use an anchor here for two things:
176-
*
177-
* 1. To determine floor position by finding the lowest detected plane. We do this by
180+
/* We determine floor position by finding the lowest detected plane. We do this by
178181
* placing an anchor in the center position of the plane, and if it's lower than the
179182
* currently placed anchor (CTX.floorAnchor), we replace it.
180183
*
181184
* (By default, ARCore's "world coordinates" space begins wherever the device is, but this
182-
* can desync over time. Anchor position adapts to world space movement.)
183-
*
184-
* ~~2. To determine the rotation of world space. This allows us to improve tracking.~~
185-
* nevermind, that doesn't seem to work, orientation is stuck :(
186-
*/
185+
* can desync over time. Anchor position adapts to world space movement. */
187186
ArTrackableList *trackables = nullptr;
188187
ArTrackableList_create(CTX.arSession, &trackables);
189188
ArFrame_getUpdatedTrackables(CTX.arSession, CTX.arFrame, AR_TRACKABLE_PLANE, trackables);
@@ -254,7 +253,6 @@ AlvrPose getPose(uint64_t timestampNs) {
254253
info("anchor pose %f %f %f %f %f %f %f", anchorRawPose[0], anchorRawPose[1], anchorRawPose[2], anchorRawPose[3], anchorRawPose[4], anchorRawPose[5], anchorRawPose[6]);
255254
}
256255

257-
258256
pose.position[0] = arRawPose[4];
259257
pose.position[1] = arRawPose[5] - anchorRawPose[5];
260258
pose.position[2] = arRawPose[6];
@@ -477,7 +475,10 @@ extern "C" JNIEXPORT void JNICALL Java_viritualisres_phonevr_ALVRActivity_resume
477475
jobject) {
478476
CardboardHeadTracker_resume(CTX.headTracker);
479477
if (CTX.arcoreEnabled && CTX.arSession != nullptr) {
480-
ArSession_resume(CTX.arSession);
478+
ArStatus arSessionStatus = ArSession_resume(CTX.arSession);
479+
if (arSessionStatus != AR_SUCCESS) {
480+
error("Failed to resume tracking: %d", arSessionStatus);
481+
}
481482
}
482483

483484
CTX.renderingParamsChanged = true;

0 commit comments

Comments
 (0)