DavidGillsjo / VideoIMUCapture-Android

Android application for capture of Video, IMU data and Camera data useful in SLAM and Structure from Motion research. Differs between Optical Image Stabilization (OIS) and Digital Video Stabilization (DVS) and can provide OIS data if the device supports it.
GNU General Public License v3.0
231 stars 43 forks source link

Linear interpolation not working #9

Open johnnyhoichuen opened 1 year ago

johnnyhoichuen commented 1 year ago

I was checking the interpolation codes and I realise the leftAccel and rightAccel is always the same which eventually causing the interpolated acc_data equals to leftAccel and rightAccel.

I wonder if it only happens on my device (Samsung S8, Android 9) only.

Inside syncInertialData() in IMUManager

image

DavidGillsjo commented 1 year ago

Interesting! This code is from the mobile-ar-sensor-logger, so I have not developed it myself. I intend to build and try your pull request on my phone so then I can try this myself as well.

From the code I guess this means that either

  1. Your device's accelerometer reuse values, maybe it does not support 100Hz and simple send the latest sampled in the buffer?
  2. Something is not right the mAccelData buffer.
johnnyhoichuen commented 1 year ago

I ran the above test before the changes made on #10 (the original code).

I do see that the IMU frequency is 100Hz. I'd love to see the result on your phone just to make sure it was not device specific.

DavidGillsjo commented 1 year ago

Sorry, I have not yet had time to look at this. I'm currently finishing up my PhD and am a bit short on time. Just wanted to let you know it is not forgotten.

Shengnan-Zhu commented 1 year ago

@DavidGillsjo @johnnyhoichuen bug here lead to "left val = right val" when linearinterpolation: https://github.com/DavidGillsjo/VideoIMUCapture-Android/blob/721f62d9585f7b8663a21d10c6d56cd95f30bdcd/android_app/app/src/main/java/se/lth/math/videoimucapture/IMUManager.java#L275 I am not familiar with java,but I guess in java, pass a non-basic type object like an array(timestamp is a basic type, so its ok), means like pass the address of the object. So each time the sensorpacket in accdata or gyrodata will point to the newest value. You can try copy the value of event.values as below: float[] val = Arrays.copyOf(event.values, event.values.length); SensorPacket sp = new SensorPacket(event.timestamp, val);

DavidGillsjo commented 1 year ago

Thanks @Shengnan-Zhu, great catch! Have you verified that is solves the bug? If you have an implementation you are very welcome to submit a pull request.

If this is the issue, it seems like Marslogger - which I forked this code from - might have this bug as well.

I'll defend my PhD by the end of this week, after that I should be able to find some time for this bug.