Map Scanning (Non-LiDAR)
Record a new VPS map on an Android device without LiDAR: the MultiSetMappingSource boundary, the scan lifecycle, drafts and uploads.
Overview
From version 2.1.0 the Android SDK can record a new map. A scan keeps camera frames, plus depth when the device has it, packages them as MappingData.zip, saves the package as a draft and uploads it to your account with the SDK's own credentials. No LiDAR sensor is needed. The API has the same shape as the iOS SDK's.
The scan engine lives in the SDK, behind MultiSetSDK.mapping (a MultiSetMapping). As with localization, your AR runtime supplies the camera through an interface, MultiSetMappingSource. The sample app's ARCore implementation is mapping/ArMappingSource.
The package follows the mobile map upload format, so a scan uploaded from the SDK is processed like any other mobile capture.
The host side
interface MultiSetMappingSource {
val depthSupported: Boolean // the AR session runs a depth API
val locationProvider: MappingLocationProvider? get() = null // geo-tags the map; 0, 0, 0 without it
fun startPreview() // camera running, coverage display still
fun startRecording() // clear the coverage display and accumulate
fun pause() // the SDK has stopped using the source
suspend fun acquireRGBFrame(): MappingRGBFrame? // the latest frame's pose; null while not tracking
}
interface MappingRGBFrame {
val position: Vec3 // raw AR camera pose
val rotation: Quat
val timestamp: Double // AR frame clock in seconds, monotonic
val hasDepth: Boolean // a depth image exists for this frame
fun readImage(): MappingCameraImage? // that same frame's pixels; null skips it
}Your app also reports to the facade, from the AR scene update and the activity lifecycle:
Pose first, pixels later, same frame. acquireRGBFrame() returns only the pose. The SDK calls readImage() only for a frame that passes every check: tracking has settled, the camera has moved at least 5 cm or turned at least 5°, and depth is present when the scan needs it. That call comes on the same main-thread turn, straight after acquireRGBFrame(), and must return the pixels of that frame. If the runtime has moved on, return null and the frame is skipped. Build the image with MappingCameraImage.copyOf(cameraImage, intrinsics, depthImage), which copies a YUV_420_888 image and an optional DEPTH16 image; you close both. Pass the raw pose and the camera image's own intrinsics. The SDK crops to 4:3, scales to 960 × 720 and converts the pose itself.
Tracking samples drive the scan. Report one MappingTrackingSample per AR camera update, with the runtime's MappingTrackingState (NORMAL, INITIALIZING, RELOCALIZING, EXCESSIVE_MOTION, INSUFFICIENT_FEATURES or UNAVAILABLE), the raw camera position, the frame time on the same clock as MappingRGBFrame.timestamp, the visible feature-point count and, if you have it, the ambient light intensity from 0 to 1. Frames are taken only while the latest sample is NORMAL, and a tracking loss or a pose jump deletes the frames from the second before it.
Depth is all or none. When depthSupported is true, the scan waits up to 2 s from the start of recording for a frame with depth. If one arrives, every frame the scan keeps carries depth. If none arrives in time, the whole scan is RGB only.
Running a scan
Call MultiSetMapping from the main thread. MultiSetMapping outlives the activity, so in onDestroy call endPreview() and setSource(null) only while the attached source is still your screen's own: a newer screen may have attached its source already.
scan is a StateFlow<MappingScanState>:
Idle
Nothing is recording.
Preparing on startScan(), or Failed when no source is attached.
Preparing
Checks that 1.5 GB is free and waits up to 15 s for a NORMAL tracking sample.
Mapping, or Failed.
Mapping
Takes a frame every 250 ms after a 1 s delay.
Zipping on stopScan() or at 10 minutes; Idle when shorter than 10 s; Failed on an error.
Zipping
Packages the scan; packagingProgress runs from 0 to 1.
Finished, or Failed.
Finished
MappingData.zip is ready.
Idle on saveDraft().
Failed(failure)
Nothing was kept. failure.message is text the user can act on.
Idle on acknowledgeFailure().
While recording, MappingScanState also reports savedFrames, blurredFrames and discardedFrames, showsMotionWarning (the camera moved or turned too fast), a tracking level (GOOD, WEAK or LOST) with the issue behind it, and autoStopReason when the SDK stopped the scan by itself.
Interruptions. Poses after an interruption are in a different world frame, so a scan never continues across one. Call reportSourceInterrupted() from onPause, before super.onPause(). A scan that has recorded at least 10 s is packaged as it stood; a shorter one fails and asks the user to start again. A scan that is already Zipping or Finished is still there when the user comes back.
Saving. saveDraft(name) needs a name of at least 3 characters and a Finished scan, and returns a MappingDraft (id, name, coordinates, frameCount, packageBytes, packagedAtMillis, thumbnailPath). The coordinates come from the source's locationProvider, or are 0, 0, 0 without one. discardScan() deletes the scan from any phase.
Drafts and upload
drafts lists the scans saved on this device and not yet uploaded, newest first. uploads maps a draft id to its MappingUploadState:
(no entry)
Idle. A successful upload removes the entry and the draft with it.
Preparing
Asking the service for an upload ticket.
Uploading(fraction)
Sending MappingData.zip, from 0 to 1.
Waiting(reason)
Queued, not transferring: a retry countdown, a draft parked until the app is opened again, or waiting for the SDK to authenticate.
Failed(message)
Not retried on its own. upload() tries again and dismissUploadFailure() clears the entry.
Retries. A dropped connection, HTTP 408, 429 or 5xx, or an expired upload URL is retried 5 times, after 10, 20, 40, 80 and 160 s. The draft is then parked until
resumeUploads().Authentication. Uploads use the SDK's tokens, from your client credentials or token provider. When those are refused, the draft waits and resumes after the next successful
initialize(). A token provider that fails is retried like a dropped connection.No duplicate maps. A retry re-uploads to the map the first attempt created.
In-process uploads. Android has no background transfer service here: the upload runs while your app's process runs, and the queue survives a restart.
initialize()resumes queued uploads after each successful authentication; also callresumeUploads()fromonResumeof the screens a user returns to.
Sample app screens
Home: Mapping card
"Create Map" and "Draft Maps", with a badge counting saved drafts.
MappingInstructionsActivity
"Before you scan": capture tips, with "Don't show this again".
MapScanActivity
Landscape scan screen: record and stop, a timer, tracking guidance, a "Move slower" warning and live coverage points, then a name card and upload progress.
DraftMapsActivity
The drafts saved on the device, each with a thumbnail, frame count, size, scan date and upload status, plus Upload, Retry and Delete.
Related
Last updated
Was this helpful?

