Giter Club home page Giter Club logo

go2-webrtc's Introduction

go2-webrtc - WebRTC API or Unitree GO2 Robots

The go2-webrtc project provides a WebRTC API for Unitree GO2 Robots, enabling real-time communication and control over these robots through a web interface. This project simplifies the process of connecting to and controlling Unitree GO2 Robots by leveraging the WebRTC protocol for efficient, low-latency communication.

Go2's WebRTC API supports all models, including Go2 Air, Pro, and Edu versions.

Features

  • WebRTC Integration: Utilizes WebRTC to establish a real-time communication channel between the web client and the robot.
  • User Interface: Includes a simple web interface for connecting to the robot, sending commands, and viewing the robot's video stream.
  • Command Execution: Allows users to execute predefined commands on the robot, such as movement and action commands.
  • Persistent Settings: Saves connection settings (token and robot IP) in the browser's localStorage for easier reconnection.

Getting Started

To get started with go2-webrtc, clone this repository and serve the index.html file from a local web server to a modern web browser. Ensure that your Unitree GO2 Robot is powered on and connected to the same network as your computer.

git clone https://github.com/tfoldi/go2-webrtc
cd go2-webrtc/javascript
python3 -m http.server

Sample Frontend Application

The javascript folder contains a sample frontend application that demonstrates how to use the JS WebRTC API to connect to and control the Unitree GO2 Robots. Explore the javascript folder for more details and examples.

Python API for Backend/Console Applications

For backend or console applications, the python folder provides a Python API that interfaces with the Unitree GO2 Robots. This API is ideal for developers looking to integrate robot control into their Python applications or scripts. Check out the python folder for documentation and examples.

Prerequisites

  • A Unitree GO2 Robot accessible over the local network. All models supported including Air, Pro and Edu
  • Local network connection (STA-L) to the robot

Obtaining security token

Connecting to your device without a security token is possible and might allow a connection to be established. However, this method limits you to a single active connection at any time. To simultaneously use multiple clients, such as a WebRTC-based application and a phone app, a valid security token is necessary. This ensures secure, multi-client access to your device.

One way is to sniff the traffic between the dog and your phone. Assuming that you have Linux or Mac:

  1. Run tinyproxy or any other HTTP proxy on your computer
  2. Set your computer's IP and port as HTTP proxy on your phone
  3. Run wireshark or ngrep on your box sniffing port 8081 like ngrep port 8081.
  4. Look for the token in the TCP stream after you connect your phone to the dog via the app

The token looks like this in the request payload:

{
    "token": "eyJ0eXAiOizI1NiJtlbiI[..]CI6MTcwODAxMzUwOX0.hiWOd9tNCIPzOOLNA",
    "sdp": "v=0\r\no=- ",
    "id": "STA_localNetwork",
    "type": "offer"
}

Another option is to obtain token via the /login/email endpoint.

curl -vX POST https://global-robot-api.unitree.com/login/email -d "email=<EMAIL>&password=<MD5 hash of your password>"

Development

This project is structured around several key JavaScript files for the frontend and a Python package for backend or console applications. To contribute or modify the project, refer to these resources for implementing additional features or improving the existing codebase. PRs are welcome.

License

This project is licensed under the BSD 2-clause License - see the LICENSE file for details.

go2-webrtc's People

Contributors

abizovnuralem avatar mvrius avatar tfoldi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

go2-webrtc's Issues

undefined topic on unitreego2 air

Hello, thank you for your excellent work! I attempted to establish a connection on the Go2 Air by following the method outlined in the README to obtain the secure token, and it was successful. However, I encountered errors when trying several commands, such as Move, Dance1, and Sit. The error message is as follows:

Connecting to robot on ip 192.168.123.161...
Offer created
{"type":"offer","sdp":"v=0\r\no=mozilla...THIS_IS_SDPARTA-99.0 8394188148764726281 0 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=sendrecv\r\na=fingerprint:sha-256 B2:64:E7:9C:59:5E:1C:C4:EE:44:3E:35:58:BF:52:D3:92:C5:D6:19:2F:DB:E8:90:36:27:3E:5D:8C:18:A6:83\r\na=group:BUNDLE 0 1 2\r\na=ice-options:trickle...
Establishing connection...
WebRTC connection established
<- msg type:undefined topic:rt/api/sport/request data:{"header":{"identity":{"id":846821836,"api_id":1008}},"parameter":"1008"}
Connecting to robot on ip 192.168.123.161...
Offer created
{"type":"offer","sdp":"v=0\r\no=mozilla...THIS_IS_SDPARTA-99.0 8307359442818234896 0 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=sendrecv\r\na=fingerprint:sha-256 1E:B7:48:C7:A7:FD:B7:93:BF:37:21:FA:C6:61:F8:83:03:14:83:51:01:90:B2:47:CC:23:58:CC:11:A5:66:44\r\na=group:BUNDLE 0 1 2\r\na=ice-options:trickle...
Establishing connection...
WebRTC connection established
<- msg type:undefined topic:rt/api/sport/request data:{"header":{"identity":{"id":846834977,"api_id":1008}},"parameter":"1008"}
<- msg type:undefined topic:rt/api/sport/request data:{"header":{"identity":{"id":846842190,"api_id":1022}},"parameter":"1022"}

ๅ›พ็‰‡

I look forward to your response. Thank you sincerely

confirm the current capability with this repo

Hi guys, thank you so much for making this available for Go2 owners!!! I'm thinking about getting the Air version to fiddle around, but would like to ask a few questions prior to ordering.

First question is about the controller bundle, Air with the controller is about $250 US dollars more than the Air alone. Is the controller a must-have? Can I use a wireless joystick/gamepad with a tablet to achieve the same thing?

Second question, with this repo + official Go2 SDK, what can and cannot be done on the Go2 Air?

Last question, I've seen a tiny tracker in one of the videos which allows Go2 to closely follow the owner. My understanding is this tracker/feature isn't compatible with Go2 Air, correct? What's the advantage of having this tracker? And is it possible to make a poor man's version of the tracker using something like UWB/BLE beacons or wireless occupancy sensors?

(new function) send a voice (send a mp3)

I am appreciate for this application :)
In the app, that is avaliable sending a voice message (like as bluetooth speaker).
Could you add that function for sending a voice of audio file to play though the go2 robot?

Can Not control the robot

Hi, authors, thanks for your great work. I have tried this code and from the browser, the robot can be connected (didn't use token). But when I executed the command, the robot didn't move. Do I need to run something else?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.