采样实时IMU数据检查阈值

时间:2020-05-04 16:04:12

标签: c++ signal-processing

我正在使用IMU传感器数据按实时方式绘制加速度值:

void Settings::realtimeDataSlot(double x_acceleration_g, double y_acceleration_g, double z_acceleration_g)
{
    static QTime time(QTime::currentTime());
    // calculate two new data points:
    double key = time.elapsed()/1000.0; // time elapsed since start of demo, in seconds
    static double lastPointKey = 0;
    if (key-lastPointKey > 0.02) // at most add point every 2 ms
    {

        ui->customPlot->graph(0)->addData(key, x_acceleration_g);
        ui->customPlot->graph(1)->addData(key, y_acceleration_g);
        ui->customPlot->graph(2)->addData(key, z_acceleration_g);


      lastPointKey = key;
    }
    // make key axis range scroll with the data (at a constant range size of 8):
    ui->customPlot->xAxis->setRange(key, 8, Qt::AlignRight);
    ui->customPlot->replot();

}

我已经显示了加速度x,y,z值,使用上面的代码,可以正常工作(x,y,z加速度值是实时显示的)。

但是现在我需要进行某种阈值检测。例如,在下图中,我有两种不同的情况,其中(A)为正加速度,然后为负加速度,(B)为负加速度,然后为正。

enter image description here

具体来说,我需要进行以下检查:

  1. 检查加速度是否超过阈值
  2. 检查之前是否有负值

有人可以指导我如何检查上述代码中的条件吗?

0 个答案:

没有答案