Image Streams Now Stop When Connection Closed (ROS2) #172
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WARNING: This has only been tested in ROS1. I have not confirmed the issue, compiled, or tested the fix in ROS2 yet.
Public API Changes
None
Description
I have a setup where my camera and my host computer are using different time domains (camera time is significantly ahead of computer time). I'm using the jpeg image streamer to stream to a browser. I found that when I close the image stream window in my browser, the subscription was not getting closed.
This is because the isBusy() function was comparing image header time stamp to ros::Time::now() when checking if pending footers were too old and needed to be removed. It would never clear old footers from the queue, preventing it from sending new images. Preventing sending new images meant that exceptions would never bubble up from the async_web_server library to indicate a connection issue
Forcing all time stamping to use ros::Time::now() instead of camera time fixed this issue because there was no longer a time domain mismatch. I chose to use system time instead of image header time because the restreamFrame() function also needs to make a timeout decision, but does not have an image header to compare to. It would be possible to use image header time all the way through by saving the latest image header timestamp, but it doesn't seem beneficial because there is no consumer for accurate camera timestamps from what I can tell. Maybe some of the other image streams care about this?
#171