From a3178b15bd9da7dd82874eb5c4b8a421d5069769 Mon Sep 17 00:00:00 2001 From: HellaJanssen <80407622+HellaJanssen@users.noreply.github.com> Date: Tue, 17 Jun 2025 22:06:31 +0200 Subject: [PATCH] Deleted test script and TI's example script --- mmw_demo_example_script.py | 134 ------------------------------------- test.py | 111 ------------------------------ 2 files changed, 245 deletions(-) delete mode 100644 mmw_demo_example_script.py delete mode 100644 test.py diff --git a/mmw_demo_example_script.py b/mmw_demo_example_script.py deleted file mode 100644 index e6b44ed..0000000 --- a/mmw_demo_example_script.py +++ /dev/null @@ -1,134 +0,0 @@ -# **************************************************************************** -# * (C) Copyright 2020, Texas Instruments Incorporated. - www.ti.com -# **************************************************************************** -# * -# * Redistribution and use in source and binary forms, with or without -# * modification, are permitted provided that the following conditions are -# * met: -# * -# * Redistributions of source code must retain the above copyright notice, -# * this list of conditions and the following disclaimer. -# * -# * Redistributions in binary form must reproduce the above copyright -# * notice, this list of conditions and the following disclaimer in the -# * documentation and/or other materials provided with the distribution. -# * -# * Neither the name of Texas Instruments Incorporated nor the names of its -# * contributors may be used to endorse or promote products derived from -# * this software without specific prior written permission. -# * -# * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# * PARTICULAR TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# * A PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# * EXEMPLARY, ORCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# * -# **************************************************************************** - - -# **************************************************************************** -# Sample mmW demo UART output parser script - should be invoked using python3 -# ex: python3 mmw_demo_example_script.py .dat -# -# Notes: -# 1. The parser_mmw_demo script will output the text version -# of the captured files on stdio. User can redirect that output to a log file, if desired -# 2. This example script also outputs the detected point cloud data in mmw_demo_output.csv -# to showcase how to use the output of parser_one_mmw_demo_output_packet -# **************************************************************************** - -import os -import sys -# import the parser function -from parser_mmw_demo import parser_one_mmw_demo_output_packet - -################################################################################## -# INPUT CONFIGURATION -################################################################################## -# get the captured file name (obtained from Visualizer via 'Record Start') -if (len(sys.argv) > 1): - capturedFileName=sys.argv[1] -else: - print ("Error: provide file name of the saved stream from Visualizer for OOB demo") - exit() - -################################################################################## -# USE parser_mmw_demo SCRIPT TO PARSE ABOVE INPUT FILES -################################################################################## -# Read the entire file -fp = open(capturedFileName,'rb') -readNumBytes = os.path.getsize(capturedFileName) -print("readNumBytes: ", readNumBytes) -allBinData = fp.read() -print("allBinData: ", allBinData[0], allBinData[1], allBinData[2], allBinData[3]) -fp.close() - -# init local variables -totalBytesParsed = 0; -numFramesParsed = 0; - -# parser_one_mmw_demo_output_packet extracts only one complete frame at a time -# so call this in a loop till end of file -while (totalBytesParsed < readNumBytes): - - # parser_one_mmw_demo_output_packet function already prints the - # parsed data to stdio. So showcasing only saving the data to arrays - # here for further custom processing - parser_result, \ - headerStartIndex, \ - totalPacketNumBytes, \ - numDetObj, \ - numTlv, \ - subFrameNumber, \ - detectedX_array, \ - detectedY_array, \ - detectedZ_array, \ - detectedV_array, \ - detectedRange_array, \ - detectedAzimuth_array, \ - detectedElevation_array, \ - detectedSNR_array, \ - detectedNoise_array = parser_one_mmw_demo_output_packet(allBinData[totalBytesParsed::1], readNumBytes-totalBytesParsed) - - # Check the parser result - print ("Parser result: ", parser_result) - if (parser_result == 0): - totalBytesParsed += (headerStartIndex+totalPacketNumBytes) - numFramesParsed+=1 - print("totalBytesParsed: ", totalBytesParsed) - ################################################################################## - # TODO: use the arrays returned by above parser as needed. - # For array dimensions, see help(parser_one_mmw_demo_output_packet) - # help(parser_one_mmw_demo_output_packet) - ################################################################################## - - - # For example, dump all S/W objects to a csv file - import csv - if (numFramesParsed == 1): - democsvfile = open('mmw_demo_output.csv', 'w', newline='') - demoOutputWriter = csv.writer(democsvfile, delimiter=',', - quotechar='', quoting=csv.QUOTE_NONE) - demoOutputWriter.writerow(["frame","DetObj#","x","y","z","v","snr","noise"]) - - for obj in range(numDetObj): - demoOutputWriter.writerow([numFramesParsed-1, obj, detectedX_array[obj],\ - detectedY_array[obj],\ - detectedZ_array[obj],\ - detectedV_array[obj],\ - detectedSNR_array[obj],\ - detectedNoise_array[obj]]) - - - else: - # error in parsing; exit the loop - break - -# All processing done; Exit -print("numFramesParsed: ", numFramesParsed) diff --git a/test.py b/test.py deleted file mode 100644 index 65c1b19..0000000 --- a/test.py +++ /dev/null @@ -1,111 +0,0 @@ -import serial -import time - -import matplotlib.pyplot as plt -from mpl_toolkits.mplot3d.axes3d import Axes3D - -from parser_mmw_demo import parser_one_mmw_demo_output_packet - -# Turning interactive mode on for plotting -plt.ion() -fig = plt.figure() - -# Change the configuration file name -configFileName = 'hedgehog.cfg' - -# ------------------------------------------------------------------ - -# Function to configure the serial ports and send the data from -# the configuration file to the radar -def serialConfig(configFileName): - - # Serial device ports - CLIport = serial.Serial('/dev/ttyACM0', 115200) - Dataport = serial.Serial('/dev/ttyACM1', 921600) - - # Read the configuration file and send it to the board - with open(configFileName, mode="rt", encoding="utf-8") as config_file: - for line in config_file: - line = line.rstrip("\r\n") - print(f"[CONFIG] writing: '{line}'") - - CLIport.write((line + "\n").encode()) - time.sleep(0.01) - - return CLIport, Dataport - -# ------------------------- MAIN ----------------------------------------- - -# Configurate the serial port -CLIport, Dataport = serialConfig(configFileName) # Enable when reading from sensor -# Dataport = open("sensor_data.bin", mode="rb") # Enable when reading from file - -# parser_one_mmw_demo_output_packet extracts only one complete frame at a time -# so call this in a loop till end of file - -def parse_frames(): - - ax = fig.add_subplot(projection="3d") - - # making the plot axis constant - ax.set_xlim(0, 1) - ax.set_ylim(0, 1) - ax.set_zlim(0, 1) - - plt.show() - - sensor_data = bytearray() - bytes_parsed = 0 - while True: - read_data = Dataport.read(256) - with open("sensor_data.bin", mode="ab") as fp: - fp.write(read_data) - - sensor_data += bytearray(read_data) - - # parser_one_mmw_demo_output_packet function already prints the - # parsed data to stdio. So showcasing only saving the data to arrays - # here for further custom processing - parser_result, \ - headerStartIndex, \ - totalPacketNumBytes, \ - numDetObj, \ - numTlv, \ - subFrameNumber, \ - detectedX_array, \ - detectedY_array, \ - detectedZ_array, \ - detectedV_array, \ - detectedRange_array, \ - detectedAzimuth_array, \ - detectedElevation_array, \ - detectedSNR_array, \ - detectedNoise_array = parser_one_mmw_demo_output_packet(sensor_data[bytes_parsed::1], len(sensor_data) - bytes_parsed) - - ax.clear() - - # Setting axis labels - ax.set_xlabel("X label") - ax.set_ylabel("Y label") - ax.set_zlabel("Z label") - - ax.set_autoscale_on(False) - ax.scatter(detectedX_array, detectedY_array, detectedZ_array) - plt.pause(0.01) - - # Check the parser result - print ("Parser result: ", parser_result) - if (parser_result == 0): - bytes_parsed += (headerStartIndex+totalPacketNumBytes) - print("totalBytesParsed: ", bytes_parsed) - else: - # bytes_parsed += 1 - continue - -if __name__ == "__main__": - try: - parse_frames() - except KeyboardInterrupt: - CLIport.write("sensorStop\n".encode()) # Enable when reading from sensor - # Dataport.close() # Enable when reading from file - exit(0)