~/satyajit

Mobile SLAM: a Livox Mid-360 on an iPhone, and the 1,180 lines of C++ that map with it

mdjsonmcp

2026-11-16 · 26 min · slam · lidar · state-estimation · point-cloud · robotics · on-device · bim

A 2:31 narrated explainer, drawn in code. Every number and picture in it is this article's own; the sources are below.

› transcript

This iPhone is mapping a room from a LiDAR on an Ethernet cable. No laptop. The phone runs the whole thing. Hi, I'm Plumbob. Mobile SLAM's core is eleven hundred and eighty lines of C plus plus. Here is what they do. The sensor stamps points and IMU with its own clock. The phone's sensors never enter the estimate. A USB-C Ethernet adapter takes the address the sensor sends to. Plain UDP sockets catch the packets. No Livox SDK. If the filter falls behind, point packets are dropped, never IMU. One worker thread feeds the filter. The IMU predicts the motion during the sweep, and every point is moved to where it was really measured. Each point fits a plane through five map neighbours. Its residual is the distance to that plane. A gate drops points too far off, looser for distant ones. One cheap Kalman step. Re-associate and step again, at most four times. Only then does the uncertainty shrink. Mapping starts with a second of standing still, to find the gyro bias and which way is down. Then you walk. Every tenth of a second, a sweep is deskewed, matched and added to the map. FAST-LIO2 keeps a tree of nearby points and deletes what falls behind you. Mobile SLAM keeps one point per voxel in a hash table. Fast, tiny, and it only grows. To localise, the saved map is cut into one metre cells, and each becomes a Gaussian. A scan arrives slightly off. Climbing the score pulls it into the cells, and the pose goes into the filter. With no heading, it tries twelve headings at five starting points. It refines the best and accepts it when enough points match. On a real Mid-360: mapping. And localising, with ninety-nine percent of points matched. For scan to BIM, the gaps are specific. No loop closure, so drift leaves walls drawn twice. One raw return per cell, noise and all. Fixed calibration, no control points. And a blind radius that hides most of a stair core. Use the phone to record raw packets and check coverage on site. Map somewhere else. FAST-LIO's filter, rewritten small. NDT, fused properly. A logger, not a survey instrument. Every source is in the full article. I'm Plumbob. Bye!

Why read this

Notabletop 60%

The whole core read line by line: FAST-LIO's filter rewritten, a hash-voxel map, NDT relocalisation, the Mid-360's UDP path, and its own simulator run.

  • Interactive explanations
  • Original analysis
  • Runs on a phone

Robotics & embodiedMITPractitioner tool

How this was scored
Is it new?
1 of 3: An incremental tweak
Can I trust it?
2 of 3: Measures key facts from files, code or configs
Can I run it?
2 of 3: Open code or weights with real limits
Will I understand it?
3 of 3: Mechanism carried by interactives built from real code or data
Can I act on it?
2 of 3: A concrete recipe, numbers or comparison
Will it last?
2 of 3: A reference for a year or more
Does it affect many?
1 of 3: A specialist community
Only here?
2 of 3: A teardown or measurement few others did

Score 67 of 100, ranked 250 of 773 rated articles. Each question is answered 0–3 by hand, and a 3 is rare. How articles are scored

On 13 November schan, the CTO of the Japanese robotics company IndustryAlpha, posted ten seconds of video with one line: "iPhone版できたわんー", roughly "the iPhone version's done". An iPhone lies on a desk with a USB-C cable in its port and a point cloud of the room growing on its screen. The cable runs, through an Ethernet adapter, to a Livox Mid-360, a 265 g LiDAR with its own IMU. There is no laptop anywhere in the chain.

The iPhone build mapping a room from a tethered Mid-360. Full 10 s clip, muted (video from @sm0219370893504's post on X).

Three days earlier he had done the same thing on an Android phone. I covered that post in the open robotics mapping roundup. Back then it linked no code and named no algorithm, so I guessed it was a FAST-LIO2-style odometry. Since then the pieces have arrived one a day. On 12 November he showed a 3D-printed holder that bolts the sensor to the phone, and on 14 November a case for an iPad mini, designed with SolidCraft and Claude, after the app turned out to run on iPads too. The iOS app went live on the App Store on 14 November. On 15 November he published both repositories under MIT: Mobile-SLAM-iOS and the Android Mobile-SLAM.

schan-lab/Mobile-SLAM-iOS@e6d857b · snapshot 2026-11-23

iPhone version of Mobile SLAM (Livox Mid-360 LIO / NDT)

stars
22
license
MIT
branch
main
forks
1
open issues
1
source
325.9 kB
commit date
2026-11-16
source by language
Swift186.1 kBC++118.0 kBC9.0 kBHTML7.1 kBPython3.6 kBMetal2.1 kBObjective-C0.0 kB

GitHub REST API, 2026-11-23 — branch, createdAt, description, forks, license, openIssues, pushedAt, stars

The SLAM is in core/. It is six files and 1,180 lines of C++17 on top of Eigen 3.4, byte-identical between the two repositories apart from one comment. Swift, SwiftUI and Metal on iOS, and Kotlin with JNI on Android, wrap it. I read every line of core/ and the iOS code that feeds it, at commit 13f2e30. This article goes through what is in there, what I could measure, and what this rig would and would not do for the work I care about, which is turning a walk through a building into a model of it.

From the Ethernet jack to the filter

The Mid-360 speaks 100BASE-TX Ethernet and nothing else. The phone needs a USB-C Ethernet adapter, or on a Lightning iPhone Apple's Lightning to USB 3 camera adapter with a USB one behind it. The README's setup is simple. Give the phone's wired interface the static address the Mid-360 sends to, which is 192.168.1.50/24 from the factory, and grant the app iOS's Local Network permission. Without that permission the packets never reach the app. The app triggers the prompt early with a throwaway Bonjour browse, which is the documented trick. The LiDAR draws 6.5 W from its own 9 to 27 V supply, so the phone only has to power the adapter.

A hand holding a black 3D-printed holder. A Livox Mid-360 with its blue dome sits on top, and an Android phone below shows a point cloud and green status chips. A USB-C Ethernet adapter cable hangs from the bottom of the phone.
The holder from 12 November, here with the Android phone: Mid-360 on top, a USB-C Ethernet adapter at the bottom, the sensor on its own power lead (photo from @sm0219370893504's post on X).

Nothing from Livox ships in the app. LidarReceiver.swift opens four plain BSD UDP sockets bound to INADDR_ANY: point cloud on 56301, IMU on 56401, status push on 56201 and discovery on 56001. Each gets a 4 MB receive buffer and its own thread at userInteractive priority. A fifth thread broadcasts a discovery request every three seconds so the app can show the sensor's serial number and IP. Mid360Config.swift speaks enough of Livox's SDK2 control protocol to read and rewrite the sensor's own address and destination, with command 0x0101 to read, 0x0100 to write and 0x0200 to reboot. Each command carries a CRC-16 over its header and a CRC-32 over its data. THIRD_PARTY_NOTICES.md calls all of this "an independent implementation; no Livox SDK code is included", and tools/fake_mid360.py is a stand-in control port for testing it.

The packet decoder is 91 lines (core/livox_packet.hpp). A point packet has a 36-byte header. Its 64-bit nanosecond timestamp sits at byte 28, followed by dot points of 14 bytes each: three int32 millimetre coordinates, a reflectivity byte and a tag byte. A point's time is the packet stamp plus its index times the packet's interval over dot. An IMU packet carries six floats, gyro in rad/s and acceleration in g, which the parser multiplies by 9.81.

Points and IMU samples are stamped by the same clock inside the Mid-360. I think that is the best design decision in the project, and a large part of why it works at all: the phone's own clock, IMU and camera never enter the estimate, so there is no phone-to-sensor time synchronisation to get wrong. The phone is a computer with a screen and an Ethernet port. On the receive thread every packet is copied into a queue, and one worker thread drains it into the filter 256 packets at a time.

FAST-LIO's filter, written again

core/lio.hpp opens with "LiDAR-inertial odometry following the FAST-LIO formulation (W. Xu, F. Zhang, 'FAST-LIO', RA-L 2021) … Independent implementation (not derived from the GPL reference code)". That matches what is in the file. It is the filter from FAST-LIO, rebuilt small, with one idea from FAST-LIO2 and a map from neither. If you have read my FAST-LIO2 walkthrough, here is the diff.

FAST-LIO2 (paper and reference code)Mobile SLAM core/lio.cpp
error state23-D: pose, LiDAR-IMU extrinsic, velocity, both biases, gravity on S2S^215-D: δθ,δp,δv,δbg,δba\delta\theta, \delta p, \delta v, \delta b_g, \delta b_a
gravityestimatedfixed at 9.81 m/s², direction from the first second of IMU
extrinsicestimated onlinefixed Mid-360 default, t_LI = (-0.011, -0.02329, 0.04412) m
registrationraw points after a voxel filter, no featuresraw points averaged per 0.2 m voxel, no features
mapikd-Tree, exact k-NN, a cube that slides with the sensorhash of 0.2 m voxels, one point per voxel, 27-voxel k-NN, never trimmed
updateiterated, information-form gainthe same, at most 4 iterations
loop closurenonenone

Point for point, the measurement model is FAST-LIO's. Each downsampled point pbp_b is moved into the world with the current estimate, pw=R pb+tp_w = R\,p_b + t. Its five nearest map points are fitted with a plane n⊤x+d=0n^\top x + d = 0 by solving Aw=−1A w = -\mathbf{1}, and the fit is thrown out if any of the five sits more than 10 cm off it. The residual is the signed distance r=n⊤pw+dr = n^\top p_w + d. Then comes the gate FAST-LIO uses: keep the point only if

s=1−0.9 ∣r∣∥pb∥>0.9,s = 1 - \frac{0.9\,|r|}{\sqrt{\lVert p_b\rVert}} > 0.9 ,

which tolerates a larger residual on a far point (about 22 cm at 4 m, 35 cm at 10 m). The Jacobian row is ∂r/∂δθ=−n⊤R [pb]×\partial r/\partial\delta\theta = -n^\top R\,[p_b]_\times and ∂r/∂δp=n⊤\partial r/\partial\delta p = n^\top. Only the first six error states see a LiDAR measurement directly. Velocity and the biases get corrected through their covariance with pose.

The update is the information form that makes FAST-LIO cheap, inverting a 15 × 15 matrix whatever the number of points:

// core/lio.cpp, iekfUpdate(): one iteration
Mat15 A = Pinv;
A.block<6, 6>(0, 0) += HtH * inv_rm;               // P^-1 + H^T H / R
Mat15 Ainv = A.inverse();
KH.block<15, 6>(0, 0) = Ainv.block<15, 6>(0, 0) * HtH * inv_rm;
Vec15 delta = -Ainv.block<15, 6>(0, 0) * Htr * inv_rm + (KH - Mat15::Identity()) * dx;

dx is how far the iterate has moved from the IMU prior. Each pass re-associates every point at the new estimate, so a scan that starts 20 cm off can snap into place over two or three passes. It stops after four iterations, or when the rotation step drops under 1e-4 rad and the position step under 1 mm. With fewer than 20 usable points the scan is counted as "degenerate" and the update is skipped. Only after the last pass does the covariance become (I−KH)P(I - KH)P. The measurement noise is laser_cov = 0.001, FAST-LIO's default.

The widget below runs that loop on a planar toy: three states instead of fifteen, walls instead of five-point plane fits, the gate and gain exactly as written. Step it in the room, then in the corridor.

The corridor is the case worth staring at. Every wall normal points across the corridor, so HH has nothing in the along-corridor column. The information form then leaves that axis at the prior: the IMU's error along the corridor survives the update untouched, and so does its σ. The code's degenerate counter does not notice, because it counts scans with fewer than 20 points, not scans whose points all say the same thing. FAST-LIO2's reference code has no check for this either. In 3D a real corridor usually offers a door frame, a light fitting or the end wall, which is enough. An office corridor with bare walls and a far end out of range is where handheld LiDAR mapping slides.

Propagation, deskewing and the first second

The IMU path is plain strapdown propagation, not preintegration. integrate() takes the midpoint of consecutive samples, subtracts the biases, rotates acceleration into the world, adds gravity, and steps position, velocity and attitude. It propagates the covariance with the usual 15 × 15 transition and adds process noise as variance times Δt2\Delta t^2 on the diagonal. Every step records the state at its start in a Seg. That record is what removes the motion blur. A Mid-360 sweep takes 100 ms. For each point, the code finds the IMU segment its timestamp falls in, extrapolates that segment's pose to the point's own time, and re-expresses the point in the IMU frame at the end of the scan:

pend=Rend⊤(Ri (RLI pL+tLI)+Pi−Pend).p_{\text{end}} = R_{\text{end}}^\top\big(R_i\,(R_{LI}\,p_L + t_{LI}) + P_i - P_{\text{end}}\big).

FAST-LIO walks backwards through the IMU samples to do this. Here the forward segments are kept and indexed. The result is the same per-point pose; it just keeps a small vector instead of re-integrating.

Initialisation wants the sensor still. The first 200 IMU samples (one second at 200 Hz) are averaged: the mean gyro becomes the gyro bias, the mean acceleration's direction becomes "down", and its magnitude sets an accelerometer scale that forces it to read exactly 9.81. The stillness test leans on the gyro (variance under 0.01, mean rate under 0.15 rad/s, with a loose accelerometer variance bound of 1.0) because, the comment says, the Mid-360's motor vibration can make the accelerometer noisy while the device is stationary. After four failed half-second windows ("~2.5 s", says the comment) it stops waiting and initialises anyway. In the app this is the orange "静止してください" (please keep still) banner you can see at the start of the screen recording below.

The Android app mapping a room with the holder: still for initialisation, then mapping. At 0:10 the overlay reads 146,581 points, Mid-360 193k点/s and IMU 199Hz. First 14.5 s of the 29 s recording, muted (video from @sm0219370893504's post on X).

A map that only grows

FAST-LIO2's ikd-Tree keeps a cube of map around the sensor. As you walk it deletes whole boxes behind you, so the search structure stays the same size however far you go. Mobile SLAM's registration map in core/voxel_map.hpp is a std::unordered_map from a packed 63-bit voxel key to one point. The voxels are 0.2 m, the point is the first one ever inserted there, and nothing is ever removed. The k-NN query looks in the 27 voxels around the query and sorts what it finds, so it returns at most 27 candidates from roughly a 60 cm cube. That is the iVox idea from Faster-LIO (which keeps several points per voxel and evicts old voxels), taken to its most frugal form. Lookups are constant time and the code is 96 lines. The cost is that the map's memory grows with the area covered, and its five "nearest neighbours" can be up to a voxel diagonal apart.

A second store keeps the map you see and export. It holds one point per 5 cm voxel, again the first to arrive, with its reflectivity. "Save PCD" writes that store as binary x y z intensity. Two properties of it matter for anyone who wants the PCD as data rather than a picture:

How big does it get? The in-app demo is a box room 15 × 10 × 4 m, which is 500 m² of floor, ceiling and walls. The demo map in the app's own App Store screenshot holds 204,166 points, about 408 per m² against the 400 per m² that one point per 5 cm cell would give a flat surface. By my arithmetic, at roughly 48 bytes per display point in a std::unordered_map plus two vectors, that room costs about 10 MB, and a floor of a building with 10,000 m² of surface would cost about 200 MB before rendering. The renderer subsamples to at most 800,000 points, and a PCD loaded for localisation is subsampled to 6 million. Version 1.1, released on 16 November, lists "長時間使ったときにメモリ使用量が増え続ける問題を修正しました" (fixed memory use that kept growing during long sessions). The design is still append-only, so the map's own memory still grows with the ground you cover.

The iOS app's PCD viewer showing a saved synthetic map from above: a teal rectangular floor with a few orange and yellow box obstacles standing on it. The header reads map_20261114_093012.pcd, 204,166 points, 15.1 by 10.1 by 4.0 metres, binary, 3 ms.
The app's PCD viewer on a map built in demo mode, the simulated 15 × 10 × 4 m room: 204,166 points (App Store screenshot from the repository's AppStore/screenshots/ja, demo data, not a real scan).

Finding yourself in a saved map

Load a saved PCD, switch to 自己位置推定 (localisation), and the filter changes job. The LiDAR stops updating the map and stops feeding point-to-plane residuals. Instead, each scan is matched against the prior map with the Normal Distributions Transform, P2D-NDT after Magnusson's 2009 thesis, in core/ndt.cpp (131 lines), and the result is fed into the same Kalman filter as a pose measurement.

NDT replaces the map's points with Gaussians. The prior map is cut into 1 m cells. Any cell with at least six points keeps its mean μ\mu and covariance Σ\Sigma. Small eigenvalues are lifted to 1 % of the largest so a flat wall does not produce a singular covariance. A scan point xx, already moved by the candidate pose, scores against its own cell and the six face neighbours:

score=∑points∑cells−d1exp⁡ ⁣(−d22 (x−μ)⊤Σ−1(x−μ)),\text{score} = \sum_{\text{points}} \sum_{\text{cells}} -d_1 \exp\!\Big(-\tfrac{d_2}{2}\,(x-\mu)^\top\Sigma^{-1}(x-\mu)\Big),

with d1,d2d_1, d_2 from Magnusson's fit for an outlier ratio of 0.55. The pose that maximises it is found with Gauss-Newton. Each step is clamped to 0.5 m and 0.2 rad, and there are up to 30 iterations while tracking. A point "matches" when its Mahalanobis distance to some cell is under 3σ (q<9q < 9), and the match ratio is what the app shows as 一致 (match). On a scan voxelised at 0.4 m, tracking accepts a result at a match of 0.35 or better. Twenty failures in a row and the state goes to "lost".

Unlike point-to-plane, NDT needs no nearest-neighbour search and copes with a sparse prior. Its weakness is the basin. A point only feels cells within one cell of where it lands, so a starting guess more than about a cell off has nothing to pull it the right way. The planar toy below is built from the same constants. Move the start and watch the scan converge or settle on the wrong walls, then switch on the global search.

The global search is how the app finds itself with no starting pose. You can tap a position on the map and drag a heading, or leave the heading out. The filter accumulates five scans while you stand still, levels them with its gravity estimate, and runs a coarse NDT of 12 iterations from every combination of 12 headings, 30° apart, and five positions: the guess and four points 1 m away. That is 60 starts. It refines the best-scoring one with 60 iterations and accepts it at a match of 0.45 or better, 45 % of points. If the search fails, the dead-reckoned position is pinned back to the guess so the IMU cannot carry it away while it waits.

Once tracking, NDT's answer goes into the filter as a direct measurement of the first six error states. HH is a selector, the residual is [ Log(R⊤Rm), pm−p ][\,\mathrm{Log}(R^\top R_m),\ p_m - p\,], and the measurement noise is 10−410^{-4} rad² and 4×10−44\times10^{-4} m², about 0.6° and 2 cm. Between scans the IMU carries the pose, so NDT always starts from a prediction 100 ms old. That keeps it inside its basin while you walk.

Two iPhone screenshots side by side. Left: mapping, with green chips reading Ethernet, Mid-360 161k points per second and IMU 200Hz, a timer at 0:11 and 42,116 points, over a coloured point cloud of a room. Right: localisation, with a chip reading 追跡中 (tracking) and 一致 99% (match 99%), the same room drawn from a loaded PCD and a red arrow for the sensor.
The iOS app on a real Mid-360: mapping at 0:11 with 42,116 points and 161k points/s (left), and localising against a saved map with a 99% match (right) (App Store screenshots from the repository's AppStore/screenshots/ja).

What the simulator says

The repository ships a Mid-360 simulator, MobileSLAM/Bridge/Mid360Synth.hpp. It drives the app's demo mode and the tools/mid360_sim.cpp packet generator. It ray-casts a 15 × 10 × 4 m room with six boxes, at 100,000 points a second by default, in 96-point packets with the Mid-360's −7° to 52° vertical field. It also emits 200 Hz IMU packets in the sensor's own format. The sensor stands still for 3 s and then moves along a smooth closed path while turning. Because it is the simulator's own path, every scan has a true pose to compare with.

I did not run any of it on my laptop. I wrote a harness that feeds the simulator's packets through the unmodified core/ as fast as one CPU core allows and compares the filter's pose at each scan with the simulator's truth. I ran it on a Linux server, built with the Xcode target's flags (-O3 -ffast-math). The run measures two things. One is how fast the core is per scan on a desktop core. The other is how close the pose stays to the truth, mapping and relocalising, when the inputs are clean.

The server is an Intel Core i7-6850K, one core pinned, with g++ 11.4.

runper scan, filter and mapper scan, whole step()pose error, rms / maxreal time
mapping, 100,000 pts/s, 120 s13.97 ms mean, 17.25 ms p9516.74 ms mean, 20.46 ms p951.38 cm / 1.62 cm5.3×
mapping, 200,000 pts/s, 120 s18.35 ms mean, 23.72 ms p9523.35 ms mean, 29.21 ms p951.44 cm / 1.74 cm3.6×
mapping, 100,000 pts/s, 600 s13.95 ms mean, 17.32 ms p9516.79 ms mean, 20.57 ms p951.51 cm / 1.68 cm5.3×

At the simulator's default rate a scan of about 9,800 points voxelises to about 4,446. Nearly all of them pass the gate (4,428 on average), and the filter converges in 1.78 iterations on average, well under its cap of four. Doubling the point rate to the Mid-360's real 200,000 a second costs a third more time per scan, not double, because the 0.2 m voxel filter absorbs most of the extra points. A scan arrives every 100 ms. On this desktop core the whole step takes about a quarter of that at the higher rate, which leaves a phone's performance cores some room but not a lot once Metal is drawing beside it. No scan was dropped and none counted as degenerate, but a synchronous harness cannot drop anything, so that line says nothing about the app's queues.

The error does not grow. Over 600 s and 289.8 m of path it sits between 1.2 and 1.6 cm from the first checkpoint to the last, and heading stays within 0.035°. Most of that 1.5 cm is a constant offset, not drift: it is in place by 30 s and barely moves after. My guess is the simulator, which puts its IMU at the LiDAR's origin, disagreeing with the 4 to 5 cm extrinsic core/ assumes, but I did not isolate it. The map is bounded because the room is. The registration map settles at 13,776 voxels, the display store at 272,311 points after 600 s, still creeping up as noise lands in new 5 cm cells, and peak resident memory for the whole process is 24.4 MB. That agrees with my estimate of about 10 MB for the display store of this room.

Relocalisation used a 60 s map of 240,954 points, which takes 35 to 46 ms to turn into NDT cells. I rotated and shifted the map and started the localiser from six guesses:

casemap rotatedstart offset from the map originguess errorresult
A100°1.7 mexacttracking at 1.5 s, 1.42 cm rms
B100°1.7 m1.0 mtracking at 1.5 s, 1.42 cm rms
C100°1.7 m3.0 mtracking at 4.0 s on the wrong pose: 180° out, 3.79 m rms, mean match 0.918
D100°26.6 mexactsame as A
E105°1.7 mexacttracking at 1.5 s, first pose 9.3 cm and 12.7° out, then 1.55 cm rms
F105°26.6 mexactsame as E

Three things come out of that. First, the global search is the expensive scan. The 60 coarse starts and the refinement take about 470 ms in one go, almost five scans' worth, after which tracking costs 3.2 to 5 ms of NDT per scan. Second, a heading 15° from the nearest coarse candidate is still found. The search's first answer is 12.7° out and accepted at a match of 0.459, just over the 0.45 bar, and the IMU-plus-NDT tracking pulls it in over the following scans. My planar toy predicted that starting far from the map's origin would hurt, because the clamped steps rotate about it. Cases D and F show it does not, at least here. Third, and the one that matters: from 3 m away, outside the 1 m search pattern, the localiser accepted a pose turned round by 180° in a room that is nearly symmetric end to end, and then tracked it confidently, at an average match of 0.918. The match ratio measures whether the scan fits a place in the map. It cannot tell you whether that place is the right one. On site, that is the failure to watch for: the app reports 追跡中 (tracking) with a high match while you are standing at the other end of the room.

Two caveats belong next to these numbers. The room is closed and the path is bounded, so the walls never leave view: this is tracking error in a best case, not drift over a walk through a building. And one desktop x86 core is not an A-series phone chip, under a phone's thermal limits, with Metal drawing 800,000 points beside it.

What a phone imposes

The phone sets four limits, and the code meets some of them and not others.

Background. iOS does not let the app run in the background, and the app does not try. Its plist declares no background modes. When the scene goes to .background, deactivate() stops the engine and closes the sockets. The map is kept and a recording is closed. Lock the phone or take a call mid-walk and mapping stops there. While the app is in front, it disables the idle timer so the screen does not sleep.

Falling behind. There are two pressure valves. The packet queue drops point packets, never IMU, once it holds 2,500 of them. The source comment says that is about a second of data, and at 200,000 points a second in the simulator's 96-point packets it is a little over one. The filter's own queue keeps at most five finished scans and drops the oldest. Both are counted and shown in the details panel as "drop scan" and "pkt". A dropped scan does not break the odometry, since the IMU bridges the gap. It is time the map does not see.

Heat. I found no use of ProcessInfo.thermalState anywhere in the app. The core does not shed work when the phone gets hot, by thinning the scan or skipping iterations. It slows down, and the queues above take the overflow.

Memory. This is the one that will end a long session, for the reasons in the map section. Nothing is evicted, and iOS kills an app that grows too far without asking.

The app also records the raw stream. Tap 記録 (record) and every UDP payload is written to raw/raw_<time>.livox, one record per packet: a type byte, a 16-bit length and the packet bytes. It lands in the Files app, excluded from iCloud backup. It is the app's own format, not Livox's LVX, but it is the SDK2 packets verbatim, and the decoder for it is the 91 lines above.

What this rig means for scan-to-BIM

My own capture work starts from 360° fisheye walks: rig structure from motion with IMU scale and gravity, then splats, meshes and point clouds, and from the clouds a building model. Cameras are cheap and pleasant to walk with, and they are at their worst exactly where buildings are: blank walls, repeated bays, low light, and metric scale that has to be argued for. A LiDAR on a stick fixes the last one outright. Ranges are metres, not a scale factor. A Mid-360 and a phone in a 3D-printed holder is the cheapest honest version of that I have seen with code attached.

It is not a survey instrument, and the gap is specific.

What I would use it for is the raw recorder, more than the map. Walk the site with the phone as a logger and a live coverage view, then run a proper pipeline offline. FAST-LIO2, or something with loop closure and control points, can read the same packets on a workstation. The live map tells you on site that you missed the plant room. The offline pass gives you the cloud you model from. The NDT localiser is useful too: walking an existing scan and seeing where you are on it is the start of a progress-capture workflow, as long as you give it a starting point and glance at the map before trusting it. In the simulator a guess 3 m off produced a confident lock turned the wrong way round.

Where I land

This is good engineering at a small scale. It is FAST-LIO's filter in 590 lines that a person can read in an evening, a Livox wire protocol in a few hundred more, an NDT localiser fused properly rather than bolted on, and a simulator that lets an App Store reviewer, or anyone, exercise the whole stack without the hardware. The trade-offs are the right ones for a phone demo: a hash map instead of a tree, a fixed calibration, no back end. Every one of them is also a reason not to treat the PCD as a deliverable. For reality capture I would install it, record raw, and do the mapping somewhere else. For a robotics student who wants to see an iterated Kalman filter work with nothing between them and the maths, it is the best starting point I know of.

If the phone has no LiDAR beside it, Accord is the camera-and-IMU route: an OpenVINS filter for the metres and Depth Anything 3 for the surfaces, tested on uncalibrated phones against a LiDAR iPhone's RTAB-Map map.

How I checked. I read core/ in full (lio.cpp, lio.hpp, ndt.cpp, ndt.hpp, voxel_map.hpp, livox_packet.hpp) and the iOS receiver, bridge, app model, simulator and project file at 13f2e30, and diffed core/ against the Android repository at 9dbb66b. The Mid-360 figures are from Livox's spec page; the app's version and dates are from Apple's lookup API. The two widgets are planar toys I wrote with the code's constants. The simulator numbers come from my harness, run on an Intel i7-6850K server, not on a phone. I did not have a Mid-360, so nothing here is measured on the real sensor, and nothing is measured on an iPhone.

Cite this article

For attribution, please use the following reference or BibTeX:

Satyajit Ghana, "Mobile SLAM: a Livox Mid-360 on an iPhone, and the 1,180 lines of C++ that map with it", ai.satyajit.si, November 2026.

bibtex
@misc{ghana2026mobileslamiphone,
  author = {Satyajit Ghana},
  title  = {Mobile SLAM: a Livox Mid-360 on an iPhone, and the 1,180 lines of C++ that map with it},
  url    = {https://ai.satyajit.si/articles/mobile-slam-iphone},
  year   = {2026}
}
share