Skip to content

Conversation

@NicholasIanMerritt
Copy link
Contributor

What changed?

Added running variance calculation and report of stdev to the remote …

How does it make Bristlemouth better?

better lc data

Where should reviewers focus?

Any breaking changes I made?

Checklist

  • Add or update unit tests for changed code
  • Ensure all submodules up to date. If this PR relies on changes in submodules, merge those PRs first, then point this PR at/after the merge commit
  • Ensure code is formatted correctly with clang-format. If there are large formatting changes, they should happen in a separate whitespace-only commit on this PR after all approvals.

…messages for the loadcell

removed problematic submodule

added Loadcell to beginning of message
@NicholasIanMerritt NicholasIanMerritt changed the title Added running variance calculation and report of stdev to the remote Added running variance calculation and report of stdev to remote LC messages Apr 14, 2025
Comment on lines +137 to 139
sprintf(data_string, "Loadcell | mean force: %f | max force: %f | min force: %f | stdev: %f | reading count: %d", mean_force,
max_force, min_force, stdev, cellular_send_read_counter);

Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend using snprintf here to avoid a buffer overflow of data_string. There also is some optimization if you make data_string a static variable. This way, the memory is allocated at compile time rather than every time this function is ran, saving you processing cycles and task memory usage.

Comment on lines +53 to +56
float running_mean = 0;
float running_var = 0;
float old_mean = 0;
float stdev = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

These values will be reset to zero every time this function is ran. To avoid this create a variable that will be static. That way the value is retained every time this function is ran. Note how max_force, min_force and mean_force are all static variables.

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.

3 participants