Skip to content

Commit

Permalink
Modify DoubleSyncBuffer sync
Browse files Browse the repository at this point in the history
  • Loading branch information
VyaasBaskar committed Jan 15, 2025
1 parent a477fd1 commit df66b9c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/frc846/cpp/frc846/math/DoubleSyncBuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ void DoubleSyncBuffer::Sync() {

for (int shift = 0; shift < max_sync_diff_; shift++) {
double correlation = 0.0;
for (size_t i = 0; i < m_buffer_1.size(); i++) {
size_t sz = m_buffer_2.size() - shift;
for (size_t i = 0; i < sz; i++) {
correlation += m_buffer_1[i] * m_buffer_2[i + shift];
}
correlation /= sz;
if (correlation > max_correlation) {
max_correlation = correlation;
sync_diff_ = shift;
Expand Down

0 comments on commit df66b9c

Please sign in to comment.