Other Parts Discussed in Thread: IWR6843AOP
Hi
below is python Code to get value from IWR6843AOPEVM using python for people tracking with vital sign.
please check it for get right value from IWR6843AOP
import binascii
import serial
import numpy as np
import cv2
import queue
import struct
cnt = 0
i = 0
synPattern = [0x02, 0x01, 0x04, 0x03, 0x06, 0x05, 0x08, 0x07]
mmWaveUARTData = serial.Serial("COM6", 921600, timeout=3.0)
while True:
header = mmWaveUARTData.read(48)
sync1, sync2, sync3, sync4, sync5, sync6, sync7, sync8, version, totalPacketLen, platform, frameNumber, subFrameNumber, chirpProcessingMargin, frameProcssingMargin, trackProcessTime, uartSentTiem, numTLVs, checksum = struct.unpack('8B9I2H', header)
if sync1 == 0x02 and sync2 == 0x01 and sync3 == 0x04 and sync4 == 0x03 and sync5 == 0x06 and sync6 == 0x05 and sync7 == 0x08 and sync8 == 0x07:
print("#################################### found header ##################################")
print("total length : {}".format(totalPacketLen))
print("frame number : {}".format(frameNumber))
print("no of TLVs : {}".format(numTLVs))
data = mmWaveUARTData.read(totalPacketLen - 48)
if data == b'':
continue
if numTLVs < 1:
continue
cnt = numTLVs
while True:
print("********* tlv cnt : {}".format(cnt))
tlvType, tlvLength = struct.unpack('2I', data[:8])
print("tlvType : {}".format(tlvType))
print("tlvLength : {}".format(tlvLength))
data1 = data[8:]
if tlvType > 20:
break
if tlvType == 0x06:
pointCloud = data[8:tlvLength]
if ((tlvLength - 28) % 8) != 0:
break
else:
#print(data[8:tlvLength])
elevationUnit, azimuthUnit, dopplerUnit, rangeUnit, snrUnit = struct.unpack('5f', pointCloud[:20])
print("elevationUnit : {}".format(elevationUnit))
print("azimuthUnit : {}".format(azimuthUnit))
print("dopplerUnit : {}".format(dopplerUnit))
print("rangeUnit : {}".format(rangeUnit))
print("snrUnit : {}".format(snrUnit))
pointCloud = pointCloud[20:]
pointValue = binascii.hexlify((pointCloud))
#print(pointValue)
cnt1 = tlvLength-28
while True:
#for k in range(0, tlvLength-28, 8):
elevation, azimuth, doppler, range, snr = struct.unpack("2B3H", pointValue[:8])
print("elevation : {}".format(elevation * elevationUnit))
print("azimuth : {}".format(azimuth * azimuthUnit))
print("doppler : {}".format(doppler * dopplerUnit))
print("range : {}".format(range * rangeUnit))
print("snr : {}".format(snr * snrUnit))
cnt1 = cnt1 - 8
if cnt1 == 0:
break
pointValue = pointValue[8:]
elif tlvType == 0x07:
targetList = data[8:tlvLength]
targetValue = binascii.hexlify((targetList))
tid, posX, posY, posZ, velX, velY, velZ, accX, accY, accz, ec0, ec1, ec2, ec3, ec4, ec5, ec6, ec7, ec8, ec9, ec10, ec11, ec12, ec13, ec14, ec15, g, confidenceLevel = struct.unpack("I9f16f2f", targetList[:112])
print("tid : {}".format(tid))
print("posX : {}".format(posX))
print("posY : {}".format(posY))
print("posZ : {}".format(posZ))
print("velX : {}".format(velX))
print("velY : {}".format(velY))
print("velZ : {}".format(velZ))
targetList = targetList[112:]
#print(data[8:tlvLength])
elif tlvType == 0x08:
targetIndex = data[8:tlvLength]
#print(data[8:tlvLength])
elif tlvType == 0x0c:
presence = data[8:tlvLength]
exit = struct.unpack("I", presence)
print("Presence : {}".format(exit))
#print(data[8:tlvLength])
elif tlvType == 0x0a:
targetIndex = data[8:tlvLength]
unwrap_waveform1, unwra_waveform2,heart_waveform1, heart_waveform2, breathing_waveform1, breathing_waveform2, heart_rate1, heart_rate2, breathing_rate1, breathing_rate2, x1, x2, y1, y2, z1, z2, id1, id2, range1, range2, angle1, angele2, rangeidx1, rangeidx2, angleidx1, angleidx2 = struct.unpack("22f4H", targetIndex[:96])
print("heart_rate1 : {}".format(heart_rate1))
print("heart_rate2 : {}".format(heart_rate2))
print("breathing1 : {}".format(breathing_waveform1))
print("breathing2 : {}".format(breathing_waveform2))
#print(data[8:tlvLength])
cnt = cnt - 1
if cnt == 0:
break
data = data[tlvLength:]
else:
pass
and
output value is below .
#################################### found header ##################################
total length : 277
frame number : 209455
no of TLVs : 4
********* tlv cnt : 4
tlvType : 6
tlvLength : 76
elevationUnit : 0.009999999776482582
azimuthUnit : 0.009999999776482582
dopplerUnit : 0.0002800000074785203
rangeUnit : 0.0002500000118743628
snrUnit : 0.03999999910593033
elevation : 0.4899999890476465
azimuth : 0.5199999883770943
doppler : 6.9809601864544675
range : 3.5977501708839554
snr : 493.5599889680743
elevation : 1.0099999774247408
azimuth : 0.5399999879300594
doppler : 3.9558401056565344
range : 6.413750304636778
snr : 493.43998897075653
elevation : 0.4899999890476465
azimuth : 0.4899999890476465
doppler : 3.4689200926513877
range : 3.59800017089583
snr : 1048.4399765655398
elevation : 1.0099999774247408
azimuth : 0.9699999783188105
doppler : 3.8841601037420332
range : 6.360250302095665
snr : 493.43998897075653
elevation : 0.47999998927116394
azimuth : 0.9899999778717756
doppler : 3.899000104138395
range : 3.341250158700859
snr : 1027.9599770233035
elevation : 1.0099999774247408
azimuth : 0.9999999776482582
doppler : 3.812480101827532
range : 6.542250310740201
snr : 493.43998897075653
********* tlv cnt : 3
tlvType : 7
tlvLength : 120
tid : 0
posX : 0.1761176735162735
posY : 3.3187012672424316
posZ : 0.9841117262840271
velX : -0.00889516156166792
velY : 0.0030599513556808233
velZ : 0.021570570766925812
********* tlv cnt : 2
tlvType : 8
tlvLength : 21
********* tlv cnt : 1
tlvType : 12
tlvLength : 12
Presence : (1,)
#################################### found header ##################################
total length : 3072
frame number : 209456
no of TLVs : 5
********* tlv cnt : 5
tlvType : 6
tlvLength : 76
elevationUnit : 0.009999999776482582
azimuthUnit : 0.009999999776482582
dopplerUnit : 0.0002800000074785203
rangeUnit : 0.0002500000118743628
snrUnit : 0.03999999910593033
elevation : 0.4899999890476465
azimuth : 0.5199999883770943
doppler : 6.9809601864544675
range : 3.5977501708839554
snr : 493.5599889680743
elevation : 1.0099999774247408
azimuth : 0.5399999879300594
doppler : 3.9558401056565344
range : 6.413750304636778
snr : 493.43998897075653
elevation : 0.4899999890476465
azimuth : 0.4899999890476465
doppler : 3.4689200926513877
range : 3.59800017089583
snr : 1048.4399765655398
elevation : 1.0099999774247408
azimuth : 0.9699999783188105
doppler : 3.8841601037420332
range : 6.360250302095665
snr : 493.43998897075653
elevation : 0.47999998927116394
azimuth : 0.9899999778717756
doppler : 3.899000104138395
range : 3.341250158700859
snr : 1027.9599770233035
elevation : 1.0099999774247408
azimuth : 0.9999999776482582
doppler : 3.812480101827532
range : 6.542250310740201
snr : 493.43998897075653
********* tlv cnt : 4
tlvType : 7
tlvLength : 120
tid : 0
posX : 0.1761176735162735
posY : 3.3187012672424316
posZ : 0.9841117262840271
velX : -0.00889516156166792
velY : 0.0030599513556808233
velZ : 0.021570570766925812
********* tlv cnt : 3
tlvType : 8
tlvLength : 14
********* tlv cnt : 2
tlvType : 12
tlvLength : 12
Presence : (1,)
********* tlv cnt : 1
tlvType : 10
tlvLength : 2802
heart_rate1 : 55.24530029296875
heart_rate2 : 55.24530029296875
breathing1 : -1.043005166759384e+36
breathing2 : -8.122871264504283e-09
#################################### found header ##################################
total length : 289
frame number : 209466
no of TLVs : 4
********* tlv cnt : 4
tlvType : 6
tlvLength : 92
elevationUnit : 0.009999999776482582
azimuthUnit : 0.009999999776482582
dopplerUnit : 0.0002800000074785203
rangeUnit : 0.0002500000118743628
snrUnit : 0.03999999910593033
elevation : 0.4999999888241291
azimuth : 0.47999998927116394
doppler : 3.540040094550932
range : 3.3402501586533617
snr : 997.1599777117372
elevation : 1.0099999774247408
azimuth : 0.9699999783188105
doppler : 3.8841601037420332
range : 3.2780001556966454
snr : 493.43998897075653
elevation : 0.4999999888241291
azimuth : 0.47999998927116394
doppler : 3.683400098379934
range : 3.0850001465296373
snr : 555.2399875894189
elevation : 1.0099999774247408
azimuth : 0.5399999879300594
doppler : 3.9558401056565344
range : 3.2245001531555317
snr : 493.43998897075653
elevation : 0.47999998927116394
azimuth : 0.4999999888241291
doppler : 3.8844401037495118
range : 3.341000158688985
snr : 1036.239976838231
elevation : 1.0099999774247408
azimuth : 0.5099999886006117
doppler : 4.027520107571036
range : 6.222000295529142
snr : 493.43998897075653
elevation : 0.47999998927116394
azimuth : 0.4999999888241291
doppler : 7.110040189902065
range : 3.0845001465058886
snr : 575.5599871352315
elevation : 1.0099999774247408
azimuth : 0.5399999879300594
doppler : 3.9558401056565344
range : 6.2967502990795765
snr : 493.43998897075653
********* tlv cnt : 3
tlvType : 7
tlvLength : 120
tid : 0
posX : 0.1761176735162735
posY : 3.3187012672424316
posZ : 0.9841117262840271
velX : -0.00889516156166792
velY : 0.0030599513556808233
velZ : 0.021570570766925812
********* tlv cnt : 2
tlvType : 8
tlvLength : 17
********* tlv cnt : 1
tlvType : 12
tlvLength : 12
Presence : (1,)
#################################### found header ##################################
total length : 256
frame number : 209467
no of TLVs : 4
********* tlv cnt : 4
tlvType : 6
tlvLength : 60
elevationUnit : 0.009999999776482582
azimuthUnit : 0.009999999776482582
dopplerUnit : 0.0002800000074785203
rangeUnit : 0.0002500000118743628
snrUnit : 0.03999999910593033
elevation : 0.47999998927116394
azimuth : 0.5199999883770943
doppler : 3.9569601056864485
range : 6.350000301608816
snr : 997.279977709055
elevation : 1.0099999774247408
azimuth : 0.9999999776482582
doppler : 3.812480101827532
range : 6.348250301525695