Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/poser_mpfit.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,21 @@ static size_t construct_input_from_scene(const MPFITData *d, survive_long_timeco
if (isReadingValue) {
const FLT *a = scene->angles[sensor][lh];

/* Guard against non-finite angles from corrupted optical data
* (bad FPGA timestamps during USB disturbances). Passing NaN
* into the MPFIT solver causes it to produce a garbage pose
* that can then assert-crash downstream. One dropped measurement
* has negligible effect on the pose solve. */
if (!isfinite(a[axis])) {
static int warned = 0;
if (!warned) {
fprintf(stderr, "[libsurvive WARN] poser_mpfit: NaN optical angle sensor %d lh %d axis %d; suppressing further\n",
(int)sensor, (int)lh, (int)axis);
warned = 1;
}
continue;
}

survive_optimizer_measurement *meas =
survive_optimizer_emplace_meas(mpfitctx, survive_optimizer_measurement_type_light);

Expand Down
Loading