tfoldi / go2-webrtc

WebRTC API for Unitree GO2 Robots
BSD 2-Clause "Simplified" License
53 stars 15 forks source link

undefined topic on unitreego2 air #8

Open kvkcon opened 5 months ago

kvkcon commented 5 months ago

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

tfoldi commented 5 months ago

for move you need additional parameters to be passed (so it needs a custom message). Does the move works using the joysticks?

tfoldi commented 5 months ago

hmm, btw based on the image the you did not connect to the robot. can you check from your computer if http://192.168.123.161:8081/ address is accessible ?

kvkcon commented 5 months ago

I have tried the go2_joystick.py script, but encountered the error "aiortc.exceptions.InvalidStateError" when trying to move or stand up/stand down. 图片 Additionally, I have tried the go2_mqtt.py script, where the terminal is able to receive pose and point cloud data, but the connection to http://192.168.123.161:8081/offer cannot be established. The webpage displays "405: Method Not Allowed". 图片 I am very confused that I can receive data from sensors like lidar, but the robot cannot execute any commands, including moving or crouching.

kvkcon commented 5 months ago

I also tried turning off the main control service "sport_mode" from the mobile app, but none of the attempts made the robot move

tfoldi commented 5 months ago

OK, something is really odd. In the last image (the mqtt one) you can clearly see incoming messages, so the connection is established. That's a good sign and shows that there is hope :D

On the web, can you try to connect with an empty token while you do not use the mobile app (you should close the app on your phone)? Then please share the contents of your dev console - that's where we should see what's wrong

kjayarajah commented 5 months ago

@kvkcon we are dealing with the same errors. The joystick code throws the Invalid State error. The MQTT code is successful in connecting and receiving data. We tried to change the code slightly - to issue a command from within MQTT (inside on_validate). Commands such as StandUp and StandDown work perfectly (command IDs 1004 and 1005, for example).

However, when we tried to execute a movement command (akin to gen_mov_command in go2_joystick.py), that fails. Also, the dog goes into a sitting down position, the front LED turns red, and becomes unresponsive.

Attaching the changed code.

Screenshot from 2024-05-09 11-16-48

This was the response in the terminal: INFO:go2_webrtc.go2_connection:Connection state is connecting INFO:go2_webrtc.go2_connection:Connection state is connected DEBUG:go2_webrtc.go2_connection:Received message: {"type":"validation","data":"FvyRAzLqsIS3gY8q4o5"} DEBUG:go2_webrtc.go2_connection:Data channel is open DEBUG:go2_webrtc.go2_connection:-> Sending message {"type": "validation", "topic": "", "data": "iUd4cavX4xIIDYwoz5Hksg=="} DEBUG:main:RTC->MQTT Received message type=validation topic=None DEBUG:go2_webrtc.go2_connection:Received message: {"type":"validation","data":"FvyRAzLqsIS3gY8q4o5"} DEBUG:go2_webrtc.go2_connection:-> Sending message {"type": "validation", "topic": "", "data": "iUd4cavX4xIIDYwoz5Hksg=="} DEBUG:main:RTC->MQTT Received message type=validation topic=None DEBUG:go2_webrtc.go2_connection:Received message: {"type":"validation", "data":"Validation Ok."} DEBUG:main:RTC->MQTT Received message type=validation topic=None DEBUG:go2_webrtc.go2_connection:Received message: {"type":"errors","data":[]} DEBUG:main:RTC->MQTT Received message type=errors topic=None DEBUG:go2_webrtc.go2_connection:Received message: {"type":"res","topic":"rt/api/sport/response","data":{"header":{"identity":{"api_id":1008,"id":1575325853},"status":{"code":0}},"data":""}} DEBUG:main:RTC->MQTT Received message type=res topic=rt/api/sport/response DEBUG:go2_webrtc.go2_connection:Received message: {"type":"rtc_inner_req","info":{"req_type":"rtt_probe_send_from_mechine","send_time_stamp":1715267292,"uuid":"9a90cf83-b080-4369-94c6-bf0e193930dc"}} DEBUG:main:RTC->MQTT Received message type=rtc_inner_req topic=None ^CINFO:go2_webrtc.go2_connection:Connection state is closed

tfoldi commented 4 months ago

can you change one thing in your code? Instead of x: 0 and y:0, try x: 0.01 and y: 0.01 to force float types in the parameter?

what firmware are you on? I will create another small example just to move the robot and we can test how it works on your end