Skip to content

fix muse s anthena timestamps#827

Merged
Andrey1994 merged 6 commits intomasterfrom
muse_timestamps
Apr 28, 2026
Merged

fix muse s anthena timestamps#827
Andrey1994 merged 6 commits intomasterfrom
muse_timestamps

Conversation

@Andrey1994
Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Andrey Parfenov <a1994ndrey@gmail.com>
Signed-off-by: Andrey Parfenov <a1994ndrey@gmail.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +980 to +983
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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@codex adress this feedback

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

  • Addressed the reviewer’s monotonicity concern in get_sample_timestamp by 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 4b7b650 and created a follow-up PR message via make_pr summarizing 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"

View task →

@Andrey1994 Andrey1994 merged commit 251edd7 into master Apr 28, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant