azinke / coloradar

API for loading the Coloradar dataset.
MIT License
20 stars 0 forks source link

coupling_calib only include the real component #2

Open kangk906 opened 7 months ago

kangk906 commented 7 months ago

Hello, I recently downloaded the dataset and noticed that in the 'coupling_calib.txt' file, all values are real numbers. However, when reviewing the associated calibration tool documentation, it specifies that coupling calibration involves a mean operation, implying that the values should include both the real and imaginary components. I'm curious to understand why the values in the 'coupling_calib.txt' file only include the real component and not the imaginary component. Could you provide some clarification on this?

azinke commented 7 months ago

Hi @kangk906, Indeed, in my understanding, it should be the mean value (from multiple frames). Hence, if complex FFT is applied, the values of the coupling calibration shall also be complex; and if a real FFT was applied, then the values could be real. For the coloradar dataset, as you've mentioned, only the real values were provided; and in the related paper, the authors described that the coupling calibration values should be subtracted from the range FFT. The example Python code for applying it showed the same. However, in the example, all the negative values of the range FFT have been discarded.

# Excerp of example code from Coloradar dataset
# in: utils/ColoRadar_tools-master/python/calibration.py

# ...

  # run range fft
  range_fft = fft(adc_data, n=num_adc_samples_per_chirp,axis=-1)

  # discard negative component of range fft output
  range_fft = range_fft[:,:,:,1:num_range_bins]

  # apply coupling calibration
  return range_fft - coupling_calib['data'].reshape(num_tx, num_rx, 1, num_range_bins)

But why, I unfortunately can't answer that exactly. It's not stated as such in the paper, so...

But should in my understanding be complex; at least I've used the full complex value when calibrating a nother radar kit. The raw recording of the Coloradar dataset for computing the coupling calibration was not available to check. If you have some explanation for it, please let me know as well.

Brucye commented 1 month ago

Hi @azinke , @kangk906 , I recently found the same question as described by @kangk906 above. I found that in the python code provided by @azinke, the method 'get_coupling_calibration' in calibration.py will read the antenna coupling calibration matrix according to [num_tx, num_rx, 1, num_adc_samples_per_chirp].

def get_coupling_calibration(self) -> np.array: # 将txt里的校准矩阵reshape了一下
    """Return the coupling calibration array to apply on the range fft."""
    return np.array(self.coupling.data).reshape(
        self.coupling.num_tx,
        self.coupling.num_rx,
        1,
        self.waveform.num_adc_samples_per_chirp,
    )

Fisrt two parameters are read form coupling_calib.txt, while num_adc_samples_per_chirp is read from waveform_cfg.txt. The problem is that sampling points described by two .txt are different. Lets take single chirp (AWR1843BOOST) as an example, 128 points in waveform_cfg.txt and 64 points in coupling_calib.txt. According to the codes provided by the dataset, the length of the data from coupling_calib.txt is 1536 (3tx4rx128). The data then are unpacked to I and Q channel as 64 sampling points. That is 3tx4rx64 points. But the data provided by dataset is 3tx4rx128 points, the length is not matched.

def read_coupling_cfg(coupling_filename): coupling_calib = {}

with open(coupling_filename, mode='r') as file:
    lines = file.readlines()
num_tx = int(lines[0].split(':')[1])
num_rx = int(lines[1].split(':')[1])
num_range_bins = int(lines[2].split(':')[1])
coupling_calib['num_tx'] = num_tx
coupling_calib['num_rx'] = num_rx
coupling_calib['num_range_bins'] = num_range_bins
coupling_calib['num_doppler_bins'] = int(lines[3].split(':')[1])
data_str = lines[4].split(':')[1]
data_arr = np.array(data_str.split(',')).astype('float')
data_arr = data_arr[:-1:2] + 1j * data_arr[1::2]
coupling_calib['data'] = data_arr.reshape(num_tx, num_rx, num_range_bins)

return coupling_calib

If we follow the code provided by @azinke , is it equivalent to treating the real and imaginary parts of the sampling points (64 each) as all real parts(128) ? At the same time, the data length in codes provided by the dataset (128 sampling points) and the dimension in antenna coupling matrix (64 sampling points) do not match. This really makes me confused. I would like to know whether you have solved the problem. If you have any progress, please let me know.

Thank you!

azinke commented 1 month ago

Hi @Brucye ! Most of the radar devices support sampling either only the I channel (only real) or both I & Q.

According to the codes provided by the dataset, the length of the data from coupling_calib.txt is 1536 (3tx4rx128). The data then are unpacked to I and Q channel as 64 sampling points. That is 3tx4rx64 points. But the data provided by dataset is 3tx4rx128 points,

This means that the dataset itself is also recorded with I & Q channels if understood properly. This means that the dataset should reconstruct the data by computing the complex values (I + jQ). At the end, you then get 64 complex data points

There would be a mismatch if the dataset had 256 entries (that would give 128 after computing the complex values).

JJQ7 commented 1 month ago

@azinke @Brucye I also have the same confusion. While checking the TI official website, I couldn't find any specific reference materials or tools to address this calibration issue. Do you have any additional guidance or materials?