fix muse s anthena timestamps#827
Conversation
Signed-off-by: Andrey Parfenov <a1994ndrey@gmail.com>
Signed-off-by: Andrey Parfenov <a1994ndrey@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f619fd385
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| double sample_timestamp = last_timestamp + (double)(sample_index + 1) / sampling_rate; | ||
| if (sample_timestamp <= current_timestamp) | ||
| { | ||
| timestamp_initialized = true; | ||
| first_device_tick = device_tick; | ||
| first_host_timestamp = get_timestamp (); | ||
| return sample_timestamp; |
There was a problem hiding this comment.
Keep per-packet timestamp interpolation monotonic
The new get_sample_timestamp logic can emit decreasing timestamps within a single payload because it decides per sample whether to use last + (sample+1)/sampling_rate or the interpolated step fallback. When current_timestamp - last_timestamp is smaller than n_samples/sampling_rate but larger than some early sample offsets (a normal jitter case), early samples take the fixed-rate path while later ones switch to interpolation, which can move backwards (e.g., with n_samples=4, sampling_rate=256, dt=10ms: sample 1 is 7.8125ms, sample 2 becomes 7.5ms). This breaks monotonic timestamps and can corrupt downstream time-based processing.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Summary
- Addressed the reviewer’s monotonicity concern in
get_sample_timestampby switching from per-sample fallback selection to a single mode per payload decision. Now the function uses fixed sampling-rate spacing only if the packet’s wall-clock span can cover the nominal payload duration; otherwise it interpolates all samples with a uniform step across the packet interval. This prevents backward timestamps within the same packet under jitter. - Kept existing guard behavior for invalid sample/rate inputs, first-packet handling, and non-increasing packet timestamps unchanged.
- Committed the fix on the current branch with commit
4b7b650and created a follow-up PR message viamake_prsummarizing the change.
Testing
- ✅
git diff --check -- src/board_controller/muse/muse_anthena.cpp - ✅
git status --short && git diff -- src/board_controller/muse/muse_anthena.cpp - ✅
git add src/board_controller/muse/muse_anthena.cpp && git commit -m "Fix Muse Anthena per-packet timestamp monotonicity"
No description provided.