MAVProxyUser / YushuTechUnitreeGo1

宇树科技 Yushu Technology (Unitree) go1 development notes
295 stars 73 forks source link

Computer values for controller/stick command #2

Closed maggusscheppi closed 1 year ago

maggusscheppi commented 1 year ago

How do I compute the hex values in this line:

infot = mqttc.publish("controller/stick", "\xac\x4a\x3a\x3e\x00\x00\x00\x00\x00\x00\x00\x00\x2e\x64\x42\x3e", qos=2)

Thx for an answer, markus

MAVProxyUser commented 1 year ago

This should help

import serial
import binascii
import struct

# rfcomm connect /dev/rfcomm0 98:DA:10:01:18:4E 

with serial.Serial('/dev/rfcomm0', 115200, timeout=1) as ser:
        while True:
                val = ser.read(20)
                [lx,rx,ry,ly,b1,b2,b3] = struct.unpack('ffffcce', val)
                print(str([lx,rx,ry,ly]))                               # Stick values  

                print( '{0:08b}'.format(int(binascii.hexlify(b1),16)) ) # Rocker Switches
                print( '{0:08b}'.format(int(binascii.hexlify(b2),16)) ) # Front Panel Buttons
                print("------------------------------------------")

Stop by #unitree on https://join.slack.com/t/robotdogs/shared_invite/zt-1fvixx89u-7T79~VxmDYdFSIoTnSagFQ

maggusscheppi commented 1 year ago

Thx a lot. Got it. After asking I also saw your mosquitto_sub snif sample. Works perfekt and with printing str(msg.payload) to the console I got what I need to create my own moves on high level.