The height, battery, North and East speed is from the flight status messages not the flight log. Apart from the battery info, this data is pretty rubbish. You will need to implement flight log parsing and information extraction, as this hasn't been done in TelloPy yet I don't think
I won't share the whole
tello.py file as it's very big, but here's the extensions I've added to telloPy
Python:
elif cmdID == self.TELLO_CMD_LOG_HEADER_WRITE:
print "log header"
p = payload.get_array()
iD = (struct.unpack('<H', p[0:2])[0])
returnpayload = bytearray([0])
returnpayload.extend(struct.pack('<H', iD))
self._sendCmd(0x50, self.TELLO_CMD_LOG_HEADER_WRITE, returnpayload)
This part listens for the "log header" from the
Tello which indicates that a log file is about to be transmitted, then sends a corresponding acknowledgement command. The
Tello should follow this with the log file.
Python:
elif cmdID == self.TELLO_CMD_LOG_DATA_WRITE:
p = bytearray(payload.get_array())
self._parseLogPacket(p)
This part listens for the log file and then sends the contents of the file to be parsed
Python:
def _parseLogPacket(self, data):
pos = 1
while pos < len(data) - 2:
if bytearray([data[pos]]) != 'U':
break
length = data[pos + 1]
if data[pos + 2] != 0:
break
try: ID = struct.unpack("H", data[pos + 4: pos + 6])[0]
except error: pass
xorBuf = bytearray(1024)
try:
xorVal = bytearray([data[pos + 6]])
except IndexError:
pass
if ID == 0x1d: #MVO Data
for i in range(length):
try:
xorBuf[i] = (data[pos + i] ^ xorVal[0])
except IndexError:
pass
velX = struct.unpack("H", xorBuf[12:14])[0]
velY = struct.unpack("H", xorBuf[14:16])[0]
velZ = struct.unpack("H", xorBuf[16:18])[0]
posX = struct.unpack("f", xorBuf[18:22])[0]
posY = struct.unpack("f", xorBuf[22:26])[0]
posZ = struct.unpack("f", xorBuf[26:30])[0]
tempPos = [posX, posY, posZ]
for i in range(3):
if tempPos[i] > 30000:
tempPos[i] = (65536 - tempPos[i]) * -1
self.position = [a - b for a,b in zip(tempPos, self.position_offset)]
pos += length
This part parses the log file (it has to be decoded from xor first). The ID at the start of the file tells you which part of the data has updated. This example is for new MVO data. If the IMU data has been updated then the ID will be different. After decoding you can pull out the relevant bits of data