PreSenseRadar / OpenRadar

An open source library for interacting with and processing radar data, specialized for MIMO mmWave radars
Apache License 2.0
604 stars 198 forks source link

recording with dca1000 without mm-wave studio #17

Open arvindsr33 opened 4 years ago

arvindsr33 commented 4 years ago

In this implementation, does the data capture using DCA1000 module require mmwave studion for capturing? Or is it possible to configure the radar module (say 1843) using a python script and then run dca = DCA1000() adc_data = dca.read() to capture the raw data?

edwin-pan commented 4 years ago

Currently you need mmwave studio. We've heard a few times before that it would be great if we could bypass mmwave studio in the manner you described. @DashKosaka should be able to guide you in the right direction if you're looking to implement something like you described.

arvindsr33 commented 4 years ago

I see, thank you for clarification. In the recent sdk release (3.3), the demo project has DCA-based LVDS streaming option enabled. It has two components - (1) programming DCA for capture and (2) configuring radar parameters. Is you python DCA1000 implementation similar to DCA programming used for demo (section 3.3.2, sdk 3.3 user guide, pages 13-17), or different?

image

I'm asking this because DCA as a standalone executable (DCA1000EVM_CLI_Control.exe, present in \mmwave_studio_02_00_00_02\mmWaveStudio\PostProc) has been implemented only in mmw Studio 2.1. In the previous Studio versions, its only a bunch of DLL's used by Studio software.

In addition, I implemented radar configuration script in python, which runs perfectly fine with DCA executable as mentioned in the user guide, but it did not work with your python DCA1000 implementation.

bayramf commented 4 years ago

@arvindsr7 In 'mmwave/dataloader/adc.py' there are already the commands to control mmWave via Python. I was able to recreate most of it, but I couldn't get the button 'Trigger Frame' to work. Unfortunately, it does not work with 'RECORD_START_CMD_CODE'. I also checked the data flow of the ethernet with WireShark when I pressed the Trigger Frame button in mmWave. But I could not get any useful information from the data packets.

@edwin-pan Do you already have a solution for this issue? Thank you.

Justus98 commented 4 years ago

@bayramf I'm working on a solution for realtime capturing and processing in Matlab. If I'm right the commands from line 22-35 of the adc.py script controls the DCA1000 and not the AWRxxxx. So by sending 'RECORD_START_CMD_CODE' (over port 4096) only your DCA1000 is ready to go. You have to tell the AWR to 'Trigger Frame'. This communication runs via USB (if I'm right) and I don't know whether there is any implementation yet?! You can retrace this by 'Trigger Frame' over mmWaveStudio. By pushing the button you won't see any UDP-packet send over Port 4096 (I'm using Wireshark). The DCA1000 will immediately start sending Data-packets to Port 4098. My solution: Control LUA-Shell over Matlab (--> See documentations)

I hope I understood your question correctly^^

bayramf commented 4 years ago

@Justus98 Thanks for your response! I would have liked to make it work through Python. Currently, I'm running a lua script through the command line, which calls and executes mmWave, and then using Python to intercept and process the data. That works also well.

However, I would be interested in a solution to run everything only through Python. If something new should arise, please commit. Thank you for your effort!

Other Topic I am just about to display a micro-Doppler in real time. I have already worked on a static version, but my results don't look very promising. Have you already implemented anything in this form? If not, would it be possible to give me a little help?

Enclosed is an exemplary micro-Doppler on which a person is located and moving at walking speed against the radar.

Micro Doppler

How I generated the signature: I created the STFT for each frame (from a total of 20) with using Hamming window of length 128 and stacked them in sequence. On the x-axis the samples are shown (each frame has 256 samples; 20 frames = 5120 samples). Velocity can be seen on the y-axis.

arvindsr33 commented 4 years ago

@bayramf, your micro-Doppler plot looks great. You could also keep the positive velocity axis to capture positive micro-motions.

You also mentioned that you're running lua script through command line and then capturing data. That's great. Are you streaming data to Python script in real-time, or are you recording into binary files first and reading them sequentially?

bayramf commented 4 years ago

@arvindsr7 Thanks a lot! I am actually much more in search of signatures like these ones (see below). Hmm, but there are no signals on the positive velocity axis. Or what did you exactly mean by keeping the positive velocity axis? Can you explain further, please?

Unbenannt

Spectrogram-of-micro-Doppler-signal-provoked-by-walking-human-The-signal-is-modeled-by

Executing mmWave through Python and Lua I run a command in Python that executes mmWave together with my settings (lua script) and then I am able to receive and process sensor data via Python.

import subprocess, time

subprocess.Popen(r'C:\User\src\Config_Files\Run_mmWaveStudio.cmd', 
                 cwd=r'C:\ti\mmwave_studio_02_00_00_02\mmWaveStudio\RunTime')
time.sleep(55) #Wait until mmwave is completely executed

dca = DCA1000()
adc_data = dca.read()
while True:
           ..........

Command for executing mmWave with settings through the shell:

cmd /C "mmWaveStudio.exe /lua C:\User\src\Config_Files\1443_mmwavestudio_config.lua"

Create a new text file and insert this command into it. Save it and change the extension to .cmd. Than put this file in the directory 'ti\mmwave_studio_02_00_00_02\mmWaveStudio\RunTime'. Now you can run it with python (see code above) and capture data. Remember to adjust the paths! Hope this helps you.

arvindsr33 commented 4 years ago

@bayramf, thanks for letting me know about data capture implementation - I'll check it out.

Micro motions, like motion of hands and legs while walking, go back and forth; so there are both positive and negative velocities involved. But when the object velocity itself is very high, say of bicycle, then these micro motions get modulated, so they might appear only as positive velocity. Still, it makes sense to keep both positive and negative velocities in micro-Doppler plot, because both contain half of the information. For instance, the bicyclist could be going away from the radar, instead of coming towards; in that case, you'll see negative micro-Doppler signatures.

So, in my opinion, it makes sense to retain all information in micro-Doppler axis, unless, in your specific application, you know for sure that there's no information in the other half.

I'm sure you could get the desired plot if you could carefully repeat the experiments of these plots. And besides, if you are thinking of machine learning based classifications, more micro-Doppler information would only be advantageous.

edwin-pan commented 4 years ago

We've looked into implementing microdoppler into OpenRadar, though we never agreed on a solution. From audio signal processing, the spectrogram is typically generated by taking windowed FFTs of a 1D time sequence of magnitude readings (like audio mic readings). Technically, this can be done with a MIMO radar as well. However, I believe we would first need to ensure that the data is reorganized into that same 1D time sequence. The data that comes out of the DCA1000 has a specific organization that I haven't had to the time to dig into (i.e. which chirp corresponding to which vrx comes first? Are they temporally consistent?). I believe if you could ensure the 1D sequence is temporally consistent, then you could use the method @bayramf mentioned with STFT of N point samples (as in, the same 'samples' denomination used per chirp that's used to find range info) + window & overlapping.

An alternative interpretation is to just perform range and doppler processing and stack these plots over time. Conveniently, you would end up with a similar time vs. frequency plot though I would hesitate to call this a proper microdoppler spectrogram. I've included an example of that such a plot would look like (link) . If anyone can sort out a more formal approach to microdoppler and share the implementation, it would make a great addition to OpenRadar.

bayramf commented 4 years ago

@arvindsr7 You are welcome, sharing is caring! ;) Thanks for your explanations. I have some thinking to do about that. Yes, you are right. More Information is only advantageous in case of machine learning based classifications.

@edwin-pan Thanks for your response. I will give this a try. If something new arises regarding a "real" micro doppler spectogram, I will let you know.

bayramf commented 4 years ago

@edwin-pan I have stacked the plots over time now. But how can I get rid of the range axis and save the data to a txt file? I have plotted the 3d array with scatter from matplotlib, but it is very slow when I want to pan or zoom. With which library do you plotted it? What also interests me is how you have processed your data with the logarithm so that you get a representation like in the video. Can you please explain further? Thank you.

Edit After some brooding, I think I got figured it out. First of all I stacked all frames over a new axis 2. So I had an array of (256 (samples), 255 (chirps), 20 (frames)). As a last step I stacked all arrays from axis 1 and finally got the frequency over time array (255, 5120). Please correct me if I am wrong. But how did you process your data with the logarithm to get the display like in the video?

Figure_1

My micro doppler doesn't quite look like yours from the video. Especially at first I can't explain why there are gaps between the signals. I'm only driving 1 Tx, maybe that's the problem?!

edwin-pan commented 4 years ago

You should have 256 samples, 255 chirps, and 20 frames. If you're looking to stack the range doppler plots, make sure to have done the FFT along both chirps and samples, making it 256 range bins by 255 doppler bins by 20 frames. If you want a 2D plot, I settled with simply accumulating along the range axis, making the final plot 20 frames by 255 doppler bins.

I'm not entirely sure what you mean by processing the data with the logarithm. There's a default log2 in the OpenRadar range_processing and doppler_processing functions that takes care of this, as well as any data interweaving to ensure correct output. I used those to build the 3D plot in the video.

For visualization, I'm using a visualization package called napari (link). It's called as follows:

# Make Cool Plot import napari viewer = napari.view_image(micro_doppler_data)

The full script I ran is here.

I suggest you open a new issue for this microdoppler discussion and, if you're willing, share the script you're running so I can take a closer look.

Cheers

bayramf commented 4 years ago

I'll try to recreate that with my data. Thanks a lot for your help!

lanqiudiyi commented 3 years ago

Hi edwin First of all, thank you for sharing. Now we are also implementing real-time adc raw data collection on the iwr6843 platform, but you must run the stuido tool first. Can you capture adc data through udp without running the studio tool in the python environment?

Carbord commented 3 years ago

@arvindsr7 Thanks a lot! I am actually much more in search of signatures like these ones (see below). Hmm, but there are no signals on the positive velocity axis. Or what did you exactly mean by keeping the positive velocity axis? Can you explain further, please?

Unbenannt

Spectrogram-of-micro-Doppler-signal-provoked-by-walking-human-The-signal-is-modeled-by

Executing mmWave through Python and Lua I run a command in Python that executes mmWave together with my settings (lua script) and then I am able to receive and process sensor data via Python.

import subprocess, time

subprocess.Popen(r'C:\User\src\Config_Files\Run_mmWaveStudio.cmd', 
                 cwd=r'C:\ti\mmwave_studio_02_00_00_02\mmWaveStudio\RunTime')
time.sleep(55) #Wait until mmwave is completely executed

dca = DCA1000()
adc_data = dca.read()
while True:
           ..........

Command for executing mmWave with settings through the shell:

cmd /C "mmWaveStudio.exe /lua C:\User\src\Config_Files\1443_mmwavestudio_config.lua"

Create a new text file and insert this command into it. Save it and change the extension to .cmd. Than put this file in the directory 'ti\mmwave_studio_02_00_00_02\mmWaveStudio\RunTime'. Now you can run it with python (see code above) and capture data. Remember to adjust the paths! Hope this helps you. Hello, we are trying to follow your way to capture the radar data in realtime.But we got the error as belows.I guess the reason may be the lua file is wrong since we use the 1843_mmwavestudio_config.lua in this openradar repository. So we would like to know how you write the 1443_mmwavestudio_config.lua. Another question is that if your way go through successfully, does it means that we don't need to press the button in mmwave studio but still can collect the data. We hope for your replies, thanks a lot. $44K`_OE5YB9CHTK$MR~OA1

eyeris commented 3 years ago

Dear all and @DashKosaka I have noticed I'm getting around half of the frames from what I can see in mmwave studio when using open radar. I tried increasing the timeout and increasing the packet delay in mmwave studio but no luck. Any ideas about what to do?

JustinOng commented 2 years ago

@Carbord I'm documenting this as I ran into the same issue:

To resolve the specific issue about "attempt to index global ar1 (a nil value)", I run "AR1xInit.lua" at the start of the script, ie as follows:

COM_PORT=17

RADARSS_BIN_PATH = "C:\\ti\\mmwave_studio_02_01_01_00\\rf_eval_firmware\\radarss\\xwr18xx_radarss.bin"
MASTERSS_BIN_PATH = "C:\\ti\\mmwave_studio_02_01_01_00\\rf_eval_firmware\\masterss\\xwr18xx_masterss.bin"

dofile("C:\\ti\\mmwave_studio_02_01_01_00\\mmWaveStudio\\Scripts\\AR1xInit.lua")
ar1.FullReset()
ar1.SOPControl(2)
ar1.Connect(COM_PORT,921600,1000)
ar1.Calling_IsConnected()
ar1.SelectChipVersion("AR1642")
ar1.SelectChipVersion("AR1642")
ar1.deviceVariantSelection("XWR1843")
ar1.frequencyBandSelection("77G")
ar1.SelectChipVersion("XWR1843")
ar1.DownloadBSSFw(RADARSS_BIN_PATH)
ar1.GetBSSFwVersion()
ar1.GetBSSPatchFwVersion()
ar1.DownloadMSSFw(MASTERSS_BIN_PATH)
ar1.GetMSSFwVersion()
ar1.PowerOn(0, 1000, 0, 0)
ar1.SelectChipVersion("AR1642")
ar1.SelectChipVersion("XWR1843")
ar1.RfEnable()
ar1.GetMSSFwVersion()
ar1.GetBSSFwVersion()
ar1.GetBSSPatchFwVersion()
ar1.ChanNAdcConfig(1, 0, 0, 1, 0, 0, 0, 2, 1, 0)
ar1.LPModConfig(0, 0)
ar1.RfInit()
ar1.DataPathConfig(513, 1216644097, 0)
ar1.LvdsClkConfig(1, 6)
ar1.LVDSLaneConfig(0, 1, 1, 0, 0, 1, 0, 0)
ar1.SetTestSource(4, 3, 0, 0, 0, 0, -327, 0, -327, 327, 327, 327, -2.5, 327, 327, 0, 0, 0, 0, -327, 0, -327, 327, 327, 327, -95, 0, 0, 0.5, 0, 1, 0, 1.5, 0, 0, 0, 0, 0, 0, 0)
ar1.ProfileConfig(0, 77, 100, 6, 60, 0, 0, 0, 0, 0, 0, 29.982, 0, 256, 10000, 0, 0, 30)
ar1.ChirpConfig(0, 0, 0, 0, 0, 0, 0, 1, 0, 0)
ar1.EnableTestSource(1)
ar1.FrameConfig(0, 0, 8, 128, 40, 0, 0, 1)

This file was generated by running mmWave Studio, going through all the configuration options, then carving out all calls to ar1.<...> from the Output tab.

ghost commented 1 year ago

@bayramf I'm working on a solution for realtime capturing and processing in Matlab. If I'm right the commands from line 22-35 of the adc.py script controls the DCA1000 and not the AWRxxxx. So by sending 'RECORD_START_CMD_CODE' (over port 4096) only your DCA1000 is ready to go. You have to tell the AWR to 'Trigger Frame'. This communication runs via USB (if I'm right) and I don't know whether there is any implementation yet?! You can retrace this by 'Trigger Frame' over mmWaveStudio. By pushing the button you won't see any UDP-packet send over Port 4096 (I'm using Wireshark). The DCA1000 will immediately start sending Data-packets to Port 4098. My solution: Control LUA-Shell over Matlab (--> See documentations)

I hope I understood your question correctly^^

This was referenced @arvindsr7 Thanks a lot! I am actually much more in search of signatures like these ones (see below). Hmm, but there are no signals on the positive velocity axis. Or what did you exactly mean by keeping the positive velocity axis? Can you explain further, please? #31

I am learning how to capture and process DCA1000+IWR1443 raw data in real time in Matlab. Do you have a relevant solution or open source code?

chomchom69420 commented 10 months ago

Hi edwin First of all, thank you for sharing. Now we are also implementing real-time adc raw data collection on the iwr6843 platform, but you must run the stuido tool first. Can you capture adc data through udp without running the studio tool in the python environment?

Hi, sorry for bringing this up here. Has anyone found out a way to do this? I am going to build something using a Jetson Nano and for that I need to do the entire setup on a linux-based system.

DagMalstaf commented 4 months ago

Hey everyone, My goal is also to use the DCA1000 + IWR6843 module to collect the raw ADC data in real-time. I am struggling a lot, is there any concrete python code to achieve this? Any help is appreciated!