Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signaling #103

Open
wants to merge 29 commits into
base: feature/login
Choose a base branch
from
Open

Signaling #103

wants to merge 29 commits into from

Conversation

hello-binit
Copy link
Collaborator

@hello-binit hello-binit commented Sep 25, 2024

Description

This PR is the second of two PRs (the first is #115) that will make web teleop deployable on the internet. It introduces "signalers", which manage sending signals to establish a WebRTC connection between a robot and an operator anywhere in the world. Web teleop already had local signaling embedded in webrtcconnections.tsx + a signaling server in server.js, which means that if you could do signaling if you could access the robot (often through ngrok tunneling or tailscale). However, since it's not common to expose tunnels/tailscale to the internet, a new way of signaling was needed. In this PR, the BaseSignaling interface is introduced and two implementations are added: LocalSignaling and FirebaseSignaling. Whereas the former still uses server.js, the latter uses Firebase's Realtime Database to transfer signals. This PR builds on the previous PR's authentication to ensure security. Lastly, we can support alternate signaling servers in the future by adding new implementations of BaseSignaling to the shared.signaling module.

Testing procedure

We will be testing this PR and the Login & Homepage PR together. Check out the "feature/signaling" branch. Go through the testing instructions for the other PR first, then go through these:

Running the interface locally

Launch the interface

  1. Go to https://localhost/operator in a browser and you should see the web interface.
    • image
  2. Open the homepage in another tab. The robot will be occupied.
    • image
  3. Close the operator panel. The robot will become available on the homepage.
  4. Stop the robot browser, and the robot will go offline on the homepage.

Running the interface online

You will need to send me your email address and robot's serial number before you can test this section. Additionally, you will need to ask me for an .env file to put in the root of your repo, change "localstorage" to "firebase" in line 4 of start_web_server_and_robot_browser.sh, and then launch the interface normally.

  1. Visit https://web.hello-robot.com/ and sign in. You should see your online and available.
    • image
  2. Press the "Call Robot" button and you should see the web interface.
    • image
    • You can bookmark the URL to call the robot without going through the homepage
    • Open the homepage in another tab. The robot will be occupied. Close the operator panel, and the robot will become available.
  3. Visit https://web.hello-robot.com/operator and the interface will not load. In the console, you'll see that the interface was unable to determine which robot to call because the URL was missing the robot parameter.
    • image
  4. Visit https://web.hello-robot.com/operator/?robot=stretch-se3-3005 to try calling a robot that doesn't belong to you. The interface will not load.
    • image
  5. Stop the interface on the robot and the robot may go offline on the homepage. There is a known bug that the robot may continue to appear online and callable on the homepage, despite the robot browser exiting. This happens because Chrome/other browsers don't give window.onbeforeunload enough time to complete entirely. In the future, we'll use heartbeats to fix this and make connectivity more robust in general.

Before opening a pull request

From the top-level of this repository, run:

  • pre-commit run --all-files

To merge

  • Squash & Merge

The logic behind joining, leaving, and sending messages via
the signaling server is now refactored into standalone classes.
The WebRTC negotiation instantiates a LocalSignaling object,
and uses an API defined by BaseSignaling to communicate with
the signaling server, without worrying about the details.
Calling a robot at https://<url>/operator/stretch-re1-xxxx will
be converted into a room UID by looking up the name <-> UID mapping
in Firebase.
The call allows one operator to connect to a robot at a time.
A second browser tab can identify if the room is already
occupied by looking at the "active" attribute of its role
within the room.
@hello-binit hello-binit changed the base branch from master to feature/login November 8, 2024 18:42
@hello-binit hello-binit changed the title WIP: Signaling Signaling Nov 8, 2024
@hello-binit hello-binit mentioned this pull request Nov 8, 2024
8 tasks
@hello-binit hello-binit marked this pull request as ready for review November 9, 2024 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant