分类 算法与数学基础 下的文章

OriginLab


Performing FFT to a signal with a large DC offset would often result in a big impulse around frequency 0 Hz, thus masking out the signals of interests with relatively small amplitude.

Remove_DC_Offset_Blog_10

Origin provides two methods to remove DC offset from the original signal before performing FFT:

  • Using FFT High-Pass Filter
  • Subtracting the Mean of Original Signal

Note that these two methods can get the same result. You can also not filter the input, but set zero to the zero frequency point for FFT result.

Using FFT High-Pass Filter

Any DC bias on the signal will show up in the frequency domain as amplitude at zero Hz, by setting the cutoff frequency to be zero DC offset can be filtered. Steps are as following:

  1. Import the fftfilter2.dat under Origin exe\Samples\Signal Processing\ folder.

  2. Highlight the source signal column Amplitude, and select menu Analysis: Signal Processing: FFT Filters.

  3. In the pop-up dialog, choose High Pass for Filter Type, uncheck Auto checkbox to set Cutoff Frequency to zero and clear the Keep DC offset check-box.

Remove_DC_Offset_Blog_07

  1. Click OK button to get the result without DC offset.

Remove_DC_Offset_Blog_08

 

Subtracting the Mean of Original Signal

  1. Now we have the original signal stored in column B (Amplitude). Hold Ctrl + D to add a new column C for storing DC offset removed signal and input DC Offset Removed as Long Name.

  2. Highlight column C, and select Set Column Values from the context menu to bring up the Set Values dialog.

  3. In Before Formula Scripts panel of the Set Values dialog, put the script:

stats col(b);

Then in the column formula text box, fill column C using the formula:

col(b)-stats.mean

Remove_DC_Offset_Blog_03

  1. Column C is the result without DC offset.

Remove_DC_Offset_Blog_09

 

Tips: 

If you need to get the DC offset, open the dialog mentioned in method one, then use the low-pass filter, and set Cutoff Frequency to zero, or use the Mean function to calculate the mean of the signal:

DCOffset = Mean(col(B));

一、采集IMU数据

         将IMU静止放置,然后采集至少3小时以上的数据用于分析IMU的随机误差,当然记录的数据越多,标定的精度越高。



二、编译bagconvert(kalibr_allan)

            根据自己matlab安装的路径,修改文件: cmake/FindMatlab.cmake

            例如:

             修改前:  find_program(MATLAB_EXE_PATH matlab  PATHS /usr/local/bin)

             修改后:  find_program(MATLAB_EXE_PATH matlab  PATHS /home/flmxi/INSTALL_Matlab/bin)

             修改cmake后按照常规的cmake编译流程即可。   


三、数据格式转换(rosbag -> mat)

      利用第二步编译的结果:bagconvert,将rosbag格式文件转换为matlab的***.mat矩阵文件。

          bagconvert            <rosbag文件>     <IMU topic>

          例如:

                  devel/lib/bagconvert/bagconvert     ~/Downloads/imu_xsens.bag    /imu/data

      命令执行完成后,生成matlab的mat矩阵文件,例如: ~/Downloads/imu_xsens.mat



四、执行allan方差分析

          根据第三步的生成结果所在的路径,修改matlab脚本文件:SCRIPT_allan_matparallel.m,


          mat_path = '~/Downloads/imu_xsens.mat';


          用命令行或图像界面运行脚本: SCRIPT_allan_matparallel.m,完成allan方差分析


         allan方差分析完成后生成matlab矩阵文件:results_20240812T163428.mat


五、绘制allan方差图

      根据第四步的结果文件: results_20240812T163428.mat,修改matlab显示脚本: SCRIPT_process_results.m

             mat_path = '../data/results_20240812T163428.mat';

      然后用命令行或图形界面执行脚本:SCRIPT_process_results.m

      结果如下: