Closed maggusscheppi closed 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
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.
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