State desync fr this time#196
Conversation
|
Doxygen warnings output: (if empty, there are no warnings). Please correct any warnings before merging. |
| 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; |
There was a problem hiding this comment.
This callback updates comms_data while the main loop could be copying it in send_to_comms().
There was a problem hiding this comment.
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.
Co-authored-by: ericv555 <46249794+ericv555@users.noreply.github.com>
| @@ -78,4 +83,4 @@ void StereoCamTrigger::send_to_comms() const { | |||
|
|
|||
| sendable.data = comms_data; | |||
There was a problem hiding this comment.
| 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.