personalrobotics / feeding_web_interface

Web interface for the robot-assisted feeding system
1 stars 0 forks source link

Temporary fix for video latency #111

Closed amalnanavati closed 10 months ago

amalnanavati commented 10 months ago

Describe this pull request. Link to relevant GitHub issues, if any.

Joint PR with ada_feeding#151

Although #106 improved video streaming by replacing the dependency on web_video_server with direct subscription to compressed images, the latency of this approach depends on the device. On a desktop computer, the video stream has 1-3 sec latency, but on an iPhone 11, it has increasing latency that gets into the tens of seconds.

Looking into it, the most likely reason for this is that roslibjs uses EventEmitter2's emit event, which is synchronous. Thus, even if the subscriber on the ROS side has no queue, a queue builds up on the web app side.

The best solution to this, as documented here, is to implement WebRTC peer-to-peer streaming between the robot and web app. That is documented in issue #112 .

However, given the learning curve and time involved in implementing WebRTC, this PR and its affiliated PR ada_feeding#151 introduces a temporary fix to the problem, in the following ways:

  1. Rate-limits the publication of image topics that the web app subscribes to to 3 Hz. (parameter set both in ada_feeding_perception/config/republisher.yaml and in VideoFeed.jsx)
  2. Every 10 seconds, have the web app unsubscribe and re-subscribe to the topic, to clear any backlog. (parameter set in VideoFeed.jsx)

Note that these parameters can be tuned to find a subjectively optimal setting.

Explain how this pull request was tested, including but not limited to the below checkmarks.


Before creating a pull request

Before merging a pull request