Skip to content

Commit 2f4303c

Browse files
Mark Stalzerclaude
authored andcommitted
solve_global_scene: treat MP_MAXITER as calibration failure
MP_MAXITER (return code 5) means the solver exhausted its iteration budget without converging. The current code treats this as success (res <= 0 is false), so the unconverged — and potentially wrong — lighthouse positions are written to disk via survive_recording and the GSS result is accepted. On the next launch those positions are loaded as the starting point for calibration. If the unconverged solve is significantly wrong, all subsequent tracking is corrupted and the only recovery is to delete config.json. Adding res == MP_MAXITER to the failure condition rejects unconverged GSS solves the same way as explicit solver errors. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bf27b41 commit 2f4303c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/poser_mpfit.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,10 @@ bool solve_global_scene(struct SurviveContext *ctx, MPFITData *d, PoserDataGloba
957957

958958
survive_get_ctx_lock(ctx);
959959
survive_recording_write_matrix(ctx->recptr, 0, 5, "GSS", &R);
960-
bool status_failure = res <= 0;
960+
/* MP_MAXITER means the solver exhausted its iteration budget without
961+
* converging. The result is an intermediate, unconverged pose — treat it
962+
* as a failure so the bad lighthouse positions are not written to disk. */
963+
bool status_failure = res <= 0 || res == MP_MAXITER;
961964
FLT sensor_covariance = d->sensor_variance * d->sensor_variance;
962965
FLT sensor_error = sqrtf(mpfitctx.stats.sensor_error / mpfitctx.stats.sensor_error_cnt);
963966
if (status_failure || sensor_error > d->opt.max_cal_error) {

0 commit comments

Comments
 (0)