personalrobotics / feeding_web_interface

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

Revamp In-App Video Streaming #106

Closed amalnanavati closed 11 months ago

amalnanavati commented 11 months ago

Description

Issues

  1. The web app often doesn't show a camera feed when returning to Bite Selection, if your phone falls asleep during Bite Selection, or if you put your phone on sleep (e.g., press the power button) during Bite Selection.
    1. Further, sometimes even if it does render an image, it is a very old image (e.g., there is lots of latency).
  2. Bite Selection overlays the mask on top of the live video feed for every mask (3 currently), hence maintaining 4 independent live video streams at once.

Design Considerations

  1. This post provides an overview of 5 ways to stream videos for robots, and the pros/cons of each.
    1. As documented in that post, latency/lag is a well-known issue with web_video_server because it guarantees delivery of every packet. The only way to avoid it is to move away from web_video_server.
    2. My hunch about why it doesn't show the image is that either React or the browser caches some elements of the page layout and therefore do not attempt to reload the web_video_server URL. Or maybe it thinks the stream is still open, but web_video_server has closed the stream, Either way, changing the URL the web app is rendering should address this.
    3. Although in theory web_video_server supports video compression (e.g., h264 / vp8), in practice I hadn't been able to get them to work. The types I was able to get to work, mjpeg and ros_compressed essentially stream individual images anyway, nixing the video compression benefit of web_video_server.
    4. Hence, I decided to move away from web_video_server and towards sending and rendering individual CompressedImage messages in the app. This should not require any more bandwidth than our existing approach, and should address the latency and blank image.
    5. However, based on the linked post and Vinitha's experience with the Stretch robot, WebRTC will likely have lower latency and lower bandwidth. This is particularly important, because when running the app with network and CPU throttling, the image doesn't render (nor does it get feedback). Hence, we should look into whether WebRTC will address that, and consider switching to WebRTC that for our web app.
  2. Since ada_feeding#141, SegmentFromPoint now returns the RGB image, so the web app can overlay that with the mask, instead of the whole video feed.

Solution

See 1.iv above.

Testing

Setup

Sim via EC2:

Real:

Tests


Before creating a pull request

Before merging a pull request