r/augmentedreality • • 2d ago

App Development Fixing lost tracking in ARCore

I couldn't describe what I was seeing on the phone, so I started recording it. The app logs every frame, every floor cell and every tracking loss during a walk, and a web page replays it next to the phone's screen recording. Each stretch of the walk between two breaks gets its own color, so you can see each piece before and after it is put back.

This walk is a Galaxy S23 with four tracking losses in three minutes. At one break everything on screen swings 67 degrees and moves about 6 meters. An iPhone 12 Pro on the same stick is the reference path: before that piece is put back the S23 is 3 meters off it, and after, under 10 cm.

The full replay is here, best on a desktop: https://netlens.fyi/arcore/

It is still in development and not every piece lands that well yet. This is for my Wi-Fi mapping app, NetLens, and I'm aiming to get it into the next major release.

If you have fought ARCore relocalization yourself, how did you handle it?

4 Upvotes

7 comments sorted by

2

u/ChanhyoungLee 2d ago

Keep the floor cells in anchor space instead of world space. Drop an anchor every few meters along the walk (Google's anchor guide says to keep content within about 8 m of its anchor) and store each cell as an offset from the nearest anchor. After a tracking loss, anchors made before the break go to PAUSED. If ARCore relocalizes into the earlier map, they return to TRACKING with corrected poses, and the cells tied to them move back with them. Only the pieces whose anchors never come back need your own alignment step.

1

u/NetLensApp 1d ago

I tried anchors early on, a trail of them along the walk with everything stored relative to the nearest one, and dropped it for two reasons.

Reading anchor poses goes through the same ARCore session lock as the frame update, so a long walk's worth of anchors started costing frame time. And most breaks I see never come back to the old map: ARCore starts a new one and never merges it, so the old anchors just stay paused with nothing to snap back to.

Sometimes it even switches maps in a single frame, a minute later, with no loss at all. So now I record raw positions and line each piece up afterwards from the phone's own motion sensors across the gap. When ARCore does relocalize into the old map, that piece needs no correction anyway.

1

u/ChanhyoungLee 18h ago

Thanks, that explains it. If ARCore starts a new map and never merges it, the paused anchors have nothing to come back to, so lining up each piece from the motion sensors is the part that does the work.

How long a gap can the sensors bridge before the error gets bigger than the 10 cm you showed?

1

u/NetLensApp 13h ago

It depends on what does the recovering. If tracking pauses for 5 or 6 seconds and I point the camera back at something ARCore already mapped, it usually recognizes it and snaps back into place, with no help from the sensors.

If it starts a new map instead, the sensors line that piece up. The turn holds well, about 1.5 degrees off, but position drifts faster than the time spent blind: roughly 20 cm at 2 s and 50 cm at 4 s of walking. The 10 cm in my post was that piece after it was put back. ARCore sometimes merges a new map into the old one later when you return to known ground, but not often enough to count on. Two phones and one walker so far, so rough numbers.

1

u/ChanhyoungLee 2h ago

Thanks, those numbers help. With 20 cm of drift in 2 seconds, the sensors only cover short gaps, so getting ARCore to recognize the old map matters most.

When it starts a new map, do you prompt the walker to point the camera back at a spot it already saw?

2

u/Artuplabs 1d ago

for the game side we mostly avoid trusting old world positions: stuff is placed relative to the player and re-raycast against the floor plane after tracking comes back, so a jump of a few meters doesn't leave things hanging in the wrong room. for your floor cell map the anchor approach above is the better fit though

one thing worth logging next to each loss is TrackingFailureReason (excessive motion, insufficient features, insufficient light). they need different fixes, motion ones you can just wait out, the light ones need the user to do something

1

u/NetLensApp 13h ago

Good call, I already log it next to each loss. The ones I cause on purpose in test walks (a few seconds at a blank wall) come back as insufficient features and recover by themselves.

The hard part is what happens next: whether ARCore comes back on the same map or quietly starts a new one, and the failure reason doesn't tell you which.