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
11 changes: 11 additions & 0 deletions src/poser_mpfit.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ 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. */
Comment on lines 189 to +194

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment could be shortened, there's redundant information with the commit message.

/* Guard against non-finite angles from corrupted data. Passing NaN
 * into the MPFIT solver causes it to produce garbage post that can 
 * crash downstream.
 */

if (!isfinite(a[axis])) {
fprintf(stderr, "[libsurvive WARN] poser_mpfit: NaN optical angle sensor %d lh %d axis %d\n",
(int)sensor, (int)lh, (int)axis);
continue;
}

survive_optimizer_measurement *meas =
survive_optimizer_emplace_meas(mpfitctx, survive_optimizer_measurement_type_light);

Expand Down
Loading