How do I get the IMU to give me distance travelled?

I am trying to get distance travelled along the Y axis by integrating the Y acceleration from the IMU. I am using the blocks shown below. But when I invoke this procedure the distance is always 0 and I get the message “Incorrect block plugged into the position socket of the block labelled “Position Y”.Expected Position”. But the block I used (highlited) says it is a position object. So what is the problem?

You are trying to extract the Y field twice. Only need to extract it once, from a Position object.

Plug the highlighted Block directly into PositionVariable or plug PositionVariable directly into Telemetry.

This allows the OpMode to function as you intended, showing Telemetry of a non-zero Y position that updates with the loop interval.

As you will see, the Y positions change (very fast) with IMU drift and double-integration.

Cosmetic improvements could include:

  • start the integration thread before loop, not inside the loop
  • experiment with Poll Interval vs. loop cycle time
  • round the Telemetry to zero decimals
  • specify the units
  • specify a starting Y position of zero
  • stop the integration thread when done

But these will not address the fundamental issue of gyro drift with double-integration. FTC teams use other ways to determine distance traveled.

Side note: this post uses the legacy BNO055 IMU and its associated Blocks. The current universal IMU interface is described here at ftc-docs.

1 Like