Accelerometer and Gyroscope timestamp issue


#1

Hi everyone,

I have a question with respect to the IMU data acquisition. I have set the sampling frequency to AccelAndGyro_1000Hz and I have verified that indeed the sampling frequency of both the gyro and the accelerometer is roughly 1000Hz. However, I observed a strange behavior. I was expecting that every time an event happens, its respective timestamp should be greater than the timestamp of the previous event. Surprisingly it seems as if the gyro and the accel are not sharing the same time. Below I attach the piece of the code responsible for streaming only IMU data with ROS and the respective log output.

  void captureSessionDidOutputSample(ST::CaptureSession *, const ST::CaptureSessionSample& sample)
      {
        switch (sample.type)
        {
          case ST::CaptureSessionSample::Type::AccelerometerEvent:
          std::cout << "[AcceleromEvent]: time = " << std::to_string(sample.accelerometerEvent.timestamp()) << std::endl;
          break;
          case ST::CaptureSessionSample::Type::GyroscopeEvent:
          std::cout << "[GyroscopeEvent]: time = " << std::to_string(sample.gyroscopeEvent.timestamp()) << std::endl;
          break;
          default:
          printf("Sample type %d unhandled\n", (int)sample.type);
        }
      }

log-output

[AcceleromEvent]: time = 524085.414523
[GyroscopeEvent]: time = 524085.411144
[AcceleromEvent]: time = 524085.415528
[GyroscopeEvent]: time = 524085.412144
[AcceleromEvent]: time = 524085.416541
[GyroscopeEvent]: time = 524085.413196
[AcceleromEvent]: time = 524085.417542
[GyroscopeEvent]: time = 524085.414150
[AcceleromEvent]: time = 524085.418550
[GyroscopeEvent]: time = 524085.415156
[AcceleromEvent]: time = 524085.419558
[GyroscopeEvent]: time = 524085.416164
[GyroscopeEvent]: time = 524085.417156
[AcceleromEvent]: time = 524085.420565
[AcceleromEvent]: time = 524085.421576
[GyroscopeEvent]: time = 524085.418210
[GyroscopeEvent]: time = 524085.419158
[AcceleromEvent]: time = 524085.422578
[GyroscopeEvent]: time = 524085.420161
[AcceleromEvent]: time = 524085.423590
[GyroscopeEvent]: time = 524085.421164

As you can see, two consecutive accelerometer or gyroscope samples differ by approximately 1ms (1000Hz), which is correct, but for some reason although the accelerometer event happens prior to the gyroscope event, the former’s timestamp for some reason is consistently greater than the latter’s which is quite paradoxical. It’s like they are not sharing the same time reference (different clock). Could you please enlighten me, why would this be happening? Am I doing something wrong?

Thanks in advance for your time.


#2

Hi, I now did some further testing with your ros1_driver in ROS for the latest SDK and confirmed the same results I got before in terms of receiving old gyroscope measurements. Previously I was running with the ROS from https://github.com/chadrockey/structure_core_ros, which I forgot to mention.

I now also checked the timestamps for the imu measurements by printing the timestamp on the function “onIMUAvailableEvent” in SCtoSensorMsgConverter.h, and also reading and printing the ROS imu message that is being published. What happens is that for each measurement, there are two events occurring at the same time, so the imu_msg gets published twice with the same measurement and same timestamp. Is this a verified bug or there is something wrong with the way I am running it? I tried this both with the ROS flag " low_latency_imu" set to true and false, and for rates AccelAndGyro_1000Hz and AccelAndGyro_200Hz. Here you can see an example of the timestamps and the difference between the time instances for the same measurement and the difference between gyro and accelerometer for the AccelAndGyro_1000Hz case.

Screenshot%20from%202019-08-27%2011-47-23