Current PI's OS is supports python 3.7.0
https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up/3
This repository contains the Batman mmWave-TMD Traffic Monitoring Detection mmWave Sensor SDK with Device Version:ES2.0 . The sample code below consists of instruction for using the mmWave lib. This mmWave-TMD Python Program works with Traffic Monitoring Detection (TMD) based Batman BM201-TMD mmWave Kit solution. This Python Program works with a Raspberry Pi 4 and/or NVIDIA Jetson Nano computer with Batman BM201-TMD Kit attached via Kit’s HAT Board; and that the BM201-TMD Kit is an easy-to-use mmWave sensor evaluation kit for tracking multiple object's movements simultaneously from 1meter ~ 50meter range with a high degree of accuracy suitable for traffic monitoring applications; and where the Python Program would detect multiple object/vehicle movements in a 3-Dimentional Area with ID tag, posX, posY, posZ, velx, vely, velz, accX, accY, accZ parameters, along with Point Clouds with elevation, azimuth, doppler, and range parameters. Note: this Python program uses matplotlib for objects movement’s 3D plot, and that the current 3D plot update rate is lagging; and where a faster 3D plot library will be desired (while the parameter data are read in real-time as normal).
Hardware Sensor:
Batman BM201-TMD provides two types of data:
BM201-TMD provides raw data as:
Point Cloud Spherical(V6): range,azimuth,elevation,doppler
Target Object (V7): tid,posX,posY,velX,velY,accX,accY,posZ,velZ,accZ
Target Index (V8): tid and status
Point Cloud Side Info (V9): snr,noise<br/>
tid: target ID
pos: position m
vel: velocity m/s
acc: acceleration m/s^2
Setup Requirements:
Elevate EVM:
Down tilt:
Library install for Python
$sudo pip3 install mmWave
Library update:
$sudo pip3 install mmWave -U
TMD_ex0.py is an example output V6(Point Cloud),V7(Target Objects),V8(Target Index), V9(Point Cloud Side Info) data
pyqtgraph_TMD_ex1.py is an example show point cloud in real time graphic use pyqtgraph
TMD_ex2_pointCloud.py is an example plot point cloud in 3D use matplotlib
pyqtgraph_3d_tmd.py is an example plot point cloud in 3D use pyqtgraph. The display speed is fast than matplotlib
If Run demo program can not find any Raw data output: Please set UART to R/W mode:
pi 3
$ls -l /dev/ttyS0
$sudo chmod +777 /dev/ttyS0
pi 2
$ls -l /dev/ttyS0
$sudo chmod +777 /dev/ttyAMA0
Jetson nano
$ls -l /dev/ttyTHS1
$sudo chmod +777 /dev/ttyTHS1
class header:
version = 0
totalPackLen = 0
platform = 0
totalPacketLen = 0
frameNumber = 0
subFrameNumber = 0
chirpMargin = 0
frameMargin = 0
trackProcessTime = 0
uartSendTime = 0
numTLVs = 0
checksum = 0
from mmWave import trafficMD
tmd = trafficMD.TrafficMD(port)
V6: Point Cloud
Each Point Cloud list consists of an array of points, Each point data structure is defined as following
point Struct:
range: float #Range in meters
azimuth: float #Azimuth in radians
elevation: float #Elevation in radians
velocity: float #Doppler in m/s
V6 =: [(range,azimuth,elevation,velocity),......]
V7: Target Object
Each Target List consists of an array of targets. Each target data structure defind as following:
target Struct:
tid: Int #Track ID
posX: float #Target position in X, m
posY: float #Target position in Y, m
velX: float #Target velocity in X, m/s
velY: float #Target velocity in Y, m/s
accX: float #Target velocity in X, m/s^2
accY: float #Target velocity in Y, m/s^2
posZ: float #Target position in Z, m
velZ: float #Target velocity in Z, m/s
accZ: float #Target velocity in Z, m/s^2
V7 =: [(tid,posX,posY,velX,velY,accX,accY,posZ,velZ,accZ),....]
V8: Target Index
Each Target List consists of an array of target IDs, A targetID at index i is the target to which point i of the previous frame's point cloud was associated. Valid IDs range from 0-249
TargetIndex Struct:
tragetID: Int #Track ID
[targetID0,targetID1,.....targetIDn]
Other Target ID values:
253:Point not associated, SNR to weak
254:Point not associated, located outside boundary of interest
255:Point not associated, considered as noise
V8 =: [id1,id2....]
V9:Point Cloud Side Info
v9 structure: [(snr,noise),....]
(dck,v6,v7,v8,v9) = tmd.tlvRead(False)
dck : True : data avaliable
False : data invalid
v6: point cloud of array
v7: target object of array
v8: target id of array
v9: point cloud side info array
return dck,v6,v7,v8,v9
-----------------
| obj o |+z board
| \ |
| el\|
| +x<-----o
| az \
----------- \ --
\+y
Based on IWR6843 3D(r,az,el) -> (x,y,z)
el: elevation φ <Theta bottom -> Obj
az: azimuth θ <Theta Obj ->Y Axis
z = r * sin(φ)
x = r * cos(φ) * sin(θ)
y = r * cos(φ) * cos(θ)
from mmWave import trafficMD
port = serial.Serial("/dev/ttyS0",baudrate = 921600, timeout = 0.5)
port = serial.Serial("/dev/ttyTHS1",baudrate = 921600, timeout = 0.5)
port = serial.Serial("/dev/tty.usbmodemGY00xxxx",baudrate = 921600, timeout = 0.5)
port = serial.Serial("/dev/ttyACM1",baudrate = 921600, timeout = 0.5)
tmd = trafficMD.TrafficMD(port)
raw data:
(dck,v6,v7,v8,v9) = tmd.tlvRead(False)
if dck:
print(v6) #you will see v6 data