Consolidate web serving code (PLANE-294) #52
Merged
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.
Implements PLANE-294
As I was thinking through option 2 of ticket PLANE-120, I realized that it would be pretty clunky to start a ws_server process for each camera AND have to run the python code for each instance to get a UI. For example we'd need to do this:
Launch the ws_server processes:
And then launch a flask app for each instance from a laptop connected to the robot wifi:
After all that was done one could navigate to
http://localhost:5000
to see camera 0 andhttp://localhost:5001
to see camera 1 in a different tab. Doable but quite clunky.I realized that the websocket server Seasocks is actually capable of serving the webpage itself, so there is no need for the python flask app at all. This really simplifies things, as now with this change all we need to do is start the ws_server processes as above, but there's no need to start the python processes. All you would need to do is get a laptop connected to the robot wifi and simply navigate to
http://<ip address of the orin>:8080
in one tab andhttp://<ip address of the orin>:8090
in another tab. And that's it!It was quite easy to implement too - just a single line of code changed in ws_server.cu. I added a directory called
public
and added theindex.html
file from theapp/template
directory in there. I made a few small changes to implement the message parsing logic in javascript rather than python, and changed the websocket protocol to websockets instead of socket.io.It was a very simple change and works really well in my testing.