Code Examples for PyRAPID¶
First, check Dependencies before using the library.
Dumping radar cube¶
The following script shows and example using radarProcessingBlocks module
for capturing raw ADC data, making radar cube (see Fig. 6)
, and storing it into a binary file in real-time. First, all FMCW configuration parameters including
Profile, Chirp, and Frame parameters are imported by instantiating
TI_FMCW_Profile_Params
,
TI_FMCW_Chirp_Params
,
and TI_FMCW_Frame_Params
and setting proper values in the fields. Also,
an instantiate of FMCW_System_Params
finds
valid estimation values that are printed out at the end.
from radar.radarProcessingBlocks import *
from radar.params import *
###########################################################
# Radar parameters #
###########################################################
profiles = TI_FMCW_Profile_Params()
profiles.K = 98.008
profiles.lambda_max = LIGHT_SPEED/(profiles.fc*1e9)
profiles.idleTime = 250.00
profiles.TxStartTime = 1.00
profiles.ADCStartTime = 2
profiles.NumChirpSamples = 162
profiles.SampRate = 4400
profiles.RampEndTime = 40.00
profiles.RxGain = 30
chirp_0 = TI_FMCW_Chirp_Params()
chirp_0.TxEn = 0
chirp_1 = TI_FMCW_Chirp_Params()
chirp_1.StartIdx = 1
chirp_1.EndChirpIdx = 1
chirp_1.TxEn = 1
frame = TI_FMCW_Frame_Params()
frame.StartChirpIdx = 0
frame.EndChirpIdx = 1
frame.NumChirpLoops = 32
frame.FramePeriod = 60
frame.NumFrames = 0
FMCW_sys = FMCW_System_Params(profiles, [chirp_0, chirp_1], frame)
print('************ Radar Configuration parameters: *********************')
print(' Effective sweeping BW (MHz): ', FMCW_sys.EffBs/1e6)
print(' Range resolution (cm): ', FMCW_sys.minRange*1e2)
print(' Maximum detectable range (m): ', FMCW_sys.maxRange)
print(' Velocity resolution (cm/s): ', FMCW_sys.minVel*1e2)
print(' Maximum velocity resolution (cm/s):', FMCW_sys.maxVel*1e2)
print('*******************************************************************')
In this example, parameters are set to give the following valid estimations:
************ Radar Configuration parameters: *********************
Effective sweeping BW (MHz): 3608.476363636364
Range resolution (cm): 4.154003349184899
Maximum detectable range (m): 3.3647427128397682
Velocity resolution (cm/s): 20.97741673197492
Maximum velocity resolution (cm/s): 335.6386677115987
*******************************************************************
Now, we can define processing blocks including the following:
DCAReader
: to read ethernet packets and pass the payloads to the next block
packetReorder
: to reorder and fill zeros in stead of dropped packets
ADCReadBits
: to convert binary data to the complex samples of 4 Rx channels
VirtualChanFormer
: to form the radar cube with 3-dimensions of (fast-time, slow-time, Rx channels) data samples.file_sink <radar.radarProcessingBlocks.file_sink> : to write the radar cubes into a
numpy
binary file for later offline processing.
###########################################################
# Processing blocks #
###########################################################
RxBufSize = FMCW_sys.FrameBytes*2
ADCbits = 16
RadarOutput = DCAReader("DCAReader", 100)
packet_reorder = packetReorder("packetReorder", RxBufSize)
readBit = ADCReadBits("readBit", ADCbits, False)
virtualChan = VirtualChanFormer("virtualChan", FMCW_sys.NumTx, profiles.NumChirpSamples)
file_snk = file_sink('binsink', 'radarCube.npy', 'b')
Now, we need to connect the defined blocks to make the flowgraph
.
if __name__ == '__main__':
tp = top_block()
tp.connect(RadarOutput, 1, packet_reorder, 1)
tp.connect(packet_reorder, 1, readBit, 1)
tp.connect(readBit, 1, virtualChan, 1)
tp.connect(virtualChan, 1, file_snk, 1)
tp.flow_start()
print('[THE END]')
The flow_start
runs an infinte loop.
This should be done before mmwave studio connects to the ethernet port as
mentioned in Texas Instruments radars .