Skip to content

State desync fr this time#196

Open
Sammyboyo wants to merge 7 commits into
mainfrom
state-desync-2
Open

State desync fr this time#196
Sammyboyo wants to merge 7 commits into
mainfrom
state-desync-2

Conversation

@Sammyboyo

@Sammyboyo Sammyboyo commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

adds a counter that tracks the number of frames that have been triggered which is what we use to sync the robot state with a given camera frame.

Most of the code is actually a new comms packet that is used to test round trip latency of comms.

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

Doxygen warnings output: (if empty, there are no warnings). Please correct any warnings before merging.

  

@Sammyboyo Sammyboyo requested a review from Rishi-H June 7, 2026 23:24
if(estimated_state_map_interrupt_safe != nullptr) {
// copy the estimated state map to the local estimated state map
estimated_state_map_interrupt_safe->fill_state_array(comms_data.state);
comms_data.frame_count = counter;

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.

This callback updates comms_data while the main loop could be copying it in send_to_comms().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe that it is impossible for the send to comms to ever get a garbage value because setting an int is only 1 instruction, and either getting the old or new value is chill I think.

Comment thread src/comms/data/test_data.hpp Outdated
Comment thread src/sensors/StereoCamTrigger.hpp Outdated
Co-authored-by: ericv555 <46249794+ericv555@users.noreply.github.com>
@@ -78,4 +83,4 @@ void StereoCamTrigger::send_to_comms() const {

sendable.data = comms_data;

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.

Suggested change
sendable.data = comms_data;
noInterrupts();
sendable.data = comms_data;
interrupts();

I would prevent interrupts from going off while comms_data is being copied. Otherwise, comms_data could be interrupted and modified in the middle of this copy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe that Rishi and I tried that but we got some weird slow loop times because of it and it seems to work ok without it, but we should probably look into it some more.

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.

I would try it again and make sure it is only that one line in it. The assignment to sendable shouldn't be more than 7 or 8 instructions, so it shouldn't cause a slowdown. If the send to comms line was in the noInterrupts it may cause a problem. If it doesnt work its no big deal though the assignment is so fast its probably really unlikely for the interrupt to go off during it.

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.

4 participants