range-Doppler and micro-Doppler maps example code

Discussion in 'X2 & X4 SoC' started by Ivo, Jul 5, 2017.

  1. Ivo

    Ivo New Member

    I found the simple_xep python script for the baseband which works nicely. Is there an also example on the range-Doppler processing for the X4M03? Like in

    While we are no experts (we want to use the X4 for machine learning) it seemed there were missing some API functions in the moduleconnector to get the necessary (pulse) information to do it.

    As a sidenote, we don't have Atmel-ICE and hence are unable to update our X4M03 with new firmware, does this pose a problem? I.e., have there been any serious bugs fixed the last 6 months? Thanks in advance.
  2. Olav Liseth

    Olav Liseth Administrator Staff Member

    Hi Ivo,

    Good you found the example, we will add more in the future. The X4M03 module only gives access to raw X4 radar data and we do not have any pulse-doppler processing examples. In it simples form:

    1. Read out and store a history of x baseband frames
    2. FFT for each range bin

    You can add filtering before the FFT, e.g an MTI filter.

    The X4M300 and X4M200 modules outputs the range doppler matrix, given the settings and configuration we use for each application. See the datasheets for more info.

    You should update XEP on your module: See instructions and changelog here: https://www.xethru.com/community/resources/xep-binary.88/

  3. Ivo

    Ivo New Member

    Hi Olav,

    Thanks, I read some more on pulse-Doppler processing and things are becoming more clear. My apologies for the straightforward questions but it is always nice to learn something new.

    1. I actually did the processing above before. In its simplest form:
    X = []
    X.append(read_frame()) # with the baseband option
    X = np.array(X) # n_samples x n_bins
    fft(X), axis=0) # fft over n_samples
    fftshift(X, axis=0)

    If this is correct I think I might have to tweak the parameters a bit (and add some filtering) as my simple test scenario (a person walk to and from the radar) doesn't seem to (visually) give the correct range-Doppler map.

    Before I do some further testing, I can do this with an older firmware too right? Or are there serious bugs and is that the reason why I get erratic results? My X4M03 reports:
    ('id:', 'XEP')
    ('version:', '1.0.3-rc.2')
    ('build:', '1.0.3-rc.2+0.sha.713e4a289e2a22c37edfe33bed5eea73d0f65d4a')
    ('info:', 'XEP:1.0.3-rc.2;X4C51:1.0.3')

    In any case I'm looking for someone with an Atmel-ICE at my department to flash the firmware.
  4. Ivo

    Ivo New Member

    Should someone be interested I have attached my basic range-Doppler script.

    It seems to work, next I'll look at some windowing (e.g., hanning), but first I need to understand the parameters a little bit better.

    How does the FPS relate to r.read_message_data_float(). Does the function block if no frame is yet available or does it error out? Does it have some internal buffer and/or does it discard frames if you do not get them fast enough?

    Attached Files:

  5. Olav Liseth

    Olav Liseth Administrator Staff Member

    Hi Ivo,

    Tried your example, but there seems to be an error:
    Module: X4M300 (Added code below to enable XEP)
    Python 2.7.13
    numpy.__version__ Out[3]: '1.12.1'

    Traceback (most recent call last):
    File "xep_rangeDoppler.py", line 136, in animate
    history = np.hanning(n_samples)*np.array(frames)
    ValueError: operands could not be broadcast together with shapes (32,) (32,178)

    I added the following to line 48 to disable sensor and enable XEP:

        # Assume an X4M300/X4M200 module and try to enter XEP mode
        app = mc.get_x4m300()
        # Stop running application and set module in manual mode.
            app.set_sensor_mode(0x13, 0) # Make sure no profile is running.
        except RuntimeError:
            # Profile not running, OK
            app.set_sensor_mode(0x12, 0) # Manual mode.
        except RuntimeError:
            # Sensor already stopped, OK
    The r.read_message_data_float is blocking and will return when data is available. MC has an internal buffer and will discard data when full. I have filed a task to update the documentation.

    Looking forward to try out your demo,



    Hi Olav,
    This is what I get from the script adding your modifications. I have supressed the hanning windowing of n_samples to make it works as it seems to be a numpy broadcasting rule problem. But still need debugging.



    Attached Files:

  7. Ivo

    Ivo New Member

    Yes, sorry. Somehow I uploaded a newer version where I was experimenting with some things. You can just remove the np.hanning and it will work fine. Or you can easily fix the broadcasting, probably something like:
    han = np.hanning(n_samples)
    history = han[n_samples,None]*np.array(frames)

    I did remove the X4M300 code as we have a X4M03 development board and as far as I know then it is not needed. I will add it back in for future versions.
  8. Ivo

    Ivo New Member

    Here is my current version of the script:
    - Fixed range-Doppler + hanning
    - Added micro-Doppler plot. I take the mean over the range for each range-Doppler map which should actually be the sum I believe. This is just so I can use the same vmin and vmax bounds with FuncAnimation.
    - Everything is in dB now
    - I threshold everything lower than -45 dB
    - Played a bit with the parameters to get higher fps

    Attached is also a movie with me walking slow/fast to and from the radar.

    If anyone has suggestions on how to tweak the radar parameters further to achieve greater resolution or fps, let me know. Or perhaps I have reached the physical limits of the X4 SOC?

    Attached Files:



    Hi Ivo,
    Thank you for sharing your code. I have had a look to the code and the illustration. - 45 dB threshold can't give the same result as in your illustration (the threshold is high). For the y axis, in the illustration you have 0 to - 50 dB min/max, impossible to obtain with the script.
    You are moving forward and backward in front of the module, how do you retrieve useful information from that signal processing ?

    For the limits of X4 SOC, xethru team is competent to answer to your question. But what I know from the forum is that X4M03 kit still have some limitations and you need to switch to Cayenne for more performance rooms.

  10. Ivo

    Ivo New Member

    Hi Chouaibou,

    Thanks for the feedback. Only the history of frames, range-Doppler and micro-Doppler plots are thresholded (the last 3 plots). The first plot is the unthresholded frame.

    > You are moving forward and backward in front of the module, how do you retrieve useful information from that > signal processing ?
    What do you mean by this exactly? We are investigating the use of machine learning for different use cases. For instance classifying between humans and dogs based on their gait (this can be seen in the micro-Doppler). However we are using a higher resolution FMCW radar for that at the moment. I'm just investigating the performance and resolution of the X4 to be able to do these kind of things.

    To that end, Cayenne is interesting. If you know other radar development kits (higher bandwidth, base frequency, continuous wave, etc.) this is very useful. Thanks.
  11. Olav Liseth

    Olav Liseth Administrator Staff Member



    Hi Ivo,
    For energy saving applications, for instance for effective presence detection with ability to discriminate human, objects and animals (based on micro doppler signature), X4 chip is enough for custom development. Just because you are not emitting high power rf signal and outband energy is well controlled. At the same time you have advantage of Utra Wide Band pulses. For radar development kit based on FMCW, i can't help you as I am using only xethru products for the moment.


    Hi Olav,
    Thank you for clarification. I have tested Ivo's python code based on 480 FPS . What is the highest FPS with acceptable SNR ? Is it any limitation ?